[PATCH 1 of 6 py3] error: move patch.PatchError so it can easily implement __bytes__ (API)
Yuya Nishihara
yuya at tcha.org
Sun Sep 17 04:19:00 UTC 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1504424733 -32400
# Sun Sep 03 16:45:33 2017 +0900
# Node ID 2a70a351319def181dfc102f8577a1f006abf970
# Parent 448725a2ef7356524bcc9638a5c5eaaf59f263af
error: move patch.PatchError so it can easily implement __bytes__ (API)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -278,7 +278,7 @@ def dorecord(ui, repo, commitfunc, cmdsu
# 1. filter patch, since we are intending to apply subset of it
try:
chunks, newopts = filterfn(ui, originalchunks)
- except patch.PatchError as err:
+ except error.PatchError as err:
raise error.Abort(_('error parsing patch: %s') % err)
opts.update(newopts)
@@ -360,7 +360,7 @@ def dorecord(ui, repo, commitfunc, cmdsu
ui.debug('applying patch\n')
ui.debug(fp.getvalue())
patch.internalpatch(ui, repo, fp, 1, eolmode=None)
- except patch.PatchError as err:
+ except error.PatchError as err:
raise error.Abort(str(err))
del fp
@@ -1334,7 +1334,7 @@ def tryimportone(ui, repo, hunk, parents
try:
patch.patch(ui, repo, tmpname, strip=strip, prefix=prefix,
files=files, eolmode=None, similarity=sim / 100.0)
- except patch.PatchError as e:
+ except error.PatchError as e:
if not partial:
raise error.Abort(str(e))
if partial:
@@ -1380,7 +1380,7 @@ def tryimportone(ui, repo, hunk, parents
try:
patch.patchrepo(ui, repo, p1, store, tmpname, strip, prefix,
files, eolmode=None)
- except patch.PatchError as e:
+ except error.PatchError as e:
raise error.Abort(str(e))
if opts.get('exact'):
editor = None
@@ -3729,7 +3729,7 @@ def _performrevert(repo, parents, ctx, a
if reversehunks:
chunks = patch.reversehunks(chunks)
- except patch.PatchError as err:
+ except error.PatchError as err:
raise error.Abort(_('error parsing patch: %s') % err)
newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks)
@@ -3751,7 +3751,7 @@ def _performrevert(repo, parents, ctx, a
if dopatch:
try:
patch.internalpatch(repo.ui, repo, fp, 1, eolmode=None)
- except patch.PatchError as err:
+ except error.PatchError as err:
raise error.Abort(str(err))
del fp
else:
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -115,6 +115,9 @@ class ParseError(Hint, Exception):
"""Raised when parsing config files and {rev,file}sets (msg[, pos])"""
__bytes__ = _tobytes
+class PatchError(Exception):
+ __bytes__ = _tobytes
+
class UnknownIdentifier(ParseError):
"""Exception raised when a {rev,file}set references an unknown identifier"""
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -46,9 +46,7 @@ stringio = util.stringio
gitre = re.compile(br'diff --git a/(.*) b/(.*)')
tabsplitter = re.compile(br'(\t+|[^\t]+)')
-class PatchError(Exception):
- pass
-
+PatchError = error.PatchError
# public functions
diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -884,7 +884,7 @@ timestamp of them isn't changed on the f
$ cat > $TESTTMP/abort.py <<EOF
> # emulate that patch.patch() is aborted at patching on "abort" file
- > from mercurial import extensions, patch as patchmod
+ > from mercurial import error, extensions, patch as patchmod
> def patch(orig, ui, repo, patchname,
> strip=1, prefix='', files=None,
> eolmode='strict', similarity=0):
@@ -894,7 +894,7 @@ timestamp of them isn't changed on the f
> strip=strip, prefix=prefix, files=files,
> eolmode=eolmode, similarity=similarity)
> if 'abort' in files:
- > raise patchmod.PatchError('intentional error while patching')
+ > raise error.PatchError('intentional error while patching')
> return r
> def extsetup(ui):
> extensions.wrapfunction(patchmod, 'patch', patch)
More information about the Mercurial-devel
mailing list