comparison mercurial/cmdutil.py @ 34251:61714510220d

error: move patch.PatchError so it can easily implement __bytes__ (API)
author Yuya Nishihara <yuya@tcha.org>
date Sun, 03 Sep 2017 16:45:33 +0900
parents e9898ad31115
children 1d6558f5ea74
comparison
equal deleted inserted replaced
34250:448725a2ef73 34251:61714510220d
276 originalchunks = patch.parsepatch(originaldiff) 276 originalchunks = patch.parsepatch(originaldiff)
277 277
278 # 1. filter patch, since we are intending to apply subset of it 278 # 1. filter patch, since we are intending to apply subset of it
279 try: 279 try:
280 chunks, newopts = filterfn(ui, originalchunks) 280 chunks, newopts = filterfn(ui, originalchunks)
281 except patch.PatchError as err: 281 except error.PatchError as err:
282 raise error.Abort(_('error parsing patch: %s') % err) 282 raise error.Abort(_('error parsing patch: %s') % err)
283 opts.update(newopts) 283 opts.update(newopts)
284 284
285 # We need to keep a backup of files that have been newly added and 285 # We need to keep a backup of files that have been newly added and
286 # modified during the recording process because there is a previous 286 # modified during the recording process because there is a previous
358 if dopatch: 358 if dopatch:
359 try: 359 try:
360 ui.debug('applying patch\n') 360 ui.debug('applying patch\n')
361 ui.debug(fp.getvalue()) 361 ui.debug(fp.getvalue())
362 patch.internalpatch(ui, repo, fp, 1, eolmode=None) 362 patch.internalpatch(ui, repo, fp, 1, eolmode=None)
363 except patch.PatchError as err: 363 except error.PatchError as err:
364 raise error.Abort(str(err)) 364 raise error.Abort(str(err))
365 del fp 365 del fp
366 366
367 # 4. We prepared working directory according to filtered 367 # 4. We prepared working directory according to filtered
368 # patch. Now is the time to delegate the job to 368 # patch. Now is the time to delegate the job to
1332 partial = opts.get('partial', False) 1332 partial = opts.get('partial', False)
1333 files = set() 1333 files = set()
1334 try: 1334 try:
1335 patch.patch(ui, repo, tmpname, strip=strip, prefix=prefix, 1335 patch.patch(ui, repo, tmpname, strip=strip, prefix=prefix,
1336 files=files, eolmode=None, similarity=sim / 100.0) 1336 files=files, eolmode=None, similarity=sim / 100.0)
1337 except patch.PatchError as e: 1337 except error.PatchError as e:
1338 if not partial: 1338 if not partial:
1339 raise error.Abort(str(e)) 1339 raise error.Abort(str(e))
1340 if partial: 1340 if partial:
1341 rejects = True 1341 rejects = True
1342 1342
1378 try: 1378 try:
1379 files = set() 1379 files = set()
1380 try: 1380 try:
1381 patch.patchrepo(ui, repo, p1, store, tmpname, strip, prefix, 1381 patch.patchrepo(ui, repo, p1, store, tmpname, strip, prefix,
1382 files, eolmode=None) 1382 files, eolmode=None)
1383 except patch.PatchError as e: 1383 except error.PatchError as e:
1384 raise error.Abort(str(e)) 1384 raise error.Abort(str(e))
1385 if opts.get('exact'): 1385 if opts.get('exact'):
1386 editor = None 1386 editor = None
1387 else: 1387 else:
1388 editor = getcommiteditor(editform='import.bypass') 1388 editor = getcommiteditor(editform='import.bypass')
3727 chunks, opts = recordfilter(repo.ui, originalchunks, 3727 chunks, opts = recordfilter(repo.ui, originalchunks,
3728 operation=operation) 3728 operation=operation)
3729 if reversehunks: 3729 if reversehunks:
3730 chunks = patch.reversehunks(chunks) 3730 chunks = patch.reversehunks(chunks)
3731 3731
3732 except patch.PatchError as err: 3732 except error.PatchError as err:
3733 raise error.Abort(_('error parsing patch: %s') % err) 3733 raise error.Abort(_('error parsing patch: %s') % err)
3734 3734
3735 newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks) 3735 newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks)
3736 if tobackup is None: 3736 if tobackup is None:
3737 tobackup = set() 3737 tobackup = set()
3749 dopatch = fp.tell() 3749 dopatch = fp.tell()
3750 fp.seek(0) 3750 fp.seek(0)
3751 if dopatch: 3751 if dopatch:
3752 try: 3752 try:
3753 patch.internalpatch(repo.ui, repo, fp, 1, eolmode=None) 3753 patch.internalpatch(repo.ui, repo, fp, 1, eolmode=None)
3754 except patch.PatchError as err: 3754 except error.PatchError as err:
3755 raise error.Abort(str(err)) 3755 raise error.Abort(str(err))
3756 del fp 3756 del fp
3757 else: 3757 else:
3758 for f in actions['revert'][0]: 3758 for f in actions['revert'][0]:
3759 checkout(f) 3759 checkout(f)