mercurial/help/hgignore.txt
author Pierre-Yves David <pierre-yves.david@fb.com>
Tue, 25 Feb 2014 18:37:06 -0800
branchstable
changeset 20590 2b7d54e929b4
parent 17267 979b107eaea2
child 20532 f1a3ae7c15df
permissions -rw-r--r--
merge: introduce new format for the state file This new format will allow us to address common bugs while doing special merge (graft, backout, rebaseā€¦) and record user choice during conflict resolution. The format is open so we can add more record for future usage. This file still store hexified version of node to help human willing to debug it by hand. The overhead or oversize are not expected be an issue. The old format is still used. It will be written to disk along side the newer format. And at parse time we detect if the data from old version of the mergestate are different from the one in the new version file. If its the same, both have most likely be written at the same time and you can trust the extra data from the new file. If it differs, the old file have been written by an older version of mercurial that did not knew about the new file. In that case we use the content of the old file.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14044
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
     1
Synopsis
17267
979b107eaea2 doc: unify section level between help topics
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 17116
diff changeset
     2
========
14044
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
     3
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
     4
The Mercurial system uses a file called ``.hgignore`` in the root
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
     5
directory of a repository to control its behavior when it searches
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
     6
for files that it is not currently tracking.
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
     7
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
     8
Description
17267
979b107eaea2 doc: unify section level between help topics
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 17116
diff changeset
     9
===========
14044
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    10
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    11
The working directory of a Mercurial repository will often contain
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    12
files that should not be tracked by Mercurial. These include backup
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    13
files created by editors and build products created by compilers.
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    14
These files can be ignored by listing them in a ``.hgignore`` file in
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    15
the root of the working directory. The ``.hgignore`` file must be
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    16
created manually. It is typically put under version control, so that
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    17
the settings will propagate to other repositories with push and pull.
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    18
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    19
An untracked file is ignored if its path relative to the repository
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    20
root directory, or any prefix path of that path, is matched against
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    21
any pattern in ``.hgignore``.
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    22
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    23
For example, say we have an untracked file, ``file.c``, at
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    24
``a/b/file.c`` inside our repository. Mercurial will ignore ``file.c``
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    25
if any pattern in ``.hgignore`` matches ``a/b/file.c``, ``a/b`` or ``a``.
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    26
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    27
In addition, a Mercurial configuration file can reference a set of
14668
2d6f1b2c6a82 help/hgignore: refer to the builtin help instead of external URLs
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 14044
diff changeset
    28
per-user or global ignore files. See the ``ignore`` configuration
2d6f1b2c6a82 help/hgignore: refer to the builtin help instead of external URLs
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 14044
diff changeset
    29
key on the ``[ui]`` section of :hg:`help config` for details of how to
2d6f1b2c6a82 help/hgignore: refer to the builtin help instead of external URLs
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 14044
diff changeset
    30
configure these files.
14044
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    31
14668
2d6f1b2c6a82 help/hgignore: refer to the builtin help instead of external URLs
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 14044
diff changeset
    32
To control Mercurial's handling of files that it manages, many
2d6f1b2c6a82 help/hgignore: refer to the builtin help instead of external URLs
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 14044
diff changeset
    33
commands support the ``-I`` and ``-X`` options; see
2d6f1b2c6a82 help/hgignore: refer to the builtin help instead of external URLs
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 14044
diff changeset
    34
:hg:`help <command>` and :hg:`help patterns` for details.
14044
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    35
17116
d8c76c82d012 help: explain effect of .hgignore on tracked files
Adrian Buehlmann <adrian@cadifra.com>
parents: 16504
diff changeset
    36
Files that are already tracked are not affected by .hgignore, even
d8c76c82d012 help: explain effect of .hgignore on tracked files
Adrian Buehlmann <adrian@cadifra.com>
parents: 16504
diff changeset
    37
if they appear in .hgignore. An untracked file X can be explicitly
d8c76c82d012 help: explain effect of .hgignore on tracked files
Adrian Buehlmann <adrian@cadifra.com>
parents: 16504
diff changeset
    38
added with :hg:`add X`, even if X would be excluded by a pattern
d8c76c82d012 help: explain effect of .hgignore on tracked files
Adrian Buehlmann <adrian@cadifra.com>
parents: 16504
diff changeset
    39
in .hgignore.
d8c76c82d012 help: explain effect of .hgignore on tracked files
Adrian Buehlmann <adrian@cadifra.com>
parents: 16504
diff changeset
    40
14044
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    41
Syntax
17267
979b107eaea2 doc: unify section level between help topics
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 17116
diff changeset
    42
======
14044
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    43
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    44
An ignore file is a plain text file consisting of a list of patterns,
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    45
with one pattern per line. Empty lines are skipped. The ``#``
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    46
character is treated as a comment character, and the ``\`` character
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    47
is treated as an escape character.
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    48
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    49
Mercurial supports several pattern syntaxes. The default syntax used
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    50
is Python/Perl-style regular expressions.
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    51
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    52
To change the syntax used, use a line of the following form::
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    53
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    54
  syntax: NAME
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    55
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    56
where ``NAME`` is one of the following:
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    57
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    58
``regexp``
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    59
  Regular expression, Python/Perl syntax.
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    60
``glob``
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    61
  Shell-style glob.
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    62
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    63
The chosen syntax stays in effect when parsing all patterns that
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    64
follow, until another syntax is selected.
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    65
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    66
Neither glob nor regexp patterns are rooted. A glob-syntax pattern of
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    67
the form ``*.c`` will match a file ending in ``.c`` in any directory,
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    68
and a regexp pattern of the form ``\.c$`` will do the same. To root a
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    69
regexp pattern, start it with ``^``.
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    70
16504
e3c7ca15cde2 doc: add note about pattern rooted/unrooted cases to "hgignore" and "patterns"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 14668
diff changeset
    71
.. note::
e3c7ca15cde2 doc: add note about pattern rooted/unrooted cases to "hgignore" and "patterns"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 14668
diff changeset
    72
  Patterns specified in other than ``.hgignore`` are always rooted.
e3c7ca15cde2 doc: add note about pattern rooted/unrooted cases to "hgignore" and "patterns"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 14668
diff changeset
    73
  Please see :hg:`help patterns` for details.
e3c7ca15cde2 doc: add note about pattern rooted/unrooted cases to "hgignore" and "patterns"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 14668
diff changeset
    74
14044
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    75
Example
17267
979b107eaea2 doc: unify section level between help topics
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 17116
diff changeset
    76
=======
14044
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    77
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    78
Here is an example ignore file. ::
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    79
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    80
  # use glob syntax.
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    81
  syntax: glob
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    82
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    83
  *.elc
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    84
  *.pyc
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    85
  *~
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    86
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    87
  # switch to regexp syntax.
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    88
  syntax: regexp
0528b69f8db4 help: move hgignore man page into built-in help (issue2769)
Yun Lee <yun.lee.bj@gmail.com>
parents:
diff changeset
    89
  ^\.pc/