[PATCH 8 of 8] changectx: use names api to simplify and extend node lookup

Sean Farley sean.michael.farley at gmail.com
Sun Dec 14 18:37:56 CST 2014


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1413527274 25200
#      Thu Oct 16 23:27:54 2014 -0700
# Node ID d096475df70e5c6b9ddfde2752749d94eadbfa0c
# Parent  85c150b347a9fc6c717864ba4f7e2d60812b5fad
changectx: use names api to simplify and extend node lookup

Previously, changectx had to know about each type of name (bookmark, tag, etc.)
to look up. Now, we use repo.namenodes to simplify (and extend) this.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -405,14 +405,18 @@ class changectx(basectx):
                 except error.FilteredLookupError:
                     raise
                 except (TypeError, LookupError):
                     pass
 
-            if changeid in repo._bookmarks:
-                self._node = repo._bookmarks[changeid]
+            # lookup bookmarks through the name interface
+            try:
+                self._node = repo.names.singlenode(changeid)
                 self._rev = repo.changelog.rev(self._node)
                 return
+            except KeyError:
+                pass
+
             if changeid in repo._tagscache.tags:
                 self._node = repo._tagscache.tags[changeid]
                 self._rev = repo.changelog.rev(self._node)
                 return
             try:


More information about the Mercurial-devel mailing list