evolve: handle invalid obsmarkers in the `debugobsconvert`
User can now recover from such situation, The error message is also changed to
point the `debugobsconvert` commands.
--- a/hgext/evolve.py Fri Feb 06 16:58:42 2015 +0000
+++ b/hgext/evolve.py Fri Feb 06 17:01:28 2015 +0000
@@ -2769,6 +2769,23 @@
_bestformat = max(obsolete.formats.keys())
+
+if getattr(obsolete, '_checkinvalidmarkers', None) is not None:
+ @eh.wrapfunction(obsolete, '_checkinvalidmarkers')
+ def _checkinvalidmarkers(orig, markers):
+ """search for marker with invalid data and raise error if needed
+
+ Exist as a separated function to allow the evolve extension for a more
+ subtle handling.
+ """
+ if 'debugobsconvert' in sys.argv:
+ return
+ for mark in markers:
+ if node.nullid in mark[1]:
+ raise util.Abort(_('bad obsolescence marker detected: '
+ 'invalid successors nullid'),
+ hint=_('You should run `hg debugobsconvert`'))
+
@command(
'debugobsconvert',
[('', 'new-format', _bestformat, _('Destination format for markers.'))],
@@ -2782,6 +2799,11 @@
known = set()
markers = []
for m in origmarkers:
+ # filter out invalid markers
+ if nullid in m[1]:
+ m = list(m)
+ m[1] = tuple(s for s in m[1] if s != nullid)
+ m = tuple(m)
if m in known:
continue
known.add(m)