Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 43677:0b7733719d21
utils: move finddirs() to pathutil
This is a follow-up to c21aca51b392 (utils: move the `dirs` definition
in pathutil (API), 2019-11-06). finddirs() is closely related to dirs
and used by it.
Differential Revision: https://phab.mercurial-scm.org/D7388
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 14 Nov 2019 08:03:26 -0800 |
parents | c21aca51b392 |
children | 38387f9e4d22 |
comparison
equal
deleted
inserted
replaced
43676:2e017696181f | 43677:0b7733719d21 |
---|---|
3489 for line in getstackframes(skip + 1, depth=depth): | 3489 for line in getstackframes(skip + 1, depth=depth): |
3490 f.write(line) | 3490 f.write(line) |
3491 f.flush() | 3491 f.flush() |
3492 | 3492 |
3493 | 3493 |
3494 def finddirs(path): | |
3495 pos = path.rfind(b'/') | |
3496 while pos != -1: | |
3497 yield path[:pos] | |
3498 pos = path.rfind(b'/', 0, pos) | |
3499 yield b'' | |
3500 | |
3501 | |
3502 # convenient shortcut | 3494 # convenient shortcut |
3503 dst = debugstacktrace | 3495 dst = debugstacktrace |
3504 | 3496 |
3505 | 3497 |
3506 def safename(f, tag, ctx, others=None): | 3498 def safename(f, tag, ctx, others=None): |