diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -902,14 +902,14 @@ class queue(object): def push(self, repo, patch=None, force=False, list=False, mergeq=None, all=False): wlock = repo.wlock() - if repo.dirstate.parents()[0] not in repo.heads(): - self.ui.status(_("(working directory not at a head)\n")) + try: + if repo.dirstate.parents()[0] not in repo.heads(): + self.ui.status(_("(working directory not at a head)\n")) - if not self.series: - self.ui.warn(_('no patches in series\n')) - return 0 + if not self.series: + self.ui.warn(_('no patches in series\n')) + return 0 - try: patch = self.lookup(patch) # Suppose our series file is: A B C and the current 'top' # patch is B. qpush C should be performed (moving forward) diff --git a/tests/test-mq-qpush-fail b/tests/test-mq-qpush-fail --- a/tests/test-mq-qpush-fail +++ b/tests/test-mq-qpush-fail @@ -16,6 +16,10 @@ echo 'syntax: glob' > .hgignore echo '.hgignore' >> .hgignore hg qinit + +echo '% test qpush on empty series' +hg qpush + hg qnew patch1 echo >> foo hg qrefresh -m 'patch 1' diff --git a/tests/test-mq-qpush-fail.out b/tests/test-mq-qpush-fail.out --- a/tests/test-mq-qpush-fail.out +++ b/tests/test-mq-qpush-fail.out @@ -1,4 +1,6 @@ adding foo +% test qpush on empty series +no patches in series patch queue now empty applying patch1 applying patch2