Submitter | Matt Harbison |
---|---|
Date | Aug. 14, 2018, 9:18 p.m. |
Message ID | <48c3e568caa07eab1ca4.1534281488@mharbison-pc.attotech.com> |
Download | mbox | patch |
Permalink | /patch/33728/ |
State | Accepted |
Headers | show |
Comments
On Tue, 14 Aug 2018 17:18:08 -0400, Matt Harbison wrote: > # HG changeset patch > # User Matt Harbison <matt_harbison@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.
Patch
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) continue fp.write('%s %s\n' % (revid, s[1])) return fp.getvalue() 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 @@ -17,10 +17,17 @@ $ hg ci -qAm 'add foo/file' $ hg tag some-tag $ hg tag -l local-tag + $ echo '1234567890123456789012345678901234567890 missing_tag' >> .hgtags + $ hg ci -m 'add a missing tag' $ hg log + changeset: 4:3fb95ee23a66 + tag: tip + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: add a missing tag + changeset: 3:593cbf6fb2b4 tag: local-tag - tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: Added tag some-tag for changeset ad681a868e44 @@ -48,12 +55,16 @@ scanning source... sorting... converting... - 3 add foo and bar - 2 remove foo - 1 add foo/file - 0 Added tag some-tag for changeset ad681a868e44 + 4 add foo and bar + 3 remove foo + 2 add foo/file + 1 Added tag some-tag for changeset ad681a868e44 + 0 add a missing tag + missing tag entry: "1234567890123456789012345678901234567890 missing_tag" $ cd new $ hg log -G --template '{rev} {node|short} ({phase}) "{desc}"\n' + o 4 3fb95ee23a66 (public) "add a missing tag" + | o 3 593cbf6fb2b4 (public) "Added tag some-tag for changeset ad681a868e44" | o 2 ad681a868e44 (public) "add foo/file" @@ -125,14 +136,16 @@ test tag rewriting scanning source... sorting... converting... - 4 add foo and bar - 3 remove foo - 2 add foo/file - 1 Added tag some-tag for changeset ad681a868e44 + 5 add foo and bar + 4 remove foo + 3 add foo/file + 2 Added tag some-tag for changeset ad681a868e44 + 1 add a missing tag + missing tag entry: "1234567890123456789012345678901234567890 missing_tag" 0 add baz $ cd new-filemap $ hg tags - tip 2:3c74706b1ff8 + tip 3:7bb553f2c68a some-tag 0:ba8636729451 $ cd ..