How to get .hgignore template to apply to subdirectories?

I have a "* .pyc" template in my .hgignore

.Pyc files are really ignored at the root level, but not inside subdirectories.

Any ideas?

+7
source share
3 answers

Use the glob syntax (put syntax: glob at the beginning of the file) and it should work. By default, Mercurial uses regular expressions by default.

 syntax: glob *.pyc 
+7
source

By default, patterns are python regular expressions. Expressions are executed in each component of the path. So you probably want \.pyc$ match files ending in .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 $" ignores "foopyc" because the undefined dot matches any character. Similarly, ".pyc" will match "foo.pyche.bar"

If you don't like the syntax of regular expressions, you can switch to global ones. For example, the current .hgignore in the Mercurial repository starts with:

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

Everything is explained in man 5 hgignore

+6
source

you can try using this code

 syntax:glob **.pyc 
+4
source

All Articles