Patchwork [4,of,7,V2] namespaces: add names method to return list of names for a given node

login
register
mail settings
Submitter Sean Farley
Date Dec. 18, 2014, 9:10 p.m.
Message ID <a6308360a56c275faf1f.1418937048@laptop.local>
Download mbox | patch
Permalink /patch/7176/
State Accepted
Headers show

Comments

Sean Farley - Dec. 18, 2014, 9:10 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1418612090 28800
#      Sun Dec 14 18:54:50 2014 -0800
# Node ID a6308360a56c275faf1fe8807babd48a37c0d012
# Parent  430e5b84bcf084090939993ab9a05f342bbb85ed
namespaces: add names method to return list of names for a given node

In the previous patch, we added a node-to-name map property. This patch just
exposes that interface to the api.

Patch

diff --git a/mercurial/namespaces.py b/mercurial/namespaces.py
--- a/mercurial/namespaces.py
+++ b/mercurial/namespaces.py
@@ -94,5 +94,10 @@  class namespaces(object):
         raise KeyError(_('no such name: %s') % name)
 
     def templatename(self, namespace):
         """method that returns the template name of a namespace"""
         return self._names[namespace]['templatename']
+
+    def names(self, repo, namespace, node):
+        """method that returns a (sorted) list of names in a namespace that
+        match a given node"""
+        return sorted(self._names[namespace]['nodemap'](repo, node))