revset: do not fall through to revspec for literal: branch (
issue4838)
If "literal:" is specified, it must not be a revset expression. It should
error out with a better message.
--- a/mercurial/revset.py Wed Oct 07 21:08:14 2015 +0100
+++ b/mercurial/revset.py Wed Oct 07 23:00:29 2015 +0900
@@ -734,9 +734,12 @@
kind, pattern, matcher = util.stringmatcher(b)
if kind == 'literal':
# note: falls through to the revspec case if no branch with
- # this name exists
+ # this name exists and pattern kind is not specified explicitly
if pattern in repo.branchmap():
return subset.filter(lambda r: matcher(getbi(r)[0]))
+ if b.startswith('literal:'):
+ raise error.RepoLookupError(_("branch '%s' does not exist")
+ % pattern)
else:
return subset.filter(lambda r: matcher(getbi(r)[0]))
--- a/tests/test-revset.t Wed Oct 07 21:08:14 2015 +0100
+++ b/tests/test-revset.t Wed Oct 07 23:00:29 2015 +0900
@@ -1328,6 +1328,9 @@
$ log 'branch(unknown)'
abort: unknown revision 'unknown'!
[255]
+ $ log 'branch("literal:unknown")'
+ abort: branch 'unknown' does not exist!
+ [255]
$ log 'branch("re:unknown")'
$ log 'present(branch("unknown"))'
$ log 'present(branch("re:unknown"))'