revlog: drop some more error aliases (API)
These should be lightly used and I doubt that will be any
strong objections to removing the aliases.
Note that some uses of ProgrammingError in this file use
translated messages. I'm pretty sure that's a bug. But the
linters don't complain, so meh.
Differential Revision: https://phab.mercurial-scm.org/D4652
--- a/mercurial/revlog.py Tue Sep 18 16:18:37 2018 -0700
+++ b/mercurial/revlog.py Tue Sep 18 16:24:36 2018 -0700
@@ -105,9 +105,6 @@
_chunksize = 1048576
LookupError = error.LookupError
-AmbiguousPrefixLookupError = error.AmbiguousPrefixLookupError
-CensoredNodeError = error.CensoredNodeError
-ProgrammingError = error.ProgrammingError
# Store flag processors (cf. 'addflagprocessor()' to register)
_flagprocessors = {
@@ -180,10 +177,10 @@
"""
if not flag & REVIDX_KNOWN_FLAGS:
msg = _("cannot register processor on unknown flag '%#x'.") % (flag)
- raise ProgrammingError(msg)
+ raise error.ProgrammingError(msg)
if flag not in REVIDX_FLAGS_ORDER:
msg = _("flag '%#x' undefined in REVIDX_FLAGS_ORDER.") % (flag)
- raise ProgrammingError(msg)
+ raise error.ProgrammingError(msg)
if flag in _flagprocessors:
msg = _("cannot register multiple processors on flag '%#x'.") % (flag)
raise error.Abort(msg)
@@ -1279,8 +1276,8 @@
# parsers.c radix tree lookup gave multiple matches
# fast path: for unfiltered changelog, radix tree is accurate
if not getattr(self, 'filteredrevs', None):
- raise AmbiguousPrefixLookupError(id, self.indexfile,
- _('ambiguous identifier'))
+ raise error.AmbiguousPrefixLookupError(
+ id, self.indexfile, _('ambiguous identifier'))
# fall through to slow path that filters hidden revisions
except (AttributeError, ValueError):
# we are pure python, or key was too short to search radix tree
@@ -1303,8 +1300,8 @@
if len(nl) == 1 and not maybewdir:
self._pcache[id] = nl[0]
return nl[0]
- raise AmbiguousPrefixLookupError(id, self.indexfile,
- _('ambiguous identifier'))
+ raise error.AmbiguousPrefixLookupError(
+ id, self.indexfile, _('ambiguous identifier'))
if maybewdir:
raise error.WdirUnsupported
return None
@@ -1572,7 +1569,7 @@
def snapshotdepth(self, rev):
"""number of snapshot in the chain before this one"""
if not self.issnapshot(rev):
- raise ProgrammingError('revision %d not a snapshot')
+ raise error.ProgrammingError('revision %d not a snapshot')
return len(self._deltachain(rev)[0]) - 1
def revdiff(self, rev1, rev2):
@@ -1696,7 +1693,8 @@
if flags == 0:
return text, True
if not operation in ('read', 'write'):
- raise ProgrammingError(_("invalid '%s' operation ") % (operation))
+ raise error.ProgrammingError(_("invalid '%s' operation") %
+ operation)
# Check all flags are known.
if flags & ~REVIDX_KNOWN_FLAGS:
raise error.RevlogError(_("incompatible revision flag '%#x'") %
--- a/mercurial/revlogutils/deltas.py Tue Sep 18 16:18:37 2018 -0700
+++ b/mercurial/revlogutils/deltas.py Tue Sep 18 16:24:36 2018 -0700
@@ -33,8 +33,6 @@
mdiff,
)
-CensoredNodeError = error.CensoredNodeError
-
# maximum <delta-chain-data>/<revision-text-length> ratio
LIMIT_DELTA2TEXT = 2
@@ -460,7 +458,7 @@
revlog.checkhash(fulltext, expectednode, p1=p1, p2=p2)
if flags & REVIDX_ISCENSORED:
raise error.RevlogError(_('node %s is not censored') % expectednode)
- except CensoredNodeError:
+ except error.CensoredNodeError:
# must pass the censored index flag to add censored revisions
if not flags & REVIDX_ISCENSORED:
raise