Patchwork D3189: context: extract partial nodeid lookup method to scmutil

login
register
mail settings
Submitter phabricator
Date April 10, 2018, 4:03 p.m.
Message ID <55759ae531fa2506a5d9c3c1c4416488@localhost.localdomain>
Download mbox | patch
Permalink /patch/30641/
State Not Applicable
Headers show

Comments

phabricator - April 10, 2018, 4:03 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG901e749ca0e1: context: extract partial nodeid lookup method to scmutil (authored by martinvonz, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D3189?vs=7878&id=7934#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3189?vs=7878&id=7934

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

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

CHANGE DETAILS




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

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -433,6 +433,15 @@ 
         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.
+    node = repo.unfiltered().changelog._partialmatch(prefix)
+    if node is None:
+        return
+    repo.changelog.rev(node)  # make sure node isn't filtered
+    return node
+
 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