Show More
@@ -1,90 +1,94 | |||||
1 | Synopsis |
|
1 | Synopsis | |
2 | ======== |
|
2 | ======== | |
3 |
|
3 | |||
4 | The Mercurial system uses a file called ``.hgignore`` in the root |
|
4 | The Mercurial system uses a file called ``.hgignore`` in the root | |
5 | directory of a repository to control its behavior when it searches |
|
5 | directory of a repository to control its behavior when it searches | |
6 | for files that it is not currently tracking. |
|
6 | for files that it is not currently tracking. | |
7 |
|
7 | |||
8 | Description |
|
8 | Description | |
9 | =========== |
|
9 | =========== | |
10 |
|
10 | |||
11 | The working directory of a Mercurial repository will often contain |
|
11 | The working directory of a Mercurial repository will often contain | |
12 | files that should not be tracked by Mercurial. These include backup |
|
12 | files that should not be tracked by Mercurial. These include backup | |
13 | files created by editors and build products created by compilers. |
|
13 | files created by editors and build products created by compilers. | |
14 | These files can be ignored by listing them in a ``.hgignore`` file in |
|
14 | These files can be ignored by listing them in a ``.hgignore`` file in | |
15 | the root of the working directory. The ``.hgignore`` file must be |
|
15 | the root of the working directory. The ``.hgignore`` file must be | |
16 | created manually. It is typically put under version control, so that |
|
16 | created manually. It is typically put under version control, so that | |
17 | the settings will propagate to other repositories with push and pull. |
|
17 | the settings will propagate to other repositories with push and pull. | |
18 |
|
18 | |||
19 | An untracked file is ignored if its path relative to the repository |
|
19 | An untracked file is ignored if its path relative to the repository | |
20 | root directory, or any prefix path of that path, is matched against |
|
20 | root directory, or any prefix path of that path, is matched against | |
21 | any pattern in ``.hgignore``. |
|
21 | any pattern in ``.hgignore``. | |
22 |
|
22 | |||
23 | For example, say we have an untracked file, ``file.c``, at |
|
23 | For example, say we have an untracked file, ``file.c``, at | |
24 | ``a/b/file.c`` inside our repository. Mercurial will ignore ``file.c`` |
|
24 | ``a/b/file.c`` inside our repository. Mercurial will ignore ``file.c`` | |
25 | if any pattern in ``.hgignore`` matches ``a/b/file.c``, ``a/b`` or ``a``. |
|
25 | if any pattern in ``.hgignore`` matches ``a/b/file.c``, ``a/b`` or ``a``. | |
26 |
|
26 | |||
27 | In addition, a Mercurial configuration file can reference a set of |
|
27 | In addition, a Mercurial configuration file can reference a set of | |
28 | per-user or global ignore files. See the ``ignore`` configuration |
|
28 | per-user or global ignore files. See the ``ignore`` configuration | |
29 | key on the ``[ui]`` section of :hg:`help config` for details of how to |
|
29 | key on the ``[ui]`` section of :hg:`help config` for details of how to | |
30 | configure these files. |
|
30 | configure these files. | |
31 |
|
31 | |||
32 | To control Mercurial's handling of files that it manages, many |
|
32 | To control Mercurial's handling of files that it manages, many | |
33 | commands support the ``-I`` and ``-X`` options; see |
|
33 | commands support the ``-I`` and ``-X`` options; see | |
34 | :hg:`help <command>` and :hg:`help patterns` for details. |
|
34 | :hg:`help <command>` and :hg:`help patterns` for details. | |
35 |
|
35 | |||
36 | Files that are already tracked are not affected by .hgignore, even |
|
36 | Files that are already tracked are not affected by .hgignore, even | |
37 | if they appear in .hgignore. An untracked file X can be explicitly |
|
37 | if they appear in .hgignore. An untracked file X can be explicitly | |
38 | added with :hg:`add X`, even if X would be excluded by a pattern |
|
38 | added with :hg:`add X`, even if X would be excluded by a pattern | |
39 | in .hgignore. |
|
39 | in .hgignore. | |
40 |
|
40 | |||
41 | Syntax |
|
41 | Syntax | |
42 | ====== |
|
42 | ====== | |
43 |
|
43 | |||
44 | An ignore file is a plain text file consisting of a list of patterns, |
|
44 | An ignore file is a plain text file consisting of a list of patterns, | |
45 | with one pattern per line. Empty lines are skipped. The ``#`` |
|
45 | with one pattern per line. Empty lines are skipped. The ``#`` | |
46 | character is treated as a comment character, and the ``\`` character |
|
46 | character is treated as a comment character, and the ``\`` character | |
47 | is treated as an escape character. |
|
47 | is treated as an escape character. | |
48 |
|
48 | |||
49 | Mercurial supports several pattern syntaxes. The default syntax used |
|
49 | Mercurial supports several pattern syntaxes. The default syntax used | |
50 | is Python/Perl-style regular expressions. |
|
50 | is Python/Perl-style regular expressions. | |
51 |
|
51 | |||
52 | To change the syntax used, use a line of the following form:: |
|
52 | To change the syntax used, use a line of the following form:: | |
53 |
|
53 | |||
54 | syntax: NAME |
|
54 | syntax: NAME | |
55 |
|
55 | |||
56 | where ``NAME`` is one of the following: |
|
56 | where ``NAME`` is one of the following: | |
57 |
|
57 | |||
58 | ``regexp`` |
|
58 | ``regexp`` | |
59 | Regular expression, Python/Perl syntax. |
|
59 | Regular expression, Python/Perl syntax. | |
60 | ``glob`` |
|
60 | ``glob`` | |
61 | Shell-style glob. |
|
61 | Shell-style glob. | |
62 |
|
62 | |||
63 | The chosen syntax stays in effect when parsing all patterns that |
|
63 | The chosen syntax stays in effect when parsing all patterns that | |
64 | follow, until another syntax is selected. |
|
64 | follow, until another syntax is selected. | |
65 |
|
65 | |||
66 | Neither glob nor regexp patterns are rooted. A glob-syntax pattern of |
|
66 | Neither glob nor regexp patterns are rooted. A glob-syntax pattern of | |
67 | the form ``*.c`` will match a file ending in ``.c`` in any directory, |
|
67 | the form ``*.c`` will match a file ending in ``.c`` in any directory, | |
68 | and a regexp pattern of the form ``\.c$`` will do the same. To root a |
|
68 | and a regexp pattern of the form ``\.c$`` will do the same. To root a | |
69 | regexp pattern, start it with ``^``. |
|
69 | regexp pattern, start it with ``^``. | |
70 |
|
70 | |||
|
71 | Subdirectories can have their own .hgignore settings by adding | |||
|
72 | ``subinclude:path/to/subdir/.hgignore`` to the root ``.hgignore``. See | |||
|
73 | :hg:`help patterns` for details on ``subinclude:`` and ``include:``. | |||
|
74 | ||||
71 | .. note:: |
|
75 | .. note:: | |
72 |
|
76 | |||
73 | Patterns specified in other than ``.hgignore`` are always rooted. |
|
77 | Patterns specified in other than ``.hgignore`` are always rooted. | |
74 | Please see :hg:`help patterns` for details. |
|
78 | Please see :hg:`help patterns` for details. | |
75 |
|
79 | |||
76 | Example |
|
80 | Example | |
77 | ======= |
|
81 | ======= | |
78 |
|
82 | |||
79 | Here is an example ignore file. :: |
|
83 | Here is an example ignore file. :: | |
80 |
|
84 | |||
81 | # use glob syntax. |
|
85 | # use glob syntax. | |
82 | syntax: glob |
|
86 | syntax: glob | |
83 |
|
87 | |||
84 | *.elc |
|
88 | *.elc | |
85 | *.pyc |
|
89 | *.pyc | |
86 | *~ |
|
90 | *~ | |
87 |
|
91 | |||
88 | # switch to regexp syntax. |
|
92 | # switch to regexp syntax. | |
89 | syntax: regexp |
|
93 | syntax: regexp | |
90 | ^\.pc/ |
|
94 | ^\.pc/ |
@@ -1,62 +1,74 | |||||
1 | Mercurial accepts several notations for identifying one or more files |
|
1 | Mercurial accepts several notations for identifying one or more files | |
2 | at a time. |
|
2 | at a time. | |
3 |
|
3 | |||
4 | By default, Mercurial treats filenames as shell-style extended glob |
|
4 | By default, Mercurial treats filenames as shell-style extended glob | |
5 | patterns. |
|
5 | patterns. | |
6 |
|
6 | |||
7 | Alternate pattern notations must be specified explicitly. |
|
7 | Alternate pattern notations must be specified explicitly. | |
8 |
|
8 | |||
9 | .. note:: |
|
9 | .. note:: | |
10 |
|
10 | |||
11 | Patterns specified in ``.hgignore`` are not rooted. |
|
11 | Patterns specified in ``.hgignore`` are not rooted. | |
12 | Please see :hg:`help hgignore` for details. |
|
12 | Please see :hg:`help hgignore` for details. | |
13 |
|
13 | |||
14 | To use a plain path name without any pattern matching, start it with |
|
14 | To use a plain path name without any pattern matching, start it with | |
15 | ``path:``. These path names must completely match starting at the |
|
15 | ``path:``. These path names must completely match starting at the | |
16 | current repository root. |
|
16 | current repository root. | |
17 |
|
17 | |||
18 | To use an extended glob, start a name with ``glob:``. Globs are rooted |
|
18 | To use an extended glob, start a name with ``glob:``. Globs are rooted | |
19 | at the current directory; a glob such as ``*.c`` will only match files |
|
19 | at the current directory; a glob such as ``*.c`` will only match files | |
20 | in the current directory ending with ``.c``. |
|
20 | in the current directory ending with ``.c``. | |
21 |
|
21 | |||
22 | The supported glob syntax extensions are ``**`` to match any string |
|
22 | The supported glob syntax extensions are ``**`` to match any string | |
23 | across path separators and ``{a,b}`` to mean "a or b". |
|
23 | across path separators and ``{a,b}`` to mean "a or b". | |
24 |
|
24 | |||
25 | To use a Perl/Python regular expression, start a name with ``re:``. |
|
25 | To use a Perl/Python regular expression, start a name with ``re:``. | |
26 | Regexp pattern matching is anchored at the root of the repository. |
|
26 | Regexp pattern matching is anchored at the root of the repository. | |
27 |
|
27 | |||
28 | To read name patterns from a file, use ``listfile:`` or ``listfile0:``. |
|
28 | To read name patterns from a file, use ``listfile:`` or ``listfile0:``. | |
29 | The latter expects null delimited patterns while the former expects line |
|
29 | The latter expects null delimited patterns while the former expects line | |
30 | feeds. Each string read from the file is itself treated as a file |
|
30 | feeds. Each string read from the file is itself treated as a file | |
31 | pattern. |
|
31 | pattern. | |
32 |
|
32 | |||
|
33 | To read a set of patterns from a file, use ``include:`` or ``subinclude:``. | |||
|
34 | ``include:`` will use all the patterns from the given file and treat them as if | |||
|
35 | they had been passed in manually. ``subinclude:`` will only apply the patterns | |||
|
36 | against files that are under the subinclude file's directory. See :hg:`help | |||
|
37 | hgignore` for details on the format of these files. | |||
|
38 | ||||
33 | All patterns, except for ``glob:`` specified in command line (not for |
|
39 | All patterns, except for ``glob:`` specified in command line (not for | |
34 | ``-I`` or ``-X`` options), can match also against directories: files |
|
40 | ``-I`` or ``-X`` options), can match also against directories: files | |
35 | under matched directories are treated as matched. |
|
41 | under matched directories are treated as matched. | |
36 |
|
42 | |||
37 | Plain examples:: |
|
43 | Plain examples:: | |
38 |
|
44 | |||
39 | path:foo/bar a name bar in a directory named foo in the root |
|
45 | path:foo/bar a name bar in a directory named foo in the root | |
40 | of the repository |
|
46 | of the repository | |
41 | path:path:name a file or directory named "path:name" |
|
47 | path:path:name a file or directory named "path:name" | |
42 |
|
48 | |||
43 | Glob examples:: |
|
49 | Glob examples:: | |
44 |
|
50 | |||
45 | glob:*.c any name ending in ".c" in the current directory |
|
51 | glob:*.c any name ending in ".c" in the current directory | |
46 | *.c any name ending in ".c" in the current directory |
|
52 | *.c any name ending in ".c" in the current directory | |
47 | **.c any name ending in ".c" in any subdirectory of the |
|
53 | **.c any name ending in ".c" in any subdirectory of the | |
48 | current directory including itself. |
|
54 | current directory including itself. | |
49 | foo/*.c any name ending in ".c" in the directory foo |
|
55 | foo/*.c any name ending in ".c" in the directory foo | |
50 | foo/**.c any name ending in ".c" in any subdirectory of foo |
|
56 | foo/**.c any name ending in ".c" in any subdirectory of foo | |
51 | including itself. |
|
57 | including itself. | |
52 |
|
58 | |||
53 | Regexp examples:: |
|
59 | Regexp examples:: | |
54 |
|
60 | |||
55 | re:.*\.c$ any name ending in ".c", anywhere in the repository |
|
61 | re:.*\.c$ any name ending in ".c", anywhere in the repository | |
56 |
|
62 | |||
57 | File examples:: |
|
63 | File examples:: | |
58 |
|
64 | |||
59 | listfile:list.txt read list from list.txt with one file pattern per line |
|
65 | listfile:list.txt read list from list.txt with one file pattern per line | |
60 | listfile0:list.txt read list from list.txt with null byte delimiters |
|
66 | listfile0:list.txt read list from list.txt with null byte delimiters | |
61 |
|
67 | |||
62 | See also :hg:`help filesets`. |
|
68 | See also :hg:`help filesets`. | |
|
69 | ||||
|
70 | Include examples:: | |||
|
71 | ||||
|
72 | include:path/to/mypatternfile reads patterns to be applied to all paths | |||
|
73 | subinclude:path/to/subignorefile reads patterns specifically for paths in the | |||
|
74 | subdirectory |
General Comments 0
You need to be logged in to leave comments.
Login now