##// END OF EJS Templates
patch: fix patchmeta/hunk synchronization in iterhunks()...
Patrick Mezard -
r14534:ecc79816 default
parent child Browse files
Show More
@@ -1122,8 +1122,9 b' def iterhunks(fp):'
1122 1122 or (context is not False and x.startswith('***************'))
1123 1123 or x.startswith('GIT binary patch')):
1124 1124 gp = None
1125 if gitpatches and gitpatches[-1][0] == bfile:
1126 gp = gitpatches.pop()[1]
1125 if (gitpatches and
1126 (gitpatches[-1][0] == afile or gitpatches[-1][1] == bfile)):
1127 gp = gitpatches.pop()[2]
1127 1128 if x.startswith('GIT binary patch'):
1128 1129 h = binhunk(lr)
1129 1130 else:
@@ -1141,17 +1142,17 b' def iterhunks(fp):'
1141 1142 continue
1142 1143 if gitpatches is None:
1143 1144 # scan whole input for git metadata
1144 gitpatches = [('b/' + gp.path, gp) for gp
1145 gitpatches = [('a/' + gp.path, 'b/' + gp.path, gp) for gp
1145 1146 in scangitpatch(lr, x)]
1146 yield 'git', [g[1] for g in gitpatches
1147 if g[1].op in ('COPY', 'RENAME')]
1147 yield 'git', [g[2] for g in gitpatches
1148 if g[2].op in ('COPY', 'RENAME')]
1148 1149 gitpatches.reverse()
1149 1150 afile = 'a/' + m.group(1)
1150 1151 bfile = 'b/' + m.group(2)
1151 while bfile != gitpatches[-1][0]:
1152 gp = gitpatches.pop()[1]
1152 while afile != gitpatches[-1][0] and bfile != gitpatches[-1][1]:
1153 gp = gitpatches.pop()[2]
1153 1154 yield 'file', ('a/' + gp.path, 'b/' + gp.path, None, gp)
1154 gp = gitpatches[-1][1]
1155 gp = gitpatches[-1][2]
1155 1156 # copy/rename + modify should modify target, not source
1156 1157 if gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD') or gp.mode:
1157 1158 afile = bfile
@@ -1189,7 +1190,7 b' def iterhunks(fp):'
1189 1190 hunknum = 0
1190 1191
1191 1192 while gitpatches:
1192 gp = gitpatches.pop()[1]
1193 gp = gitpatches.pop()[2]
1193 1194 yield 'file', ('a/' + gp.path, 'b/' + gp.path, None, gp)
1194 1195
1195 1196 def applydiff(ui, fp, changed, backend, store, strip=1, eolmode='strict'):
General Comments 0
You need to be logged in to leave comments. Login now