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

login
register
mail settings
Submitter Sean Farley
Date March 30, 2014, 11:09 p.m.
Message ID <c70e4216df9d4d9a41b5.1396220945@laptop.local>
Download mbox | patch
Permalink /patch/4154/
State Deferred
Headers show

Comments

Sean Farley - March 30, 2014, 11:09 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@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.

Patch

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?