Show More
@@ -306,16 +306,16 b' class dirstate(object):' | |||||
306 | bs += 1 |
|
306 | bs += 1 | |
307 | return ret |
|
307 | return ret | |
308 |
|
308 | |||
309 |
def _supported(self, f, |
|
309 | def _supported(self, f, mode, verbose=False): | |
310 |
if stat.S_ISREG( |
|
310 | if stat.S_ISREG(mode) or stat.S_ISLNK(mode): | |
311 | return True |
|
311 | return True | |
312 | if verbose: |
|
312 | if verbose: | |
313 | kind = 'unknown' |
|
313 | kind = 'unknown' | |
314 |
if stat.S_ISCHR( |
|
314 | if stat.S_ISCHR(mode): kind = _('character device') | |
315 |
elif stat.S_ISBLK( |
|
315 | elif stat.S_ISBLK(mode): kind = _('block device') | |
316 |
elif stat.S_ISFIFO( |
|
316 | elif stat.S_ISFIFO(mode): kind = _('fifo') | |
317 |
elif stat.S_ISSOCK( |
|
317 | elif stat.S_ISSOCK(mode): kind = _('socket') | |
318 |
elif stat.S_ISDIR( |
|
318 | elif stat.S_ISDIR(mode): kind = _('directory') | |
319 | self._ui.warn(_('%s: unsupported file type (type is %s)\n') |
|
319 | self._ui.warn(_('%s: unsupported file type (type is %s)\n') | |
320 | % (self.pathto(f), kind)) |
|
320 | % (self.pathto(f), kind)) | |
321 | return False |
|
321 | return False | |
@@ -364,7 +364,6 b' class dirstate(object):' | |||||
364 | if not self._root.endswith(os.sep): |
|
364 | if not self._root.endswith(os.sep): | |
365 | common_prefix_len += 1 |
|
365 | common_prefix_len += 1 | |
366 |
|
366 | |||
367 | # recursion free walker, faster than os.walk. |
|
|||
368 | normpath = util.normpath |
|
367 | normpath = util.normpath | |
369 | listdir = os.listdir |
|
368 | listdir = os.listdir | |
370 | lstat = os.lstat |
|
369 | lstat = os.lstat | |
@@ -374,11 +373,14 b' class dirstate(object):' | |||||
374 | join = os.path.join |
|
373 | join = os.path.join | |
375 | s_isdir = stat.S_ISDIR |
|
374 | s_isdir = stat.S_ISDIR | |
376 | supported = self._supported |
|
375 | supported = self._supported | |
|
376 | _join = self._join | |||
|
377 | known = {'.hg': 1} | |||
377 |
|
378 | |||
|
379 | # recursion free walker, faster than os.walk. | |||
378 | def findfiles(s): |
|
380 | def findfiles(s): | |
379 | work = [s] |
|
381 | work = [s] | |
380 | if directories: |
|
382 | if directories: | |
381 |
yield 'd', normpath(s[common_prefix_len:]), |
|
383 | yield 'd', normpath(s[common_prefix_len:]), lstat(s) | |
382 | while work: |
|
384 | while work: | |
383 | top = work.pop() |
|
385 | top = work.pop() | |
384 | names = listdir(top) |
|
386 | names = listdir(top) | |
@@ -396,9 +398,10 b' class dirstate(object):' | |||||
396 | if isdir(join(top, '.hg')): |
|
398 | if isdir(join(top, '.hg')): | |
397 | continue |
|
399 | continue | |
398 | for f in names: |
|
400 | for f in names: | |
399 |
np = pconvert( |
|
401 | np = pconvert(join(nd, f)) | |
400 |
if |
|
402 | if np in known: | |
401 | continue |
|
403 | continue | |
|
404 | known[np] = 1 | |||
402 | p = join(top, f) |
|
405 | p = join(top, f) | |
403 | # don't trip over symlinks |
|
406 | # don't trip over symlinks | |
404 | st = lstat(p) |
|
407 | st = lstat(p) | |
@@ -407,24 +410,19 b' class dirstate(object):' | |||||
407 | work.append(p) |
|
410 | work.append(p) | |
408 | if directories: |
|
411 | if directories: | |
409 | yield 'd', np, st |
|
412 | yield 'd', np, st | |
410 |
if |
|
413 | if np in dc and match(np): | |
411 | yield 'm', np, st |
|
414 | yield 'm', np, st | |
412 | elif imatch(np): |
|
415 | elif imatch(np): | |
413 | if supported(np, st): |
|
416 | if supported(np, st.st_mode): | |
414 | yield 'f', np, st |
|
417 | yield 'f', np, st | |
415 | elif np in dc: |
|
418 | elif np in dc: | |
416 | yield 'm', np, st |
|
419 | yield 'm', np, st | |
417 |
|
420 | |||
418 | known = {'.hg': 1} |
|
|||
419 | def seen(fn): |
|
|||
420 | if fn in known: return True |
|
|||
421 | known[fn] = 1 |
|
|||
422 |
|
||||
423 | # step one, find all files that match our criteria |
|
421 | # step one, find all files that match our criteria | |
424 | files.sort() |
|
422 | files.sort() | |
425 | for ff in files: |
|
423 | for ff in files: | |
426 | nf = normpath(ff) |
|
424 | nf = normpath(ff) | |
427 |
f = |
|
425 | f = _join(ff) | |
428 | try: |
|
426 | try: | |
429 | st = lstat(f) |
|
427 | st = lstat(f) | |
430 | except OSError, inst: |
|
428 | except OSError, inst: | |
@@ -447,8 +445,11 b' class dirstate(object):' | |||||
447 | for e in sorted_: |
|
445 | for e in sorted_: | |
448 | yield e |
|
446 | yield e | |
449 | else: |
|
447 | else: | |
450 | if not seen(nf) and match(nf): |
|
448 | if nf in known: | |
451 | if supported(ff, st, verbose=True): |
|
449 | continue | |
|
450 | known[nf] = 1 | |||
|
451 | if match(nf): | |||
|
452 | if supported(ff, st.st_mode, verbose=True): | |||
452 | yield 'f', nf, st |
|
453 | yield 'f', nf, st | |
453 | elif ff in dc: |
|
454 | elif ff in dc: | |
454 | yield 'm', nf, st |
|
455 | yield 'm', nf, st | |
@@ -458,7 +459,10 b' class dirstate(object):' | |||||
458 | ks = dc.keys() |
|
459 | ks = dc.keys() | |
459 | ks.sort() |
|
460 | ks.sort() | |
460 | for k in ks: |
|
461 | for k in ks: | |
461 | if not seen(k) and imatch(k): |
|
462 | if k in known: | |
|
463 | continue | |||
|
464 | known[k] = 1 | |||
|
465 | if imatch(k): | |||
462 | yield 'm', k, None |
|
466 | yield 'm', k, None | |
463 |
|
467 | |||
464 | def status(self, files, match, list_ignored, list_clean): |
|
468 | def status(self, files, match, list_ignored, list_clean): | |
@@ -484,7 +488,7 b' class dirstate(object):' | |||||
484 | raise |
|
488 | raise | |
485 | st = None |
|
489 | st = None | |
486 | # We need to re-check that it is a valid file |
|
490 | # We need to re-check that it is a valid file | |
487 | if st and self._supported(fn, st): |
|
491 | if st and self._supported(fn, st.st_mode): | |
488 | nonexistent = False |
|
492 | nonexistent = False | |
489 | # XXX: what to do with file no longer present in the fs |
|
493 | # XXX: what to do with file no longer present in the fs | |
490 | # who are not removed in the dirstate ? |
|
494 | # who are not removed in the dirstate ? |
General Comments 0
You need to be logged in to leave comments.
Login now