hgext/rebase.py
changeset 13875 ff3c683eb8ff
parent 13856 0995eee8ffe4
child 13878 a8d13ee0ce68
equal deleted inserted replaced
13874:9d67277c9204 13875:ff3c683eb8ff
   232         if skipped:
   232         if skipped:
   233             ui.note(_("%d revisions have been skipped\n") % len(skipped))
   233             ui.note(_("%d revisions have been skipped\n") % len(skipped))
   234     finally:
   234     finally:
   235         release(lock, wlock)
   235         release(lock, wlock)
   236 
   236 
   237 def rebasemerge(repo, rev, first=False):
       
   238     'return the correct ancestor'
       
   239     oldancestor = ancestor.ancestor
       
   240 
       
   241     def newancestor(a, b, pfunc):
       
   242         if b == rev:
       
   243             return repo[rev].parents()[0].rev()
       
   244         return oldancestor(a, b, pfunc)
       
   245 
       
   246     if not first:
       
   247         ancestor.ancestor = newancestor
       
   248     else:
       
   249         repo.ui.debug("first revision, do not change ancestor\n")
       
   250     try:
       
   251         stats = merge.update(repo, rev, True, True, False)
       
   252         return stats
       
   253     finally:
       
   254         ancestor.ancestor = oldancestor
       
   255 
       
   256 def checkexternal(repo, state, targetancestors):
   237 def checkexternal(repo, state, targetancestors):
   257     """Check whether one or more external revisions need to be taken in
   238     """Check whether one or more external revisions need to be taken in
   258     consideration. In the latter case, abort.
   239     consideration. In the latter case, abort.
   259     """
   240     """
   260     external = nullrev
   241     external = nullrev
   315         merge.update(repo, p1, False, True, False)
   296         merge.update(repo, p1, False, True, False)
   316     else:
   297     else:
   317         repo.ui.debug(" already in target\n")
   298         repo.ui.debug(" already in target\n")
   318     repo.dirstate.write()
   299     repo.dirstate.write()
   319     repo.ui.debug(" merge against %d:%s\n" % (repo[rev].rev(), repo[rev]))
   300     repo.ui.debug(" merge against %d:%s\n" % (repo[rev].rev(), repo[rev]))
   320     first = repo[rev].rev() == repo[min(state)].rev()
   301     base = None
   321     stats = rebasemerge(repo, rev, first)
   302     if repo[rev].rev() != repo[min(state)].rev():
   322     return stats
   303         base = repo[rev].parents()[0].node()
       
   304     return merge.update(repo, rev, True, True, False, base)
   323 
   305 
   324 def defineparents(repo, rev, target, state, targetancestors):
   306 def defineparents(repo, rev, target, state, targetancestors):
   325     'Return the new parent relationship of the revision that will be rebased'
   307     'Return the new parent relationship of the revision that will be rebased'
   326     parents = repo[rev].parents()
   308     parents = repo[rev].parents()
   327     p1 = p2 = nullrev
   309     p1 = p2 = nullrev