comparison hgext/rebase.py @ 45547:2dcf595f6985

rebase: when collapsing, p1 == dest, so use the former only `dest` is the destination we're rebasing onto, which is always the same as `p1` when using `--collapse`. This lets us simplify a bit. Differential Revision: https://phab.mercurial-scm.org/D9073
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 23 Sep 2020 09:21:26 -0700
parents 3d47b5c7fe8d
children 25e365d5aa8f
comparison
equal deleted inserted replaced
45546:3d47b5c7fe8d 45547:2dcf595f6985
560 560
561 return newnode 561 return newnode
562 562
563 def _rebasenode(self, tr, rev, allowdivergence, progressfn): 563 def _rebasenode(self, tr, rev, allowdivergence, progressfn):
564 repo, ui, opts = self.repo, self.ui, self.opts 564 repo, ui, opts = self.repo, self.ui, self.opts
565 dest = self.destmap[rev]
566 ctx = repo[rev] 565 ctx = repo[rev]
567 desc = _ctxdesc(ctx) 566 desc = _ctxdesc(ctx)
568 if self.state[rev] == rev: 567 if self.state[rev] == rev:
569 ui.status(_(b'already rebased %s\n') % desc) 568 ui.status(_(b'already rebased %s\n') % desc)
570 elif ( 569 elif (
614 self.resume = False 613 self.resume = False
615 else: 614 else:
616 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')} 615 overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')}
617 with ui.configoverride(overrides, b'rebase'): 616 with ui.configoverride(overrides, b'rebase'):
618 stats = rebasenode( 617 stats = rebasenode(
619 repo, 618 repo, rev, p1, p2, base, self.collapsef, wctx=self.wctx,
620 rev,
621 p1,
622 p2,
623 base,
624 self.collapsef,
625 dest,
626 wctx=self.wctx,
627 ) 619 )
628 if stats.unresolvedcount > 0: 620 if stats.unresolvedcount > 0:
629 if self.inmemory: 621 if self.inmemory:
630 raise error.InMemoryMergeConflictsError() 622 raise error.InMemoryMergeConflictsError()
631 else: 623 else:
1463 1455
1464 repo.dirstate.setbranch(repo[newnode].branch()) 1456 repo.dirstate.setbranch(repo[newnode].branch())
1465 return newnode 1457 return newnode
1466 1458
1467 1459
1468 def rebasenode(repo, rev, p1, p2, base, collapse, dest, wctx): 1460 def rebasenode(repo, rev, p1, p2, base, collapse, wctx):
1469 """Rebase a single revision rev on top of p1 using base as merge ancestor""" 1461 """Rebase a single revision rev on top of p1 using base as merge ancestor"""
1470 # Merge phase 1462 # Merge phase
1471 # Update to destination and merge it with local 1463 # Update to destination and merge it with local
1472 p1ctx = repo[p1] 1464 p1ctx = repo[p1]
1473 if wctx.isinmemory(): 1465 if wctx.isinmemory():
1499 labels=[b'dest', b'source'], 1491 labels=[b'dest', b'source'],
1500 wc=wctx, 1492 wc=wctx,
1501 ) 1493 )
1502 wctx.setparents(p1ctx.node(), repo[p2].node()) 1494 wctx.setparents(p1ctx.node(), repo[p2].node())
1503 if collapse: 1495 if collapse:
1504 copies.graftcopies(wctx, ctx, repo[dest]) 1496 copies.graftcopies(wctx, ctx, p1ctx)
1505 else: 1497 else:
1506 # If we're not using --collapse, we need to 1498 # If we're not using --collapse, we need to
1507 # duplicate copies between the revision we're 1499 # duplicate copies between the revision we're
1508 # rebasing and its first parent. 1500 # rebasing and its first parent.
1509 copies.graftcopies(wctx, ctx, ctx.p1()) 1501 copies.graftcopies(wctx, ctx, ctx.p1())