changeset 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
files mercurial/pathutil.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/pathutil.py	Mon Jan 16 12:10:20 2023 +0000
+++ b/mercurial/pathutil.py	Fri Jan 06 17:29:42 2023 +0000
@@ -314,6 +314,13 @@
     yield b''
 
 
+def finddirs_rev_noroot(path: bytes) -> Iterator[bytes]:
+    pos = path.find(pycompat.ossep)
+    while pos != -1:
+        yield path[:pos]
+        pos = path.find(pycompat.ossep, pos + 1)
+
+
 class dirs:
     '''a multiset of directory names from a set of file paths'''