D1815: merge: only abort in IMM if files are actually marked as driver-resolved

phillco (Phil Cohen) phabricator at mercurial-scm.org
Fri Jan 5 18:01:20 UTC 2018


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

REVISION SUMMARY
  Before, we would raise whenever the `usemergedriver` condition was set when merging in-memory,
  which equated to "any merge with (cd, dc, or m) actions in a repo with a mergedriver script".
  This was done to be as conservative as possible.
  
  However, a better solution is to run the preprocess() script and only raise if any files are
  marked to actually be driver-resolved. That way we only restart the merge if we absolutely need
  to.
  
  Since some of our preprocess() scripts aren't ready yet, I also added
  experimental.inmemory.nomergedriver in a previous change so we can deploy this in a build before the preprocess scripts are good to go.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1556,11 +1556,9 @@
     usemergedriver = not overwrite and mergeactions and ms.mergedriver
 
     if usemergedriver:
-        if wctx.isinmemory():
-            raise error.InMemoryMergeConflictsError("in-memory merge does not "
-                                                    "support mergedriver")
         ms.commit()
         proceed = driverpreprocess(repo, ms, wctx, labels=labels)
+        drivverresolved = [f for f in ms.driverresolved()]
 
         # Note which files were marked as driver-resolved but not matched by
         # experimental.inmemorydisallowedpaths. This will allow us to keep
@@ -1573,9 +1571,17 @@
         if not pathsconfig:
             pathsconfig = ".^"
         regex = util.re.compile(pathsconfig)
-        unmatched = [f for f in ms.driverresolved() if not regex.match(f)]
+        unmatched = [f for f in drivverresolved if not regex.match(f)]
         repo.ui.log('imm_mergedriver', '',
-            driver_resolved_missed="|".join(sorted(unmatched)))
+            driver_resolved_missed="|".join(sorted(unmatched)),
+            in_memory=wctx.isinmemory())
+
+        # If preprocess() marked any files as driver-resolved and we're merging
+        # in-memory, abort on the assumption that driver scripts require the
+        # working directory.
+        if drivverresolved and wctx.isinmemory():
+            raise error.InMemoryMergeConflictsError("in-memory merge does not "
+                                                    "support mergedriver")
 
         # the driver might leave some files unresolved
         unresolvedf = set(ms.unresolved())



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


More information about the Mercurial-devel mailing list