continue: added support for transplant
authorTaapas Agrawal <taapas2897@gmail.com>
Wed, 24 Jul 2019 18:32:36 +0530
changeset 42734 0a4303c77637
parent 42733 50c2c3eae64e
child 42735 389233789952
continue: added support for transplant This creates a seperate function `continuetransplant()` containing logic for resuming transplant from interrupted state. `continuetransplant()` is then registered as `continuefunc` for state detection API. Results are shown in tests. Differential Revision: https://phab.mercurial-scm.org/D6689
hgext/transplant.py
tests/test-transplant.t
--- a/hgext/transplant.py	Fri Aug 09 05:09:54 2019 -0400
+++ b/hgext/transplant.py	Wed Jul 24 18:32:36 2019 +0530
@@ -734,6 +734,13 @@
         if cleanupfn:
             cleanupfn()
 
+def continuecmd(ui, repo):
+    """logic to resume an interrupted transplant using
+    'hg continue'"""
+    with repo.wlock():
+        tp = transplanter(ui, repo, {})
+        return tp.resume(repo, repo, {})
+
 revsetpredicate = registrar.revsetpredicate()
 
 @revsetpredicate('transplanted([set])')
@@ -760,6 +767,7 @@
 def extsetup(ui):
     statemod.addunfinished (
         'transplant', fname='transplant/journal', clearable=True,
+        continuefunc=continuecmd,
         statushint=_('To continue:    hg transplant --continue\n'
                      'To abort:       hg update'),
         cmdhint=_("use 'hg transplant --continue' or 'hg update' to abort")
--- a/tests/test-transplant.t	Fri Aug 09 05:09:54 2019 -0400
+++ b/tests/test-transplant.t	Wed Jul 24 18:32:36 2019 +0530
@@ -1,8 +1,16 @@
+#testcases commandmode continueflag
   $ cat <<EOF >> $HGRCPATH
   > [extensions]
   > transplant=
   > EOF
 
+#if continueflag
+  $ cat >> $HGRCPATH <<EOF
+  > [alias]
+  > continue = transplant --continue
+  > EOF
+#endif
+
   $ hg init t
   $ cd t
   $ hg transplant
@@ -424,8 +432,9 @@
   updated to "e8643552fde5: foobar"
   1 other heads for branch "default"
   $ rm added
-  $ hg transplant --continue
-  abort: no transplant to continue
+  $ hg continue
+  abort: no transplant to continue (continueflag !)
+  abort: no operation in progress (no-continueflag !)
   [255]
   $ hg transplant 1
   applying 46ae92138f3c
@@ -492,7 +501,7 @@
   # To abort:       hg update
   
   $ echo fixed > baz
-  $ hg transplant --continue
+  $ hg continue
   9d6d6b5a8275 transplanted as d80c49962290
   applying 1dab759070cf
   1dab759070cf transplanted to aa0ffe6bd5ae
@@ -881,7 +890,7 @@
   [255]
   $ hg status
   ? b.rej
-  $ hg transplant --continue
+  $ hg continue
   645035761929 skipped due to empty diff
 
   $ cd ..