Patchwork [4,of,4,evolve-ext-V3] evolve: extract logic to new method _evolvemerge

login
register
mail settings
Submitter Shusen LIU
Date Dec. 18, 2015, 1 p.m.
Message ID <4667333602f72a879dc9.1450443649@dev1221.lla1.facebook.com>
Download mbox | patch
Permalink /patch/12150/
State Superseded
Delegated to: Pierre-Yves David
Headers show

Comments

Shusen LIU - Dec. 18, 2015, 1 p.m.
# HG changeset patch
# User Shusen LIU <liushusen@fb.com>
# Date 1450309148 28800
#      Wed Dec 16 15:39:08 2015 -0800
# Node ID 4667333602f72a879dc9e38695a05e4dce84cfe9
# Parent  ac88e87192bbe50481bdef3a1aa01d4036987326
evolve: extract logic to new method _evolvemerge

This patch introduces a new method _evolvemerge to merge orig to dest in relocate method.
This simplifies the code of the method relocate and allows us to re-use it later to support a continued keywork to implement evolve state.

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -942,14 +942,7 @@ 
     tr = repo.transaction('relocate')
     try:
         try:
-            if repo['.'].rev() != dest.rev():
-                merge.update(repo, dest, False, True, False)
-            if bmactive(repo):
-                repo.ui.status(_("(leaving bookmark %s)\n") % bmactive(repo))
-            bmdeactivate(repo)
-            if keepbranch:
-                repo.dirstate.setbranch(orig.branch())
-            r = merge.graft(repo, orig, orig.p1(), ['local', 'graft'])
+            r = _evolvemerge(repo, orig, dest,keepbranch)
             if r[-1]:  #some conflict
                 raise error.Abort(
                         'unresolved merge conflicts (see hg help resolve)')
@@ -3683,6 +3676,17 @@ 
     if oldbookmarks or destbookmarks:
         repo._bookmarks.recordchange(tr)
 
+def _evolvemerge(repo, orig, dest, keepbranch):
+    if repo['.'].rev() != dest.rev():
+        merge.update(repo, dest, False, True, False)
+    if bmactive(repo):
+        repo.ui.status(_("(leaving bookmark %s)\n") % bmactive(repo))
+    bmdeactivate(repo)
+    if keepbranch:
+        repo.dirstate.setbranch(orig.branch())
+    r = merge.graft(repo, orig, orig.p1(), ['local', 'graft'])
+    return r
+
 def _evolvestatewrite(repo, data):
     repo.vfs.write('evolvestate',
                     '|'.join([data['orig'], data['dest'], data['commitmsg']]))