changeset 4133:a9ee6c53af8d

mq: abort cleanly when invalid patch name is given to qguard
author Christian Ebert <blacktrash@gmx.net>
date Sat, 03 Mar 2007 17:54:13 +0100
parents 0d94e4a3ddb4
children 9dc64c8414ca 49d7a035235b
files hgext/mq.py tests/test-mq-guards tests/test-mq-guards.out
diffstat 3 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Mon Feb 19 12:38:58 2007 +0300
+++ b/hgext/mq.py	Sat Mar 03 17:54:13 2007 +0100
@@ -1712,7 +1712,10 @@
     if patch is None:
         raise util.Abort(_('no patch to work with'))
     if args or opts['none']:
-        q.set_guards(q.find_series(patch), args)
+        idx = q.find_series(patch)
+        if idx is None:
+            raise util.Abort(_('no patch named %s') % patch)
+        q.set_guards(idx, args)
         q.save_dirty()
     else:
         status(q.series.index(q.lookup(patch)))
--- a/tests/test-mq-guards	Mon Feb 19 12:38:58 2007 +0300
+++ b/tests/test-mq-guards	Sat Mar 03 17:54:13 2007 +0100
@@ -27,6 +27,9 @@
 hg qpop -a
 
 echo % should fail
+hg qguard does-not-exist.patch +bleh
+
+echo % should fail
 hg qguard +fail
 
 hg qpush
--- a/tests/test-mq-guards.out	Mon Feb 19 12:38:58 2007 +0300
+++ b/tests/test-mq-guards.out	Sat Mar 03 17:54:13 2007 +0100
@@ -1,6 +1,8 @@
 adding x
 Patch queue now empty
 % should fail
+abort: no patch named does-not-exist.patch
+% should fail
 abort: no patches applied
 applying a.patch
 Now at: a.patch