comparison mercurial/cmdutil.py @ 33720:93422d0068f8

status: avoid recursing into ignored directory with "--terse u" Let "isignoreddir" function first check that supplied directory is itself ignored before walking recursively into its content. Otherwise, the command is awfully slow when one has an ignored directory with a lot of content. Update and rephrase function docstring accordingly.
author Denis Laxalde <denis.laxalde@logilab.fr>
date Mon, 24 Jul 2017 10:34:32 +0200
parents 6f4bc9688ca9
children ab0c55c2ad9a
comparison
equal deleted inserted replaced
33719:db3dc11356ed 33720:93422d0068f8
464 else: 464 else:
465 return False 465 return False
466 return True 466 return True
467 467
468 def isignoreddir(localpath): 468 def isignoreddir(localpath):
469 """ 469 """Return True if `localpath` directory is ignored or contains only
470 This function checks whether the directory contains only ignored files 470 ignored files and should hence be considered ignored.
471 and hence should the directory be considered ignored. Returns True, if
472 that should be ignored otherwise False.
473 """ 471 """
474 dirpath = os.path.join(root, localpath) 472 dirpath = os.path.join(root, localpath)
473 if ignorefn(dirpath):
474 return True
475 for f in os.listdir(dirpath): 475 for f in os.listdir(dirpath):
476 filepath = os.path.join(dirpath, f) 476 filepath = os.path.join(dirpath, f)
477 if os.path.isdir(filepath): 477 if os.path.isdir(filepath):
478 # recursion here 478 # recursion here
479 ret = isignoreddir(os.path.join(localpath, f)) 479 ret = isignoreddir(os.path.join(localpath, f))