[PATCH] revlog: add a fast path for "ambiguous identifier"
Jun Wu
quark at fb.com
Wed Jun 22 22:12:51 UTC 2016
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1466627449 -3600
# Wed Jun 22 21:30:49 2016 +0100
# Node ID f19c6c3a03d78276d6db8c699fc84f453586b895
# Parent aa1d56003872cba207d908706da059141dd901a5
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r f19c6c3a03d7
revlog: add a fast path for "ambiguous identifier"
Before fd1bb7c, if the C index.partialmatch raises RevlogError, the Python
code raises "ambiguous identifier" error immediately, which is efficient.
fd1bb7c took hidden revisions into consideration and forced the slow path
enumerating the changelog to double-check hidden revisions. But it's not
necessary if we know the revlog has no hidden revisions.
This patch adds back the fast path for unfiltered revlogs.
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -941,8 +941,11 @@ class revlog(object):
return None
except RevlogError:
# parsers.c radix tree lookup gave multiple matches
+ # fast path: for unfiltered changelog, radix tree is accurate
+ if not getattr(self, 'filteredrevs', None):
+ raise LookupError(id, self.indexfile,
+ _('ambiguous identifier'))
# fall through to slow path that filters hidden revisions
- pass
except (AttributeError, ValueError):
# we are pure python, or key was too short to search radix tree
pass
More information about the Mercurial-devel
mailing list