658: Error : The patch to '<filepath>' didn't apply cleanly.

suda****@gmai***** (Google Code) (Is this you? Claim this profile.)
Sept. 21, 2009
What's the URL of the page containing the problem?

http://reviewboard.eng.vmware.com/r/43966/diff/#index_header

What steps will reproduce the problem?
1. I have a change that moves files from one directory to another (i.e.
integrate/delete)
2. generated diffs using p5 diff -u -c ...
3. Upload the diffs and try to view the diffs.

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

Normal diffs - what I see is
http://reviewboard.eng.vmware.com/r/43966/diff/#index_header (paraphrased
below)

What operating system are you using? What browser?
Windows XP / Firefox 3.0.1


Please provide any additional information below.

The output is like the following:


The patch to '<filepath>' didn't apply cleanly. The temporary files have
been left in '/tmp/reviewboard.U-4jPA' for debugging purposes. `patch`
returned: patching file /tmp/reviewboard.U-4jPA/tmpI632Lt patch: ****
malformed patch at line 5:

Traceback (most recent call last):
  File "/root/reviewboard/diffviewer/views.py", line 82, in view_diff
    files = get_diff_files(diffset, None, interdiffset, highlighting)
  File "/root/reviewboard/diffviewer/diffutils.py", line 577, in get_diff_files
    enable_syntax_highlighting)
  File "/root/reviewboard/diffviewer/diffutils.py", line 502, in generate_files
    lambda: get_chunks(filediff.diffset,
  File "/root/reviewboard/djblets/util/misc.py", line 47, in cache_memoize
    data = lookup_callable()
  File "/root/reviewboard/diffviewer/diffutils.py", line 505, in <lambda>
    enable_syntax_highlighting))
  File "/root/reviewboard/diffviewer/diffutils.py", line 301, in get_chunks
    new = get_patched_file(old, filediff)
  File "/root/reviewboard/diffviewer/diffutils.py", line 214, in
get_patched_file
    return patch(filediff.diff, buffer, filediff.dest_file)
  File "/root/reviewboard/diffviewer/diffutils.py", line 112, in patch
    (filename, tempdir, patch_output))
Exception: The patch to '<filepath>' didn't apply cleanly. The temporary
files have been left in '/tmp/reviewboard.U-4jPA' for debugging purposes.
`patch` returned: patching file /tmp/reviewboard.U-4jPA/tmpI632Lt
patch: **** malformed patch at line 5:
#1 ciao****@gmai***** (Google Code) (Is this you? Claim this profile.)
We're having the exact same error for a diff of an xml file. Here is the diff that 
can reproduce the problem:

--- //depot/project/module.xml //depot/project/module.xml#6
+++ //depot/project/module.xml 2008-12-04 12:00:46
@@ -1,17 +1,4 @@
 <module>
-       <mainmenu label="Overview" id="overview" description="Access statistics, 
performance graphs, and links to helpful tools." icon="icon_mainmenu.png" 
smallicon="icon_mainmenu_small.pn
g">
-       </mainmenu>
-</module>+    <mainmenu path="/system/mainmenu.jsp?menu=Overview">
+    </mainmenu>
+</module>
#2 miguel.r********@gmai***** (Google Code) (Is this you? Claim this profile.)
same issue here.
I get the same error when posting reviews for newly created file (nothing to diff
against)
#3 dev****@gmai***** (Google Code) (Is this you? Claim this profile.)
We get exactly a similar error to the above while trying to view the diff in Review
Board for some of the modified files  (java code modification using Eclipse
IDE)committed into SVN repository. 

We had tried to post the review via post-review tool as well as creating diff via svn
diff command and uploading it via GUI; in both cases the error persists.  
#4 manjuna********@gmai***** (Google Code) (Is this you? Claim this profile.)
I too getting this error for few of the c files. Looks like patch is failing.

The patch to 'src/amuoci.c' didn't apply cleanly. The temporary files have been left 
in 'c:\winnt\temp\reviewboard.qoyghn' for debugging purposes. `patch` returned: 
patching file c:\winnt\temp\reviewboard.qoyghn\tmpqbb31p Hunk #1 succeeded at 544 
with fuzz 2. Hunk #2 FAILED at 592. Hunk #3 succeeded at 642 with fuzz 1. Hunk #4 
FAILED at 656. 2 out of 6 hunks FAILED -- saving rejects to file 
c:\winnt\temp\reviewboard.qoyghn\tmpqbb31p-new.rej 

Traceback (most recent call last):
  File "c:\python25\lib\site-packages\ReviewBoard-1.0-
py2.5.egg\reviewboard\diffviewer\views.py", line 152, in view_diff
    interdiffset, highlighting, True)
  File "c:\python25\lib\site-packages\ReviewBoard-1.0-
py2.5.egg\reviewboard\diffviewer\diffutils.py", line 623, in get_diff_files
    large_data=True)
  File "c:\python25\lib\site-packages\Djblets-0.5-py2.5.egg\djblets\util\misc.py", 
line 143, in cache_memoize
    data = lookup_callable()
  File "c:\python25\lib\site-packages\ReviewBoard-1.0-
py2.5.egg\reviewboard\diffviewer\diffutils.py", line 622, in <lambda>
    enable_syntax_highlighting),
  File "c:\python25\lib\site-packages\ReviewBoard-1.0-
py2.5.egg\reviewboard\diffviewer\diffutils.py", line 345, in get_chunks
    new = get_patched_file(old, filediff)
  File "c:\python25\lib\site-packages\ReviewBoard-1.0-
py2.5.egg\reviewboard\diffviewer\diffutils.py", line 261, in get_patched_file
    return patch(filediff.diff, buffer, filediff.dest_file)
  File "c:\python25\lib\site-packages\ReviewBoard-1.0-
py2.5.egg\reviewboard\diffviewer\diffutils.py", line 129, in patch
    (filename, tempdir, patch_output))
Exception: The patch to 'src/amuoci.c' didn't apply cleanly. The temporary files 
have been left in 'c:\winnt\temp\reviewboard.qoyghn' for debugging purposes.
`patch` returned: patching file c:\winnt\temp\reviewboard.qoyghn\tmpqbb31p
Hunk #1 succeeded at 544 with fuzz 2.
Hunk #2 FAILED at 592.
Hunk #3 succeeded at 642 with fuzz 1.
Hunk #4 FAILED at 656.
2 out of 6 hunks FAILED -- saving rejects to file 
c:\winnt\temp\reviewboard.qoyghn\tmpqbb31p-new.rej
chipx86
#5 chipx86
This usually indicates that the revision is wrong. How was the diff generated, and
what repository type?
#6 manjuna********@gmai***** (Google Code) (Is this you? Claim this profile.)
diff is generated on UNIX and copied from screen to windows and that was the 
problem. Now he tried did an ftp and it worked. With the Review Baord 1.0 facing 
some problem for new request in two places. I am opening a new ticket shortly.
chipx86
#7 chipx86
But how was the diff generated? What tool, parameters?

Copying from screen to windows will break things. I assume you mean copy/paste. That
won't necessarily get the right control characters (tabs, same type of newlines,
etc). You will need to transfer the file directly.

You also should look into using post-review, which will make life a lot easier.
#8 manjuna********@gmai***** (Google Code) (Is this you? Claim this profile.)
diff was generated using cvs diff -u amuoci.c > amuoci.diff on UNIX. Here use made a 
mistake of copy/paste from UNIX shell to Windows. Now it worked after ftp. 
Sure, I will take a look into post-review and propose to our team hear. Thanks for 
the tip! 
#9 manjuna********@gmai***** (Google Code) (Is this you? Claim this profile.)
I tried with latest post-review version 0.8. The problem is we do have post-
review.exe so we need to use UWIN / MKS / Cigwin to run this script on Windows. It 
would have been good if we have a post-review.exe stand alone application so user 
can use it here. I have no problem of using without exe but others are not 
comfortable.
chipx86
#10 chipx86
Ah yeah, that's a potential problem for now. However, I do plan to get a
post-review.exe into the next release.
#11 manjuna********@gmai***** (Google Code) (Is this you? Claim this profile.)
That's great!
#12 sanji*****@gmai***** (Google Code) (Is this you? Claim this profile.)
I also encountered this issue after a perforce to svn migration. Fixing the ident
(RCS) strings solved the issue. 

The diff provided by svn had the perforce repo path in the ident string for the
original copy. However the local copy used by review board had SVN Keywords
substituted. As a result patch utility errored out
david
#13 david
This is almost always caused by either (a) creating the diff incorrectly (for
example, with the wrong line-endings), or (b) a character set mismatch. If there are
specific bugs in the RB code, please file those separately.
  • +NotABug
#14 dars*****@gmai***** (Google Code) (Is this you? Claim this profile.)
I get the same problem "Exception: The patch to 'file' didn't apply cleanly." This is a very intermittent issue. Earlier the diff was viewable but not anymore. Not sure what went wrong all of a sudden. 
#15 gju****@gmai***** (Google Code) (Is this you? Claim this profile.)
I would strongly vote and appreciate a solution/suggestions on this issue:
Our environment is reviewboard 1.6.14 on Ubuntu 12.04 (64bits) w/ python 2.7, SCM is CVS 
We experienced quite a few this problems. 
As DARSHAN pointed out the problem is intermittent. For a single file in a diff package sometimes works, sometimes not.

We tested on our old reviewboard (1.5.5), same error for the same diff package (and backend CVS repository)

Diff currently unavailable. Error: The patch to 'project_sam.xml' didn't apply cleanly. The temporary files have been left in '/tmp/reviewboard.CRgaUy' for debugging purposes. `patch` returned: patching file /tmp/reviewboard.CRgaUy/tmpGdkjyO Hunk #1 FAILED at 1. 1 out of 1 hunk FAILED -- saving rejects to file /tmp/reviewboard.CRgaUy/tmpGdkjyO-new.rej Details 
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.14-py2.7.egg/reviewboard/diffviewer/views.py", line 384, in view_diff_fragment
    file = get_requested_diff_file()
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.14-py2.7.egg/reviewboard/diffviewer/views.py", line 310, in get_requested_diff_file
    populate_diff_chunks(files, highlighting)
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.14-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 1188, in populate_diff_chunks
    large_data=True)
  File "/usr/local/lib/python2.7/dist-packages/Djblets-0.6.27-py2.7.egg/djblets/util/misc.py", line 156, in cache_memoize
    data = lookup_callable()
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.14-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 1187, in <lambda>
    enable_syntax_highlighting)),
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.14-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 595, in get_chunks
    new = get_patched_file(old, filediff)
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.14-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 388, in get_patched_file
    return patch(diff, buffer, filediff.dest_file)
  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.14-py2.7.egg/reviewboard/diffviewer/diffutils.py", line 247, in patch
    (filename, tempdir, patch_output))
Exception: The patch to 'project_sam.xml' didn't apply cleanly. The temporary files have been left in '/tmp/reviewboard.CRgaUy' for debugging purposes.
`patch` returned: patching file /tmp/reviewboard.CRgaUy/tmpGdkjyO
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file /tmp/reviewboard.CRgaUy/tmpGdkjyO-new.rej
david
#16 david
Getting rejects usually indicates some problem with how the diff was generated. Check the .rej file to see what failed.
#17 gju****@gmai***** (Google Code) (Is this you? Claim this profile.)
I attached the .rej file as below for information because I can not figure out the problem from the file.
Thanks!
  • +
    Index: project_sam.xml
    --- project_sam.xml	21 Dec 2012 18:14:34 -0000	1.181.2.4
    +++ project_sam.xml	7 Jan 2013 15:36:34 -0000
    @@ -1,5335 +1,5335 @@
     <!--
     ==========================================================================================
     
      $Id: project_sam.xml,v 1.181.2.4 2012/12/21 18:14:34 kmorin Exp $
     
      SAM Project descriptor file. This file describes applications in our project and
      defines sub-modules & libraries the application requires.
     
      See TWiki build documentation: http://shenzi/twiki/bin/view/Sam/SamPnTBuildDocumentation
     
      To validate the syntax of this file execute "ant parse.preprocessor"
     
      To generate the build targets from the project descriptor file execute "ant run.preprocessor"
     
      Copyright (c) 2011-2012 Alcatel-Lucent.
     ==========================================================================================
     -->
     <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:noNamespaceSchemaLocation="../tools/project/modules/mode
david
#18 david
Is this a newly-added file?
#19 gju****@gmai***** (Google Code) (Is this you? Claim this profile.)
It's an existing file in CVS.
We experienced that the same file change sometime works, sometimes not.
#20 acafe*****@gmai***** (Google Code) (Is this you? Claim this profile.)
I have got this error too using a cvs generated diff (cvs diff -u foo.c)
I found that it was barfing on changes to the
$Id$
$Source$
lines in the file. When these were removed from the diff the error went away.