From patchwork Thu Jan 15 06:58:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4,of,5] namespaces: add colorname member to namespace object From: Sean Farley X-Patchwork-Id: 7471 Message-Id: <3f25179d696ba392ade8.1421305100@laptop.local> To: mercurial-devel@selenic.com Date: Wed, 14 Jan 2015 22:58:20 -0800 # HG changeset patch # User Sean Farley # Date 1421295062 28800 # Wed Jan 14 20:11:02 2015 -0800 # Node ID 3f25179d696ba392ade8b1c83024e14bcb1dd534 # Parent f3e5bd1b6dc1dfae3c5b6d5940aa7657ccdda789 namespaces: add colorname member to namespace object Previously, there was no way to change the color label used for 'hg log' output. This patch just adds the member to the object, a future patch will change 'hg log' to use this. diff --git a/mercurial/namespaces.py b/mercurial/namespaces.py --- a/mercurial/namespaces.py +++ b/mercurial/namespaces.py @@ -118,33 +118,39 @@ 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, logname=None, listnames=None, - namemap=None, nodemap=None): + def __init__(self, name, templatename=None, logname=None, colorname=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 + colorname: the name to use for colored 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.colorname = colorname 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 + # if colorname is not specified, just use the logname as a backup + if self.colorname is None: + self.colorname = self.logname + 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))