##// END OF EJS Templates
Implementation of per-user .hgignore....
mcmillen@cs.cmu.edu -
r2003:62647394 default
parent child Browse files
Show More
@@ -236,6 +236,12 b' ui::'
236 Print debugging information. True or False. Default is False.
236 Print debugging information. True or False. Default is False.
237 editor;;
237 editor;;
238 The editor to use during a commit. Default is $EDITOR or "vi".
238 The editor to use during a commit. Default is $EDITOR or "vi".
239 ignore;;
240 A file to read per-user ignore patterns from. This file should be in
241 the same format as a repository-wide .hgignore file. This option
242 supports hook syntax, so if you want to specify multiple ignore
243 files, you can do so by setting something like
244 "ignore.other = ~/.hgignore2".
239 interactive;;
245 interactive;;
240 Allow to prompt the user. True or False. Default is True.
246 Allow to prompt the user. True or False. Default is True.
241 logtemplate;;
247 logtemplate;;
@@ -34,7 +34,11 b' class dirstate(object):'
34 return cwd[len(self.root) + 1:]
34 return cwd[len(self.root) + 1:]
35
35
36 def hgignore(self):
36 def hgignore(self):
37 '''return the contents of .hgignore as a list of patterns.
37 '''return the contents of .hgignore files as a list of patterns.
38
39 the files parsed for patterns include:
40 .hgignore in the repository root
41 any additional files specified in the [ui] section of ~/.hgrc
38
42
39 trailing white space is dropped.
43 trailing white space is dropped.
40 the escape character is backslash.
44 the escape character is backslash.
@@ -58,36 +62,44 b' class dirstate(object):'
58 elif line[i] == '#': break
62 elif line[i] == '#': break
59 line = line[:i].rstrip()
63 line = line[:i].rstrip()
60 if line: yield line
64 if line: yield line
65 files = [self.wjoin('.hgignore')]
66 files.extend(self.ui.hgignorefiles())
61 pats = []
67 pats = []
62 try:
68 for f in files:
63 fp = open(self.wjoin('.hgignore'))
69 try:
64 syntax = 'relre:'
70 fp = open(f)
65 for line in parselines(fp):
71 syntax = 'relre:'
66 if line.startswith('syntax:'):
72 for line in parselines(fp):
67 s = line[7:].strip()
73 if line.startswith('syntax:'):
68 try:
74 s = line[7:].strip()
69 syntax = syntaxes[s]
75 try:
70 except KeyError:
76 syntax = syntaxes[s]
71 self.ui.warn(_(".hgignore: ignoring invalid "
77 except KeyError:
72 "syntax '%s'\n") % s)
78 self.ui.warn(_("%s: ignoring invalid "
73 continue
79 "syntax '%s'\n") % (f, s))
74 pat = syntax + line
80 continue
75 for s in syntaxes.values():
81 pat = syntax + line
76 if line.startswith(s):
82 for s in syntaxes.values():
77 pat = line
83 if line.startswith(s):
78 break
84 pat = line
79 pats.append(pat)
85 break
80 except IOError: pass
86 pats.append(pat)
87 except IOError: pass
81 return pats
88 return pats
82
89
83 def ignore(self, fn):
90 def ignore(self, fn):
84 '''default match function used by dirstate and localrepository.
91 '''default match function used by dirstate and
85 this honours the .hgignore file, and nothing more.'''
92 localrepository. this honours the repository .hgignore file
93 and any other files specified in the [ui] section of .hgrc.'''
86 if self.blockignore:
94 if self.blockignore:
87 return False
95 return False
88 if not self.ignorefunc:
96 if not self.ignorefunc:
89 ignore = self.hgignore()
97 ignore = self.hgignore()
90 if ignore:
98 if ignore:
99 # FIXME: if there are errors in patterns, matcher will
100 # print out an error containing src ('.hgignore');
101 # really, we want the original source file to be
102 # printed instead.
91 files, self.ignorefunc, anypats = util.matcher(self.root,
103 files, self.ignorefunc, anypats = util.matcher(self.root,
92 inc=ignore,
104 inc=ignore,
93 src='.hgignore')
105 src='.hgignore')
@@ -123,6 +123,15 b' class ui(object):'
123 def extensions(self):
123 def extensions(self):
124 return self.configitems("extensions")
124 return self.configitems("extensions")
125
125
126 def hgignorefiles(self):
127 result = []
128 cfgitems = self.configitems("ui")
129 for key, value in cfgitems:
130 if key == 'ignore' or key.startswith('ignore.'):
131 path = os.path.expanduser(value)
132 result.append(path)
133 return result
134
126 def diffopts(self):
135 def diffopts(self):
127 if self.diffcache:
136 if self.diffcache:
128 return self.diffcache
137 return self.diffcache
General Comments 0
You need to be logged in to leave comments. Login now