comparison mercurial/pathutil.py @ 49907:7623d79f872c

pathutil: add the more efficient finddir iterator (to be used in subsequent commits)
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Fri, 06 Jan 2023 17:29:42 +0000
parents 15175774e1c5
children 789e152a6bdb
comparison
equal deleted inserted replaced
49906:15175774e1c5 49907:7623d79f872c
312 yield path[:pos] 312 yield path[:pos]
313 pos = path.rfind(b'/', 0, pos) 313 pos = path.rfind(b'/', 0, pos)
314 yield b'' 314 yield b''
315 315
316 316
317 def finddirs_rev_noroot(path: bytes) -> Iterator[bytes]:
318 pos = path.find(pycompat.ossep)
319 while pos != -1:
320 yield path[:pos]
321 pos = path.find(pycompat.ossep, pos + 1)
322
323
317 class dirs: 324 class dirs:
318 '''a multiset of directory names from a set of file paths''' 325 '''a multiset of directory names from a set of file paths'''
319 326
320 def __init__(self, map, only_tracked=False): 327 def __init__(self, map, only_tracked=False):
321 """ 328 """