Currently, branch('re:nonexistentbranch') returns an empty revset, while branch('nonexistentbranch') falls back to parsing nonexistentbranch as another revset expression, and fails with "unknown revision 'nonexistentbranch'" - which makes some sense. However, branch('literal:nonexistentbranch') also gets parsed as branch(revset) instead of branch(string), due to _stringmatcher not distinguishing between explicit and implicit literals, and fails with an "unknown revision" error as well. This is clearly not what the user would expect - "literal" IMO implies "don't try to parse as revset". Also, this makes scripting mercurial a lot more difficult, requiring additional exception handling. Plus, one might expect a revset like "branch('literal:a') + branch('literal:b')" to work even if one of the two branches is missing/empty - but it doesn't. branch(nonexistentbranch) should throw "unknown revision", while branch('literal:nonexistentbranch') should clearly return an empty revset; I'm not sure about branch('nonexistentbranch'). Maybe tag('nonexistenttag') or tag('literal:nonexistenttag') should get the same treatment.
Yuya, you might be interested in this one, due to the string treated as identifier issue. $ hg log -r "branch('literal:nosuch')" abort: unknown revision 'literal:nosuch'! $ hg log -r "tag('literal:nosuch')" abort: tag 'nosuch' does not exist! $ hg log -r "bookmark('literal:nosuch')" abort: bookmark 'literal:nosuch' does not exist! I think all three should abort like tag().
I don't think aborting is a good idea here; all 3 should report empty revsets. It would make it a lot easier to script Hg using python-hglib. Also, "tag('tag_that_exists') + tag('tag_that_doesnt_exist')" should definitely not abort, but return the commit pointed to by tag_that_exists.
I agree with Matt. "literal:" isn't the keyword to suppress errors. You can use present() to ignore invalid revision. Here's a summary how errors are handled: https://selenic.com/repo/hg/rev/eeb5d5ab14a6
Fixed by: changeset: 31145:832feae7c986 parent: 31143:93a3687a94d7 user: Yuya Nishihara <yuya@tcha.org> date: Wed Oct 07 23:00:29 2015 +0900 summary: revset: do not fall through to revspec for literal: branch (issue4838)
Bug was set to TESTING for 7 days, resolving