Mercurial > public > mercurial-scm > hg-stable
diff 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 |
line wrap: on
line diff
--- a/hgext/rebase.py Fri Dec 27 13:03:40 2019 -0800 +++ b/hgext/rebase.py Mon Jan 06 15:24:36 2020 -0800 @@ -1481,7 +1481,8 @@ # as well as other data we litter on it in other places. wctx = repo[None] repo.dirstate.write(repo.currenttransaction()) - repo.ui.debug(b" merge against %d:%s\n" % (rev, repo[rev])) + ctx = repo[rev] + repo.ui.debug(b" merge against %d:%s\n" % (rev, ctx)) if base is not None: repo.ui.debug(b" detach base %d:%s\n" % (base, repo[base])) # When collapsing in-place, the parent is the common ancestor, we @@ -1496,16 +1497,16 @@ labels=[b'dest', b'source'], wc=wctx, ) + destctx = repo[dest] if collapse: - copies.duplicatecopies(repo, wctx, rev, dest) + copies.graftcopies(repo, wctx, ctx, destctx) else: # If we're not using --collapse, we need to # duplicate copies between the revision we're # rebasing and its first parent, but *not* # duplicate any copies that have already been # performed in the destination. - p1rev = repo[rev].p1().rev() - copies.duplicatecopies(repo, wctx, rev, p1rev, skiprev=dest) + copies.graftcopies(repo, wctx, ctx, ctx.p1(), skip=destctx) return stats