diff --git a/hgext/remotenames.py b/hgext/remotenames.py --- a/hgext/remotenames.py +++ b/hgext/remotenames.py @@ -33,6 +33,7 @@ from mercurial.node import ( ) from mercurial import ( bookmarks, + error, extensions, logexchange, namespaces, @@ -355,6 +356,7 @@ def _revsetutil(repo, subset, x, rtypes) kind, pattern, matcher = stringutil.stringmatcher( revsetlang.getstring(args[0], _('argument must be a string'))) else: + kind = pattern = None matcher = util.always nodes = set() @@ -366,6 +368,9 @@ def _revsetutil(repo, subset, x, rtypes) if not matcher(name): continue nodes.update(ns.nodes(repo, name)) + if kind == 'literal' and not nodes: + raise error.RepoLookupError(_("remote name '%s' does not exist") + % pattern) revs = (cl.rev(n) for n in nodes if cl.hasnode(n)) return subset & smartset.baseset(revs) diff --git a/tests/test-logexchange.t b/tests/test-logexchange.t --- a/tests/test-logexchange.t +++ b/tests/test-logexchange.t @@ -478,13 +478,23 @@ Testing for a single remote name which e | ~ -Testing for a single name which does not exists +Testing for a literal name which does not exists, which should fail. $ hg log -r 'remotebranches(def)' -GT "{rev}:{node|short} {remotenames}\n" + abort: remote name 'def' does not exist! + [255] $ hg log -r 'remotebookmarks("server3")' -GT "{rev}:{node|short} {remotenames}\n" + abort: remote name 'server3' does not exist! + [255] $ hg log -r 'remotenames("server3")' -GT "{rev}:{node|short} {remotenames}\n" + abort: remote name 'server3' does not exist! + [255] + +Testing for a pattern which does not match anything, which shouldn't fail. + + $ hg log -r 'remotenames("re:^server3$")' Testing for multiple names, which is not supported.