Mercurial > hg
comparison mercurial/namespaces.py @ 24151:38824c53c2f1 stable
revset: mask specific names for named() predicate
Before this patch, revset predicate "tag()" and "named('tags')" differ
from each other, because the former doesn't include "tip" but the
latter does.
For equivalence, "named('tags')" shouldn't include the revision
corresponded to "tip". But just removing "tip" from the "tags"
namespace causes breaking backward compatibility, even though "tip"
itself is planned to be eliminated, as mentioned below.
http://selenic.com/pipermail/mercurial-devel/2015-February/066157.html
To mask specific names ("tip" in this case) for "named()" predicate,
this patch introduces "deprecated" into "namespaces", and makes
"named()" predicate examine whether each names are masked by the
namespace, to which they belong.
"named()" will really work correctly after 3.3.1 (see 873eb5db89c8 for
detail), and fixing this on STABLE before 3.3.1 can prevent initial
users of "named()" from expecting "named('tags')" to include "tip".
It is reason why this patch is posted for STABLE, even though problem
itself isn't so serious.
This may have to be flagged as "(BC)", if applied on DEFAULT.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Thu, 05 Feb 2015 14:45:49 +0900 |
parents | 448bb32b8ee6 |
children | d8e0c591781c |
comparison
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 |