2184: Mercurial rename support: Pure file renames with *no actual changes* to the file fails with "Diff did not apply cleanly"

yuzisee
June 11, 2014
What version are you running?
Reviewboard 1.6 RC2 (also reproducible on RC1)

What's the URL of the page containing the problem?


What steps will reproduce the problem?
1. hg mv OLD_FILENAME NEW_FILENAME
2. hg commit -m "Rename a file without changing it"
3. hg export -g `hg parent --template '{node}'` > my_patch.diff
4. Log in to reviewboard
5. Create a review and upload this patch to reviewboard
6. Open your newly created review
7. Click [View Diff]

What is the expected output? What do you see instead?

You should see the usual diff view, with:
  Files changed:
    1. NEW_FILENAME (was OLD_FILENAME) [no changes]

Instead, you see:
The patch to 'NEW_FILENAME' didn't apply cleanly. The temporary files have been left in '/tmp/reviewboard.IzIH1V' for debugging purposes. `patch` returned: patch: **** Only garbage was found in the patch input.

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6rc2-py2.7.egg/reviewboard/diffviewer/views.py", line 151, in view_diff
    interdiffset, highlighting, True)
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6rc2-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 1071, in get_diff_files
    large_data=True)
  File "/usr/local/lib/python2.7/dist-packages/Djblets-0.6.9-py2.7.egg/djblets/util/misc.py", line 166, in cache_memoize
    data = lookup_callable()
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6rc2-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 1070, in <lambda>
    enable_syntax_highlighting)),
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6rc2-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 552, in get_chunks
    new = get_patched_file(old, filediff)
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6rc2-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 374, in get_patched_file
    return patch(filediff.diff, buffer, filediff.dest_file)
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6rc2-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 242, in patch
    (filename, tempdir, patch_output))
Exception: The patch to 'LICENSE' didn't apply cleanly. The temporary files have been left in '/tmp/reviewboard.IzIH1V' for debugging purposes.
`patch` returned: patch: **** Only garbage was found in the patch input.

Contents of /tmp/reviewboard.IzIH1V are attached to this bug report.

What operating system are you using? What browser?

Reviewboard is installed on Ubuntu (AWS/EC2)

% lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 11.04
Release:        11.04
Codename:       natty
% uname -a
Linux hostname 2.6.38-8-virtual #42-Ubuntu SMP Mon Apr 11 04:06:34 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

Please provide any additional information below.
diff --git a/OLD_FILENAME b/NEW_FILENAME
foobar
foo
bar
#1 yuzisee
In comparison, the following WORKS PERFECTLY

1. hg mv OLD_FILENAME NEW_FILENAME
2. vim NEW_FILENAME
3. (make some changes to the file)
4. hg commit -m "Rename a file without changing it"
5. hg export -g `hg parent --template '{node}'` > my_patch.diff
6. Log in to reviewboard
7. Create a review and upload this patch to reviewboard
8. Open your newly created review
9. Click [View Diff]

This works as expected. The only difference is whether you modify the file after renaming it or not. It seems that patch just has trouble applying empty patches.
#2 Carl.va*******@gmai***** (Google Code) (Is this you? Claim this profile.)
This bug applies to more than just Mercurial changesets.

I've tested in both mercurial and git that:  (reviewboard 1.6RC2)

1. Renames without modifications
2. Deletes of empty files
3. Addition of empty files

All three have similar properties in that the diff file contains meta data, but no actual diff headers, thus reviewboard internal patching fails.
#3 dt**@wifisl****** (Google Code) (Is this you? Claim this profile.)
Still seeing this in 1.6.1 :(.
david
#4 david
  • +Component-SCMTools
    +Component-DiffViewer
#5 jon.ba*******@gmai***** (Google Code) (Is this you? Claim this profile.)
Still seeing this in 1.7.6
#6 philip.w*********@gmai***** (Google Code) (Is this you? Claim this profile.)
I think hg remove might cause a similar issue.
#7 DerpMh******@gmai***** (Google Code) (Is this you? Claim this profile.)
1.7.16 We have a similar issue (maybe exactly the same) using SVN.  I suspect it has something to do with the patch file containing 2 diffs for the same file (one for the deletion one for the addition).  

Error information: The patch to 'https://devsubversion/svn/Development/Branches/SW22.5.0/Projects/SiteWatch/Common/deltime.pas' didn't apply cleanly. The temporary files have been left in '/tmp/reviewboard.ZD632t' for debugging purposes.
`patch` returned: patching file /tmp/reviewboard.ZD632t/tmp3eUZCF
Reversed (or previously applied) patch detected!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file /tmp/reviewboard.ZD632t/tmp3eUZCF-new.rej

I've saved the files/logs in case there's anything useful.  I have not attempted to duplicate.
#8 bruce*****@gmai***** (Google Code) (Is this you? Claim this profile.)
I came across this problem today: the problem is that patch didn't used to understand features of git-style diffs, including renames. Installing patch 2.7 (http://savannah.gnu.org/projects/patch/) or newer should fix this.
david
#9 david
That sounds like great news. :)
  • +ThirdParty
#10 bruce*****@gmai***** (Google Code) (Is this you? Claim this profile.)
I wonder if there should be a note in the documentation (install guide or release notes?) mentioning that people might want to have patch 1.7 or newer installed on the RB server since it's relatively recent (2012).
david
#11 david
Sure, we can do that.