Skip to content
Snippets Groups Projects
Commit c6cdc123f6e4 authored by Patrick Mezard's avatar Patrick Mezard
Browse files

patch: fails immediately upon malformed hunk

patch(1) does silently ignore malformed hunks but this is not something we want
to copy.
parent aa2fe1f52ff4
No related branches found
No related tags found
No related merge requests found
...@@ -1007,17 +1007,12 @@ ...@@ -1007,17 +1007,12 @@
current_hunk = None current_hunk = None
if ((sourcefile or state == BFILE) and ((not context and x[0] == '@') or if ((sourcefile or state == BFILE) and ((not context and x[0] == '@') or
((context is not False) and x.startswith('***************')))): ((context is not False) and x.startswith('***************')))):
try: if context is None and x.startswith('***************'):
if context is None and x.startswith('***************'): context = True
context = True gpatch = changed.get(bfile)
gpatch = changed.get(bfile) create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD'
create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD' remove = bfile == '/dev/null' or gpatch and gpatch.op == 'DELETE'
remove = bfile == '/dev/null' or gpatch and gpatch.op == 'DELETE' current_hunk = hunk(x, hunknum + 1, lr, context, create, remove)
current_hunk = hunk(x, hunknum + 1, lr, context, create, remove)
except PatchError, err:
ui.debug(err)
current_hunk = None
continue
hunknum += 1 hunknum += 1
if emitfile: if emitfile:
emitfile = False emitfile = False
......
...@@ -150,6 +150,25 @@ ...@@ -150,6 +150,25 @@
$ rm -r b $ rm -r b
import of malformed plain diff should fail
$ hg clone -r0 a b
requesting all changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 2 changes to 2 files
updating to branch default
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg --cwd a diff -r0:1 > tip.patch
$ sed 's/1,1/foo/' < tip.patch > broken.patch
$ hg --cwd b import -mpatch ../broken.patch
applying ../broken.patch
abort: bad hunk #1
[255]
$ rm -r b
hg -R repo import hg -R repo import
put the clone in a subdir - having a directory named "a" put the clone in a subdir - having a directory named "a"
used to hide a bug. used to hide a bug.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment