Bug 3850 - tag() revset is inconsistent with branch() when name is given as regex
Summary: tag() revset is inconsistent with branch() when name is given as regex
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: earlier
Hardware: All All
: normal bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-05 15:43 UTC by Michal Sznajder
Modified: 2017-11-01 18:05 UTC (History)
7 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Sznajder 2013-03-05 15:43 UTC
If there is no branch matching regex then nothing is returned:

    $ hg log --rev "branch('re:unknown')" ; echo $?
    0

However for unknown tag error is reported:

    $ hg log --rev "tag('re:unknown')" ; echo $?
    abort: no tags exist that match 'unknown'
    255

I would expect that in case no tags are matching revset no revision is reported and no error code is returned.
Comment 1 Kevin Bullock 2013-03-05 15:57 UTC
I would expect the same thing.
Comment 2 Pierre-Yves David 2013-03-06 04:04 UTC
Your objection make senses.
Comment 3 Matt Mackall 2013-03-18 16:50 UTC
Adding Simon, who touched this last.
Comment 4 Simon King 2013-03-18 17:54 UTC
Here is the current behaviour for various cases:

"Classic" lookups:

  $: hg log -r 'tag("nonexistent")'; echo $?
  abort: tag 'nonexistent' does not exist
  255

  $: hg log -r 'branch("nonexistent")'; echo $?
  abort: unknown revision 'nonexistent'!
  255

Explicit "literal" lookups:

  $: hg log -r 'tag("literal:nonexistent")'; echo $?
  abort: tag 'nonexistent' does not exist
  255

  $: hg log -r 'branch("literal:nonexistent")'; echo $?
  abort: unknown revision 'literal:nonexistent'!
  255

Regex lookups:

  $: hg log -r 'tag("re:nonexistent")'; echo $?
  abort: no tags exist that match 'nonexistent'
  255

  $: hg log -r 'branch("re:nonexistent")'; echo $?
  0

You are asking that the tag/regex case be changed to be like the branch/regex case. I don't feel strongly either way but it could be argued that making the branch/regex case fail like the others would be more consistent.

For completeness, here is the behaviour of other regex-accepting rev sets:

  $: hg log -r 'bookmark("nonexistent")'; echo $?
  abort: bookmark 'nonexistent' does not exist
  255

  $: hg log -r 'bookmark("re:nonexistent")'; echo $?
  abort: no bookmarks exist that match 'nonexistent'
  255

  $: hg log -r 'bookmark("literal:nonexistent")'; echo $?
  abort: bookmark 'literal:nonexistent' does not exist
  255


  $: hg log -r 'extra("source", "nonexistent")'; echo $?
  0

  $: hg log -r 'extra("source", "re:nonexistent")'; echo $?
  0


  $: hg log -r 'user("nonexistent")'; echo $?
  0

  $: hg log -r 'user("re:nonexistent")'; echo $?
  0


  $: hg log -r 'grep("really-nonexistent")'; echo $?
  0

As a side note, the error message in the branch/literal and bookmark/literal cases probably shouldn't include the "literal:" prefix.

I'm happy to have a go at fixing this, as long as someone confirms that this is the behaviour you want: when the tag, branch and bookmark revset expressions are given a pattern that doesn't match anything, they should return the empty set without raising an error.
Comment 5 Kevin Bullock 2013-03-20 11:19 UTC
Fix is in crew: http://hg.intevation.org/mercurial/crew/rev/9e39a717a23e
Comment 6 Matt Harbison 2014-12-22 12:59 UTC
Fixed by 9e39a717a23e, released in 2.6