merge.applyupdates: call driverpreprocess before starting merge actions
authorSiddharth Agarwal <sid0@fb.com>
Thu, 15 Oct 2015 01:19:10 -0700
changeset 26786 121f80d14e4b
parent 26785 e9a0d5f5c225
child 26787 64848559413a
merge.applyupdates: call driverpreprocess before starting merge actions We also need to update our internal state to whatever state driverpreprocess leaves it in. Adding an error state separate from the unresolved count is too big a refactoring for now, so we hack around it by setting it to a positive value to indicate an error state.
mercurial/merge.py
--- a/mercurial/merge.py	Thu Oct 15 01:17:29 2015 -0700
+++ b/mercurial/merge.py	Thu Oct 15 01:19:10 2015 -0700
@@ -942,6 +942,27 @@
         util.setflags(repo.wjoin(f), 'l' in flags, 'x' in flags)
         updated += 1
 
+    mergeactions = actions['m']
+    # the ordering is important here -- ms.mergedriver will raise if the merge
+    # driver has changed, and we want to be able to bypass it when overwrite is
+    # True
+    usemergedriver = not overwrite and mergeactions and ms.mergedriver
+
+    if usemergedriver:
+        ms.commit()
+        proceed = driverpreprocess(repo, ms, wctx, labels=labels)
+        # the driver might leave some files unresolved
+        unresolvedf = set(ms.unresolved())
+        if not proceed:
+            # XXX setting unresolved to at least 1 is a hack to make sure we
+            # error out
+            return updated, merged, removed, max(len(unresolvedf), 1)
+        newactions = []
+        for f, args, msg in mergeactions:
+            if f in unresolvedf:
+                newactions.append((f, args, msg))
+        mergeactions = newactions
+
     # premerge
     tocomplete = []
     for f, args, msg in actions['m']: