181 return Ignore.ignore(root, ignorefiles)
182
183
184 def gen_files(root, parent, paths, exclude):
185 """Return a function producing file names, relative to the current
186 directory, of any file changed on this branch (limited to 'paths' if
187 requested), and excluding files for which exclude returns a true value """
188
189 # Taken entirely from Python 2.6's os.path.relpath which we would use if we
190 # could.
191 def relpath(path, here):
192 c = os.path.abspath(os.path.join(root, path)).split(os.path.sep)
193 s = os.path.abspath(here).split(os.path.sep)
194 l = len(os.path.commonprefix((s, c)))
195 return os.path.join(*[os.path.pardir] * (len(s)-l) + c[l:])
196
197 def ret(select=None):
198 if not select:
199 select = lambda x: True
200
201 for f in git_file_list(parent, paths):
202 f = relpath(f, '.')
203 try:
204 res = git("diff %s HEAD %s" % (parent, f))
205 except GitError, e:
206 # This ignores all the errors that can be thrown. Usually, this means
207 # that git returned non-zero because the file doesn't exist, but it
208 # could also fail if git can't create a new file or it can't be
209 # executed. Such errors are 1) unlikely, and 2) will be caught by other
210 # invocations of git().
211 continue
212 empty = not res.readline()
213 if (os.path.isfile(f) and not empty and select(f) and not exclude(f)):
214 yield f
215 return ret
216
217
218 def comchk(root, parent, flist, output):
219 output.write("Comments:\n")
220
221 return Comments.comchk(git_comments(parent), check_db=True,
222 output=output)
223
224
225 def mapfilechk(root, parent, flist, output):
226 ret = 0
227
228 # We are interested in examining any file that has the following
229 # in its final path segment:
230 # - Contains the word 'mapfile'
231 # - Begins with 'map.'
232 # - Ends with '.map'
233 # We don't want to match unless these things occur in final path segment
234 # because directory names with these strings don't indicate a mapfile.
|
181 return Ignore.ignore(root, ignorefiles)
182
183
184 def gen_files(root, parent, paths, exclude):
185 """Return a function producing file names, relative to the current
186 directory, of any file changed on this branch (limited to 'paths' if
187 requested), and excluding files for which exclude returns a true value """
188
189 # Taken entirely from Python 2.6's os.path.relpath which we would use if we
190 # could.
191 def relpath(path, here):
192 c = os.path.abspath(os.path.join(root, path)).split(os.path.sep)
193 s = os.path.abspath(here).split(os.path.sep)
194 l = len(os.path.commonprefix((s, c)))
195 return os.path.join(*[os.path.pardir] * (len(s)-l) + c[l:])
196
197 def ret(select=None):
198 if not select:
199 select = lambda x: True
200
201 for abspath in git_file_list(parent, paths):
202 path = relpath(abspath, '.')
203 try:
204 res = git("diff %s HEAD %s" % (parent, path))
205 except GitError, e:
206 # This ignores all the errors that can be thrown. Usually, this
207 # means that git returned non-zero because the file doesn't
208 # exist, but it could also fail if git can't create a new file
209 # or it can't be executed. Such errors are 1) unlikely, and 2)
210 # will be caught by other invocations of git().
211 continue
212 empty = not res.readline()
213 if (os.path.isfile(path) and not empty and
214 select(path) and not exclude(abspath)):
215 yield path
216 return ret
217
218
219 def comchk(root, parent, flist, output):
220 output.write("Comments:\n")
221
222 return Comments.comchk(git_comments(parent), check_db=True,
223 output=output)
224
225
226 def mapfilechk(root, parent, flist, output):
227 ret = 0
228
229 # We are interested in examining any file that has the following
230 # in its final path segment:
231 # - Contains the word 'mapfile'
232 # - Begins with 'map.'
233 # - Ends with '.map'
234 # We don't want to match unless these things occur in final path segment
235 # because directory names with these strings don't indicate a mapfile.
|