Add Add insert/replace/remove line count to DiffSet and FileDiff.

Review Request #1702 — Created July 6, 2010 and discarded

Information

Review Board

Reviewers

This patch adds the features requested by Mike Conley for his statistics extension.

I was wondering if it wouldn't be useful to change the description on the summary at the beginning and end of each diff viewer to also present this information instead of just the number of chunks. What do you think?
Testing on the command line.
chipx86
  1. I would love to see little headers telling how many inserts, deletes and removes there are. That can be a separate change, or you can fold it into this change, but I think it would be awesome.
  2. reviewboard/diffviewer/diffutils.py (Diff revision 1)
     
     
     
     
     
     
    We should prevent saving models when we don't need to (as this will temporarily lock the table), so before setting and saving, let's check each of those fields to see if anything changed.
  3. reviewboard/diffviewer/models.py (Diff revision 1)
     
     
     
     
     
     
     
     
     
     
     
    I know it's a bit redundant, but I'd rather these made their own queries. The reason is that if a caller is only interested in one of these counts, we shouldn't be performing three aggregate queries. Just slightly more efficient, even if it's a little bit of code duplication.
    
    You could potentially create a private helper function in that class for generating a query given a field name, and use that in these functions and in line_counts.
  4. 
      
mike_conley
  1. Thanks for doing this - it'll be great to integrate this into my extension.  :D
    
    Just one observation - see below.  Thanks,
    
    -Mike
  2. When I tried to run evolve, django-evolution flipped out because there were no default values for these new fields set, and I had pre-existing records.
    1. Which database type? Can you show me the exact error? It should have worked, as far as I can tell.
    2. Plain ol' sqlite3.  I just ended up nuking my DB and starting from scratch, so I can't show you the exact error.  :/  Works fine for me now.
  3. 
      
edufelipe
  1. 
      
  2. I think Christian will have to take a look at this. I ran the evolution just fine, and I did provide both default and initial value.
    
    I am not really sure what is going on here.
  3. 
      
edufelipe
Review request changed
Status:
Discarded