mercurial/help/filesets.txt
author Chris Jerdonek <chris.jerdonek@gmail.com>
Wed, 04 Dec 2013 20:38:27 -0800
changeset 20742 3681de20b0a7
parent 18960 170fc0949fb6
child 23109 cf56f7a60b45
permissions -rw-r--r--
parsers: fail fast if Python has wrong minor version (issue4110) This change causes an informative ImportError to be raised when importing the parsers extension module if the minor version of the currently-running Python interpreter doesn't match that of the Python used when compiling the extension module. This change also exposes a parsers.versionerrortext constant in the C implementation of the module. Its presence can be used to determine whether this behavior is present in a version of the module. The value of the constant is the leading text of the ImportError raised and is set to "Python minor version mismatch". Here is an example of what the new error looks like: Traceback (most recent call last): File "test.py", line 1, in <module> import mercurial.parsers ImportError: Python minor version mismatch: The Mercurial extension modules were compiled with Python 2.7.6, but Mercurial is currently using Python with sys.hexversion=33883888: Python 2.5.6 (r256:88840, Nov 18 2012, 05:37:10) [GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] at: /opt/local/Library/Frameworks/Python.framework/Versions/2.5/Resources/ Python.app/Contents/MacOS/Python The reason for raising an error in this scenario is that Python's C API is known not to be compatible from minor version to minor version, even if sys.api_version is the same. See for example this Python bug report about incompatibilities between 2.5 and 2.6+: http://bugs.python.org/issue8118 These incompatibilities can cause Mercurial to break in mysterious, unforeseen ways. For example, when Mercurial compiled with Python 2.7 was run with 2.5, the following crash occurred when running "hg status": http://bz.selenic.com/show_bug.cgi?id=4110 After this crash was fixed, running with Python 2.5 no longer crashes, but the following puzzling behavior still occurs: $ hg status ... File ".../mercurial/changelog.py", line 123, in __init__ revlog.revlog.__init__(self, opener, "00changelog.i") File ".../mercurial/revlog.py", line 251, in __init__ d = self._io.parseindex(i, self._inline) File ".../mercurial/revlog.py", line 158, in parseindex index, cache = parsers.parse_index2(data, inline) TypeError: data is not a string which can be reproduced more simply with: import mercurial.parsers as parsers parsers.parse_index2("", True) Both the crash and the TypeError occurred because the Python C API's PyString_Check() returns the wrong value when the C header files from Python 2.7 are run with Python 2.5. This is an example of an incompatibility of the sort mentioned in the Python bug report above. Failing fast with an informative error message results in a better user experience in cases like the above. The information in the ImportError also simplifies troubleshooting for those on Mercurial mailing lists, the bug tracker, etc. This patch only adds the version check to parsers.c, which is sufficient to affect command-line commands like "hg status" and "hg summary". An idea for a future improvement is to move the version-checking C code to a more central location, and have it run when importing all Mercurial extension modules and not just parsers.c.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14686
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     1
Mercurial supports a functional language for selecting a set of
18960
170fc0949fb6 check-code: check txt files for trailing whitespace
Mads Kiilerich <madski@unity3d.com>
parents: 15825
diff changeset
     2
files.
14686
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     3
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     4
Like other file patterns, this pattern type is indicated by a prefix,
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     5
'set:'. The language supports a number of predicates which are joined
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     6
by infix operators. Parenthesis can be used for grouping.
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     7
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     8
Identifiers such as filenames or patterns must be quoted with single
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     9
or double quotes if they contain characters outside of
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    10
``[.*{}[]?/\_a-zA-Z0-9\x80-\xff]`` or if they match one of the
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    11
predefined predicates. This generally applies to file patterns other
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    12
than globs and arguments for predicates.
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    13
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    14
Special characters can be used in quoted identifiers by escaping them,
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    15
e.g., ``\n`` is interpreted as a newline. To prevent them from being
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    16
interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``.
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    17
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    18
There is a single prefix operator:
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    19
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    20
``not x``
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    21
  Files not in x. Short form is ``! x``.
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    22
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    23
These are the supported infix operators:
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    24
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    25
``x and y``
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    26
  The intersection of files in x and y. Short form is ``x & y``.
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    27
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    28
``x or y``
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    29
  The union of files in x and y. There are two alternative short
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    30
  forms: ``x | y`` and ``x + y``.
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    31
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    32
``x - y``
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    33
  Files in x but not in y.
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    34
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    35
The following predicates are supported:
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    36
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    37
.. predicatesmarker
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    38
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    39
Some sample queries:
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    40
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    41
- Show status of files that appear to be binary in the working directory::
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    42
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    43
    hg status -A "set:binary()"
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    44
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    45
- Forget files that are in .hgignore but are already tracked::
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    46
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    47
    hg forget "set:hgignore() and not ignored()"
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    48
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    49
- Find text files that contain a string::
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    50
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    51
    hg locate "set:grep(magic) and not binary()"
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    52
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    53
- Find C files in a non-standard encoding::
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    54
15825
8b611944eb84 filesets: use example with quotes for encoding predicate
Martin Geisler <mg@aragost.com>
parents: 14829
diff changeset
    55
    hg locate "set:**.c and not encoding('UTF-8')"
14686
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    56
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    57
- Revert copies of large binary files::
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    58
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    59
    hg revert "set:copied() and binary() and size('>1M')"
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    60
14829
968c301a1005 help: fileset foo.lst was named files.lst
Arne Babenhauserheide <bab@draketo.de>
parents: 14686
diff changeset
    61
- Remove files listed in foo.lst that contain the letter a or b::
14686
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    62
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    63
    hg remove "set: 'listfile:foo.lst' and (**a* or **b*)"
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    64
6ab8b17adc03 fileset: add a help topic
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    65
See also :hg:`help patterns`.