diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5152,6 +5152,9 @@ def push(ui, repo, dest=None, **opts): if revs: revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)] + if not revs: + raise util.Abort(_("specified revisions evaluate to an empty set"), + hint=_("use different revision arguments")) repo._subtoppath = dest try: diff --git a/tests/test-push-warn.t b/tests/test-push-warn.t --- a/tests/test-push-warn.t +++ b/tests/test-push-warn.t @@ -19,6 +19,14 @@ $ hg add t3 $ hg commit -m "3" +Specifying a revset that evaluates to null will abort + + $ hg push -r '0 & 1' ../a + pushing to ../a + abort: specified revisions evaluate to an empty set + (use different revision arguments) + [255] + $ hg push ../a pushing to ../a searching for changes