obsolete: harden convertion from first format stable
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Fri, 06 Jul 2012 17:15:30 +0200
branchstable
changeset 341 7653f80fd7a4
parent 340 37b543215187
child 344 9bbcd2746898
obsolete: harden convertion from first format
hgext/obsolete.py
--- a/hgext/obsolete.py	Fri Jul 06 16:32:53 2012 +0200
+++ b/hgext/obsolete.py	Fri Jul 06 17:15:30 2012 +0200
@@ -589,8 +589,13 @@
                         'date':  '%i %i' % util.makedate(),
                         'user': ui.username(),
                         }
-                    store.create(prec, sucs, 0, meta)
-                    cnt += 1
+                    try:
+                        store.create(prec, sucs, 0, meta)
+                        cnt += 1
+                    except ValueError:
+                        repo.ui.write_err("invalid old marker line: %s"
+                                          % (line))
+                        err += 1
             finally:
                 f.close()
             util.unlink(repo.join('obsolete-relations'))
@@ -623,11 +628,11 @@
                 try:
                     store.create(bin(oldobject), [bin(n) for n in oldsubjects],
                                  0, meta)
+                    cnt += 1
                 except ValueError:
                     repo.ui.write_err("invalid marker %s -> %s\n"
                                  % (oldobject, oldsubjects))
                     err += 1
-                cnt += 1
             util.unlink(repo.sjoin('obsoletemarkers'))
     finally:
         del repo._importoldobsolete