Show More
@@ -1193,21 +1193,20 b' def iterhunks(fp):' | |||||
1193 | gp = gitpatches.pop()[2] |
|
1193 | gp = gitpatches.pop()[2] | |
1194 | yield 'file', ('a/' + gp.path, 'b/' + gp.path, None, gp) |
|
1194 | yield 'file', ('a/' + gp.path, 'b/' + gp.path, None, gp) | |
1195 |
|
1195 | |||
1196 |
def applydiff(ui, fp |
|
1196 | def applydiff(ui, fp, backend, store, strip=1, eolmode='strict'): | |
1197 | """Reads a patch from fp and tries to apply it. |
|
1197 | """Reads a patch from fp and tries to apply it. | |
1198 |
|
1198 | |||
1199 | The dict 'changed' is filled in with all of the filenames changed |
|
1199 | Returns 0 for a clean patch, -1 if any rejects were found and 1 if | |
1200 | by the patch. Returns 0 for a clean patch, -1 if any rejects were |
|
1200 | there was any fuzz. | |
1201 | found and 1 if there was any fuzz. |
|
|||
1202 |
|
1201 | |||
1203 | If 'eolmode' is 'strict', the patch content and patched file are |
|
1202 | If 'eolmode' is 'strict', the patch content and patched file are | |
1204 | read in binary mode. Otherwise, line endings are ignored when |
|
1203 | read in binary mode. Otherwise, line endings are ignored when | |
1205 | patching then normalized according to 'eolmode'. |
|
1204 | patching then normalized according to 'eolmode'. | |
1206 | """ |
|
1205 | """ | |
1207 |
return _applydiff(ui, fp, patchfile, backend, store, |
|
1206 | return _applydiff(ui, fp, patchfile, backend, store, strip=strip, | |
1208 | eolmode=eolmode) |
|
1207 | eolmode=eolmode) | |
1209 |
|
1208 | |||
1210 |
def _applydiff(ui, fp, patcher, backend, store, |
|
1209 | def _applydiff(ui, fp, patcher, backend, store, strip=1, | |
1211 | eolmode='strict'): |
|
1210 | eolmode='strict'): | |
1212 |
|
1211 | |||
1213 | def pstrip(p): |
|
1212 | def pstrip(p): | |
@@ -1222,10 +1221,8 b' def _applydiff(ui, fp, patcher, backend,' | |||||
1222 | if not current_file: |
|
1221 | if not current_file: | |
1223 | continue |
|
1222 | continue | |
1224 | ret = current_file.apply(values) |
|
1223 | ret = current_file.apply(values) | |
1225 |
if ret > |
|
1224 | if ret > 0: | |
1226 | changed.add(current_file.fname) |
|
1225 | err = 1 | |
1227 | if ret > 0: |
|
|||
1228 | err = 1 |
|
|||
1229 | elif state == 'file': |
|
1226 | elif state == 'file': | |
1230 | if current_file: |
|
1227 | if current_file: | |
1231 | rejects += current_file.close() |
|
1228 | rejects += current_file.close() | |
@@ -1236,7 +1233,6 b' def _applydiff(ui, fp, patcher, backend,' | |||||
1236 | path = pstrip(gp.path) |
|
1233 | path = pstrip(gp.path) | |
1237 | if gp.oldpath: |
|
1234 | if gp.oldpath: | |
1238 | copysource = pstrip(gp.oldpath) |
|
1235 | copysource = pstrip(gp.oldpath) | |
1239 | changed.add(path) |
|
|||
1240 | if gp.op == 'RENAME': |
|
1236 | if gp.op == 'RENAME': | |
1241 | backend.unlink(copysource) |
|
1237 | backend.unlink(copysource) | |
1242 | if not first_hunk: |
|
1238 | if not first_hunk: | |
@@ -1354,7 +1350,7 b' def internalpatch(ui, repo, patchobj, st' | |||||
1354 | except TypeError: |
|
1350 | except TypeError: | |
1355 | fp = patchobj |
|
1351 | fp = patchobj | |
1356 | try: |
|
1352 | try: | |
1357 |
ret = applydiff(ui, fp, |
|
1353 | ret = applydiff(ui, fp, backend, store, strip=strip, | |
1358 | eolmode=eolmode) |
|
1354 | eolmode=eolmode) | |
1359 | finally: |
|
1355 | finally: | |
1360 | if fp != patchobj: |
|
1356 | if fp != patchobj: |
@@ -130,7 +130,7 b' Merge:' | |||||
130 | patch failed, unable to continue (try -v) |
|
130 | patch failed, unable to continue (try -v) | |
131 | patch failed, rejects left in working dir |
|
131 | patch failed, rejects left in working dir | |
132 | patch didn't work out, merging patcha |
|
132 | patch didn't work out, merging patcha | |
133 |
|
|
133 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
134 | 0 files updated, 2 files merged, 0 files removed, 0 files unresolved |
|
134 | 0 files updated, 2 files merged, 0 files removed, 0 files unresolved | |
135 | (branch merge, don't forget to commit) |
|
135 | (branch merge, don't forget to commit) | |
136 | applying patcha2 |
|
136 | applying patcha2 |
General Comments 0
You need to be logged in to leave comments.
Login now