mercurial/namespaces.py
branchstable
changeset 24151 38824c53c2f1
parent 23967 448bb32b8ee6
child 24180 d8e0c591781c
equal deleted inserted replaced
24150:150425deffd1 24151:38824c53c2f1
    39         tagnodemap = lambda repo, name: repo.nodetags(name)
    39         tagnodemap = lambda repo, name: repo.nodetags(name)
    40         n = namespace("tags", templatename="tag",
    40         n = namespace("tags", templatename="tag",
    41                       # i18n: column positioning for "hg log"
    41                       # i18n: column positioning for "hg log"
    42                       logfmt=_("tag:         %s\n"),
    42                       logfmt=_("tag:         %s\n"),
    43                       listnames=tagnames,
    43                       listnames=tagnames,
    44                       namemap=tagnamemap, nodemap=tagnodemap)
    44                       namemap=tagnamemap, nodemap=tagnodemap,
       
    45                       deprecated=set(['tip']))
    45         self.addnamespace(n)
    46         self.addnamespace(n)
    46 
    47 
    47         bnames = lambda repo: repo.branchmap().keys()
    48         bnames = lambda repo: repo.branchmap().keys()
    48         bnamemap = lambda repo, name: tolist(repo.branchtip(name, True))
    49         bnamemap = lambda repo, name: tolist(repo.branchtip(name, True))
    49         bnodemap = lambda repo, node: [repo[node].branch()]
    50         bnodemap = lambda repo, node: [repo[node].branch()]
   124                       of the plural namespace name)
   125                       of the plural namespace name)
   125       'listnames': list of all names in the namespace (usually the keys of a
   126       'listnames': list of all names in the namespace (usually the keys of a
   126                    dictionary)
   127                    dictionary)
   127       'namemap': function that takes a name and returns a list of nodes
   128       'namemap': function that takes a name and returns a list of nodes
   128       'nodemap': function that takes a node and returns a list of names
   129       'nodemap': function that takes a node and returns a list of names
       
   130       'deprecated': set of names to be masked for ordinary use
   129 
   131 
   130     """
   132     """
   131 
   133 
   132     def __init__(self, name, templatename=None, logname=None, colorname=None,
   134     def __init__(self, name, templatename=None, logname=None, colorname=None,
   133                  logfmt=None, listnames=None, namemap=None, nodemap=None):
   135                  logfmt=None, listnames=None, namemap=None, nodemap=None,
       
   136                  deprecated=None):
   134         """create a namespace
   137         """create a namespace
   135 
   138 
   136         name: the namespace to be registered (in plural form)
   139         name: the namespace to be registered (in plural form)
   137         templatename: the name to use for templating
   140         templatename: the name to use for templating
   138         logname: the name to use for log output; if not specified templatename
   141         logname: the name to use for log output; if not specified templatename
   142         logfmt: the format to use for (l10n-ed) log output; if not specified
   145         logfmt: the format to use for (l10n-ed) log output; if not specified
   143                 it is composed from logname
   146                 it is composed from logname
   144         listnames: function to list all names
   147         listnames: function to list all names
   145         namemap: function that inputs a node, output name(s)
   148         namemap: function that inputs a node, output name(s)
   146         nodemap: function that inputs a name, output node(s)
   149         nodemap: function that inputs a name, output node(s)
       
   150         deprecated: set of names to be masked for ordinary use
   147 
   151 
   148         """
   152         """
   149         self.name = name
   153         self.name = name
   150         self.templatename = templatename
   154         self.templatename = templatename
   151         self.logname = logname
   155         self.logname = logname
   166         # if logfmt is not specified, compose it from logname as backup
   170         # if logfmt is not specified, compose it from logname as backup
   167         if self.logfmt is None:
   171         if self.logfmt is None:
   168             # i18n: column positioning for "hg log"
   172             # i18n: column positioning for "hg log"
   169             self.logfmt = ("%s:" % self.logname).ljust(13) + "%s\n"
   173             self.logfmt = ("%s:" % self.logname).ljust(13) + "%s\n"
   170 
   174 
       
   175         if deprecated is None:
       
   176             self.deprecated = set()
       
   177         else:
       
   178             self.deprecated = deprecated
       
   179 
   171     def names(self, repo, node):
   180     def names(self, repo, node):
   172         """method that returns a (sorted) list of names in a namespace that
   181         """method that returns a (sorted) list of names in a namespace that
   173         match a given node"""
   182         match a given node"""
   174         return sorted(self.nodemap(repo, node))
   183         return sorted(self.nodemap(repo, node))
   175 
   184