Patchwork [2,of,4] namespaces: add __iter__ and iteritems methods

mail settings
Submitter Sean Farley
Date Jan. 7, 2015, 10:02 p.m.
Message ID <f160a3816c78174022f2.1420668133@laptop.local>
Download mbox | patch
Permalink /patch/7361/
State Accepted
Commit 19d6271a70db2de90dbd672d21a6d0d129113f66
Headers show


Sean Farley - Jan. 7, 2015, 10:02 p.m.
# HG changeset patch
# User Sean Farley <>
# Date 1419268057 28800
#      Mon Dec 22 09:07:37 2014 -0800
# Node ID f160a3816c78174022f29f623b27cc08768a0135
# Parent  f1bede576d4a0369e2cd5245cde1ee2c96ee5ee5
namespaces: add __iter__ and iteritems methods

Iterating over all the namespaces is a common operation, naturally, so we add
those methods now. Since we are using a sorted dictionary, this method just
calls the underlying __iter__ or iteritems method.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -47,10 +47,16 @@  class namespaces(object):
     def __getitem__(self, namespace):
         """returns the namespace object"""
         return self._names[namespace]
+    def __iter__(self):
+        return self._names.__iter__()
+    def iteritems(self):
+        return self._names.iteritems()
     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