diff hgext/convert/hg.py @ 39021:7e023ce26c7f stable

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.)
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 14 Aug 2018 14:00:35 -0400
parents ce566e0f73d0
children 73cf21b2e8a6
line wrap: on
line diff
--- a/hgext/convert/hg.py	Thu Aug 09 13:04:52 2018 +0800
+++ b/hgext/convert/hg.py	Tue Aug 14 14:00:35 2018 -0400
@@ -143,12 +143,17 @@
         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()