3426: "Didn't apply patch cleanly"

nick.******@gmai***** (Google Code) (Is this you? Claim this profile.)
Oct. 30, 2014
What version are you running?
2.0.1

What's the URL of the page containing the problem?
r/[number]/diff

What steps will reproduce the problem?
1. Click "Update diff" on existing review request
2. Upload the new diff
3. Try to view the diff

What is the expected output? What do you see instead?
Expecting to see the diff, instead see an error saying:

The patch to '[filename]' didn't apply cleanly. The temporary files have been left in '/tmp/reviewboard.[id]' for debugging purposes. `patch` returned:

This may be a bug in the software, a temporary outage, or an issue with the format of your diff.

What operating system are you using? What browser?
Windows, reviewboard running on a linux server. Viewing in Chrome.

Please provide any additional information below.
This is similar to issue #3398. I took a look at the .rej and .diff files in the temp folder--they look almost identical. If I try to patch locally with the diff file, it works just fine.

If I take a look at my apache error logs, I see something like:
Warning:root:Attempting to override delete count on FileDiffData [hash] from 16 to None (FileDiff None)
david
#1 david
Can you check that the file it's trying to patch looks correct?
  • +NeedInfo
#2 nick.******@gmai***** (Google Code) (Is this you? Claim this profile.)
Is that also stored within the temp folder? In there I see:
tmp1 and tmp1-new files, both have nothing in them
myfile.py.diff, which is the diff I uploaded (except it's been renamed)
tmp1-new.rej, which is nearly identical to the .diff file
david
#3 david
It should be the tmp1 file. If it's empty, something went wrong fetching the file from the repository.

What SCM are you using?
#4 nick.******@gmai***** (Google Code) (Is this you? Claim this profile.)
Git
david
#5 david
How is your repository configured? What is the raw file URL?
#6 nick.******@gmai***** (Google Code) (Is this you? Claim this profile.)
We're using gitweb and hosting the repos at the default location on our server (/srv/git/repositories)
#7 nick.******@gmai***** (Google Code) (Is this you? Claim this profile.)
Ah, here is the raw file URL:
http://server/gitweb/?p=myrepo.git;a=blob_plain;f=<filename>;h=<revisiona>
david
#8 david
I think your issue is "<revisiona>" (should be "<revision>")
#9 nick.******@gmai***** (Google Code) (Is this you? Claim this profile.)
Shoot, admin's telling me that that was just a typo when he sent me the url... It actually is just revision.
#10 nick.******@gmai***** (Google Code) (Is this you? Claim this profile.)
Sorry for bothering you with this, thanks for your help so far.

I've got it traced back to get_original_file in diffutils.py. repository.get_file(...) is not returning anything; data is just empty. The repo is correct, and I can't detect anything in my request that's out of the ordinary. The 'filediff' arg looks ok too.

Could there maybe be a permissions error somewhere?
#11 nick.******@gmai***** (Google Code) (Is this you? Claim this profile.)
Finally fixed the problem. It seems the repo in the server was a few commits ahead. I had to pull the repo fresh, use my first patch to get the file in there (and then generate a parent patch). Then I used my second patch (the one that wouldn't upload), which ended up not applying, even though the .rej file just had a few comment differences. I fixed that, generated a new diff, then uploaded that and the parent--after which everything worked ok.

I really hope I don't have to go through this process every time the server-side repo gets a few commits ahead of my local one--but then again, I suck at git, and might be doing something completely wrong.
david
#12 david
It shouldn't matter if any new commits have been pushed--that's why we take advantage of the blob IDs in your diff.

How are you creating your diff files?
#13 nick.******@gmai***** (Google Code) (Is this you? Claim this profile.)
git diff --full-index [hash of last commit that I uploaded] [file that was changed] > changes.diff
chipx86
#14 chipx86
Can you give that example with a sample tree of commits? (Just a diagram showing commits, what's upstream, and what's still local to your tree.)

We strongly recommend that you run RBTools, since this will generate a correct diff and handle uploading it to Review Board for you, along with filling out the description and other fields based on your commit.
david
#15 david
  • -NeedInfo
    +Incomplete