Patchwork [stable,v2] convert: mercurial source: convert global tags only - not local tags

login
register
mail settings
Submitter Mads Kiilerich
Date May 16, 2014, 12:31 a.m.
Message ID <ba5ad90775f6bc2860b8.1400200302@localhost.localdomain>
Download mbox | patch
Permalink /patch/4779/
State Accepted
Headers show

Comments

Mads Kiilerich - May 16, 2014, 12:31 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1400200227 -7200
#      Fri May 16 02:30:27 2014 +0200
# Node ID ba5ad90775f6bc2860b890a5c08f7da947f2e58b
# Parent  883e268cb860c0ea2eb0faa94114e11c3a4a3893
convert: mercurial source: convert global tags only - not local tags

Mercurial tags can be local (tag -l, stored in .hg/localtags) or global (normal
tags, tracked in .hgtags) ... or extensions can add other kind of tags.

Convert would take all tags (except "tip"), not just the ones from .hgtags, and
put them into .hgtags.

Instead, convert only the global tags that come from .hgtags.
Sean Farley - May 16, 2014, 1:46 a.m.
Mads Kiilerich <mads@kiilerich.com> writes:

> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1400200227 -7200
> #      Fri May 16 02:30:27 2014 +0200
> # Node ID ba5ad90775f6bc2860b890a5c08f7da947f2e58b
> # Parent  883e268cb860c0ea2eb0faa94114e11c3a4a3893
> convert: mercurial source: convert global tags only - not local tags
>
> Mercurial tags can be local (tag -l, stored in .hg/localtags) or global (normal
> tags, tracked in .hgtags) ... or extensions can add other kind of tags.
>
> Convert would take all tags (except "tip"), not just the ones from .hgtags, and
> put them into .hgtags.
>
> Instead, convert only the global tags that come from .hgtags.
>
> diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
> --- a/hgext/convert/hg.py
> +++ b/hgext/convert/hg.py
> @@ -394,7 +394,8 @@ class mercurial_source(converter_source)
>                        sortkey=ctx.rev())
>  
>      def gettags(self):
> -        tags = [t for t in self.repo.tagslist() if t[0] != 'tip']
> +        tags = [t for t in self.repo.tagslist()
> +                if self.repo.tagtype(t[0]) == 'global']

Nitpicking but there could be a comment that says:

# only convert global tags since extensions may add local tags which
# would not make sense to convert
Pierre-Yves David - May 18, 2014, 5:04 a.m.
On 05/15/2014 05:31 PM, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1400200227 -7200
> #      Fri May 16 02:30:27 2014 +0200
> # Node ID ba5ad90775f6bc2860b890a5c08f7da947f2e58b
> # Parent  883e268cb860c0ea2eb0faa94114e11c3a4a3893
> convert: mercurial source: convert global tags only - not local tags

This one have been pushed to the clowncopter after adding small comment 
before the code change.

   # This will get written to .hgtags, filter non global tags out.

(queued)

Patch

diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -394,7 +394,8 @@  class mercurial_source(converter_source)
                       sortkey=ctx.rev())
 
     def gettags(self):
-        tags = [t for t in self.repo.tagslist() if t[0] != 'tip']
+        tags = [t for t in self.repo.tagslist()
+                if self.repo.tagtype(t[0]) == 'global']
         return dict([(name, hex(node)) for name, node in tags
                      if self.keep(node)])
 
diff --git a/tests/test-convert-hg-sink.t b/tests/test-convert-hg-sink.t
--- a/tests/test-convert-hg-sink.t
+++ b/tests/test-convert-hg-sink.t
@@ -16,8 +16,10 @@ 
   $ echo file > foo/file
   $ hg ci -qAm 'add foo/file'
   $ hg tag some-tag
+  $ hg tag -l local-tag
   $ hg log
   changeset:   3:593cbf6fb2b4
+  tag:         local-tag
   tag:         tip
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000