hgext/rebase.py
branchstable
changeset 33686 2f427b57bf90
parent 33620 5a5f600b06ad
child 34368 f61f5af5ed31
equal deleted inserted replaced
33685:2dbd6d259cd2 33686:2f427b57bf90
   506             newwd = self.originalwd
   506             newwd = self.originalwd
   507         if newwd not in [c.rev() for c in repo[None].parents()]:
   507         if newwd not in [c.rev() for c in repo[None].parents()]:
   508             ui.note(_("update back to initial working directory parent\n"))
   508             ui.note(_("update back to initial working directory parent\n"))
   509             hg.updaterepo(repo, newwd, False)
   509             hg.updaterepo(repo, newwd, False)
   510 
   510 
       
   511         collapsedas = None
   511         if not self.keepf:
   512         if not self.keepf:
   512             collapsedas = None
       
   513             if self.collapsef:
   513             if self.collapsef:
   514                 collapsedas = newnode
   514                 collapsedas = newnode
   515             clearrebased(ui, repo, self.dest, self.state, self.skipped,
   515         clearrebased(ui, repo, self.dest, self.state, self.skipped,
   516                          collapsedas)
   516                      collapsedas, self.keepf)
   517 
   517 
   518         clearstatus(repo)
   518         clearstatus(repo)
   519         clearcollapsemsg(repo)
   519         clearcollapsemsg(repo)
   520 
   520 
   521         ui.note(_("rebase completed\n"))
   521         ui.note(_("rebase completed\n"))
  1352             state[r] = revpruned
  1352             state[r] = revpruned
  1353         else:
  1353         else:
  1354             state[r] = revprecursor
  1354             state[r] = revprecursor
  1355     return originalwd, dest.rev(), state
  1355     return originalwd, dest.rev(), state
  1356 
  1356 
  1357 def clearrebased(ui, repo, dest, state, skipped, collapsedas=None):
  1357 def clearrebased(ui, repo, dest, state, skipped, collapsedas=None, keepf=False):
  1358     """dispose of rebased revision at the end of the rebase
  1358     """dispose of rebased revision at the end of the rebase
  1359 
  1359 
  1360     If `collapsedas` is not None, the rebase was a collapse whose result if the
  1360     If `collapsedas` is not None, the rebase was a collapse whose result if the
  1361     `collapsedas` node."""
  1361     `collapsedas` node.
       
  1362 
       
  1363     If `keepf` is not True, the rebase has --keep set and no nodes should be
       
  1364     removed (but bookmarks still need to be moved).
       
  1365     """
  1362     tonode = repo.changelog.node
  1366     tonode = repo.changelog.node
  1363     # Move bookmark of skipped nodes to destination. This cannot be handled
  1367     replacements = {}
  1364     # by scmutil.cleanupnodes since it will treat rev as removed (no successor)
  1368     moves = {}
  1365     # and move bookmark backwards.
       
  1366     bmchanges = [(name, tonode(max(adjustdest(repo, rev, dest, state))))
       
  1367                  for rev in skipped
       
  1368                  for name in repo.nodebookmarks(tonode(rev))]
       
  1369     if bmchanges:
       
  1370         with repo.transaction('rebase') as tr:
       
  1371             repo._bookmarks.applychanges(repo, tr, bmchanges)
       
  1372     mapping = {}
       
  1373     for rev, newrev in sorted(state.items()):
  1369     for rev, newrev in sorted(state.items()):
  1374         if newrev >= 0 and newrev != rev:
  1370         if newrev >= 0 and newrev != rev:
  1375             if rev in skipped:
  1371             oldnode = tonode(rev)
  1376                 succs = ()
  1372             newnode = collapsedas or tonode(newrev)
  1377             elif collapsedas is not None:
  1373             moves[oldnode] = newnode
  1378                 succs = (collapsedas,)
  1374             if not keepf:
  1379             else:
  1375                 if rev in skipped:
  1380                 succs = (tonode(newrev),)
  1376                     succs = ()
  1381             mapping[tonode(rev)] = succs
  1377                 else:
  1382     scmutil.cleanupnodes(repo, mapping, 'rebase')
  1378                     succs = (newnode,)
       
  1379                 replacements[oldnode] = succs
       
  1380     scmutil.cleanupnodes(repo, replacements, 'rebase', moves)
  1383 
  1381 
  1384 def pullrebase(orig, ui, repo, *args, **opts):
  1382 def pullrebase(orig, ui, repo, *args, **opts):
  1385     'Call rebase after pull if the latter has been invoked with --rebase'
  1383     'Call rebase after pull if the latter has been invoked with --rebase'
  1386     ret = None
  1384     ret = None
  1387     if opts.get('rebase'):
  1385     if opts.get('rebase'):