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

login
register
mail settings
Submitter phabricator
Date Jan. 5, 2018, 6:01 p.m.
Message ID <differential-rev-PHID-DREV-yz5ehd5gpf2ju77a6v5w-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26571/
State Superseded
Headers show

Comments

phabricator - Jan. 5, 2018, 6:01 p.m.
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




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

Patch

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())