GJ.
GJ.

Reputation: 5364

How to get .hgignore pattern to apply to subdirectories?

I have in my .hgignore the pattern "*.pyc"

The .pyc files are indeed ignored at the root level, but not inside subdirectories.

Any ideas?

Upvotes: 7

Views: 8791

Answers (3)

Script
Script

Reputation: 101

you can try to use this code

syntax:glob


**.pyc

Upvotes: 4

Samir Talwar
Samir Talwar

Reputation: 14330

Use glob syntax (put syntax: glob at the top of the file), and it should work. Mercurial defaults to regular expressions by default.

syntax: glob

*.pyc

Upvotes: 7

Nicolas Dumazet
Nicolas Dumazet

Reputation: 7231

By default, the patterns are python regular expressions. The expressions are searched in every component of the path. So you probably want \.pyc$ to match files ending with .pyc

$ hg init test-ignore
$ cd test-ignore 
$ touch foo.pyc
$ mkdir bar 
$ touch bar/bar.pyc
$ echo "\.pyc$" > .hgignore
$ hg st        
? .hgignore

Note that ".pyc$" will ignore "foopyc" as the unescaped dot matches any character. Similarly ".pyc" would match "foo.pyche.bar"

If you dislike the regular expression syntax, you can switch to globals. For instance, the current .hgignore in Mercurial's repository starts with:

syntax: glob

*.elc
*.orig
*.rej
*~
*.mergebackup
*.o
*.so
*.pyd
*.pyc
*.swp
*.prof
\#*\#
.\#*

Everything is explained in man 5 hgignore

Upvotes: 7

Related Questions