tests/list-tree.py
author Arseniy Alekseyev <aalekseyev@janestreet.com>
Fri, 26 Apr 2024 19:10:35 +0100
changeset 51626 865efc020c33
parent 48875 6000f5b25c9b
permissions -rw-r--r--
dirstate: remove the python-side whitelist of allowed matchers This whitelist is too permissive because it allows matchers that contain disallowed ones deep inside, for example through `intersectionmatcher`. It is also too restrictive because it doesn't pass through some of the matchers we support, such as `patternmatcher`. It's also unnecessary because unsupported matchers raise `FallbackError` and we fall back anyway. Making this change makes more of the tests use rust code path, and therefore subtly change behavior. For example, rust status in largefiles repos seems to have strange behavior.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35217
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
     1
import argparse
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
     2
import os
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
     3
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
     4
ap = argparse.ArgumentParser()
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
     5
ap.add_argument('path', nargs='+')
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
     6
opts = ap.parse_args()
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
     7
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 35380
diff changeset
     8
35217
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
     9
def gather():
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
    10
    for p in opts.path:
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
    11
        if not os.path.exists(p):
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
    12
            return
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
    13
        if os.path.isdir(p):
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
    14
            yield p + os.path.sep
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
    15
            for dirpath, dirs, files in os.walk(p):
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
    16
                for d in dirs:
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
    17
                    yield os.path.join(dirpath, d) + os.path.sep
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
    18
                for f in files:
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
    19
                    yield os.path.join(dirpath, f)
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
    20
        else:
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
    21
            yield p
aa905f9cdcda tests: write and use a custom helper script to avoid find's -printf
Augie Fackler <augie@google.com>
parents:
diff changeset
    22
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 35380
diff changeset
    23
35380
acff41957b34 tests: stabilize the sorted output of list-tree.py on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 35217
diff changeset
    24
print('\n'.join(sorted(gather(), key=lambda x: x.replace(os.path.sep, '/'))))