Patchwork [1,of,4] namespaces: add __getitem__ property

mail settings
Submitter Sean Farley
Date Jan. 2, 2015, 11:42 p.m.
Message ID <165fc028b31c989af76a.1420242122@laptop.local>
Download mbox | patch
Permalink /patch/7303/
State Accepted
Commit d7324c242c3fd509c7c8dbc8cfca6534ea2251ec
Headers show


Sean Farley - Jan. 2, 2015, 11:42 p.m.
# HG changeset patch
# User Sean Farley <>
# Date 1419198992 28800
#      Sun Dec 21 13:56:32 2014 -0800
# Node ID 165fc028b31c989af76a944c5ecfbbbb19579629
# Parent  42908c3275c63b7d2d6c871094c1e2c8f7ba31c8
namespaces: add __getitem__ property

Since the namespaces object uses an underlying (sorted) dictionary to store the
namespaces, it makes sense to expose this to naturally gain access to those


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -40,10 +40,14 @@  class namespaces(object):
         n = ns("branches", "branch",
                lambda repo, name: tolist(repo.branchtip(name)),
                lambda repo, node: [repo[node].branch()])
+    def __getitem__(self, namespace):
+        """returns the namespace object"""
+        return self._names[namespace]
     def addnamespace(self, namespace, order=None):
         """register a namespace
         namespace: the name to be registered (in plural form)
         order: optional argument to specify the order of namespaces