negative ignore?

Asked by grigsoft

Sorry, the answer must be obvious or am I just weird?
I'm a newbie, and I only need to put several file types under bzr control, let's say that cpp, h and rc.
Is it possible to configure .ignore file to use negative logic? With git I could write this:
.ignore:
*
!*.cpp
!*.h

How do I do this with bzr? I know I can specify files manually in "bzr add", but that's too tedious.
I also suspect that I can create aliases for required commands so "bzr a" would mean "bzr add *.cpp *h".
Is there some other way?

Thank you!

Question information

Language:
English Edit question
Status:
Solved
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Solved by:
grigsoft
Solved:
Last query:
Last reply:
Revision history for this message
grigsoft (grigsoft) said :
#1

Sorry, I have found question #91931.
It seems that I could not even specify file mask in add. Too bad.

Revision history for this message
Jeff Parsons (justjeff) said :
#2

The Bazaar documentation contains an example of using a regular expression to ignore all files except those under a particular top-level directory:

    http://doc.bazaar.canonical.com/bzr.2.0/en/user-reference/index.html#ignore

You could extend this to ignore any files except those with your desired extensions. Try the following in your .bzrignore file.

    RE:^.*\.(?!cpp$)(?!h$)[^.]*$

You can then just add another negative lookahead assertion in the same manner for any extension you want to include. There might be a more elegant way to express that, but I'm not particularly familiar with Python regular expressions. For a full reference of the syntax used, see

    http://docs.python.org/library/re.html

Revision history for this message
Martin Pool (mbp) said :
#3

The '!' syntax is supported in bzr 2.1.