[PATCH 7 of 9 RFC] localrepo: generate a template keyword for new namespaces

Sean Farley sean.michael.farley at gmail.com
Sun Mar 30 18:09:05 CDT 2014


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1396219075 18000
#      Sun Mar 30 17:37:55 2014 -0500
# Node ID c70e4216df9d4d9a41b54dfb88e000b377c73825
# Parent  bd0a4d48b4ec44de53ec8710f077ddf1850900a4
localrepo: generate a template keyword for new namespaces

When a new namespace is passed to repo.mark, we will generate a new template
keyword that is the namespace with 'list' appended to it. This is because there
is no easy way to make a plural word.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -15,10 +15,11 @@ import match as matchmod
 import merge as mergemod
 import tags as tagsmod
 from lock import release
 import weakref, errno, os, time, inspect
 import branchmap, pathutil
+import templatekw
 propertycache = util.propertycache
 filecache = scmutil.filecache
 
 class repofilecache(filecache):
     """All filecache usage on repo are done for logic that should be unfiltered
@@ -656,16 +657,18 @@ class localrepository(object):
             if n == node:
                 marks.append(bookmark)
         return sorted(marks)
 
     def _createmarkernamespace(self, namespace):
-        '''Function to create a dictionary entry for namespace. Exists to avoid code
-        duplication.
+        '''Function to create a dictionary entry for namespace and a template
+        keyword. Exists to avoid code duplication.
         '''
         if namespace not in self._markers:
             # ensure a blank dictionary exists
             self._markers[namespace] = {}
+            kw = lambda **args: templatekw.showmarkers(namespace, **args)
+            templatekw.keywords[namespace + 'list'] = kw
 
     def mark(self, namespace, name, node):
         '''Add a mark to self._markers[namespace][name]
 
         RFC: should we allow tags and bookmarks to be set this way?


More information about the Mercurial-devel mailing list