changeset 42156:14589f1989e9 stable

context: check file exists before getting data from _wrappedctx overlayworkingctx class is used to do in-memory merging. The data() function of that class has logic to look for data() in the wrappedctx if the file data in cache is empty and if the file is dirty. This assumes that if a file is dirty and cache has empty data for it, it will exists in the _wrappedctx. However this assumption can be False in case when we are merging a file which is empty in destination. In these cases, the backup file 'foo.orig' created by our internal merge algorithms will be empty, however it won't be present in _wrappedctx. This case will lead us to error like the one this patch is fixing. Let's only fallback to getting data from wrappedctx if cache has 'None' as data. Differential Revision: https://phab.mercurial-scm.org/D6308
author Pulkit Goyal <pulkit@yandex-team.ru>
date Wed, 24 Apr 2019 19:42:43 +0300
parents 818051048c2e
children 723ed4402896
files mercurial/context.py tests/test-rebase-inmemory.t
diffstat 2 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Wed Apr 24 19:28:46 2019 +0300
+++ b/mercurial/context.py	Wed Apr 24 19:42:43 2019 +0300
@@ -1824,7 +1824,7 @@
     def data(self, path):
         if self.isdirty(path):
             if self._cache[path]['exists']:
-                if self._cache[path]['data']:
+                if self._cache[path]['data'] is not None:
                     return self._cache[path]['data']
                 else:
                     # Must fallback here, too, because we only set flags.
--- a/tests/test-rebase-inmemory.t	Wed Apr 24 19:28:46 2019 +0300
+++ b/tests/test-rebase-inmemory.t	Wed Apr 24 19:42:43 2019 +0300
@@ -797,5 +797,9 @@
   $ hg rebase -r . -d 1 --config ui.merge=internal:merge3
   rebasing 2:fb62b706688e "add b to foo" (tip)
   merging foo
-  abort: foo.orig@e780cf6f9041: not found in manifest!
-  [255]
+  hit merge conflicts; re-running rebase without in-memory merge
+  rebasing 2:fb62b706688e "add b to foo" (tip)
+  merging foo
+  warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]