diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -977,10 +977,11 @@ repo.ui.debug(" detach base %d:%s\n" % (base, repo[base])) # When collapsing in-place, the parent is the common ancestor, we # have to allow merging with it. + wctx = repo[None] stats = mergemod.update(repo, rev, True, True, base, collapse, labels=['dest', 'source']) if collapse: - copies.duplicatecopies(repo, rev, dest) + copies.duplicatecopies(repo, wctx, rev, dest) else: # If we're not using --collapse, we need to # duplicate copies between the revision we're @@ -988,7 +989,7 @@ # duplicate any copies that have already been # performed in the destination. p1rev = repo[rev].p1().rev() - copies.duplicatecopies(repo, rev, p1rev, skiprev=dest) + copies.duplicatecopies(repo, wctx, rev, p1rev, skiprev=dest) return stats def adjustdest(repo, rev, destmap, state, skipped): diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -1935,6 +1935,11 @@ self._repo.wwrite(self._path, data, flags, backgroundclose=backgroundclose) + def markcopied(self, src): + """marks this file a copy of `src`""" + if self._repo.dirstate[self._path] in "nma": + self._repo.dirstate.copy(src, self._path) + def clearunknown(self): """Removes conflicting items in the working directory so that ``write()`` can be called successfully. diff --git a/mercurial/copies.py b/mercurial/copies.py --- a/mercurial/copies.py +++ b/mercurial/copies.py @@ -842,7 +842,7 @@ data['incompletediverge'][sf] = [of, f] return -def duplicatecopies(repo, rev, fromrev, skiprev=None): +def duplicatecopies(repo, wctx, rev, fromrev, skiprev=None): '''reproduce copies from fromrev to rev in the dirstate If skiprev is specified, it's a revision that should be used to @@ -863,5 +863,4 @@ # actually be in the dirstate if dst in exclude: continue - if repo.dirstate[dst] in "nma": - repo.dirstate.copy(src, dst) + wctx[dst].markcopied(src) diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -2001,5 +2001,5 @@ repo.setparents(repo['.'].node(), pother) repo.dirstate.write(repo.currenttransaction()) # fix up dirstate for copies and renames - copies.duplicatecopies(repo, ctx.rev(), pctx.rev()) + copies.duplicatecopies(repo, repo[None], ctx.rev(), pctx.rev()) return stats