# HG changeset patch # User Christian Ebert # Date 2007-03-03 16:54:13 # Node ID a9ee6c53af8db43a746a91e9f015677598a5eb7e # Parent 0d94e4a3ddb498dc58dec6f38a48c86047ddd733 mq: abort cleanly when invalid patch name is given to qguard diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1712,7 +1712,10 @@ def guard(ui, repo, *args, **opts): 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))) diff --git a/tests/test-mq-guards b/tests/test-mq-guards --- a/tests/test-mq-guards +++ b/tests/test-mq-guards @@ -27,6 +27,9 @@ hg qrefresh hg qpop -a echo % should fail +hg qguard does-not-exist.patch +bleh + +echo % should fail hg qguard +fail hg qpush diff --git a/tests/test-mq-guards.out b/tests/test-mq-guards.out --- a/tests/test-mq-guards.out +++ b/tests/test-mq-guards.out @@ -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