Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 24247:6e19516094a3
patch.applydiff: accept a prefix parameter
This is preparation for upcoming patches that will add support for applying a
patch within a subdirectory.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Fri, 06 Mar 2015 22:24:49 -0800 |
parents | 394a91cb3d4a |
children | 26fa5ff9e660 |
comparison
equal
deleted
inserted
replaced
24246:394a91cb3d4a | 24247:6e19516094a3 |
---|---|
1351 i += cmd | 1351 i += cmd |
1352 else: | 1352 else: |
1353 raise PatchError(_('unexpected delta opcode 0')) | 1353 raise PatchError(_('unexpected delta opcode 0')) |
1354 return out | 1354 return out |
1355 | 1355 |
1356 def applydiff(ui, fp, backend, store, strip=1, eolmode='strict'): | 1356 def applydiff(ui, fp, backend, store, strip=1, prefix='', eolmode='strict'): |
1357 """Reads a patch from fp and tries to apply it. | 1357 """Reads a patch from fp and tries to apply it. |
1358 | 1358 |
1359 Returns 0 for a clean patch, -1 if any rejects were found and 1 if | 1359 Returns 0 for a clean patch, -1 if any rejects were found and 1 if |
1360 there was any fuzz. | 1360 there was any fuzz. |
1361 | 1361 |
1362 If 'eolmode' is 'strict', the patch content and patched file are | 1362 If 'eolmode' is 'strict', the patch content and patched file are |
1363 read in binary mode. Otherwise, line endings are ignored when | 1363 read in binary mode. Otherwise, line endings are ignored when |
1364 patching then normalized according to 'eolmode'. | 1364 patching then normalized according to 'eolmode'. |
1365 """ | 1365 """ |
1366 return _applydiff(ui, fp, patchfile, backend, store, strip=strip, | 1366 return _applydiff(ui, fp, patchfile, backend, store, strip=strip, |
1367 eolmode=eolmode) | 1367 prefix=prefix, eolmode=eolmode) |
1368 | 1368 |
1369 def _applydiff(ui, fp, patcher, backend, store, strip=1, prefix='', | 1369 def _applydiff(ui, fp, patcher, backend, store, strip=1, prefix='', |
1370 eolmode='strict'): | 1370 eolmode='strict'): |
1371 | 1371 |
1372 if prefix: | 1372 if prefix: |