changeset 26537:832feae7c986

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.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 07 Oct 2015 23:00:29 +0900
parents 93a3687a94d7
children 5c9ec1cc671a
files mercurial/revset.py tests/test-revset.t
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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"))'