D3189: context: extract partial nodeid lookup method to scmutil

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Sun Apr 8 16:03:42 UTC 2018


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We will add another caller soon, and there's a non-obvious reason to
  use the unfiltered repo that we don't want to copy across the code
  base.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3189

AFFECTED FILES
  mercurial/context.py
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -433,6 +433,11 @@
         hexfunc = short
     return '%d:%s' % (rev, hexfunc(node))
 
+def resolvepartialhexnodeid(repo, prefix):
+    # Uses unfiltered repo because it's faster when then prefix is ambiguous/
+    # This matches the "shortest" template function.
+    return repo.unfiltered().changelog._partialmatch(prefix)
+
 def isrevsymbol(repo, symbol):
     try:
         revsymbol(repo, symbol)
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -450,7 +450,7 @@
             except KeyError:
                 pass
 
-            self._node = repo.unfiltered().changelog._partialmatch(changeid)
+            self._node = scmutil.resolvepartialhexnodeid(repo, changeid)
             if self._node is not None:
                 self._rev = repo.changelog.rev(self._node)
                 return



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list