3

I would like to use the .hgignore file of Mercurial to ignore all files with file extension .tex, except those .tex files in one particular directory and whatever subdirectory of this directory.

I presume syntax: regexp will be required for this. A brief explanation of the particular regular expression used, would also be very welcome, so that we can all learn a bit here.

Serge Stroobandt
  • 28,495
  • 9
  • 107
  • 102
  • possible duplicate of [How can I ignore all directories except one using .hgignore?](http://stackoverflow.com/questions/3637496/how-can-i-ignore-all-directories-except-one-using-hgignore) – Brad Rem Aug 31 '13 at 11:49
  • @BradRem Not quite, because there is also the file extension issue here. – Serge Stroobandt Aug 31 '13 at 11:52

1 Answers1

2

Let's say you want to exclude the directory named exclude. The following regex would then match all files that end in .tex unless exclude/ comes somewhere before that:

^(?!.*\bexclude/).*\.tex$
Tim Pietzcker
  • 328,213
  • 58
  • 503
  • 561