hgext3rd/topic/__init__.py
changeset 2646 b5723184fc62
parent 2645 2e3f63f4a519
child 2647 b9cfb8bd0965
equal deleted inserted replaced
2645:2e3f63f4a519 2646:b5723184fc62
   307     rewrote = 0
   307     rewrote = 0
   308     needevolve = False
   308     needevolve = False
   309     l = repo.lock()
   309     l = repo.lock()
   310     txn = repo.transaction('rewrite-topics')
   310     txn = repo.transaction('rewrite-topics')
   311     try:
   311     try:
   312         newp = None
       
   313         oldp = None
       
   314         p1 = None
   312         p1 = None
   315         p2 = None
   313         p2 = None
       
   314         successors = {}
   316         for c in repo.set('%r', revset):
   315         for c in repo.set('%r', revset):
   317             def filectxfn(repo, ctx, path):
   316             def filectxfn(repo, ctx, path):
   318                 try:
   317                 try:
   319                     return c[path]
   318                     return c[path]
   320                 except error.ManifestLookupError:
   319                 except error.ManifestLookupError:
   340                 c, oldtopic, newtopic))
   339                 c, oldtopic, newtopic))
   341             ui.debug('fixedextra: %r\n' % fixedextra)
   340             ui.debug('fixedextra: %r\n' % fixedextra)
   342             # While changing topic of set of linear commits, make sure that
   341             # While changing topic of set of linear commits, make sure that
   343             # we base our commits on new parent rather than old parent which
   342             # we base our commits on new parent rather than old parent which
   344             # was obsoleted while changing the topic
   343             # was obsoleted while changing the topic
   345             if newp and c.p1().node() == oldp:
   344             p1 = c.p1().node()
   346                 p1 = newp
   345             p2 = c.p2().node()
   347                 p2 = c.p2().node()
   346             if p1 in successors:
   348             elif newp and c.p2().node() == oldp:
   347                 p1 = successors[p1]
   349                 p1 = c.p1().node()
   348             if p2 in successors:
   350                 p2 = newp
   349                 p2 = successors[p2]
   351             else:
       
   352                 p1 = c.p1().node()
       
   353                 p2 = c.p2().node()
       
   354             mc = context.memctx(
   350             mc = context.memctx(
   355                 repo, (p1, p2), c.description(),
   351                 repo, (p1, p2), c.description(),
   356                 c.files(), filectxfn,
   352                 c.files(), filectxfn,
   357                 user=c.user(), date=c.date(), extra=fixedextra)
   353                 user=c.user(), date=c.date(), extra=fixedextra)
   358             newnode = repo.commitctx(mc)
   354             newnode = repo.commitctx(mc)
   359             oldp = c.node()
   355             successors[c.node()] = newnode
   360             newp = newnode
       
   361             ui.debug('new node id is %s\n' % node.hex(newnode))
   356             ui.debug('new node id is %s\n' % node.hex(newnode))
   362             needevolve = needevolve or (len(c.children()) > 0)
   357             needevolve = needevolve or (len(c.children()) > 0)
   363             obsolete.createmarkers(repo, [(c, (repo[newnode],))])
   358             obsolete.createmarkers(repo, [(c, (repo[newnode],))])
   364             rewrote += 1
   359             rewrote += 1
   365         txn.close()
   360         txn.close()