Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get .hgignore pattern to apply to subdirectories?

Tags:

mercurial

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

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

Any ideas?

like image 465
GJ. Avatar asked Dec 26 '10 00:12

GJ.


3 Answers

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

like image 148
Nicolas Dumazet Avatar answered Oct 19 '22 00:10

Nicolas Dumazet


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
like image 7
Samir Talwar Avatar answered Oct 18 '22 23:10

Samir Talwar


you can try to use this code

syntax:glob


**.pyc
like image 4
Script Avatar answered Oct 18 '22 23:10

Script