Submitter | Sean Farley |
---|---|
Date | Jan. 15, 2015, 6:58 a.m. |
Message ID | <f3e5bd1b6dc1dfae3c5b.1421305099@laptop.local> |
Download | mbox | patch |
Permalink | /patch/7470/ |
State | Accepted |
Headers | show |
Comments
On 01/14/2015 10:58 PM, Sean Farley wrote: > # HG changeset patch > # User Sean Farley <sean.michael.farley@gmail.com> > # Date 1421294804 28800 > # Wed Jan 14 20:06:44 2015 -0800 > # Node ID f3e5bd1b6dc1dfae3c5b6d5940aa7657ccdda789 > # Parent eb89945cb5f4535e5f8d3f2dfc9935f864291de2 > 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. > > diff --git a/mercurial/namespaces.py b/mercurial/namespaces.py > --- a/mercurial/namespaces.py > +++ b/mercurial/namespaces.py > @@ -118,27 +118,33 @@ class namespace(object): > 'namemap': function that takes a name and returns a list of nodes > 'nodemap': function that takes a node and returns a list of names > > """ > > - def __init__(self, name, templatename=None, listnames=None, namemap=None, > - nodemap=None): > + def __init__(self, name, templatename=None, logname=None, listnames=None, > + namemap=None, nodemap=None): > """create a namespace > > name: the namespace to be registered (in plural form) > templatename: the name to use for templating > + logname: the name to use for log output > listnames: function to list all names > namemap: function that inputs a node, output name(s) > nodemap: function that inputs a name, output node(s) > > """ > self.name = name > self.templatename = templatename > + self.logname = logname > self.listnames = listnames > self.namemap = namemap > self.nodemap = nodemap > > + # if logname is not specified, use the template name as backup > + if self.logname is None: > + self.logname = self.templatename This information (using template if None) should be somewhere in the main documentation
Patch
diff --git a/mercurial/namespaces.py b/mercurial/namespaces.py --- a/mercurial/namespaces.py +++ b/mercurial/namespaces.py @@ -118,27 +118,33 @@ class namespace(object): 'namemap': function that takes a name and returns a list of nodes 'nodemap': function that takes a node and returns a list of names """ - def __init__(self, name, templatename=None, listnames=None, namemap=None, - nodemap=None): + def __init__(self, name, templatename=None, logname=None, listnames=None, + namemap=None, nodemap=None): """create a namespace name: the namespace to be registered (in plural form) templatename: the name to use for templating + logname: the name to use for log output listnames: function to list all names namemap: function that inputs a node, output name(s) nodemap: function that inputs a name, output node(s) """ self.name = name self.templatename = templatename + self.logname = logname self.listnames = listnames self.namemap = namemap self.nodemap = nodemap + # if logname is not specified, use the template name as backup + if self.logname is None: + self.logname = self.templatename + def names(self, repo, node): """method that returns a (sorted) list of names in a namespace that match a given node""" return sorted(self.nodemap(repo, node))