mercurial/namespaces.py
changeset 23875 e573dd08aeaf
parent 23874 fef1146b8442
child 23967 448bb32b8ee6
equal deleted inserted replaced
23874:fef1146b8442 23875:e573dd08aeaf
   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, logname=None, listnames=None,
   123     def __init__(self, name, templatename=None, logname=None, colorname=None,
   124                  namemap=None, nodemap=None):
   124                  listnames=None, 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
   129         logname: the name to use for log output; if not specified templatename
   130                  is used
   130                  is used
       
   131         colorname: the name to use for colored log output; if not specified
       
   132                    logname is used
   131         listnames: function to list all names
   133         listnames: function to list all names
   132         namemap: function that inputs a node, output name(s)
   134         namemap: function that inputs a node, output name(s)
   133         nodemap: function that inputs a name, output node(s)
   135         nodemap: function that inputs a name, output node(s)
   134 
   136 
   135         """
   137         """
   136         self.name = name
   138         self.name = name
   137         self.templatename = templatename
   139         self.templatename = templatename
   138         self.logname = logname
   140         self.logname = logname
       
   141         self.colorname = colorname
   139         self.listnames = listnames
   142         self.listnames = listnames
   140         self.namemap = namemap
   143         self.namemap = namemap
   141         self.nodemap = nodemap
   144         self.nodemap = nodemap
   142 
   145 
   143         # if logname is not specified, use the template name as backup
   146         # if logname is not specified, use the template name as backup
   144         if self.logname is None:
   147         if self.logname is None:
   145             self.logname = self.templatename
   148             self.logname = self.templatename
       
   149 
       
   150         # if colorname is not specified, just use the logname as a backup
       
   151         if self.colorname is None:
       
   152             self.colorname = self.logname
   146 
   153 
   147     def names(self, repo, node):
   154     def names(self, repo, node):
   148         """method that returns a (sorted) list of names in a namespace that
   155         """method that returns a (sorted) list of names in a namespace that
   149         match a given node"""
   156         match a given node"""
   150         return sorted(self.nodemap(repo, node))
   157         return sorted(self.nodemap(repo, node))