D6750: context: filter out invalid copies from workingctx.p[12]copies()

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Aug 20 12:29:40 EDT 2019


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  workingctx normally gets its lists of modified, added, removed files
  etc. based on the dirstate status. Its constructor also accepts a
  "changes" argument to override the status from the dirstate. This is
  used for partial commits. If a "changed" argument was passed, we
  should clearly also filter out copies to those paths, which I had
  previously missed. This patch adds that filtering and fixes the bugs
  demonstrated in the previous patch.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6750

AFFECTED FILES
  mercurial/context.py
  tests/test-copies-in-changeset.t

CHANGE DETAILS

diff --git a/tests/test-copies-in-changeset.t b/tests/test-copies-in-changeset.t
--- a/tests/test-copies-in-changeset.t
+++ b/tests/test-copies-in-changeset.t
@@ -197,13 +197,37 @@
   $ echo a2 > a
   $ hg mv b c
   $ hg ci -m 'modify a, move b to c'
-  $ (hg --config ui.interactive=yes split 2>&1 | grep mercurial.error) <<EOF
+  $ hg --config ui.interactive=yes split <<EOF
   > y
   > y
   > n
   > y
   > EOF
-  mercurial.error.ProgrammingError: some copy targets missing from file list
+  diff --git a/a b/a
+  1 hunks, 1 lines changed
+  examine changes to 'a'?
+  (enter ? for help) [Ynesfdaq?] y
+  
+  @@ -1,1 +1,1 @@
+  -a
+  +a2
+  record this change to 'a'?
+  (enter ? for help) [Ynesfdaq?] y
+  
+  diff --git a/b b/c
+  rename from b
+  rename to c
+  examine changes to 'b' and 'c'?
+  (enter ? for help) [Ynesfdaq?] n
+  
+  created new head
+  diff --git a/b b/c
+  rename from b
+  rename to c
+  examine changes to 'b' and 'c'?
+  (enter ? for help) [Ynesfdaq?] y
+  
+  saved backup bundle to $TESTTMP/split/.hg/strip-backup/9a396d463e04-2d9e6864-split.hg
   $ cd ..
 
 Test committing half a rename
@@ -213,6 +237,5 @@
   $ echo a > a
   $ hg ci -Aqm 'add a'
   $ hg mv a b
-  $ hg ci -m 'remove a' a 2>&1 | grep mercurial.error
-  mercurial.error.ProgrammingError: some copy targets missing from file list
+  $ hg ci -m 'remove a' a
   $ cd ..
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1558,9 +1558,10 @@
         parents = self._repo.dirstate.parents()
         p1manifest = self._repo[parents[0]].manifest()
         p2manifest = self._repo[parents[1]].manifest()
+        changedset = set(self.added()) | set(self.modified())
         narrowmatch = self._repo.narrowmatch()
         for dst, src in self._repo.dirstate.copies().items():
-            if not narrowmatch(dst):
+            if dst not in changedset or not narrowmatch(dst):
                 continue
             if src in p1manifest:
                 p1copies[dst] = src



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list