# HG changeset patch # User Pierre-Yves David <pierre-yves.david@octobus.net> # Date 1533071837 -7200 # Tue Jul 31 23:17:17 2018 +0200 # Node ID d8148c04d494bc0dbb918c97117e97e20c506352 # Parent 09765fb952a4864282f2018fbbc4e375892fd040 partial-repos: get set to remove from a config file Hardcoding stuff creates various issues. Lets move to something more flexible. diff --git a/create_stripped_cached_repos.py b/create_stripped_cached_repos.py --- a/create_stripped_cached_repos.py +++ b/create_stripped_cached_repos.py @@ -7,21 +7,12 @@ import yaml import urllib -# changesets stripped in partial clones -PARTIAL_REVSET = ( - "same", - "last(all(), 10)", - "last(all(), 100)", - "last(all(), 1000)", -) - - def read_configuration(config_path): with open(config_path) as config_file: return yaml.load(config_file.read()) -def clone_repositories(config, repos_dir): +def clone_repositories(config, partial_revset, repos_dir): cachedir = join(repos_dir, ".cache") try: os.makedirs(cachedir) @@ -30,7 +21,9 @@ raise for repo_name, repo in config["repos"].items(): clonedir = join(repos_dir, repo_name) - for revset in PARTIAL_REVSET: + print partial_revset + for pset, setconfig in partial_revset.items(): + revset = setconfig.get('remove') repo_suffix = urllib.quote_plus(revset) partialdir = join(cachedir, "partial-{}-{}".format(repo_name, repo_suffix)) if not isdir(partialdir): @@ -46,7 +39,7 @@ subprocess.check_call( ["hg", "clone", "--noupdate", clonedir, partialdir] ) - if revset != "same": + if revset is not None: subprocess.check_call( [ "hg", @@ -64,6 +57,8 @@ ["hg", "--cwd", partialdir, "debugupdatecache"] ) +partial_revset = read_configuration("partial-sets.yaml") + config = read_configuration("config.yaml") -clone_repositories(config, "repos") +clone_repositories(config, partial_revset['partial-sets'], "repos") diff --git a/partial-sets.yaml b/partial-sets.yaml new file mode 100644 --- /dev/null +++ b/partial-sets.yaml @@ -0,0 +1,8 @@ +partial-sets: + same: + last-ten: + remove: "last(all(), 10)" + last-hundred: + remove: "last(all(), 100)" + last-thousand: + remove: "last(all(), 1000)"