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

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sun Apr 28 06:56:28 CDT 2013


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 at 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 at lares.dti.ne.jp


More information about the Mercurial-devel mailing list