comparison hgext/rebase.py @ 34367:f61f5af5ed31

merge with stable
author Martin von Zweigbergk <martinvonz@google.com>
date Sat, 30 Sep 2017 07:52:48 -0700
parents 4f969b9e0cf5 2f427b57bf90
children a5a810df4c81
comparison
equal deleted inserted replaced
34366:d00910b286cd 34367:f61f5af5ed31
545 newwd = self.originalwd 545 newwd = self.originalwd
546 if newwd not in [c.rev() for c in repo[None].parents()]: 546 if newwd not in [c.rev() for c in repo[None].parents()]:
547 ui.note(_("update back to initial working directory parent\n")) 547 ui.note(_("update back to initial working directory parent\n"))
548 hg.updaterepo(repo, newwd, False) 548 hg.updaterepo(repo, newwd, False)
549 549
550 collapsedas = None
550 if not self.keepf: 551 if not self.keepf:
551 collapsedas = None
552 if self.collapsef: 552 if self.collapsef:
553 collapsedas = newnode 553 collapsedas = newnode
554 clearrebased(ui, repo, self.destmap, self.state, self.skipped, 554 clearrebased(ui, repo, self.destmap, self.state, self.skipped,
555 collapsedas) 555 collapsedas, self.keepf)
556 556
557 clearstatus(repo) 557 clearstatus(repo)
558 clearcollapsemsg(repo) 558 clearcollapsemsg(repo)
559 559
560 ui.note(_("rebase completed\n")) 560 ui.note(_("rebase completed\n"))
1514 # if all parents of this revision are done, then so is this revision 1514 # if all parents of this revision are done, then so is this revision
1515 if parents and all((state.get(p) == p for p in parents)): 1515 if parents and all((state.get(p) == p for p in parents)):
1516 state[rev] = rev 1516 state[rev] = rev
1517 return originalwd, destmap, state 1517 return originalwd, destmap, state
1518 1518
1519 def clearrebased(ui, repo, destmap, state, skipped, collapsedas=None): 1519 def clearrebased(ui, repo, destmap, state, skipped, collapsedas=None,
1520 keepf=False):
1520 """dispose of rebased revision at the end of the rebase 1521 """dispose of rebased revision at the end of the rebase
1521 1522
1522 If `collapsedas` is not None, the rebase was a collapse whose result if the 1523 If `collapsedas` is not None, the rebase was a collapse whose result if the
1523 `collapsedas` node.""" 1524 `collapsedas` node.
1525
1526 If `keepf` is not True, the rebase has --keep set and no nodes should be
1527 removed (but bookmarks still need to be moved).
1528 """
1524 tonode = repo.changelog.node 1529 tonode = repo.changelog.node
1525 # Move bookmark of skipped nodes to destination. This cannot be handled 1530 replacements = {}
1526 # by scmutil.cleanupnodes since it will treat rev as removed (no successor) 1531 moves = {}
1527 # and move bookmark backwards.
1528 bmchanges = [(name, tonode(state[rev]))
1529 for rev in skipped
1530 for name in repo.nodebookmarks(tonode(rev))]
1531 if bmchanges:
1532 with repo.transaction('rebase') as tr:
1533 repo._bookmarks.applychanges(repo, tr, bmchanges)
1534 mapping = {}
1535 for rev, newrev in sorted(state.items()): 1532 for rev, newrev in sorted(state.items()):
1536 if newrev >= 0 and newrev != rev: 1533 if newrev >= 0 and newrev != rev:
1537 if rev in skipped: 1534 oldnode = tonode(rev)
1538 succs = () 1535 newnode = collapsedas or tonode(newrev)
1539 elif collapsedas is not None: 1536 moves[oldnode] = newnode
1540 succs = (collapsedas,) 1537 if not keepf:
1541 else: 1538 if rev in skipped:
1542 succs = (tonode(newrev),) 1539 succs = ()
1543 mapping[tonode(rev)] = succs 1540 else:
1544 scmutil.cleanupnodes(repo, mapping, 'rebase') 1541 succs = (newnode,)
1542 replacements[oldnode] = succs
1543 scmutil.cleanupnodes(repo, replacements, 'rebase', moves)
1545 1544
1546 def pullrebase(orig, ui, repo, *args, **opts): 1545 def pullrebase(orig, ui, repo, *args, **opts):
1547 'Call rebase after pull if the latter has been invoked with --rebase' 1546 'Call rebase after pull if the latter has been invoked with --rebase'
1548 ret = None 1547 ret = None
1549 if opts.get('rebase'): 1548 if opts.get('rebase'):