##// END OF EJS Templates
patch: remove internal patcher fallback and NoHunk error...
Patrick Mezard -
r12671:1b4e3152 default
parent child Browse files
Show More
@@ -18,9 +18,6 b" gitre = re.compile('diff --git a/(.*) b/"
18 18 class PatchError(Exception):
19 19 pass
20 20
21 class NoHunks(PatchError):
22 pass
23
24 21 # helper functions
25 22
26 23 def copyfile(src, dst, basedir):
@@ -997,7 +994,6 b' def iterhunks(ui, fp, sourcefile=None):'
997 994 # performed already for the current file. Useful when the file
998 995 # section may have no hunk.
999 996 gitworkdone = False
1000 empty = None
1001 997
1002 998 while True:
1003 999 newfile = newgitfile = False
@@ -1009,7 +1005,6 b' def iterhunks(ui, fp, sourcefile=None):'
1009 1005 current_hunk.fix_newline()
1010 1006 yield 'hunk', current_hunk
1011 1007 current_hunk = None
1012 empty = False
1013 1008 if ((sourcefile or state == BFILE) and ((not context and x[0] == '@') or
1014 1009 ((context is not False) and x.startswith('***************')))):
1015 1010 try:
@@ -1027,14 +1022,12 b' def iterhunks(ui, fp, sourcefile=None):'
1027 1022 if emitfile:
1028 1023 emitfile = False
1029 1024 yield 'file', (afile, bfile, current_hunk)
1030 empty = False
1031 1025 elif state == BFILE and x.startswith('GIT binary patch'):
1032 1026 current_hunk = binhunk(changed[bfile])
1033 1027 hunknum += 1
1034 1028 if emitfile:
1035 1029 emitfile = False
1036 1030 yield 'file', ('a/' + afile, 'b/' + bfile, current_hunk)
1037 empty = False
1038 1031 current_hunk.extract(lr)
1039 1032 elif x.startswith('diff --git'):
1040 1033 # check for git diff, scanning the whole patch file if needed
@@ -1083,9 +1076,6 b' def iterhunks(ui, fp, sourcefile=None):'
1083 1076 bfile = parsefilename(l2)
1084 1077
1085 1078 if newfile:
1086 if empty:
1087 raise NoHunks
1088 empty = not gitworkdone
1089 1079 gitworkdone = False
1090 1080
1091 1081 if newgitfile or newfile:
@@ -1095,15 +1085,10 b' def iterhunks(ui, fp, sourcefile=None):'
1095 1085 if current_hunk:
1096 1086 if current_hunk.complete():
1097 1087 yield 'hunk', current_hunk
1098 empty = False
1099 1088 else:
1100 1089 raise PatchError(_("malformed patch %s %s") % (afile,
1101 1090 current_hunk.desc))
1102 1091
1103 if (empty is None and not gitworkdone) or empty:
1104 raise NoHunks
1105
1106
1107 1092 def applydiff(ui, fp, changed, strip=1, sourcefile=None, eolmode='strict'):
1108 1093 """Reads a patch from fp and tries to apply it.
1109 1094
@@ -1270,22 +1255,7 b' def patch(patchname, ui, strip=1, cwd=No'
1270 1255 if patcher:
1271 1256 return externalpatch(patcher, args, patchname, ui, strip, cwd,
1272 1257 files)
1273 else:
1274 try:
1275 1258 return internalpatch(patchname, ui, strip, cwd, files, eolmode)
1276 except NoHunks:
1277 ui.warn(_('internal patcher failed\n'
1278 'please report details to '
1279 'http://mercurial.selenic.com/bts/\n'
1280 'or mercurial@selenic.com\n'))
1281 patcher = (util.find_exe('gpatch') or util.find_exe('patch')
1282 or 'patch')
1283 ui.debug('no valid hunks found; trying with %r instead\n' %
1284 patcher)
1285 if util.needbinarypatch():
1286 args.append('--binary')
1287 return externalpatch(patcher, args, patchname, ui, strip, cwd,
1288 files)
1289 1259 except PatchError, err:
1290 1260 s = str(err)
1291 1261 if s:
General Comments 0
You need to be logged in to leave comments. Login now