Mercurial > hg
changeset 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 | 150425deffd1 |
children | 97a548aeb749 |
files | mercurial/namespaces.py mercurial/revset.py tests/test-revset.t |
diffstat | 3 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/namespaces.py Sun Mar 01 00:18:43 2015 -0300 +++ b/mercurial/namespaces.py Thu Feb 05 14:45:49 2015 +0900 @@ -41,7 +41,8 @@ # i18n: column positioning for "hg log" logfmt=_("tag: %s\n"), listnames=tagnames, - namemap=tagnamemap, nodemap=tagnodemap) + namemap=tagnamemap, nodemap=tagnodemap, + deprecated=set(['tip'])) self.addnamespace(n) bnames = lambda repo: repo.branchmap().keys() @@ -126,11 +127,13 @@ dictionary) 'namemap': function that takes a name and returns a list of nodes 'nodemap': function that takes a node and returns a list of names + 'deprecated': set of names to be masked for ordinary use """ def __init__(self, name, templatename=None, logname=None, colorname=None, - logfmt=None, listnames=None, namemap=None, nodemap=None): + logfmt=None, listnames=None, namemap=None, nodemap=None, + deprecated=None): """create a namespace name: the namespace to be registered (in plural form) @@ -144,6 +147,7 @@ listnames: function to list all names namemap: function that inputs a node, output name(s) nodemap: function that inputs a name, output node(s) + deprecated: set of names to be masked for ordinary use """ self.name = name @@ -168,6 +172,11 @@ # i18n: column positioning for "hg log" self.logfmt = ("%s:" % self.logname).ljust(13) + "%s\n" + if deprecated is None: + self.deprecated = set() + else: + self.deprecated = deprecated + def names(self, repo, node): """method that returns a (sorted) list of names in a namespace that match a given node"""
--- a/mercurial/revset.py Sun Mar 01 00:18:43 2015 -0300 +++ b/mercurial/revset.py Thu Feb 05 14:45:49 2015 +0900 @@ -1277,7 +1277,8 @@ names = set() for ns in namespaces: for name in ns.listnames(repo): - names.update(repo[n].rev() for n in ns.nodes(repo, name)) + if name not in ns.deprecated: + names.update(repo[n].rev() for n in ns.nodes(repo, name)) names -= set([node.nullrev]) return subset & names