equal
deleted
inserted
replaced
1279 |
1279 |
1280 if rejects: |
1280 if rejects: |
1281 return -1 |
1281 return -1 |
1282 return err |
1282 return err |
1283 |
1283 |
1284 def _externalpatch(ui, repo, patcher, patchname, strip, cwd, files, |
1284 def _externalpatch(ui, repo, patcher, patchname, strip, files, |
1285 similarity): |
1285 similarity): |
1286 """use <patcher> to apply <patchname> to the working directory. |
1286 """use <patcher> to apply <patchname> to the working directory. |
1287 returns whether patch was applied with fuzz factor.""" |
1287 returns whether patch was applied with fuzz factor.""" |
1288 |
1288 |
1289 fuzz = False |
1289 fuzz = False |
1290 args = [] |
1290 args = [] |
|
1291 cwd = repo.root |
1291 if cwd: |
1292 if cwd: |
1292 args.append('-d %s' % util.shellquote(cwd)) |
1293 args.append('-d %s' % util.shellquote(cwd)) |
1293 fp = util.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip, |
1294 fp = util.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip, |
1294 util.shellquote(patchname))) |
1295 util.shellquote(patchname))) |
1295 try: |
1296 try: |
1353 files.update(dict.fromkeys(backend.close())) |
1354 files.update(dict.fromkeys(backend.close())) |
1354 if ret < 0: |
1355 if ret < 0: |
1355 raise PatchError(_('patch failed to apply')) |
1356 raise PatchError(_('patch failed to apply')) |
1356 return ret > 0 |
1357 return ret > 0 |
1357 |
1358 |
1358 def patch(ui, repo, patchname, strip=1, cwd=None, files=None, eolmode='strict', |
1359 def patch(ui, repo, patchname, strip=1, files=None, eolmode='strict', |
1359 similarity=0): |
1360 similarity=0): |
1360 """Apply <patchname> to the working directory. |
1361 """Apply <patchname> to the working directory. |
1361 |
1362 |
1362 'eolmode' specifies how end of lines should be handled. It can be: |
1363 'eolmode' specifies how end of lines should be handled. It can be: |
1363 - 'strict': inputs are read in binary mode, EOLs are preserved |
1364 - 'strict': inputs are read in binary mode, EOLs are preserved |
1372 if files is None: |
1373 if files is None: |
1373 files = {} |
1374 files = {} |
1374 try: |
1375 try: |
1375 if patcher: |
1376 if patcher: |
1376 return _externalpatch(ui, repo, patcher, patchname, strip, |
1377 return _externalpatch(ui, repo, patcher, patchname, strip, |
1377 cwd, files, similarity) |
1378 files, similarity) |
1378 return internalpatch(ui, repo, patchname, strip, files, eolmode, |
1379 return internalpatch(ui, repo, patchname, strip, files, eolmode, |
1379 similarity) |
1380 similarity) |
1380 except PatchError, err: |
1381 except PatchError, err: |
1381 raise util.Abort(str(err)) |
1382 raise util.Abort(str(err)) |
1382 |
1383 |