comparison mercurial/dirstate.py @ 2062:5460f0196f77

merge with crew.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Thu, 13 Apr 2006 12:44:40 -0700
parents 5987c1eac2ce a514c7509fa9
children f1fda71e134e
comparison
equal deleted inserted replaced
2061:5987c1eac2ce 2062:5460f0196f77
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()
383 for fn in dc: 385 for fn in dc:
384 if nf == fn or (fn.startswith(nf) and fn[len(nf)] == '/'): 386 if nf == fn or (fn.startswith(nf) and fn[len(nf)] == '/'):
385 found = True 387 found = True
386 break 388 break
387 if not found: 389 if not found:
388 self.ui.warn('%s: %s\n' % ( 390 if inst.errno != errno.ENOENT or not badmatch:
389 util.pathto(self.getcwd(), ff), 391 self.ui.warn('%s: %s\n' % (
390 inst.strerror)) 392 util.pathto(self.getcwd(), ff),
393 inst.strerror))
394 elif badmatch and badmatch(ff) and statmatch(ff, None):
395 yield 'b', ff, None
391 continue 396 continue
392 if stat.S_ISDIR(st.st_mode): 397 if stat.S_ISDIR(st.st_mode):
393 cmp1 = (lambda x, y: cmp(x[1], y[1])) 398 cmp1 = (lambda x, y: cmp(x[1], y[1]))
394 sorted_ = [ x for x in findfiles(f) ] 399 sorted_ = [ x for x in findfiles(f) ]
395 sorted_.sort(cmp1) 400 sorted_.sort(cmp1)