[convert] properly exclude null successors from convertion stable
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 10 Jul 2012 16:03:29 +0200
branchstable
changeset 350 b836862d48b4
parent 345 62de989b2a02
child 351 4ecbaec1d664
[convert] properly exclude null successors from convertion Old remain of the old way to kill changeset.
hgext/obsolete.py
tests/test-oldconvert.t
--- a/hgext/obsolete.py	Fri Jul 06 18:43:25 2012 +0200
+++ b/hgext/obsolete.py	Tue Jul 10 16:03:29 2012 +0200
@@ -609,7 +609,7 @@
                 del oldmark['id']  # dropped for now
                 del oldmark['reason']  # unused until then
                 oldobject = str(oldmark.pop('object'))
-                oldsubjects = [str(s) for s in oldmark.pop('subjects')]
+                oldsubjects = [str(s) for s in oldmark.pop('subjects', [])]
                 LOOKUP_ERRORS = (error.RepoLookupError, error.LookupError)
                 if len(oldobject) != 40:
                     try:
@@ -626,7 +626,9 @@
                 meta = dict((k.encode('utf-8'), v.encode('utf-8'))
                              for k, v in oldmark.iteritems())
                 try:
-                    store.create(bin(oldobject), [bin(n) for n in oldsubjects],
+                    succs = [bin(n) for n in oldsubjects]
+                    succs = [n for n in succs if n != nullid]
+                    store.create(bin(oldobject), succs,
                                  0, meta)
                     cnt += 1
                 except ValueError:
--- a/tests/test-oldconvert.t	Fri Jul 06 18:43:25 2012 +0200
+++ b/tests/test-oldconvert.t	Tue Jul 10 16:03:29 2012 +0200
@@ -78,9 +78,6 @@
   >     }, 
   >     {
   >         "reason": "import from older format.", 
-  >         "subjects": [
-  >             "a37154106de358121a32a3dd6ba0281931550515"
-  >         ], 
   >         "user": "Pierre-Yves David <pierre-yves.david@logilab.fr>", 
   >         "date": [
   >             1336557472.7875929, 
@@ -92,7 +89,7 @@
   >     {
   >         "reason": "import from older format.", 
   >         "subjects": [
-  >             "dc8d8aa6e8ac490fcafd074d570df0787ee0ee69"
+  >             "0000000000000000000000000000000000000000"
   >         ], 
   >         "user": "Pierre-Yves David <pierre-yves.david@logilab.fr>", 
   >         "date": [
@@ -111,7 +108,7 @@
   $ hg debugconvertobsolete --traceback
   3 obsolete marker converted
   $ hg debugsuccessors
-  2c3784e102bb dc8d8aa6e8ac
+  2c3784e102bb
   3e03d82708d4 3218406b50ed
-  5c722672795c a37154106de3
+  5c722672795c
   7c3bad9141dc d67cd0334eee