[PATCH V2] revset: omit dropping tip from the result of tag() (BC)

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Wed Feb 4 07:05:39 UTC 2015


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1423033325 -32400
#      Wed Feb 04 16:02:05 2015 +0900
# Node ID be0452c3be1b5f4bb9b425049a36f81238873fc2
# Parent  e1dbe0b215ae137eec53ceb12440536d570a83d2
revset: omit dropping tip from the result of tag() (BC)

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 between "hg tags", "tag()" and "named('tags')", this
patch omits dropping "tip" from the result of "tags" predicate, when
no pattern is specified to it.

This patch chooses this policy for simplicity, even though this may
break backward compatibility for existing tools, which expect that
"tip" isn't listed up in the result of "tag()".

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1824,7 +1824,7 @@ def tag(repo, subset, x):
         else:
             s = set([cl.rev(n) for t, n in repo.tagslist() if matcher(t)])
     else:
-        s = set([cl.rev(n) for t, n in repo.tagslist() if t != 'tip'])
+        s = set([cl.rev(n) for t, n in repo.tagslist()])
     return subset & s
 
 def tagged(repo, subset, x):
diff --git a/tests/test-revset-dirstate-parents.t b/tests/test-revset-dirstate-parents.t
--- a/tests/test-revset-dirstate-parents.t
+++ b/tests/test-revset-dirstate-parents.t
@@ -33,13 +33,20 @@ null revision
 working dir with a single parent
   $ echo a > a
   $ hg ci -Aqm0
+  $ log 'tag()'
+  0
+  $ log 'tip'
+  0
   $ log 'p1()'
   0
   $ log 'tag() and p1()'
+  0
   $ log 'p2()'
   $ log 'parents()'
   0
   $ log 'tag() and parents()'
+  0
+  $ log 'tag() and p2()'
 
 merge in progress
   $ echo b > b
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -544,8 +544,10 @@ Test null revision
   4
   $ log 'tagged()'
   6
+  9
   $ log 'tag()'
   6
+  9
   $ log 'tag(1.0)'
   6
   $ log 'tag(tip)'
@@ -789,6 +791,7 @@ we can use patterns when searching for t
 
   $ log 'tag()'
   6
+  9
   $ log 'named("tags")'
   6
   9


More information about the Mercurial-devel mailing list