Patchwork [STABLE] tag: add detail description about that local tag may hide global one

login
register
mail settings
Submitter Katsunori FUJIWARA
Date April 26, 2013, 3:32 p.m.
Message ID <1f68ea7d2f395fe35452.1366990368@feefifofum>
Download mbox | patch
Permalink /patch/1486/
State Superseded
Headers show

Comments

Katsunori FUJIWARA - April 26, 2013, 3:32 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1366988052 -32400
#      Fri Apr 26 23:54:12 2013 +0900
# Branch stable
# Node ID 1f68ea7d2f395fe35452d633d23ed72247865e35
# Parent  be207d9b7e4bc222f4ba72ad9a266df83d939ca4
tag: add detail description about that local tag may hide global one

In this patch, use "regular" instead of "global", because original
help document of "hg tags" uses the former, even though "global" is
usually used in source code.
Katsunori FUJIWARA - April 28, 2013, 11:56 a.m.
At Sat, 27 Apr 2013 13:05:01 -0500,
Kevin Bullock wrote:
> 
> On 26 Apr 2013, at 10:32 AM, FUJIWARA Katsunori wrote:
> 
> > # HG changeset patch
> > # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> > # Date 1366988052 -32400
> > #      Fri Apr 26 23:54:12 2013 +0900
> > # Branch stable
> > # Node ID 1f68ea7d2f395fe35452d633d23ed72247865e35
> > # Parent  be207d9b7e4bc222f4ba72ad9a266df83d939ca4
> > tag: add detail description about that local tag may hide global one
> 
> I don't think this is just a documentation problem. While experimenting with local vs. global tags, I produced a repository in which 'hg update' and 'hg log' think the local tag takes precedence, but 'hg tags -v' reports the global tag's target -- yet also shows the tag as 'local'!
>
> Working on a test case. Short version:
> 
> $ hg init a && cd a
> $ echo a>a
> $ hg ci -Am0
> $ hg tag -l t0
> $ echo b>a
> $ hg ci -m1
> $ hg tag -f t1

I assume that above is typo of "hg tag -f t0" (not "t1").

> $ hg tags -v
> tip                                2:18555d753664
> t0                                 1:f623ad5141d6 local
> #                                  ^^^ WAT

The cause of this is that tag type is overwritten as "local" even if
global tag is preferred.

I already confirmed that the patch below can show tag type correctly
in this case.

====================
         if (bnode != anode and anode in bhist and
             (bnode not in ahist or len(bhist) > len(ahist))):
             anode = bnode
+        else:
+            tagtypes[name] = tagtype
         ahist.extend([n for n in bhist if n not in ahist])
         alltags[name] = anode, ahist
-        tagtypes[name] = tagtype
====================
http://selenic.com/repo/hg/file/f01a351db791/mercurial/tags.py#l126

> $ hg up -q t0
> $ hg sum
> parent: 0:ab6e289ce0b3 t0
>  0
> branch: default
> commit: (clean)
> update: 2 new changesets (update)
> $ hg up -q
> $ hg tags -v
> tip                                2:18555d753664
> t0                                 0:ab6e289ce0b3 local
> #                                  ^^^ double-WAT

The cause of this is that tag cache invokes "_updatetags()" without
rank information (= history of overwriting). This is already mentioned
in comment.

====================
    if cachetags is not None:
        assert not shouldwrite
        # XXX is this really 100% correct?  are there oddball special
        # cases where a global tag should outrank a local tag but won't,
        # because cachetags does not contain rank info?
        _updatetags(cachetags, 'global', alltags, tagtypes)
====================

Discarding tag cache can avoid this problem, but it should have
performance impact on large (and/or many headed ".hgtags" ?)
repository.

Can we put rank information into tag cache without compatibility
breaking ?

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp
Matt Mackall - July 16, 2013, 6:12 p.m.
On Sun, 2013-04-28 at 20:56 +0900, FUJIWARA Katsunori wrote:

> Can we put rank information into tag cache without compatibility
> breaking ?

No, but we can easily change cache formats just by changing the cache
name and dropping all support for the old version.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5538,6 +5538,11 @@ 
     ".hg/localtags" is used for local tags (not shared among
     repositories).
 
+    .. container:: verbose
+
+      In many cases, local tag has higher priority than regular one.
+      See :hg:`help tags` with --verbose for details.
+
     Tag commits are usually made at the head of a branch. If the parent
     of the working directory is not a branch head, :hg:`tag` aborts; use
     -f/--force to force the tag commit to be based on a non-head
@@ -5624,6 +5629,20 @@ 
     This lists both regular and local tags. When the -v/--verbose
     switch is used, a third column "local" is printed for local tags.
 
+    .. container:: verbose
+
+      In many cases, local tag has higher priority than regular one.
+
+      For example, existing local tag may be kept visible, even after
+      successful creation of the regular one overwriting it.
+
+      Or, Local tag removal, which is achieved by re-tagging with null id,
+      may hide same name regular tag in the future.
+
+      Please check ".hg/localtags" and edit it manually, if certain regular
+      tag is not visible or hidden by existing local one in the output
+      of this command.
+
     Returns 0 on success.
     """