Mercurial > hg
comparison hgext/rebase.py @ 44090:2f0a44c69e07
copies: replace duplicatecopies() by function that takes contexts
The callers mostly have context objects, so let's avoid looking up the
same context objects inside `duplicatecopies()`.
I also renamed the function to `graftcopies()` since I think that
better matches its purpose. I did it in the same commit so it's easier
for extensions to switch between the functions.
Differential Revision: https://phab.mercurial-scm.org/D7858
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 06 Jan 2020 15:24:36 -0800 |
parents | 894c91c2e363 |
children | 833210fbd900 |
comparison
equal
deleted
inserted
replaced
44089:bd22e90c54b3 | 44090:2f0a44c69e07 |
---|---|
1479 repo.ui.debug(b" already in destination\n") | 1479 repo.ui.debug(b" already in destination\n") |
1480 # This is, alas, necessary to invalidate workingctx's manifest cache, | 1480 # This is, alas, necessary to invalidate workingctx's manifest cache, |
1481 # as well as other data we litter on it in other places. | 1481 # as well as other data we litter on it in other places. |
1482 wctx = repo[None] | 1482 wctx = repo[None] |
1483 repo.dirstate.write(repo.currenttransaction()) | 1483 repo.dirstate.write(repo.currenttransaction()) |
1484 repo.ui.debug(b" merge against %d:%s\n" % (rev, repo[rev])) | 1484 ctx = repo[rev] |
1485 repo.ui.debug(b" merge against %d:%s\n" % (rev, ctx)) | |
1485 if base is not None: | 1486 if base is not None: |
1486 repo.ui.debug(b" detach base %d:%s\n" % (base, repo[base])) | 1487 repo.ui.debug(b" detach base %d:%s\n" % (base, repo[base])) |
1487 # When collapsing in-place, the parent is the common ancestor, we | 1488 # When collapsing in-place, the parent is the common ancestor, we |
1488 # have to allow merging with it. | 1489 # have to allow merging with it. |
1489 stats = mergemod.update( | 1490 stats = mergemod.update( |
1494 ancestor=base, | 1495 ancestor=base, |
1495 mergeancestor=collapse, | 1496 mergeancestor=collapse, |
1496 labels=[b'dest', b'source'], | 1497 labels=[b'dest', b'source'], |
1497 wc=wctx, | 1498 wc=wctx, |
1498 ) | 1499 ) |
1500 destctx = repo[dest] | |
1499 if collapse: | 1501 if collapse: |
1500 copies.duplicatecopies(repo, wctx, rev, dest) | 1502 copies.graftcopies(repo, wctx, ctx, destctx) |
1501 else: | 1503 else: |
1502 # If we're not using --collapse, we need to | 1504 # If we're not using --collapse, we need to |
1503 # duplicate copies between the revision we're | 1505 # duplicate copies between the revision we're |
1504 # rebasing and its first parent, but *not* | 1506 # rebasing and its first parent, but *not* |
1505 # duplicate any copies that have already been | 1507 # duplicate any copies that have already been |
1506 # performed in the destination. | 1508 # performed in the destination. |
1507 p1rev = repo[rev].p1().rev() | 1509 copies.graftcopies(repo, wctx, ctx, ctx.p1(), skip=destctx) |
1508 copies.duplicatecopies(repo, wctx, rev, p1rev, skiprev=dest) | |
1509 return stats | 1510 return stats |
1510 | 1511 |
1511 | 1512 |
1512 def adjustdest(repo, rev, destmap, state, skipped): | 1513 def adjustdest(repo, rev, destmap, state, skipped): |
1513 r"""adjust rebase destination given the current rebase state | 1514 r"""adjust rebase destination given the current rebase state |