[issue2549] revset "and" operator sometimes leads to surprising results with limit()

Brodie Rao bugs at mercurial.selenic.com
Mon Dec 13 18:14:38 CST 2010


New submission from Brodie Rao <brodie at bitheap.org>:

Consider the following repository:

  $ hg init foo
  $ cd foo
  $ echo a > a
  $ hg ci -Am a
  adding a
  $ echo b > b
  $ hg ci -Am b
  adding b
  $ hg up 0
  $ echo c > c
  $ hg ci -Am c
  adding c
  created new head
  $ hg merge
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
  $ hg ci -m merge

History now looks like this:

  $ hg log --template '{rev} - {desc|firstline}\n'
  3 - merge
  2 - c
  1 - b
  0 - a

If I want to see, of the last 3 changes, those that are not merges, I might use a 
revset and get this result:

  $ hg debugrevspec 'limit(sort(all(), -rev), 3) and not merge()'
  2
  1

However, what actually happens is that it evaluates "not merge()" first, then gets 
the intersection of that set with "limit(sort(all(), -rev), 3)":

  $ hg debugrevspec 'limit(sort(all(), -rev), 3) and not merge()'
  2
  1
  0

I'm guessing this is a side effect of the revset optimizer.

----------
messages: 14644
nosy: brodie, mg, mpm
priority: bug
status: unread
title: revset "and" operator sometimes leads to surprising results with limit()
topic: 1.7, revset, surprise

____________________________________________________
Mercurial issue tracker <bugs at mercurial.selenic.com>
<http://mercurial.selenic.com/bts/issue2549>
____________________________________________________


More information about the Mercurial-devel mailing list