D6133: rebase: fix crash with in-memory rebase and copies

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Mar 14 21:51:14 UTC 2019


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

REVISION SUMMARY
  When using regular on-disk rebase, filectx.markcopies() calls to
  dirstate.copy(), which happily records the copy. Then it's simply
  ignored if it doesn't matter for the commit (as in the test case I
  added in the previous patch). Let's do the same for overlayworkingctx.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/context.py
  tests/test-rebase-inmemory.t

CHANGE DETAILS

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
@@ -756,5 +756,7 @@
   |
   o  0: b173517d0057 'a'
   
-  $ hg rebase -b 5 -d tip 2>&1 | grep '** ProgrammingError'
-  ** ProgrammingError: markcopied() called on clean context
+  $ hg rebase -b 5 -d tip
+  rebasing 3:ca58782ad1e4 "b"
+  rebasing 5:71cb43376053 "merge"
+  note: not rebasing 5:71cb43376053 "merge", its destination already has all its changes
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1891,10 +1891,8 @@
             return self._wrappedctx[path].date()
 
     def markcopied(self, path, origin):
-        if self.isdirty(path):
-            self._cache[path]['copied'] = origin
-        else:
-            raise error.ProgrammingError('markcopied() called on clean context')
+        self._markdirty(path, exists=True, date=self.filedate(path),
+                        flags=self.flags(path), copied=origin)
 
     def copydata(self, path):
         if self.isdirty(path):
@@ -2098,7 +2096,8 @@
             del self._cache[path]
         return keys
 
-    def _markdirty(self, path, exists, data=None, date=None, flags=''):
+    def _markdirty(self, path, exists, data=None, date=None, flags='',
+        copied=None):
         # data not provided, let's see if we already have some; if not, let's
         # grab it from our underlying context, so that we always have data if
         # the file is marked as existing.
@@ -2111,7 +2110,7 @@
             'data': data,
             'date': date,
             'flags': flags,
-            'copied': None,
+            'copied': copied,
         }
 
     def filectx(self, path, filelog=None):



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


More information about the Mercurial-devel mailing list