Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
6178:81afdd016867 | 6179:36ab165abbe2 |
---|---|
888 # our states | 888 # our states |
889 BFILE = 1 | 889 BFILE = 1 |
890 context = None | 890 context = None |
891 lr = linereader(fp) | 891 lr = linereader(fp) |
892 dopatch = True | 892 dopatch = True |
893 # gitworkdone is True if a git operation (copy, rename, ...) was | |
894 # performed already for the current file. Useful when the file | |
895 # section may have no hunk. | |
893 gitworkdone = False | 896 gitworkdone = False |
894 | 897 |
895 while True: | 898 while True: |
896 newfile = False | 899 newfile = False |
897 x = lr.readline() | 900 x = lr.readline() |
936 yield 'git', gitpatches | 939 yield 'git', gitpatches |
937 for gp in gitpatches: | 940 for gp in gitpatches: |
938 changed[gp.path] = (gp.op, gp) | 941 changed[gp.path] = (gp.op, gp) |
939 # else error? | 942 # else error? |
940 # copy/rename + modify should modify target, not source | 943 # copy/rename + modify should modify target, not source |
941 if changed.get(bfile[2:], (None, None))[0] in ('COPY', | 944 gitop = changed.get(bfile[2:], (None, None))[0] |
942 'RENAME'): | 945 if gitop in ('COPY', 'DELETE', 'RENAME'): |
943 afile = bfile | 946 afile = bfile |
944 gitworkdone = True | 947 gitworkdone = True |
945 newfile = True | 948 newfile = True |
946 elif x.startswith('---'): | 949 elif x.startswith('---'): |
947 # check for a unified diff | 950 # check for a unified diff |