Better Moved Files

Review Request #2905 — Created Feb. 19, 2012 and submitted

Information

Review Board

Reviewers

Uses info from the diff to detect if files have been moved and displays the result in the diff viewer.

This adds the functionality of parsing git's extended header of detecting moved files. Before, the diff would show two changes: a deleted file and a new file. Now, there is only one change and it is displayed correctly in the diff viewer. Since a file may be moved and have no actual diff data (and no revision), some extra checks are now required to compensate for this. These may be different depending on the SCM, so a more generic approach might be required.
Using "git diff -M" to manually create a patch that contains:
-Files that have been moved and not edited
-Files that have been both moved and edited

(post-review has been updated but has not been posted yet, so to test you must manually create a diff)
Description From Last Updated

For multi-line conditions, use parens instead of \. Also make sure that the alignment is consistent on each.

chipx86chipx86

Blank line before this.

chipx86chipx86

I know we didn't do this with deleted, but this should compare against self.MOVED. (You can update deleted to do …

chipx86chipx86

This should go inside the conditional's body. So: if .... # Moved ...

chipx86chipx86

I don't love the negation method. I find it's easier to read it if each check stands alone whenever possible.

chipx86chipx86

Best not to modify unrelated lines. It distracts from the main purpose of the review, muddies up the history of …

chipx86chipx86

Using Django 1.4 (that will be required as soon as an upstream thing is fixed in a module we depend …

chipx86chipx86

"length"

chipx86chipx86

If you add a "(moved)" suffix to the file name, this can just be: "No changes were made to this …

chipx86chipx86
chipx86
  1. Got any screenshots showing a moved file with a couple changes?
  2. 
      
chipx86
  1. Got any screenshots showing a moved file with a couple changes?
  2. 
      
DD
SM
  1. 
      
  2. Would it make sense to highlight that a change was made here? When quickly viewing the review request the name change isn't obvious. Maybe this could be highlighted yellow like in the code, or have some sort of icon?
    1. Yeah, something would be good. I wouldn't use color. I think a "(moved)" suffix on the 2nd file (like, "manage_new.py (moved)") would be sufficient.
  3. 
      
chipx86
  1. 
      
  2. reviewboard/diffviewer/diffutils.py (Diff revision 1)
     
     
     
    Show all issues
    For multi-line conditions, use parens instead of \. Also make sure that the alignment is consistent on each.
  3. reviewboard/diffviewer/diffutils.py (Diff revision 1)
     
     
    Show all issues
    Blank line before this.
  4. reviewboard/diffviewer/models.py (Diff revision 1)
     
     
    Show all issues
    I know we didn't do this with deleted, but this should compare against self.MOVED. (You can update deleted to do that too.)
  5. reviewboard/scmtools/git.py (Diff revision 1)
     
     
    Show all issues
    This should go inside the conditional's body. So:
    
    if ....
        # Moved ...
  6. reviewboard/scmtools/git.py (Diff revision 1)
     
     
    Show all issues
    I don't love the negation method. I find it's easier to read it if each check stands alone whenever possible.
  7. reviewboard/scmtools/git.py (Diff revision 1)
     
     
     
    Show all issues
    Best not to modify unrelated lines. It distracts from the main purpose of the review, muddies up the history of lines a bit, and can cause merge conflicts if other people modify the same lines. In this case, that's exactly what's happening, because I rewrote these functions, so there will be some merge ugliness.
  8. Show all issues
    Using Django 1.4 (that will be required as soon as an upstream thing is fixed in a module we depend on), you can change this to use {% elif ... %}
  9. Show all issues
    "length"
  10. Show all issues
    If you add a "(moved)" suffix to the file name, this can just be:
    
    "No changes were made to this file."
  11. 
      
DD
chipx86
  1. Ship It!
  2. 
      
DD
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (30737e9)
Loading...