Patchwork [evolve-ext] evolve: evolve --divergent failed when merge had nothing to do (issue4950)

login
register
mail settings
Submitter Laurent Charignon
Date Nov. 18, 2015, 1:06 a.m.
Message ID <60dbe75bdfa5211cbaec.1447808802@lcharignon-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/11451/
State Accepted
Headers show

Comments

Laurent Charignon - Nov. 18, 2015, 1:06 a.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1447808767 28800
#      Tue Nov 17 17:06:07 2015 -0800
# Node ID 60dbe75bdfa5211cbaeccb2af182be967d950638
# Parent  48547b4c77defdd17c670b1eb0eb94272edf0207
evolve: evolve --divergent failed when merge had nothing to do (issue4950)

Before this patch, if the divergence resolution lead to an empty commit, the
transaction would be rolled back and the divergence not resolved.
This patch allows empty commits in that case. It is legitimate to end up with
an empty commit in that case, for example when divergent commits differ over
their commit messages.

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -2008,8 +2008,10 @@  def _solvedivergent(ui, repo, divergent,
 /!\ * hg kill -n Y W Z
 """)
     if progresscb: progresscb()
+    emtpycommitallowed = repo.ui.backupconfig('ui', 'allowemptycommit')
     tr = repo.transaction('stabilize-divergent')
     try:
+        repo.ui.setconfig('ui', 'allowemptycommit', True)
         repo.dirstate.beginparentchange()
         repo.dirstate.setparents(divergent.node(), node.nullid)
         repo.dirstate.endparentchange()
@@ -2024,6 +2026,7 @@  def _solvedivergent(ui, repo, divergent,
         phases.retractboundary(repo, tr, other.phase(), [new.node()])
         tr.close()
     finally:
+        repo.ui.restoreconfig(emtpycommitallowed)
         tr.release()
 
 def divergentdata(ctx):
diff --git a/tests/test-divergent.t b/tests/test-divergent.t
--- a/tests/test-divergent.t
+++ b/tests/test-divergent.t
@@ -67,4 +67,45 @@  With --all --any we dedupe the divergent
   |
   o  0:135f39f4bd78@default(draft) add _a []
   
+Test divergence resolution when it yields to an empty commit (issue4950)
+cdivergent2 contains the same content than cdivergent1 and they are divergent
+versions of the revision _c
+
+  $ hg up "desc(_a)"
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ mkcommit _c
+  created new head
+  $ hg up "desc(_a)"
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ mkcommit cdivergent1
+  created new head
+  $ hg up "desc(_a)"
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo "cdivergent1" > cdivergent1
+  $ hg add cdivergent1
+  $ hg ci -m "cdivergent2"
+  created new head
+  $ hg prune -s "desc(cdivergent1)" "desc(_c)"
+  1 changesets pruned
+  $ hg prune -s "desc(cdivergent2)" "desc(_c)" --hidden
+  1 changesets pruned
+  2 new divergent changesets
+  $ hg log -G
+  @  8:0a768ef678d9@default(draft) cdivergent2 [divergent]
+  |
+  | o  7:26c7705fee96@default(draft) add cdivergent1 [divergent]
+  |/
+  | o  5:c26f1d3baed2@default(draft) add bdivergent1 []
+  |/
+  o  0:135f39f4bd78@default(draft) add _a []
+  
+  $ hg evolve --all --any --divergent
+  merge:[7] add cdivergent1
+  with: [8] cdivergent2
+  base: [6] add _c
+  updating to "local" conflict
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  working directory is now at 6602ff5a79dc
+ 
   $ cd ..