Implement the 'goto' command
[stgit] / stgit / commands / pop.py
index 3da135c..9bee9f1 100644 (file)
@@ -57,7 +57,10 @@ def func(parser, options, args):
 
     if options.to:
         if options.to not in applied:
-            raise CmdException, 'Patch "%s" not applied' % options.to
+            if options.to in crt_series.get_unapplied():
+                raise CmdException, 'Patch "%s" is not currently applied.' % options.to
+            else:
+                raise CmdException, 'Patch "%s" does not exist.' % options.to
         patches = applied[:applied.index(options.to)]
     elif options.number:
         patches = applied[:options.number]
@@ -69,15 +72,6 @@ def func(parser, options, args):
     if patches == []:
         raise CmdException, 'No patches to pop'
 
-    # pop everything to the given patch
-    p = patches[-1]
-    if len(patches) == 1:
-        print 'Popping patch "%s"...' % p,
-    else:
-        print 'Popping "%s" - "%s" patches...' % (patches[0], p),
-    sys.stdout.flush()
-
-    crt_series.pop_patch(p)
+    pop_patches(patches)
 
-    print 'done'
     print_crt_patch()