Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 14382:2d16f15da7bd
patch: remove patch.patch() cwd argument
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Thu, 19 May 2011 22:44:01 +0200 |
parents | d4192500586a |
children | 1bd52cb12a55 |
comparison
equal
deleted
inserted
replaced
14381:d4192500586a | 14382:2d16f15da7bd |
---|---|
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 |