Regular expression Mercurial.hgignore

Using Mercurial, I need to ignore all files and directories, except for the "tests" and "languages" directories and files in these directories. So that all this can be done with regular expressions and .hgignoere

Files:

  • Tests \ junk.txt
  • CMS \ Tests \ some_file.txt
  • CMS \ Languages ​​\ Users \ lang.txt
  • languages ​​\ lang2.txt
  • tests.txt
  • proba / tests.txt

I tried with this:

^(?!test|test/|test$|languages|languages/|languages$)

but this only matches files starting with test and language:

  • Tests \ junk.txt
  • languages ​​\ lang2.txt

I want to combine also

  • CMS \ Tests \ some_file.txt
  • CMS \ Languages ​​\ Users \ lang.txt

Any advice would be appreciated.

+5
source share
4 answers

Use balls, they are easier:

C:> dir
tests  languages pr0n espionage more_pr0n

C:> type .hgignore
syntax: glob
pr0n/*
espionage/*
more_pr0n/*

added . If you are concerned that there will be new directories that will not be ignored, you should:

hg add .hgignore
hg commit 
echo "new_directory/*" >> .hgignore
hg commit

, , .

+2

, , ?: -- .hgignore. , , , , hg add - , mercurial ( cvs/svn) .

, .hgignore :

.*

hg add 'hg add'. , , , , , , .

+2

hgignore:

, , , file.c, /b/file.c . Mercurial file.c, .hgignore a/b/file.c, a/b a.

, , . , , ///, /// foo/. -, , / foo/:

^(?!(one|foo)(/|$))

^ (/|$) one|foo . /, /:

^one/(?!(two)(/|$))

two . , , /, /:

^one/two/(?!(three|four)(/|$))

.

0

.

. manpage.

, , file, file.c, a/b/file.c . Mercurial file.c, - .hgignore a/b/file.c, a/b a.

So, let's say you create a regular expression that will not match the path containing test, and the file proba/tests.txtis in your working directory. This regular expression will be applied to first probaand will match what will cause the file to be ignored.

-1
source

All Articles