hgext/obsolete.py
branchstable
changeset 350 b836862d48b4
parent 344 9bbcd2746898
child 351 4ecbaec1d664
equal deleted inserted replaced
345:62de989b2a02 350:b836862d48b4
   607             some = True
   607             some = True
   608             for oldmark in json.loads(data):
   608             for oldmark in json.loads(data):
   609                 del oldmark['id']  # dropped for now
   609                 del oldmark['id']  # dropped for now
   610                 del oldmark['reason']  # unused until then
   610                 del oldmark['reason']  # unused until then
   611                 oldobject = str(oldmark.pop('object'))
   611                 oldobject = str(oldmark.pop('object'))
   612                 oldsubjects = [str(s) for s in oldmark.pop('subjects')]
   612                 oldsubjects = [str(s) for s in oldmark.pop('subjects', [])]
   613                 LOOKUP_ERRORS = (error.RepoLookupError, error.LookupError)
   613                 LOOKUP_ERRORS = (error.RepoLookupError, error.LookupError)
   614                 if len(oldobject) != 40:
   614                 if len(oldobject) != 40:
   615                     try:
   615                     try:
   616                         oldobject = repo[oldobject].node()
   616                         oldobject = repo[oldobject].node()
   617                     except LOOKUP_ERRORS:
   617                     except LOOKUP_ERRORS:
   624 
   624 
   625                 oldmark['date'] = '%i %i' % tuple(oldmark['date'])
   625                 oldmark['date'] = '%i %i' % tuple(oldmark['date'])
   626                 meta = dict((k.encode('utf-8'), v.encode('utf-8'))
   626                 meta = dict((k.encode('utf-8'), v.encode('utf-8'))
   627                              for k, v in oldmark.iteritems())
   627                              for k, v in oldmark.iteritems())
   628                 try:
   628                 try:
   629                     store.create(bin(oldobject), [bin(n) for n in oldsubjects],
   629                     succs = [bin(n) for n in oldsubjects]
       
   630                     succs = [n for n in succs if n != nullid]
       
   631                     store.create(bin(oldobject), succs,
   630                                  0, meta)
   632                                  0, meta)
   631                     cnt += 1
   633                     cnt += 1
   632                 except ValueError:
   634                 except ValueError:
   633                     repo.ui.write_err("invalid marker %s -> %s\n"
   635                     repo.ui.write_err("invalid marker %s -> %s\n"
   634                                  % (oldobject, oldsubjects))
   636                                  % (oldobject, oldsubjects))