Use the original file name from the parent diff for files that are moved by the parent diff.

Review Request #9637 — Created Feb. 14, 2018 and updated

giorgiob
Review Board
release-3.0.x
4573
fc7838e...
reviewboard
If a file is modified in the current diff and renamed / moved in the parent
diff, we have to use the file name from the parent diff as source file in
diffutils.get_original_file() otherwise the file diff will not be displayed
correctly.

This fixes bug 4573.

Testing done:
In a local Mercurial project, created a changeset that moves a file, and
subsequently a changeset the modifies the moved file. Created a review for
the second changeset using rbt post.
Without the fix, the diff for the file is not displayed because the source
file cannot be found.
With the fix, the diff is displayed correctly.

A similar test has been performed by creating a copy of an existing file
in the first changeset.

Description From Last Updated

parent_diff contains UTF-8-encoded data. Without this conversion line 222 can throw an exception: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 ...

GI giorgiob
GI
GI
GI
GI
GI
  1. 
      
  2. reviewboard/diffviewer/diffutils.py (Diff revisions 3 - 4)
     
     

    parent_diff contains UTF-8-encoded data.

    Without this conversion line 222 can throw an exception: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position ...: ordinal not in range(128)
    I suppose the "in" operator in

    from_prefix in l
    

    tries to decode the string l as ASCII, but I am not sure if this is the case and how to avoid it.

    A better solution would be welcome.

  3. 
      
misery
  1. 
      
  2. Ping! Could someone review this? :-)

  3. 
      
GI
Review request changed

Commit:

-6bf59ad3411532f9e3d19aed76dd5937aa0d8bd5
+fc7838e61a575c38994f7430cb6afd7ed76f708e

Diff:

Revision 5 (+47 -1)

Show changes

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
misery
  1. 
      
  2. Anyone?

  3. 
      
Loading...