Commit Graph

45 Commits

Author SHA1 Message Date
FUJIWARA Katsunori
c9c2aa4085 test: add test for the issue introduced by 63af8381691a (issue3669)
63af8381691a (released as Mercurial 2.3) introduced the issue that the
revset program started with 40 hexadecimal letters caused unexpected
result at "hg log" execution.

This issue was already fixed by b579dcd15206 (released as 2.3.1), but
there is no test to examine whether this issue is certainly fixed or
not: no test fails even if b579dcd15206 is backed out.

This patch adds test for this issue.

Added test is also confirmed to fail, when it is tested against:

  - Mercurial 2.3, or
  - Mercurial 2.3.1 or later with backing b579dcd15206 out
2012-10-23 17:06:31 +09:00
Ivan Andrus
3a1f5d9617 revsets: add branchpoint() function
The branchpoint() function returns changesets with more than one child.
Eventually I would like to be able to see only branch points and merge
points in a graphical log to see the topology of the repository.
2012-08-13 21:50:45 +02:00
Bryan O'Sullivan
513bd920fa revset: ensure we are reversing a list (issue3530) 2012-07-04 09:38:07 -07:00
Adrian Buehlmann
18c4705033 test-revset: enable for Windows
In MSYS, the test fails like this if the hghave exit at the beginning is
removed:

  --- C:\Users\adi\hgrepos\hg-main\tests\test-revset.t
  +++ C:\Users\adi\hgrepos\hg-main\tests\test-revset.t.err
  @@ -58,7 +58,7 @@
     $ hg co 3
     2 files updated, 0 files merged, 0 files removed, 0 files unresolved
     $ hg branch /a/b/c/
  -  marked working directory as branch /a/b/c/
  +  marked working directory as branch a:/b/c/
     (branches are permanent and global, did you want a bookmark?)
     $ hg ci -Aqm"5 bug"

  @@ -252,7 +252,7 @@
     2 a-b-c-
     3 +a+b+c+
     4 -a-b-c-
  -  5 /a/b/c/
  +  5 a:/b/c/
     6 _a_b_c_
     7 .a.b.c.
     $ log 'children(ancestor(4,5))'

due to the posix path conversion done by MSYS globally, as explained here

  http://www.mingw.org/wiki/Posix_path_conversion

The solution is a bit lame, but it is simple and works: don't use strings that
look like '/a/b', in order not to trigger the path magic done by MSYS.

So, if we can agree not to insist on testing branch names starting with '/',
then this relatively simple patch makes the test pass both on Windows with MSYS
and Linux.
2012-06-03 09:06:15 +02:00
Simon King
099a5c925c revset: add pattern matching to 'extra' revset expression 2012-05-30 23:14:04 +01:00
Simon King
93954249b9 revset: add pattern matching to the 'user' revset expression 2012-05-30 23:13:58 +01:00
Simon King
85110850a9 revset: add pattern matching to 'branch' revset expression 2012-05-30 23:13:33 +01:00
Simon King
9ecf845d55 revset: add pattern matching to 'tag' revset expression
If the string provided to the 'tag' predicate starts with 're:', the rest
of the string will be treated as a regular expression and matched against
all tags in the repository.

There is a slight backwards-compatibility problem for people who actually
have tags that start with 're:'. As a workaround, these tags can be matched
using a 'literal:' prefix.

If no tags match the pattern, an error is raised. This matches the behaviour
of the previous exact-match code.
2012-05-30 23:13:33 +01:00
Matt Mackall
8c3c80ff37 merge with stable 2012-05-22 14:37:20 -05:00
Patrick Mezard
139c15da66 revset: fix infinite alias expansion detection
The alias expansion code it changed from:
1- Get replacement tree
2- Substitute arguments in the replacement tree
3- Expand the replacement tree again

into:

1- Get the replacement tree
2- Expand the replacement tree
3- Expand the arguments
4- Substitute the expanded arguments in the replacement tree

and fixes cases like:

  [revsetalias]
  level1($1, $2) = $1 or $2
  level2($1, $2) = level1($2, $1)

  $ hg log -r "level2(level1(1, 2), 3)"

where the original version incorrectly aborted on infinite expansion
error, because it was confusing the expanded aliases with their
arguments.
2012-05-19 17:19:55 +02:00
Patrick Mezard
c7a80dee31 revset: explicitely tag alias arguments for expansion
The current revset alias expansion code works like:
1- Get the replacement tree
2- Substitute the variables in the replacement tree
3- Expand the replacement tree

It makes it easy to substitute alias arguments because the placeholders
are always replaced before the updated replacement tree is expanded
again. Unfortunately, to fix other alias expansion issues, we need to
reorder the sequence and delay the argument substitution. To solve this,
a new "virtual" construct called _aliasarg() is introduced and injected
when parsing the aliases definitions. Only _aliasarg() will be
substituted in the argument expansion phase instead of all regular
matching string. We also check user inputs do not contain unexpected
_aliasarg() instances to avoid argument injections.
2012-05-19 17:18:29 +02:00
Henrik Stuart
97ebbbffd1 revset: add function for matching extra data (issue2767) 2012-05-12 10:20:57 +02:00
Patrick Mezard
1ecfe35e64 revset: make matching() preserve input revision order 2012-05-09 18:45:14 +02:00
Patrick Mezard
bed77ab945 revset: fix adds/modifies/removes and patterns (issue3403)
The fast path was triggered if the argument was not like "type:value", with
type a known pattern type. This is wrong for several reasons:
- path:value is valid for the fast path
- '*' is interpreted as a glob by default and is not valid for fast path

Fast path detection is now done after the pattern is parsed, and the normalized
path is extracted for direct comparison. All this seems a bit complicated, it
is tempting to drop the fast path completely. Also, the hasfile() revset does
something similar (only check .files()), without a fast path. If the fast path
is really that efficient maybe it should be used there too.

Note that:

  $ log 'modifies("set:modified()")'

is different from:

  $ log 'modifies("*")'

because of the usual merge ctx.files()/status(ctx.p1(), ctx) differences.

Reported by Steffen Eichenberg <steffen.eichenberg@msg-gillardon.de>
2012-04-26 14:24:46 +02:00
Angel Ezquerra
103460f1f9 tests: add tests for matching keyword
This adds a couple of tests for the revset "matching" keyword:

1. Test that the 2nd parameter is optional
2. Test that all the 1st argument can be a revset and that all the supported
fields of the 2nd argument work.
2012-04-15 00:27:31 +02:00
Matt Mackall
af300e88ec merge with stable 2012-04-12 20:52:39 -05:00
Patrick Mezard
00224d1ac6 graphlog: correctly handle calls in subdirectories 2012-04-11 11:32:00 +02:00
Patrick Mezard
4bfe090298 revset: do not ignore input revisions in roots()
0233b606220f is also partially reverted to use the 'narrow' parameter again and
make less changesets parents lookups.
2012-04-08 11:11:30 +02:00
Patrick Mezard
e329a7b4ce debugrevspec: pretty print output
Before:

  ('func', ('symbol', 'reverse'), ('func', ('symbol', 'sort'), ('list', ('or',
  ('symbol', '2'), ('symbol', '3')), ('symbol', 'date'))))

After:

  (func
    ('symbol', 'reverse')
    (func
      ('symbol', 'sort')
      (list
        (or
          ('symbol', '2')
          ('symbol', '3'))
        ('symbol', 'date'))))

v2:
- Rebased on stable to avoid having to merge tests output
2012-02-24 11:02:21 +01:00
FUJIWARA Katsunori
96875b39e1 revset: add tests for 'remote()' predicate 2012-01-27 22:29:58 +09:00
Patrick Mezard
231c7be7bb revset: fix alias substitution recursion (issue3240)
The revset aliases expansion worked like:

  expr = "some revset"
  for alias in aliases:
      expr = alias.process(expr)

where "process" was replacing the alias with its *unexpanded* substitution,
recursively. So it only worked when aliases were applied in proper dependency
order.

This patch rewrites the expansion process so all aliases are expanded
recursively at every tree level, after parent alias rewriting and variable
expansion.
2012-02-09 21:03:07 +01:00
FUJIWARA Katsunori
09db6940ae i18n: use "encoding.lower()" to normalize specified string for revset
some problematic encoding (e.g.: cp932) uses ASCII alphabet characters
in byte sequence of multi byte characters.

"str.lower()" on such byte sequence may treat distinct characters as
same one, and cause unexpected log matching.

this patch uses "encoding.lower()" instead of "str.lower()" to
normalize strings for compare.
2011-12-25 20:35:16 +09:00
Matt Mackall
a968007692 merge with stable 2011-12-08 16:01:44 -06:00
Matt Mackall
a69962e18c branch: warn on branching 2011-12-08 14:32:44 -06:00
Mads Kiilerich
c9c5f0a2ca tests: introduce 'hghave msys' to skip tests that would fail because of msys 2011-11-21 01:49:20 +01:00
Mads Kiilerich
ed0023acf6 revset: fix aliases with 0 or more than 2 parameters
The existing code seemed to have incorrect assumptions about how parameter
lists are represented by the parser.

Now the match and replace functions have been merged and simplified by using
getlist().
2011-06-22 01:55:00 +02:00
Thomas Arendsen Hein
282b06cd6f revset: add desc(string) to search in commit messages
Like keyword(), but does not search in filenames and users.
No grepdesc() or descgrep() added, because it might be bad to introduce
grepfoo() versions of too many string searches.
2011-06-16 22:47:34 +02:00
Mads Kiilerich
6cadc46456 revset: avoid over-aggresive optimizations of non-filtering functions (issue2549)
When limit, last, min and max were evaluated they worked on a reduced set in the
wrong way. Now they work on an unrestricted set (the whole repo) and get
limited later on.
2011-05-01 17:35:05 +02:00
Alexander Solovyov
2f6ab6bf04 revset aliases 2011-04-30 18:30:14 +02:00
Kevin Gessner
9374e33026 revset: add tests for multiple and mixed ^ and ~ operators 2011-04-30 18:53:56 +02:00
Kevin Gessner
c6374d2d98 revset: add ^ and ~ operators from parentrevspec extension
^ (Nth parent) and ~ (Nth first ancestor) are infix operators that match
certain ancestors of the set:

  set^0
  the set

  set^1 (also available as set^)
  the first parent of every changeset in set

  set^2
  the second parent of every changeset in set

  set~0
  the set

  set~1
  the first ancestor (i.e. the first parent) of every changeset in set

  set~2
  the second ancestor (i.e. first parent of first parent) of every changeset
  in set

  set~N
  the Nth ancestor (following first parents only) of every changeset in set;
  set~N is equivalent to set^1^1..., with ^1 repeated N times.
2011-04-30 17:43:04 +02:00
Augie Fackler
52f8941398 revsets: preserve ordering with the or operator
This is valuable because now revsets like 'bookmarks() or tip' will
always show tip after bookmarks unless tip was itself a bookmark. This
is a somewhat contrived example, but this behavior is useful for
"where am I" type aliases that use log and revsets.
2011-04-13 12:30:41 -05:00
Idan Kamara
3828767e58 tests: add tests for non-existant branch/tag/bookmark 2011-04-10 11:30:53 +03:00
Bernhard Leiner
baf797018e revset: report a parse error if a revset is not parsed completely (issue2654) 2011-03-16 23:09:14 +01:00
Mads Kiilerich
635406bf76 tests: use (esc) for all non-ASCII test output 2010-11-08 01:41:41 +01:00
Wagner Bruna
d4398837df revset: disable subset optimization for parents() and children() (issue2437)
For the boolean operators, the subset optimization works by calculating
the cheaper argument first, and passing the subset to the second
argument to restrict the revision domain. This works well for filtering
predicates.

But parents() don't work like a filter: it may return revisions outside the
specified set. So, combining it with boolean operators may easily yield
incorrect results. For instance, for the following revision graph:

0 -- 1

the expression '0 and parents(1)' should evaluate as follows:

0 and parents(1) ->
0 and 0 ->
0

But since [0] is passed to parents() as a subset, we get instead:

0 and parents(1 and 0) ->
0 and parents([]) ->
0 and [] ->
[]

This also affects children(), p1() and p2(), for the same reasons.
Predicates that call these (like heads()) are also affected.

We work around this issue by ignoring the subset when propagating
the call inside those predicates.
2010-10-15 03:30:38 -03:00
Benoit Boissinot
d7dc2daaa0 revset: use 'requires' instead of 'wants' in error message 2010-10-16 18:50:53 +02:00
Augie Fackler
5fe5470142 revset: add id() and rev() to allow explicitly referring to changes by hash or rev 2010-10-11 09:44:19 -05:00
Augie Fackler
4a386faa07 revset: rename tagged() to tag() and allow it to take an optional tag name 2010-10-10 12:41:36 -05:00
Matt Mackall
67a62aa820 revset: lower precedence of minus infix (issue2361) 2010-10-07 11:45:17 -05:00
Brodie Rao
2104af5ee2 revset: support raw string literals
This adds support for r'...' and r"..." as string literals. Strings
with the "r" prefix will not have their escape characters interpreted.

This is especially useful for grep(), where, with regular string
literals, \number is interpreted as an octal escape code, and \b is
interpreted as the backspace character (\x08).
2010-09-24 15:36:53 -05:00
Martin Geisler
989dda555a merge with stable 2010-09-20 15:42:58 +02:00
Matt Mackall
08439e0f2d tests: add exit codes to unified tests 2010-09-16 17:51:32 -05:00
Nicolas Dumazet
90787c08f9 util: get rid of extra trailing whitespace in parsedate abort message 2010-08-30 13:29:44 +09:00
Nicolas Dumazet
77b77244a8 tests: unify test-revset 2010-08-30 13:23:32 +09:00