[PATCH 3 of 3] namespaces: add branches

Ryan McElroy rm at fb.com
Sun Dec 14 21:35:33 CST 2014


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1413584832 25200
#      Fri Oct 17 15:27:12 2014 -0700
# Node ID 39cead85fd58ae6693592074656b284ed736d9bc
# Parent  8b7c99b4d8ef8cd40712ad4c154111a51871e1b4
namespaces: add branches

Note that the exception-catching from the previous branchtip check is moved up
to catch exceptions from the try block surrounding the namespace lookup.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -414,11 +414,6 @@ class changectx(basectx):
                 return
             except KeyError:
                 pass
-
-            try:
-                self._node = repo.branchtip(changeid)
-                self._rev = repo.changelog.rev(self._node)
-                return
             except error.FilteredRepoLookupError:
                 raise
             except error.RepoLookupError:
diff --git a/mercurial/namespaces.py b/mercurial/namespaces.py
--- a/mercurial/namespaces.py
+++ b/mercurial/namespaces.py
@@ -44,6 +44,9 @@ class namespaces(object):
         addns("tags",
               lambda repo, name: tolist(repo._tagscache.tags.get(name)))
 
+        addns("branches",
+              lambda repo, name: tolist(repo.branchtip(name)))
+
     def addnamespace(self, namespace, namemap, order=None):
         """
         register a namespace


More information about the Mercurial-devel mailing list