[PATCH STABLE] convert: don't drop missing or corrupt tag entries

Yuya Nishihara yuya at tcha.org
Tue Aug 14 19:21:05 EDT 2018


On Tue, 14 Aug 2018 17:18:08 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1534269635 14400
> #      Tue Aug 14 14:00:35 2018 -0400
> # Branch stable
> # Node ID 48c3e568caa07eab1ca4e0514451335f4b074dba
> # Parent  5caee9f923ae19baa74386fb0ac8ff50ab8e2669
> convert: don't drop missing or corrupt tag entries
> 
> Cleaning up the tags file could be a useful feature in some cases, so maybe
> there should be a switch for this.  However, the default hg -> hg convert tries
> to maintain identical hashes (thus convert.hg.saverev is off by default, but is
> on by default for other source types).  It looks like _rewritesubstate() has a
> `continue` in it, and therefore a similar problem.
> 
> I ran into this conversion divergence when a coworker "merged" two repositories
> by copy/pasting all of the files from the source repo and massaging the code,
> and forgetting to revert the .hg* files.  That silently emptied the .hgtags file
> after the conversion.  (This isn't the manifest node bug Yuya has been helping
> with- this occurred well after the bzr -> hg conversion and wasn't a merge
> commit, which made it extra puzzling.  That bug is still an issue.)
> 
> diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
> --- a/hgext/convert/hg.py
> +++ b/hgext/convert/hg.py
> @@ -143,12 +143,17 @@ class mercurial_sink(common.converter_si
>          for line in data.splitlines():
>              s = line.split(' ', 1)
>              if len(s) != 2:
> +                self.ui.warn(_('invalid tag entry: "%s"\n') % line)
> +                fp.write('%s\n' % line)  # Bogus, but keep for hash stability
>                  continue
>              revid = revmap.get(source.lookuprev(s[0]))
>              if not revid:
>                  if s[0] == nodemod.nullhex:
>                      revid = s[0]
>                  else:
> +                    # missing, but keep for hash stability
> +                    self.ui.warn(_('missing tag entry: "%s"\n') % line)
> +                    fp.write('%s\n' % line)

Doesn't it leave tags on skipped revisions?

I understand this sort of feature is needed, but there would be no point to
keep invalid/unknown tags if we aren't trying to preserve hashes.


More information about the Mercurial-devel mailing list