diff mercurial/patch.py @ 6179:36ab165abbe2

patch: fix iterhunks() with trailing binary file removal Like some renames or copy operations, binary file removal does not generate any "file" or "hunk" action, but was not tagged as such and let iterhunk() assume no hunk was applied for the deleted file.
author Patrick Mezard <pmezard@gmail.com>
date Thu, 28 Feb 2008 00:07:37 +0100
parents 2da5b19a6460
children f89fd07fc51d
line wrap: on
line diff
--- a/mercurial/patch.py	Wed Feb 27 14:58:44 2008 -0800
+++ b/mercurial/patch.py	Thu Feb 28 00:07:37 2008 +0100
@@ -890,6 +890,9 @@
     context = None
     lr = linereader(fp)
     dopatch = True
+    # gitworkdone is True if a git operation (copy, rename, ...) was
+    # performed already for the current file. Useful when the file
+    # section may have no hunk.
     gitworkdone = False
 
     while True:
@@ -938,8 +941,8 @@
                         changed[gp.path] = (gp.op, gp)
                 # else error?
                 # copy/rename + modify should modify target, not source
-                if changed.get(bfile[2:], (None, None))[0] in ('COPY',
-                                                               'RENAME'):
+                gitop = changed.get(bfile[2:], (None, None))[0]
+                if gitop in ('COPY', 'DELETE', 'RENAME'):
                     afile = bfile
                     gitworkdone = True
             newfile = True