17
17
"""Lists of ignore files, etc."""
21
from bzrlib import config
19
23
# This was the full ignore list for bzr 0.8
20
24
# please keep these sorted (in C locale order) to aid merging
98
def parse_ignore_file(f):
99
"""Read in all of the lines in the file and turn it into an ignore list"""
101
for line in f.read().decode('utf8').split('\n'):
102
line = line.rstrip('\r\n')
103
if not line or line.startswith('#'):
109
def _create_user_ignores():
110
"""Create ~/.bazaar/ignore, and fill it with the defaults"""
112
# We need to create the file
113
path = config.user_ignore_config_filename()
114
config.ensure_config_dir_exists()
117
except (IOError, OSError), e:
118
if e.errno not in (errno.EPERM,):
120
# if EPERM, we don't have write access to home dir
121
# so we won't save anything
124
for pattern in USER_DEFAULTS:
125
f.write(pattern.encode('utf8') + '\n')
130
def get_user_ignores():
131
"""Get the list of user ignored files, possibly creating it."""
132
path = config.user_ignore_config_filename()
133
patterns = USER_DEFAULTS[:]
136
except (IOError, OSError), e:
137
if e.errno not in (errno.ENOENT,):
139
# Create the ignore file, and just return the default
140
_create_user_ignores()
144
return parse_ignore_file(f)