Mercurial > hg
comparison mercurial/namespaces.py @ 23874:fef1146b8442
namespaces: add logname member to namespace object
Previously, there was no way to change the name used for 'hg log' output. This
was inconvenient for extensions that want a template name longer than 12
characters (e.g. remotebookmarks) but a different name for 'hg log'.
This patch only adds the member to the object, a future patch will update the
'hg log' code.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Wed, 14 Jan 2015 20:06:44 -0800 |
parents | 9ef234021667 |
children | e573dd08aeaf |
comparison
equal
deleted
inserted
replaced
23873:9ef234021667 | 23874:fef1146b8442 |
---|---|
118 'namemap': function that takes a name and returns a list of nodes | 118 'namemap': function that takes a name and returns a list of nodes |
119 'nodemap': function that takes a node and returns a list of names | 119 'nodemap': function that takes a node and returns a list of names |
120 | 120 |
121 """ | 121 """ |
122 | 122 |
123 def __init__(self, name, templatename=None, listnames=None, namemap=None, | 123 def __init__(self, name, templatename=None, logname=None, listnames=None, |
124 nodemap=None): | 124 namemap=None, nodemap=None): |
125 """create a namespace | 125 """create a namespace |
126 | 126 |
127 name: the namespace to be registered (in plural form) | 127 name: the namespace to be registered (in plural form) |
128 templatename: the name to use for templating | 128 templatename: the name to use for templating |
129 logname: the name to use for log output; if not specified templatename | |
130 is used | |
129 listnames: function to list all names | 131 listnames: function to list all names |
130 namemap: function that inputs a node, output name(s) | 132 namemap: function that inputs a node, output name(s) |
131 nodemap: function that inputs a name, output node(s) | 133 nodemap: function that inputs a name, output node(s) |
132 | 134 |
133 """ | 135 """ |
134 self.name = name | 136 self.name = name |
135 self.templatename = templatename | 137 self.templatename = templatename |
138 self.logname = logname | |
136 self.listnames = listnames | 139 self.listnames = listnames |
137 self.namemap = namemap | 140 self.namemap = namemap |
138 self.nodemap = nodemap | 141 self.nodemap = nodemap |
142 | |
143 # if logname is not specified, use the template name as backup | |
144 if self.logname is None: | |
145 self.logname = self.templatename | |
139 | 146 |
140 def names(self, repo, node): | 147 def names(self, repo, node): |
141 """method that returns a (sorted) list of names in a namespace that | 148 """method that returns a (sorted) list of names in a namespace that |
142 match a given node""" | 149 match a given node""" |
143 return sorted(self.nodemap(repo, node)) | 150 return sorted(self.nodemap(repo, node)) |