equal
deleted
inserted
replaced
292 self.ui.warn(_('%s: unsupported file type (type is %s)\n') % ( |
292 self.ui.warn(_('%s: unsupported file type (type is %s)\n') % ( |
293 util.pathto(self.getcwd(), f), |
293 util.pathto(self.getcwd(), f), |
294 kind)) |
294 kind)) |
295 return False |
295 return False |
296 |
296 |
297 def statwalk(self, files=None, match=util.always, dc=None, ignored=False): |
297 def statwalk(self, files=None, match=util.always, dc=None, ignored=False, |
|
298 badmatch=None): |
298 self.lazyread() |
299 self.lazyread() |
299 |
300 |
300 # walk all files by default |
301 # walk all files by default |
301 if not files: |
302 if not files: |
302 files = [self.root] |
303 files = [self.root] |
309 file_ = util.pconvert(file_) |
310 file_ = util.pconvert(file_) |
310 if not ignored and file_ not in dc and self.ignore(file_): |
311 if not ignored and file_ not in dc and self.ignore(file_): |
311 return False |
312 return False |
312 return match(file_) |
313 return match(file_) |
313 |
314 |
314 return self.walkhelper(files=files, statmatch=statmatch, dc=dc) |
315 return self.walkhelper(files=files, statmatch=statmatch, dc=dc, |
315 |
316 badmatch=badmatch) |
316 def walk(self, files=None, match=util.always, dc=None): |
317 |
|
318 def walk(self, files=None, match=util.always, dc=None, badmatch=None): |
317 # filter out the stat |
319 # filter out the stat |
318 for src, f, st in self.statwalk(files, match, dc): |
320 for src, f, st in self.statwalk(files, match, dc, badmatch=badmatch): |
319 yield src, f |
321 yield src, f |
320 |
322 |
321 # walk recursively through the directory tree, finding all files |
323 # walk recursively through the directory tree, finding all files |
322 # matched by the statmatch function |
324 # matched by the statmatch function |
323 # |
325 # |
328 # and st is the stat result if the file was found in the directory. |
330 # and st is the stat result if the file was found in the directory. |
329 # |
331 # |
330 # dc is an optional arg for the current dirstate. dc is not modified |
332 # dc is an optional arg for the current dirstate. dc is not modified |
331 # directly by this function, but might be modified by your statmatch call. |
333 # directly by this function, but might be modified by your statmatch call. |
332 # |
334 # |
333 def walkhelper(self, files, statmatch, dc): |
335 def walkhelper(self, files, statmatch, dc, badmatch=None): |
334 # recursion free walker, faster than os.walk. |
336 # recursion free walker, faster than os.walk. |
335 def findfiles(s): |
337 def findfiles(s): |
336 work = [s] |
338 work = [s] |
337 while work: |
339 while work: |
338 top = work.pop() |
340 top = work.pop() |
377 for fn in dc: |
379 for fn in dc: |
378 if nf == fn or (fn.startswith(nf) and fn[len(nf)] == '/'): |
380 if nf == fn or (fn.startswith(nf) and fn[len(nf)] == '/'): |
379 found = True |
381 found = True |
380 break |
382 break |
381 if not found: |
383 if not found: |
382 self.ui.warn('%s: %s\n' % ( |
384 if inst.errno != errno.ENOENT or not badmatch: |
383 util.pathto(self.getcwd(), ff), |
385 self.ui.warn('%s: %s\n' % ( |
384 inst.strerror)) |
386 util.pathto(self.getcwd(), ff), |
|
387 inst.strerror)) |
|
388 elif badmatch and badmatch(ff) and statmatch(ff, None): |
|
389 yield 'b', ff, None |
385 continue |
390 continue |
386 if stat.S_ISDIR(st.st_mode): |
391 if stat.S_ISDIR(st.st_mode): |
387 cmp1 = (lambda x, y: cmp(x[1], y[1])) |
392 cmp1 = (lambda x, y: cmp(x[1], y[1])) |
388 sorted_ = [ x for x in findfiles(f) ] |
393 sorted_ = [ x for x in findfiles(f) ] |
389 sorted_.sort(cmp1) |
394 sorted_.sort(cmp1) |