changectx: use names api to simplify and extend node lookup
authorSean Farley <sean.michael.farley@gmail.com>
Thu, 16 Oct 2014 23:27:54 -0700
changeset 23560 aead63705504
parent 23559 3b3a962e3677
child 23561 3c2419e07df5
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.
mercurial/context.py
--- a/mercurial/context.py	Fri Oct 17 15:28:40 2014 -0700
+++ b/mercurial/context.py	Thu Oct 16 23:27:54 2014 -0700
@@ -407,10 +407,14 @@
                 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)