obsolete: Only warn on bad obsolete marker stable
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Wed, 04 Jul 2012 17:51:33 +0200
branchstable
changeset 336 7db8107eef30
parent 335 c27a465daef2
child 337 ebfd1b96a013
obsolete: Only warn on bad obsolete marker Older version probably created invalide one.
hgext/obsolete.py
--- a/hgext/obsolete.py	Wed Jul 04 16:27:08 2012 +0200
+++ b/hgext/obsolete.py	Wed Jul 04 17:51:33 2012 +0200
@@ -569,6 +569,7 @@
 def cmddebugconvertobsolete(ui, repo):
     """import markers from an .hg/obsolete-relations file"""
     cnt = 0
+    error = 0
     l = repo.lock()
     some = False
     try:
@@ -602,12 +603,20 @@
             for oldmark in json.loads(data):
                 del oldmark['id'] # dropped for now
                 del oldmark['reason'] # unused until then
+                oldobject = oldmark['object']
+                oldsubjects = oldmark['subjects']
                 oldmark['subjects'] = [bin(n) for n in oldmark['subjects']]
                 oldmark['object'] = bin(oldmark['object'])
                 oldmark['date'] = '%i %i' % tuple(oldmark['date'])
-                store.create(oldmark.pop('object'),
-                             oldmark.pop('subjects'),
-                             0, oldmark)
+                assert oldmark['object'], repr(oldmark['object'])
+                try:
+                    store.create(oldmark.pop('object'),
+                                 oldmark.pop('subjects'),
+                                 0, oldmark)
+                except ValueError:
+                    repo.ui.write_err("invalid marker %s -> %s\n"
+                                 % (oldobject, oldsubjects))
+                    error += 1
                 cnt += 1
             util.unlink(repo.sjoin('obsoletemarkers'))
     finally:
@@ -616,6 +625,8 @@
     if not some:
             ui.warn('nothing to do\n')
     ui.status('%i obsolete marker converted\n' % cnt)
+    if error:
+        ui.write_err('%i conversion failed. check you graph!\n' % error)
 
 @command('debugsuccessors', [], '')
 def cmddebugsuccessors(ui, repo):