Patchwork [evolve-ext] evolve: extract logic to new method _evolvemerge

login
register
mail settings
Submitter Shusen LIU
Date Dec. 20, 2015, 11:44 p.m.
Message ID <1b84076e17532c186584.1450655080@dev1221.lla1.facebook.com>
Download mbox | patch
Permalink /patch/12190/
State Superseded
Delegated to: Pierre-Yves David
Headers show

Comments

Shusen LIU - Dec. 20, 2015, 11:44 p.m.
# HG changeset patch
# User Shusen LIU <liushusen@fb.com>
# Date 1450654835 28800
#      Sun Dec 20 15:40:35 2015 -0800
# Node ID 1b84076e17532c1865846fda8bfeae5e5554058e
# Parent  52c276d2ddb2f076c84ef8258038ef7b5ee00fe4
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)')
@@ -3692,3 +3685,14 @@ 
         repo._bookmarks[book] = dest.node()
     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