Patchwork [3,of,4] transplant: only use checkunfinished if not continue

login
register
mail settings
Submitter timeless@mozdev.org
Date Jan. 6, 2016, 5:12 a.m.
Message ID <ca8dfff2add30ea34a82.1452057156@waste.org>
Download mbox | patch
Permalink /patch/12559/
State Accepted
Headers show

Comments

timeless@mozdev.org - Jan. 6, 2016, 5:12 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1452056361 0
#      Wed Jan 06 04:59:21 2016 +0000
# Node ID ca8dfff2add30ea34a82ab8eb9cc70aeb552d381
# Parent  8f40cd2a9924a0f024a58dcda5d737347849b87b
transplant: only use checkunfinished if not continue

Patch

diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -303,6 +303,9 @@ 
 
         return n
 
+    def canresume(self):
+        return os.path.exists(os.path.join(self.path, 'journal'))
+
     def resume(self, repo, source, opts):
         '''recover last transaction and apply remaining changesets'''
         if os.path.exists(os.path.join(self.path, 'journal')):
@@ -627,11 +630,14 @@ 
 
     tp = transplanter(ui, repo, opts)
 
-    cmdutil.checkunfinished(repo)
     p1, p2 = repo.dirstate.parents()
     if len(repo) > 0 and p1 == revlog.nullid:
         raise error.Abort(_('no revision checked out'))
-    if not opts.get('continue'):
+    if opts.get('continue'):
+        if not tp.canresume():
+            raise error.Abort(_('no transplant to continue'))
+    else:
+        cmdutil.checkunfinished(repo)
         if p2 != revlog.nullid:
             raise error.Abort(_('outstanding uncommitted merges'))
         m, a, r, d = repo.status()[:4]
diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -376,6 +376,9 @@ 
   $ hg up -C
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ rm added
+  $ hg transplant --continue
+  abort: no transplant to continue
+  [255]
   $ hg transplant 1
   applying 46ae92138f3c
   patching file foo