Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 12675:c6cdc123f6e4
patch: fails immediately upon malformed hunk
patch(1) does silently ignore malformed hunks but this is not something we want
to copy.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sat, 09 Oct 2010 15:13:08 -0500 |
parents | aa2fe1f52ff4 |
children | 80a3d1121c10 |
comparison
equal
deleted
inserted
replaced
12674:aa2fe1f52ff4 | 12675:c6cdc123f6e4 |
---|---|
1005 current_hunk.fix_newline() | 1005 current_hunk.fix_newline() |
1006 yield 'hunk', current_hunk | 1006 yield 'hunk', current_hunk |
1007 current_hunk = None | 1007 current_hunk = None |
1008 if ((sourcefile or state == BFILE) and ((not context and x[0] == '@') or | 1008 if ((sourcefile or state == BFILE) and ((not context and x[0] == '@') or |
1009 ((context is not False) and x.startswith('***************')))): | 1009 ((context is not False) and x.startswith('***************')))): |
1010 try: | 1010 if context is None and x.startswith('***************'): |
1011 if context is None and x.startswith('***************'): | 1011 context = True |
1012 context = True | 1012 gpatch = changed.get(bfile) |
1013 gpatch = changed.get(bfile) | 1013 create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD' |
1014 create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD' | 1014 remove = bfile == '/dev/null' or gpatch and gpatch.op == 'DELETE' |
1015 remove = bfile == '/dev/null' or gpatch and gpatch.op == 'DELETE' | 1015 current_hunk = hunk(x, hunknum + 1, lr, context, create, remove) |
1016 current_hunk = hunk(x, hunknum + 1, lr, context, create, remove) | |
1017 except PatchError, err: | |
1018 ui.debug(err) | |
1019 current_hunk = None | |
1020 continue | |
1021 hunknum += 1 | 1016 hunknum += 1 |
1022 if emitfile: | 1017 if emitfile: |
1023 emitfile = False | 1018 emitfile = False |
1024 yield 'file', (afile, bfile, current_hunk) | 1019 yield 'file', (afile, bfile, current_hunk) |
1025 elif state == BFILE and x.startswith('GIT binary patch'): | 1020 elif state == BFILE and x.startswith('GIT binary patch'): |