Commit Graph

68 Commits

Author SHA1 Message Date
timeless
998fd9af34 fileset: add hint for list error to use or 2015-12-23 17:54:13 +00:00
FUJIWARA Katsunori
2cb14bf8f0 fileset: detect unintentional existing() invocation at runtime
A fileset predicate can invoke 'matchctx.existing()' successfully,
even if it isn't marked as "existing caller". It is aborted only in
some corner cases: e.g. there were one deleted file in the working
directory (see 2c5c0790cbcc for detail).

This patch makes 'matchctx.existing()' invocation abort if not
'_existingenabled', which is true only while "existing caller"
running.

After this changes, non-"existing caller" predicate function is
aborted immediately, whenever it invokes 'matchctx.existing()'. This
prevent developer from forgetting to mark a predicate as "existing
caller".

BTW, unintentional 'matchctx.status()' invocation can be detected
easily without any additional trick like this patch, because it
returns 'None' if a predicate isn't marked as "status caller", and
referring field (e.g. '.modified') of it is always aborted.
2015-12-21 22:31:16 +09:00
FUJIWARA Katsunori
cde1d3d500 fileset: use set instead of list to mark predicates for efficiency (API)
This reduces cost of examining whether given predicate calls
'matchctx.status()' or 'matchctx.existing()' in 'getfileset()' at
runtime.

This kind of examination is used also in subsequent patch, which
detects unintentional 'matchctx.existing()' invocation per each
predicate evaluation.
2015-12-21 22:31:16 +09:00
FUJIWARA Katsunori
90eaf4bbec fileset: use decorator to mark a predicate as "existing caller"
This can localize changes for adding (or removing) an "existing
caller" predicate function in source code.
2015-12-21 22:31:16 +09:00
FUJIWARA Katsunori
c965a4dbaa fileset: use decorator to mark a predicate as "status caller"
Before this patch, predicates calling 'matchctx.status()' are listed
up by immediate list value in 'getfileset()'.

This prevents 3rd party extensions from adding specific predicate
calling 'matchctx.status()'.

This uses decorator to mark a predicate as "status caller".

This can also localize changes for adding (or removing) a "status
caller" predicate function in source code.
2015-12-21 22:31:16 +09:00
FUJIWARA Katsunori
a8588195a6 fileset: use decorator to mark a function as fileset predicate
Using decorator can localize changes for adding (or removing) a
fileset predicate function in source code.

It is also useful to pick predicates up for specific purpose. For
example, subsequent patches marks predicates as "call status" or "use
existing" via decorator.

To avoid (1) redundancy between "predicate name" and (the beginning
of) help document, and (2) accidental typo of help document, this
patch also makes decorator put predicate declration into the beginning
of help.
2015-12-21 22:31:16 +09:00
FUJIWARA Katsunori
655c371178 fileset: treat encoding and eol as the predicate calling _existing
Before this patch, predicate function 'encoding' and 'eol' aren't
listed up in '_existingcallers', even though they invoke 'existing()'.

This causes unexpected failure of these predicate, if there is a
(manually) deleted file in the working directory.

2c5c0790cbcc and 12b403664548 seem to overlook putting already
existing 'encoding' or newly introduced 'eol' into '_existingcallers'.

This patch also changes order of fileset "eol(unix)" output in test,
because "existing caller" predicates show "A(dded)" files before
"C(lean)" ones.
2015-12-21 22:31:16 +09:00
liscju
616740cead fileset: add missing() predicate (issue4925)
Help of status cmd defines status file of 'missing', what is
called in fileset 'deleted'. To stay consistent this patch
introduces missing() predicate which in fact is alias to
'deleted'.
2015-11-18 20:55:32 +01:00
Siddharth Agarwal
178aa21f0d fileset: switch to mergestate.read()
See previous patches for why we're doing this.
2015-11-17 13:57:38 -08:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Yuya Nishihara
375ffa2a98 fileset: handle error of string unescaping 2015-09-10 23:32:36 +09:00
timeless@mozdev.org
9489eda0f2 help: filesets show hg resolve command 2015-09-08 11:35:22 -04:00
timeless@mozdev.org
7134fe8574 help: filesets show hg status command 2015-09-08 11:30:01 -04:00
Matt Mackall
6c04738a65 merge with stable 2015-08-10 15:30:28 -05:00
Gregory Szorc
bf31c39d5d fileset: use absolute_import 2015-08-08 18:34:37 -07:00
Anton Shestakov
6a4a921104 filesets: ignore unit case in size() predicate for single value
When specifying one plain value in size(), e.g. size(1k), fileset tries to
guess the upper bound automatically (see the comment in _sizetomax()). It
didn't ignore the specified unit's case, and so size("1 GB"), for example,
produced this error:

hg: parse error: couldn't parse size: 1 GB

Let's do the same thing that util.sizetoint() does: .lower().

The two test lines without output just check that there are no parse errors.
2015-08-08 14:42:27 +08:00
Yuya Nishihara
b4caf94446 parser: separate actions for primary expression and prefix operator
This will allow us to define both a primary expression, ":", and a prefix
operator, ":y". The ambiguity will be resolved by the next patch.

Prefix actions in elements table are adjusted as follows:

  original prefix      primary  prefix
  -----------------    -------- -----------------
  ("group", 1, ")") -> n/a      ("group", 1, ")")
  ("negate", 19)    -> n/a      ("negate", 19)
  ("symbol",)       -> "symbol" n/a
2015-07-05 12:02:13 +09:00
Yuya Nishihara
4645c24be5 parser: fill invalid infix and suffix actions by None
This can simplify the expansion of (prefix, infix, suffix) actions.
2015-07-05 11:17:22 +09:00
Yuya Nishihara
b677e35b5b parser: add comment about structure of elements to each table 2015-07-05 11:06:58 +09:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Yuya Nishihara
fe462ed8ac parser: accept iterator of tokens instead of tokenizer function and program
This can simplify the interface of parse() function. Our tokenizer tends to
have optional arguments other than the message to be parsed.

Before this patch, the "lookup" argument existed only for the revset, and the
templater had to pack [program, start, end] to be passed to its tokenizer.
2015-06-21 00:49:26 +09:00
Matt Harbison
1306998af7 fileset: don't suggest private or undocumented queries
Unlike revsets, it looks like all of the filesets are documented, so there's
really nothing to test.  This is aimed more at parity with revsets and
future-proofing.
2015-06-20 11:07:36 -04:00
Yuya Nishihara
dfdaf0679a fileset: pretty print syntax tree in debug output 2015-04-26 22:26:44 +09:00
Yuya Nishihara
c52c748a86 fileset: move validation of incomplete parsing to parse() function
fileset.parse() should be responsible for all parsing errors as well.
2015-04-26 19:50:42 +09:00
Siddharth Agarwal
63850f5fd4 fileset: add a fileset for portable filenames
This has mostly the same semantics as the files that the 'ui.portablefilenames'
config option would warn or abort about. The only difference is filenames that
case-fold to the same string -- given a set of filenames we've already
checked we can check whether a new one collides with them, but we don't have a
way to tell which filename it collided with.
2015-03-19 21:26:18 -07:00
Matt Harbison
72de876f6c fileset: replace 'ctx._repo' with 'ctx.repo()' 2015-03-12 23:02:19 -04:00
Augie Fackler
18d6bf235a fileset: use UnknownIdentifier where appropriate 2015-01-26 14:31:48 -05:00
FUJIWARA Katsunori
13d9d50897 i18n: add i18n comment to error messages of filesets predicates 2014-11-01 02:43:08 +09:00
Martin von Zweigbergk
05e97c1d55 fileset: access status fields by name rather than index 2014-10-04 21:58:01 -07:00
Augie Fackler
acff2f02d0 merge with stable 2014-01-01 18:28:40 -05:00
Yuya Nishihara
cb7a1dd14c fileset, revset: do not use global parser object for thread safety
parse() cannot be called at the same time because a parser object keeps its
states.  This is no problem for command-line hg client, but it would cause
strange errors in multi-threaded hgweb.

Creating parser object is not too expensive.

original:
% python -m timeit -s 'from mercurial import revset' 'revset.parse("0::tip")'
100000 loops, best of 3: 11.3 usec per loop

thread-safe:
% python -m timeit -s 'from mercurial import revset' 'revset.parse("0::tip")'
100000 loops, best of 3: 13.1 usec per loop
2013-12-21 12:44:19 +09:00
Augie Fackler
9f876f6c89 cleanup: move stdlib imports to their own import statement
There are a few warnings still produced by my import checker, but
those are false positives produced by modules that share a name with
stdlib modules.
2013-11-06 16:48:06 -05:00
Matt Mackall
704604439e fileset: handle underbar in symbols
This was documented, but not implemented.
2013-07-23 14:18:56 -05:00
Bryan O'Sullivan
502e5bc1d1 util: migrate fileset._sizetoint to util.sizetoint
The size counting code introduced in 233431858f4c duplicated existing
(but unknown-to-me) code in fileset, so prepare to eliminate the
duplication.
2013-05-14 15:16:43 -07:00
Matt Mackall
2ad3a48eb3 filesets: add eol predicate 2013-03-29 16:48:32 -07:00
Mads Kiilerich
2d6545f8b6 subrepos: process subrepos in sorted order
Add sorted() in places found by testing with PYTHONHASHSEED=random and code
inspection.

An alternative to sprinkling sorted() all over would be to change substate to a
custom dict with sorted iterators...
2012-12-12 02:38:14 +01:00
Patrick Mezard
57f8b328dc fileset: fix generator vs list bug in fast path
$ hg debugfileset 'a or b'

would only return a or b but not both because the base file list was a
generator instead of a replayable sequence.
2012-08-15 22:50:23 +02:00
Patrick Mezard
afc53271b1 fileset: do not traceback on invalid grep pattern 2012-08-15 19:25:45 +02:00
Patrick Mezard
5874c142ff fileset: matchctx.existing() must consider ignored files
When running:

  $ hg debugfileset 'binary() and ignored()'

getfileset() was correctly retrieving ignored files but
matchctx.existing() was not taking them in account. Just add them along
with unknown files.
2012-08-15 22:29:32 +02:00
Patrick Mezard
faab1846cc fileset: matchctx.existing() must consider unknown files
By default, unknown files are ignored. If the 'unknown()' predicate
appears in the syntax tree, then they are taken in account.
Unfortunately, matchctx.existing() was filtering against non-deleted
context files, which does not include unknown files. So:

  $ hg debugfileset 'binary() and unknown()'

would not return existing binary unknown files.
2012-08-15 22:29:09 +02:00
Patrick Mezard
663673858e fileset: exclude deleted files from matchctx.existing()
Running:

  $ hg debugfileset 'binary()'

would traceback if there were one deleted file in the working directory.
It happened because matchctx.existing() was filtering files against the
ctx.__contains__() but deleted files are still considered part of
workingctx.
2012-08-15 21:44:00 +02:00
Patrick Mezard
95df23a5ab fileset: actually implement 'minusset'
$ hg debugfileset 'a* - a1'

was tracing back because 'minus' symbol was not supported.
2012-08-15 19:02:04 +02:00
Angel Ezquerra
5aafeb5916 fileset: add "subrepo" fileset symbol
This new fileset symbol returns a list of subrepos whose paths match a given
pattern. If the argument has no pattern type set, an exact
match is performed.

If no argument is passed, return a list of all subrepos.
2012-03-22 21:12:15 +01:00
Matt Mackall
da19c55d26 fileset: don't attempt to check data predicates against removed files 2012-01-20 22:19:40 -06:00
Idan Kamara
9401c4603c fileset: fix typo in binary() doc 2011-07-04 14:36:16 +03:00
Wagner Bruna
6e3f89657d fileset: add i18n hints for keywords 2011-06-27 13:48:25 -03:00
Mads Kiilerich
1794513e71 fileset: copied takes no arguments 2011-06-24 01:10:35 +02:00
Mads Kiilerich
7cf147b1a4 revset and fileset: fix typos in parser error messages 2011-06-22 01:55:00 +02:00
Mads Kiilerich
9f3fc0b58e fileset: use ParseError pos field correctly
The pos field is intended to describe the position of the error - it should not
be used for other potentially interesting information.
2011-06-24 00:18:41 +02:00
Mads Kiilerich
473bcd3ed1 parsers: fix localization markup of parser errors 2011-06-21 00:17:52 +02:00