hgext/uncommit.py
changeset 41342 fe83040400b7
parent 41341 19c590ce8661
child 41397 0bd56c291359
equal deleted inserted replaced
41341:19c590ce8661 41342:fe83040400b7
    96 def _fixdirstate(repo, oldctx, newctx, match=None):
    96 def _fixdirstate(repo, oldctx, newctx, match=None):
    97     """ fix the dirstate after switching the working directory from oldctx to
    97     """ fix the dirstate after switching the working directory from oldctx to
    98     newctx which can be result of either unamend or uncommit.
    98     newctx which can be result of either unamend or uncommit.
    99     """
    99     """
   100     ds = repo.dirstate
   100     ds = repo.dirstate
       
   101     ds.setparents(newctx.node(), node.nullid)
   101     copies = dict(ds.copies())
   102     copies = dict(ds.copies())
   102     s = newctx.status(oldctx, match=match)
   103     s = newctx.status(oldctx, match=match)
   103     for f in s.modified:
   104     for f in s.modified:
   104         if ds[f] == 'r':
   105         if ds[f] == 'r':
   105             # modified + removed -> removed
   106             # modified + removed -> removed
   174             else:
   175             else:
   175                 # Fully removed the old commit
   176                 # Fully removed the old commit
   176                 mapping[old.node()] = ()
   177                 mapping[old.node()] = ()
   177 
   178 
   178             with repo.dirstate.parentchange():
   179             with repo.dirstate.parentchange():
   179                 repo.dirstate.setparents(newid, node.nullid)
       
   180                 _fixdirstate(repo, old, repo[newid], match)
   180                 _fixdirstate(repo, old, repo[newid], match)
   181 
   181 
   182             scmutil.cleanupnodes(repo, mapping, 'uncommit', fixphase=True)
   182             scmutil.cleanupnodes(repo, mapping, 'uncommit', fixphase=True)
   183 
   183 
   184 def predecessormarkers(ctx):
   184 def predecessormarkers(ctx):
   237         newprednode = repo.commitctx(newctx)
   237         newprednode = repo.commitctx(newctx)
   238         newpredctx = repo[newprednode]
   238         newpredctx = repo[newprednode]
   239         dirstate = repo.dirstate
   239         dirstate = repo.dirstate
   240 
   240 
   241         with dirstate.parentchange():
   241         with dirstate.parentchange():
   242             dirstate.setparents(newprednode, node.nullid)
       
   243             _fixdirstate(repo, curctx, newpredctx)
   242             _fixdirstate(repo, curctx, newpredctx)
   244 
   243 
   245         mapping = {curctx.node(): (newprednode,)}
   244         mapping = {curctx.node(): (newprednode,)}
   246         scmutil.cleanupnodes(repo, mapping, 'unamend', fixphase=True)
   245         scmutil.cleanupnodes(repo, mapping, 'unamend', fixphase=True)