Patchwork [5,of,5,mergedriver] merge: perform all premerges before concluding any merges

login
register
mail settings
Submitter Siddharth Agarwal
Date Oct. 9, 2015, 11:10 p.m.
Message ID <bdd42c70d9206a26a760.1444432224@dev6666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/10943/
State Changes Requested
Headers show

Comments

Siddharth Agarwal - Oct. 9, 2015, 11:10 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1444431546 25200
#      Fri Oct 09 15:59:06 2015 -0700
# Node ID bdd42c70d9206a26a7602ca0b2a8e00b656af147
# Parent  ff24df65dfb8265cc2e328ec6d27c3b034421c99
merge: perform all premerges before concluding any merges

This is going to enable a bunch of things:
- being able to abort the entire merge process from within a merge tool
- custom merge drivers that only need premerged code

The output changes are expected here and indicate how the merge process has
changed.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -314,8 +314,6 @@  class mergestate(object):
         mergectx = filemerge.mergectx(self._repo, self._local, lfile, fcd, fco,
                                       fca, labels=labels)
         paused, r = mergectx.premerge()
-        if paused:
-            r = mergectx.merge()
 
         if r is None:
             # no real conflict
@@ -323,6 +321,9 @@  class mergestate(object):
             self._dirty = True
         elif not r:
             self.mark(dfile, 'r')
+
+        if paused:
+            self._pausedmerges.append((dfile, mergectx))
         return r
 
     def concludemerges(self):
diff --git a/tests/test-lfconvert.t b/tests/test-lfconvert.t
--- a/tests/test-lfconvert.t
+++ b/tests/test-lfconvert.t
@@ -124,9 +124,9 @@  add some changesets to rename/remove/mer
   $ hg commit -q -m"remove large, normal3"
   $ hg merge
   merging sub/maybelarge.dat and stuff/maybelarge.dat to stuff/maybelarge.dat
-  warning: $TESTTMP/bigfile-repo/stuff/maybelarge.dat looks like a binary file. (glob)
+  merging sub/normal2 and stuff/normal2 to stuff/normal2
+  warning: $TESTTMP/bigfile-repo/stuff/maybelarge.dat looks like a binary file.
   warning: conflicts while merging stuff/maybelarge.dat! (edit, then use 'hg resolve --mark')
-  merging sub/normal2 and stuff/normal2 to stuff/normal2
   0 files updated, 1 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]
diff --git a/tests/test-merge-force.t b/tests/test-merge-force.t
--- a/tests/test-merge-force.t
+++ b/tests/test-merge-force.t
@@ -192,27 +192,27 @@  Merge with remote
   remote changed content1_content2_missing_missing-untracked which local deleted
   use (c)hanged version or leave (d)eleted? c
   merging content1_content2_content1_content4-tracked
-  warning: conflicts while merging content1_content2_content1_content4-tracked! (edit, then use 'hg resolve --mark')
   merging content1_content2_content2_content1-tracked
   merging content1_content2_content2_content4-tracked
-  warning: conflicts while merging content1_content2_content2_content4-tracked! (edit, then use 'hg resolve --mark')
   merging content1_content2_content3_content1-tracked
   merging content1_content2_content3_content3-tracked
-  warning: conflicts while merging content1_content2_content3_content3-tracked! (edit, then use 'hg resolve --mark')
   merging content1_content2_content3_content4-tracked
-  warning: conflicts while merging content1_content2_content3_content4-tracked! (edit, then use 'hg resolve --mark')
   merging content1_content2_missing_content1-tracked
   merging content1_content2_missing_content4-tracked
+  merging missing_content2_content2_content4-tracked
+  merging missing_content2_content3_content3-tracked
+  merging missing_content2_content3_content4-tracked
+  merging missing_content2_missing_content4-tracked
+  merging missing_content2_missing_content4-untracked
+  warning: conflicts while merging content1_content2_content1_content4-tracked! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging content1_content2_content2_content4-tracked! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging content1_content2_content3_content3-tracked! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging content1_content2_content3_content4-tracked! (edit, then use 'hg resolve --mark')
   warning: conflicts while merging content1_content2_missing_content4-tracked! (edit, then use 'hg resolve --mark')
-  merging missing_content2_content2_content4-tracked
   warning: conflicts while merging missing_content2_content2_content4-tracked! (edit, then use 'hg resolve --mark')
-  merging missing_content2_content3_content3-tracked
   warning: conflicts while merging missing_content2_content3_content3-tracked! (edit, then use 'hg resolve --mark')
-  merging missing_content2_content3_content4-tracked
   warning: conflicts while merging missing_content2_content3_content4-tracked! (edit, then use 'hg resolve --mark')
-  merging missing_content2_missing_content4-tracked
   warning: conflicts while merging missing_content2_missing_content4-tracked! (edit, then use 'hg resolve --mark')
-  merging missing_content2_missing_content4-untracked
   warning: conflicts while merging missing_content2_missing_content4-untracked! (edit, then use 'hg resolve --mark')
   39 files updated, 3 files merged, 8 files removed, 10 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
diff --git a/tests/test-merge-types.t b/tests/test-merge-types.t
--- a/tests/test-merge-types.t
+++ b/tests/test-merge-types.t
@@ -283,10 +283,8 @@  h: l vs l, different
 
   $ hg merge
   merging a
-  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
   warning: cannot merge flags for b
   merging b
-  warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
   warning: cannot merge flags for c
   merging d
   warning: internal :merge cannot merge symlinks for d
@@ -297,6 +295,8 @@  h: l vs l, different
   merging h
   warning: internal :merge cannot merge symlinks for h
   warning: conflicts while merging h! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
   3 files updated, 0 files merged, 0 files removed, 5 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]
@@ -342,10 +342,8 @@  h: l vs l, different
   $ hg up -Cqr1
   $ hg merge
   merging a
-  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
   warning: cannot merge flags for b
   merging b
-  warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
   warning: cannot merge flags for c
   merging d
   warning: internal :merge cannot merge symlinks for d
@@ -356,6 +354,8 @@  h: l vs l, different
   merging h
   warning: internal :merge cannot merge symlinks for h
   warning: conflicts while merging h! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
   3 files updated, 0 files merged, 0 files removed, 5 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]
diff --git a/tests/test-merge9.t b/tests/test-merge9.t
--- a/tests/test-merge9.t
+++ b/tests/test-merge9.t
@@ -27,8 +27,8 @@  a file-level merge failed
 test with the rename on the remote side
   $ HGMERGE=false hg merge
   merging bar
+  merging foo and baz to baz
   merging bar failed!
-  merging foo and baz to baz
   1 files updated, 1 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]
@@ -41,8 +41,8 @@  test with the rename on the local side
   3 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ HGMERGE=false hg merge
   merging bar
+  merging baz and foo to baz
   merging bar failed!
-  merging baz and foo to baz
   1 files updated, 1 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]
diff --git a/tests/test-rename-merge2.t b/tests/test-rename-merge2.t
--- a/tests/test-rename-merge2.t
+++ b/tests/test-rename-merge2.t
@@ -347,12 +347,12 @@  args:
   picked tool 'python ../merge' for b (binary False symlink False)
   merging b
   my b@62e7bf090eba+ other b@49b6d8032493 ancestor a@924404dff337
-  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
-  merge tool returned: 0
    rev: versions differ -> m
   picked tool 'python ../merge' for rev (binary False symlink False)
   merging rev
   my rev@62e7bf090eba+ other rev@49b6d8032493 ancestor rev@924404dff337
+  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
+  merge tool returned: 0
   launching merge tool: python ../merge *$TESTTMP/t/t/rev* * * (glob)
   merge tool returned: 0
   0 files updated, 2 files merged, 0 files removed, 0 files unresolved
@@ -417,12 +417,12 @@  m "um a c" "um x c" "      " "10 do merg
   picked tool 'python ../merge' for b (binary False symlink False)
   merging b
   my b@86a2aa42fc76+ other b@af30c7647fc7 ancestor b@000000000000
-  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
-  merge tool returned: 0
    rev: versions differ -> m
   picked tool 'python ../merge' for rev (binary False symlink False)
   merging rev
   my rev@86a2aa42fc76+ other rev@af30c7647fc7 ancestor rev@924404dff337
+  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
+  merge tool returned: 0
   launching merge tool: python ../merge *$TESTTMP/t/t/rev* * * (glob)
   merge tool returned: 0
   0 files updated, 2 files merged, 0 files removed, 0 files unresolved
@@ -451,12 +451,12 @@  m "um a c" "um x c" "      " "10 do merg
   picked tool 'python ../merge' for b (binary False symlink False)
   merging b
   my b@59318016310c+ other b@bdb19105162a ancestor b@000000000000
-  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
-  merge tool returned: 0
    rev: versions differ -> m
   picked tool 'python ../merge' for rev (binary False symlink False)
   merging rev
   my rev@59318016310c+ other rev@bdb19105162a ancestor rev@924404dff337
+  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
+  merge tool returned: 0
   launching merge tool: python ../merge *$TESTTMP/t/t/rev* * * (glob)
   merge tool returned: 0
   0 files updated, 2 files merged, 1 files removed, 0 files unresolved
@@ -484,12 +484,12 @@  m "um a c" "um x c" "      " "10 do merg
   picked tool 'python ../merge' for b (binary False symlink False)
   merging b
   my b@86a2aa42fc76+ other b@8dbce441892a ancestor b@000000000000
-  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
-  merge tool returned: 0
    rev: versions differ -> m
   picked tool 'python ../merge' for rev (binary False symlink False)
   merging rev
   my rev@86a2aa42fc76+ other rev@8dbce441892a ancestor rev@924404dff337
+  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
+  merge tool returned: 0
   launching merge tool: python ../merge *$TESTTMP/t/t/rev* * * (glob)
   merge tool returned: 0
   1 files updated, 2 files merged, 0 files removed, 0 files unresolved
@@ -518,12 +518,12 @@  m "um a c" "um x c" "      " "10 do merg
   picked tool 'python ../merge' for b (binary False symlink False)
   merging b
   my b@59318016310c+ other b@bdb19105162a ancestor b@000000000000
-  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
-  merge tool returned: 0
    rev: versions differ -> m
   picked tool 'python ../merge' for rev (binary False symlink False)
   merging rev
   my rev@59318016310c+ other rev@bdb19105162a ancestor rev@924404dff337
+  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
+  merge tool returned: 0
   launching merge tool: python ../merge *$TESTTMP/t/t/rev* * * (glob)
   merge tool returned: 0
   0 files updated, 2 files merged, 1 files removed, 0 files unresolved
@@ -551,12 +551,12 @@  m "um a c" "um x c" "      " "10 do merg
   picked tool 'python ../merge' for b (binary False symlink False)
   merging b
   my b@86a2aa42fc76+ other b@8dbce441892a ancestor b@000000000000
-  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
-  merge tool returned: 0
    rev: versions differ -> m
   picked tool 'python ../merge' for rev (binary False symlink False)
   merging rev
   my rev@86a2aa42fc76+ other rev@8dbce441892a ancestor rev@924404dff337
+  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
+  merge tool returned: 0
   launching merge tool: python ../merge *$TESTTMP/t/t/rev* * * (glob)
   merge tool returned: 0
   1 files updated, 2 files merged, 0 files removed, 0 files unresolved
@@ -584,12 +584,12 @@  m "um a c" "um x c" "      " "10 do merg
   picked tool 'python ../merge' for b (binary False symlink False)
   merging b
   my b@0b76e65c8289+ other b@4ce40f5aca24 ancestor b@000000000000
-  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
-  merge tool returned: 0
    rev: versions differ -> m
   picked tool 'python ../merge' for rev (binary False symlink False)
   merging rev
   my rev@0b76e65c8289+ other rev@4ce40f5aca24 ancestor rev@924404dff337
+  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
+  merge tool returned: 0
   launching merge tool: python ../merge *$TESTTMP/t/t/rev* * * (glob)
   merge tool returned: 0
   0 files updated, 2 files merged, 0 files removed, 0 files unresolved
@@ -620,12 +620,12 @@  m "um a c" "um x c" "      " "10 do merg
   picked tool 'python ../merge' for b (binary False symlink False)
   merging b
   my b@02963e448370+ other b@8dbce441892a ancestor b@000000000000
-  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
-  merge tool returned: 0
    rev: versions differ -> m
   picked tool 'python ../merge' for rev (binary False symlink False)
   merging rev
   my rev@02963e448370+ other rev@8dbce441892a ancestor rev@924404dff337
+  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
+  merge tool returned: 0
   launching merge tool: python ../merge *$TESTTMP/t/t/rev* * * (glob)
   merge tool returned: 0
   1 files updated, 2 files merged, 0 files removed, 0 files unresolved
@@ -655,12 +655,12 @@  m "um a c" "um x c" "      " "10 do merg
   picked tool 'python ../merge' for b (binary False symlink False)
   merging b
   my b@0b76e65c8289+ other b@bdb19105162a ancestor b@000000000000
-  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
-  merge tool returned: 0
    rev: versions differ -> m
   picked tool 'python ../merge' for rev (binary False symlink False)
   merging rev
   my rev@0b76e65c8289+ other rev@bdb19105162a ancestor rev@924404dff337
+  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
+  merge tool returned: 0
   launching merge tool: python ../merge *$TESTTMP/t/t/rev* * * (glob)
   merge tool returned: 0
   0 files updated, 2 files merged, 0 files removed, 0 files unresolved
@@ -691,12 +691,12 @@  m "um a c" "um x c" "      " "10 do merg
   picked tool 'python ../merge' for b (binary False symlink False)
   merging a and b to b
   my b@e300d1c794ec+ other b@49b6d8032493 ancestor a@924404dff337
-  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
-  merge tool returned: 0
    rev: versions differ -> m
   picked tool 'python ../merge' for rev (binary False symlink False)
   merging rev
   my rev@e300d1c794ec+ other rev@49b6d8032493 ancestor rev@924404dff337
+  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
+  merge tool returned: 0
   launching merge tool: python ../merge *$TESTTMP/t/t/rev* * * (glob)
   merge tool returned: 0
   0 files updated, 2 files merged, 0 files removed, 0 files unresolved
@@ -726,12 +726,12 @@  m "um a c" "um x c" "      " "10 do merg
   picked tool 'python ../merge' for b (binary False symlink False)
   merging b and a to b
   my b@62e7bf090eba+ other a@f4db7e329e71 ancestor a@924404dff337
-  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
-  merge tool returned: 0
    rev: versions differ -> m
   picked tool 'python ../merge' for rev (binary False symlink False)
   merging rev
   my rev@62e7bf090eba+ other rev@f4db7e329e71 ancestor rev@924404dff337
+  launching merge tool: python ../merge *$TESTTMP/t/t/b* * * (glob)
+  merge tool returned: 0
   launching merge tool: python ../merge *$TESTTMP/t/t/rev* * * (glob)
   merge tool returned: 0
   0 files updated, 2 files merged, 0 files removed, 0 files unresolved
diff --git a/tests/test-status-color.t b/tests/test-status-color.t
--- a/tests/test-status-color.t
+++ b/tests/test-status-color.t
@@ -325,8 +325,8 @@  test 'resolve -l'
   created new head
   $ hg merge
   merging a
+  merging b
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
-  merging b
   warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
   0 files updated, 0 files merged, 0 files removed, 2 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon