Patchwork [7,of,7,evolve-ext] _evolvecontinue

login
register
mail settings
Submitter Shusen LIU
Date Dec. 7, 2015, 1:46 a.m.
Message ID <d4434829efcea7b19f30.1449452812@dev1221.lla1.facebook.com>
Download mbox | patch
Permalink /patch/11885/
State Rejected, archived
Delegated to: Laurent Charignon
Headers show

Comments

Shusen LIU - Dec. 7, 2015, 1:46 a.m.
# HG changeset patch
# User Shusen LIU <liushusen@fb.com>
# Date 1449451999 28800
#      Sun Dec 06 17:33:19 2015 -0800
# Node ID d4434829efcea7b19f30e329c879f10dcf078e0f
# Parent  a4d5a278c733fb3c8f06bc857dc401349f6e9697
_evolvecontinue

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -111,6 +111,7 @@ 
 from mercurial import wireproto
 from mercurial import localrepo
 from mercurial.hgweb import hgweb_mod
+from mercurial.lock import release
 
 cmdtable = {}
 command = cmdutil.command(cmdtable)
@@ -944,6 +945,10 @@ 
         try:
             r = _evolvemerge(repo, orig, dest,keepbranch)
             if r[-1]:  #some conflict
+                _evolvestatewrite(repo, {'orig': orig.hex(),
+                                         'dest': dest.hex(),
+                                         'commitmsg': commitmsg,
+                                        })
                 raise error.Abort(
                         'unresolved merge conflicts (see hg help resolve)')
             nodenew = _relocatecommit(repo, orig, commitmsg)
@@ -959,6 +964,7 @@ 
             exc.__class__ = LocalMergeFailure
             raise
         _finalizerelocate(repo, orig, dest, nodenew, tr)
+        _evolvestatedelete(repo)
         tr.close()
     finally:
         tr.release()
@@ -1641,8 +1647,8 @@ 
             raise error.Abort('cannot specify both "--any" and "--continue"')
         if allopt:
             raise error.Abort('cannot specify both "--all" and "--continue"')
-        graftcmd = commands.table['graft'][0]
-        return graftcmd(ui, repo, old_obsolete=True, **{'continue': True})
+        _evolvecontinue(repo)
+        return 0
     cmdutil.bailifchanged(repo)
 
 
@@ -1779,7 +1785,6 @@ 
         try:
             relocate(repo, orig, target, keepbranch)
         except MergeFailure:
-            repo.opener.write('graftstate', orig.hex() + '\n')
             repo.ui.write_err(_('evolve failed!\n'))
             repo.ui.write_err(
                 _('fix conflict and run "hg evolve --continue"'
@@ -3691,3 +3696,29 @@ 
         repo.dirstate.setbranch(orig.branch())
     r = merge.graft(repo, orig, orig.p1(), ['local', 'graft'])
     return r
+
+def _evolvecontinue(repo):
+    state = _evolvestateread(repo)
+    orig = repo[state['orig']]
+    dest = repo[state['dest']]
+    commitmsg = state['commitmsg']
+
+    desc = '%d:%s "%s"' % (orig.rev(), orig,
+                           orig.description().split('\n', 1)[0])
+    names = repo.nodetags(orig.node()) + repo.nodebookmarks(orig.node())
+    if names:
+        desc += ' (%s)' % ' '.join(names)
+    repo.ui.status(_('evolving %s\n') % desc)
+
+    wlock = lock = None
+    try:
+        wlock = repo.wlock() # must come first
+        lock = repo.lock()
+        tr = repo.transaction("evolvecontinue")
+        # perform write operation
+        nodenew = _relocatecommit(repo, orig, commitmsg, True)
+        _finalizerelocate(repo, orig, dest, nodenew, tr)
+        _evolvestatedelete(repo)
+        tr.close()
+    finally:
+        release(tr, lock, wlock) # reverse order
diff --git a/tests/test-stabilize-conflict.t b/tests/test-stabilize-conflict.t
--- a/tests/test-stabilize-conflict.t
+++ b/tests/test-stabilize-conflict.t
@@ -100,7 +100,7 @@ 
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     babar count up to five
-  
+
 
 
 proper behavior with conflict using internal:merge
@@ -157,7 +157,7 @@ 
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     babar count up to five
-  
+
 (fix the conflict and continue)
 
   $ hg revert -r 5 --all
@@ -166,7 +166,7 @@ 
   $ hg resolve --all -m
   (no more unresolved files)
   $ hg evolve --continue
-  grafting 5:71c18f70c34f "babar count up to fifteen"
+  evolving 5:71c18f70c34f "babar count up to fifteen"
   $ hg resolve -l
   $ hg log -G
   @  changeset:   8:7f3d9db50b5d
@@ -185,7 +185,7 @@ 
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     babar count up to five
-  
+
 proper behavior with conflict using an external merge tool
 ----------------------------------------------------------
 
@@ -247,7 +247,7 @@ 
      user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     babar count up to five
-  
+
   $ cat babar
   un
   deux
diff --git a/tests/test-stabilize-result.t b/tests/test-stabilize-result.t
--- a/tests/test-stabilize-result.t
+++ b/tests/test-stabilize-result.t
@@ -51,7 +51,7 @@ 
   | x  1:102a90ea7b4a@default(draft) bk:[] addb
   |/
   o  0:07f494440405@default(draft) bk:[] adda
-  
+
   $ hg debugobsolete
   102a90ea7b4a3361e4082ed620918c261189a36a fb9d051ec0a450a4aa2ffc8c324979832ef88065 0 (*) {'user': 'test'} (glob)
   c5727dbded3c3a6877cf60d6bb552a76812cb844 0 {102a90ea7b4a3361e4082ed620918c261189a36a} (*) {'user': 'test'} (glob)
@@ -97,13 +97,13 @@ 
   +a
   +newer a
   $ hg evolve --continue
-  grafting 5:3655f0f50885 "newer a"
+  evoleing 5:3655f0f50885 "newer a"
   abort: unresolved merge conflicts (see "hg help resolve")
   [255]
   $ hg resolve -m a
   (no more unresolved files)
   $ hg evolve --continue
-  grafting 5:3655f0f50885 "newer a"
+  evoleing 5:3655f0f50885 "newer a"
 
 Stabilize latecomer with different parent
 =========================================
@@ -116,7 +116,7 @@ 
   o  7:66719795a494@default(draft) bk:[changea] changea
   |
   o  0:07f494440405@default(draft) bk:[] adda
-  
+
 Add another commit
 
   $ hg gdown
@@ -153,7 +153,7 @@ 
   o  7:66719795a494@default(public) bk:[changea] changea
   |
   o  0:07f494440405@default(public) bk:[] adda
-  
+
 
 Stabilize!
 
@@ -188,7 +188,7 @@ 
   o  7:66719795a494@default(public) bk:[changea] changea
   |
   o  0:07f494440405@default(public) bk:[] adda
-  
+
 
 Stabilize divergent changesets with same parent
 ===============================================
@@ -217,7 +217,7 @@ 
   o  7:66719795a494@default(public) bk:[changea] changea
   |
   o  0:07f494440405@default(public) bk:[] adda
-  
+
   $ echo 'babar' >> a
   $ hg amend
   $ hg up --hidden 15
@@ -244,7 +244,7 @@ 
   o  7:66719795a494@default(public) bk:[changea] changea
   |
   o  0:07f494440405@default(public) bk:[] adda
-  
+
 
 Stabilize it
 
@@ -299,7 +299,7 @@ 
   o  7:66719795a494@default(public) bk:[changea] changea
   |
   o  0:07f494440405@default(public) bk:[] adda
-  
+
   $ hg summary
   parent: 21:f344982e63c4 tip
    More addition
@@ -315,7 +315,7 @@ 
   # Node ID f344982e63c462b1e44c0371c804685389e673a9
   # Parent  7bc2f5967f5e4ed277f60a89b7b04cc5d6407ced
   More addition
-  
+
   diff -r 7bc2f5967f5e -r f344982e63c4 a
   --- a/a	Thu Jan 01 00:00:00 1970 +0000
   +++ b/a	Thu Jan 01 00:00:00 1970 +0000