discussing ignore rules

Wayne Davison wayned at samba.org
Wed May 10 20:04:56 BST 2006


I would like to see a way to specify ignore rules that apply to all bzr
projects because I have some file names that I use in my personal habits
that need to be ignored by bzr (e.g. I output diff info to a file named
"x.patch"), but these rules shouldn't get added a project's .bzrignore
file (because other folks don't need to ignore my personal filenames).

Earlier this year some folks discussed moving all the DEFAULT_IGNORE
values into each project's .bzrignore file, but I don't think that all
ignores should go into that file.  To me there is a division of rules
that affect the current project because of how it is built (such as *.o
files that derive from *.c files), and rules that ignore files because
of the tools and/or temp-file names that are personal to the user (such
as ".*.swp", "CVS", etc.).  So, if folks still think we should create a
.bzrignore file when "bzr init" is run, I think that it should only
contain the rules that are for project-oriented generated files.

One way to handle this division would be to honor a file named
~/.bazaar/ignore that lets each user configure what files they need to
ignore that are not project specific.  The presence of this file could
override the inclusion of the DEFAULT_IGNORE rules (or perhaps half of
the default ignores if they were split into the categories detailed
above).

I have added support for the ~/.bazaar/ignore file to my version of bzr,
and have attached a patch for this.  In this version, the presence of
this ignore file disables the inclusion of the DEFAULT_IGNORE rules.

I also attempted to separate the DEFAULT_IGNORE list into my two
categories, and attached "ignore" for the file that should go into
~/.bazaar, and "bzrignore" for the file that should get installed by
"bzr init" (I had to guess at some of the rules, so I may have mis-
classified something).

Finally, two comments about the DEFAULT_IGNORE list in bzrlib/__init__.py:
There are two rules to ignore *.o, and the .jamdeps line doesn't have a
trailing comma after the closing single-quote.

..wayne..
-------------- next part --------------
--- bzrlib/workingtree.py	
+++ bzrlib/workingtree.py	
@@ -52,6 +52,7 @@
                            quotefn)
 from bzrlib.conflicts import Conflict, ConflictList, CONFLICT_SUFFIXES
 import bzrlib.bzrdir as bzrdir
+import bzrlib.config as config
 from bzrlib.decorators import needs_read_lock, needs_write_lock
 import bzrlib.errors as errors
 from bzrlib.errors import (BzrCheckError,
@@ -983,7 +984,13 @@
         if hasattr(self, '_ignorelist'):
             return self._ignorelist
 
-        l = bzrlib.DEFAULT_IGNORE[:]
+        global_ignore = pathjoin(config.config_dir(), 'ignore')
+        try:
+            f = file(global_ignore, 'rb')
+            l = [ ]
+            l.extend([line.rstrip("\n\r") for line in f.readlines()])
+        except Exception, e:
+            l = bzrlib.DEFAULT_IGNORE[:]
         if self.has_filename(bzrlib.IGNORE_FILENAME):
             f = self.get_file_byname(bzrlib.IGNORE_FILENAME)
             l.extend([line.rstrip("\n\r") for line in f.readlines()])

-------------- next part --------------
#*#
*$
*,v
*.BAK
*.bak
*.orig
*.tmp
.*.tmp
*~
.#*
.*.sw[nop]
.sw[nop]
.DS_Store
.arch-ids
.arch-inventory
.bzr.log
.del-*
.hg
.git
.svn
.tmp*
BitKeeper
CVS
CVS.adm
RCS
SCCS
TAGS
_darcs
{arch}
-------------- next part --------------
*.a
*.o
*.obj
*.elc
*.exe
*.la
*.lo
*.py[oc]
*.so
.jamdeps
.libs
.make.state
.sconsign*
aclocal.m4
autom4te*
config.h
config.h.in
config.log
config.status
config.sub
stamp-h
stamp-h.in
stamp-h1


More information about the bazaar mailing list