Differences between revisions 8 and 9
Revision 8 as of 2009-05-19 19:31:03
Size: 381
Editor: localhost
Comment: converted to 1.6 markup
Revision 9 as of 2010-03-10 16:08:34
Size: 1623
Editor: PaulBoddie
Comment: Some explanations. Feel free to revert this edit, suggesting where such material might usefully be relocated to.
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:

== How It Works ==

Each path within the repository is presented to the ignore pattern matcher, so it would be presented with something like this:

{{{
code
code/something
code/targets
code/targets/platform
target
target/executable
}}}

This is just like the output of the Unix `find` command. To match only `target` at the top level of a repository, you would use this in `.hgignore` (using the `regex` syntax):

{{{
^target$
}}}

To match anything called `target` elsewhere in the repository, you would need to have something like this:

{{{
/target$
}}}

The above pattern will ignore files and whole directories (by "pruning" those directories and thus ignoring their contents). If you need to ignore the contents of a directory, which is not in itself particularly useful, you would start with this pattern:

{{{
/target/
}}}

Since the above pattern would only appear in paths for files below a directory called `target`, it would only match those files, not the directory itself. You could then extend this pattern to match specific files, however:

{{{
/target/.*\.o$
}}}

This would match all files ending with `.o` below (within and in subdirectories at any depth of) the `target` directory.

The .hgignore file sits in the working directory, next to the .hg folder. It is a file versioned as any other versioned file in the working directory, which is used to hold the content of the ignore patterns that are used for any command operating on the working directory.

Man Page: hgignore(5)

How It Works

Each path within the repository is presented to the ignore pattern matcher, so it would be presented with something like this:

code
code/something
code/targets
code/targets/platform
target
target/executable

This is just like the output of the Unix find command. To match only target at the top level of a repository, you would use this in .hgignore (using the regex syntax):

^target$

To match anything called target elsewhere in the repository, you would need to have something like this:

/target$

The above pattern will ignore files and whole directories (by "pruning" those directories and thus ignoring their contents). If you need to ignore the contents of a directory, which is not in itself particularly useful, you would start with this pattern:

/target/

Since the above pattern would only appear in paths for files below a directory called target, it would only match those files, not the directory itself. You could then extend this pattern to match specific files, however:

/target/.*\.o$

This would match all files ending with .o below (within and in subdirectories at any depth of) the target directory.

.hgignore (last edited 2014-09-30 15:09:19 by mpm)