tests/list-tree.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Tue, 14 Dec 2021 23:56:38 +0100
changeset 48499 52034c42c09d
parent 43076 2372284d9457
child 48875 6000f5b25c9b
permissions -rw-r--r--
rank: add a "rank" value to the revlog-entry tuple The rank of a revision is the size of sub-graph it defines as a head. In other words, the rank of X is the size of `ancestors(X)` (X included). This is a property that can help various algorithm and we intend to store it in changelog-v2. We start with adding this new information to the "entry tuple", with a default value. We will start to compute and persist the rank later. Differential Revision: https://phab.mercurial-scm.org/D11936

from __future__ import (
    absolute_import,
    print_function,
)

import argparse
import os

ap = argparse.ArgumentParser()
ap.add_argument('path', nargs='+')
opts = ap.parse_args()


def gather():
    for p in opts.path:
        if not os.path.exists(p):
            return
        if os.path.isdir(p):
            yield p + os.path.sep
            for dirpath, dirs, files in os.walk(p):
                for d in dirs:
                    yield os.path.join(dirpath, d) + os.path.sep
                for f in files:
                    yield os.path.join(dirpath, f)
        else:
            yield p


print('\n'.join(sorted(gather(), key=lambda x: x.replace(os.path.sep, '/'))))