diff --git a/repo-scripts/make-reference b/repo-scripts/make-reference index 2e0076fa9c33b4d4a8283dd1dd90554492c78b76_cmVwby1zY3JpcHRzL21ha2UtcmVmZXJlbmNl..20a9a4d5c6b96607b1d2b1936b8eb1fcaad09ff5_cmVwby1zY3JpcHRzL21ha2UtcmVmZXJlbmNl 100755 --- a/repo-scripts/make-reference +++ b/repo-scripts/make-reference @@ -13,6 +13,47 @@ import yaml +def gather_repo_stats(repo, repo_id, repo_source): + """ Gather repo related stats + """ + hgversion = shell_exec(["hg", "version", "-T", "{ver}"]) + + numrevs = count_line_exec(["hg", "-R", repo, "log", "-T", "{rev}\n"]) + numrevshidden = count_line_exec( + ["hg", "-R", repo, "--hidden", "log", "-T", "{rev}\n"] + ) + + numheads = count_line_exec( + ["hg", "-R", repo, "heads", "-t", "-T", "{rev}\n"] + ) + numheadshidden = count_line_exec( + ["hg", "-R", repo, "--hidden", "heads", "-t", "-T", "{rev}\n"] + ) + + numbranches = count_line_exec( + ["hg", "-R", repo, "branches", "-c", "-T", "{rev}\n"] + ) + numbrancheshidden = count_line_exec( + ["hg", "-R", repo, "--hidden", "branches", "-c", "-T", "{rev}\n"] + ) + + # Generate YAML file + return { + "reference-repo": { + "id": repo_id, + "enabled": True, + "source": repo_source, + "hg-version": hgversion, + "number-revisions": {"visible": numrevs, "all": numrevshidden}, + "number-heads": {"visible": numheads, "all": numheadshidden}, + "number-named-branch": { + "visible": numbranches, + "all": numbrancheshidden, + }, + } + } + + def shell_exec(command, env=None): # Simulate bash script printing the commands it runs process = subprocess.Popen( @@ -64,42 +105,7 @@ shell_exec(["hg", "-R", repo_main, "debugupdatecache"]) ### Compute stats - hgversion = shell_exec(["hg", "version", "-T", "{ver}"]) - - numrevs = count_line_exec(["hg", "-R", repo_main, "log", "-T", "{rev}\n"]) - numrevshidden = count_line_exec( - ["hg", "-R", repo_main, "--hidden", "log", "-T", "{rev}\n"] - ) - - numheads = count_line_exec( - ["hg", "-R", repo_main, "heads", "-t", "-T", "{rev}\n"] - ) - numheadshidden = count_line_exec( - ["hg", "-R", repo_main, "--hidden", "heads", "-t", "-T", "{rev}\n"] - ) - - numbranches = count_line_exec( - ["hg", "-R", repo_main, "branches", "-c", "-T", "{rev}\n"] - ) - numbrancheshidden = count_line_exec( - ["hg", "-R", repo_main, "--hidden", "branches", "-c", "-T", "{rev}\n"] - ) - - # Generate YAML file - data = { - "reference-repo": { - "id": repo_id, - "enabled": True, - "source": repo_source, - "hg-version": hgversion, - "number-revisions": {"visible": numrevs, "all": numrevshidden}, - "number-heads": {"visible": numheads, "all": numheadshidden}, - "number-named-branch": { - "visible": numbranches, - "all": numbrancheshidden, - }, - } - } + data = gather_repo_stats(repo_main, repo_id, repo_source) # Write data to the benchrepo file with open(repo_details, "w") as repo_details_file: