# HG changeset patch # User Martin von Zweigbergk # Date 2019-01-09 23:54:45 # Node ID 313812cbf4ca14a47f3b1e4fb4330be8fdd4167c # Parent 70845eb656a9fc56c8e145c9e282774ec6fe1e71 copies: fix duplicatecopies() with overlay context The reasoning for this check is in 78d760aa3607 (duplicatecopies: do not mark items not in the dirstate as copies, 2013-03-28). The check was then moved to workingfilectx in 754b5117622f (context: add workingfilectx.markcopied, 2017-10-15) and no corresponding check was added later when overlayworkingfilectx was added. Rather than adding the check there, this patch adds a more generic check on the callers side and removes the check in workingfilectx.markcopied(). Differential Revision: https://phab.mercurial-scm.org/D6380 diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -1773,8 +1773,7 @@ class workingfilectx(committablefilectx) 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) + self._repo.dirstate.copy(src, self._path) def clearunknown(self): """Removes conflicting items in the working directory so that diff --git a/mercurial/copies.py b/mercurial/copies.py --- a/mercurial/copies.py +++ b/mercurial/copies.py @@ -798,4 +798,5 @@ def duplicatecopies(repo, wctx, rev, fro for dst, src in pathcopies(repo[fromrev], repo[rev]).iteritems(): if dst in exclude: continue - wctx[dst].markcopied(src) + if dst in wctx: + wctx[dst].markcopied(src) diff --git a/tests/test-rebase-inmemory.t b/tests/test-rebase-inmemory.t --- a/tests/test-rebase-inmemory.t +++ b/tests/test-rebase-inmemory.t @@ -795,12 +795,10 @@ Rebase across a copy with --collapse $ hg co -q 0 $ echo a2 > a $ hg ci -qm 'modify a' -BROKEN: obviously... $ hg rebase -r . -d 1 --collapse rebasing 2:41c4ea50d4cf "modify a" (tip) merging b and a to b - abort: a@b977edf6f839: not found in manifest! - [255] + saved backup bundle to $TESTTMP/rebase-rename-collapse/.hg/strip-backup/41c4ea50d4cf-b90b7994-rebase.hg $ cd .. Test rebasing when the file we are merging in destination is empty