Skip to content
Snippets Groups Projects
Commit 20a9a4d5c6b9 authored by Boris Feld's avatar Boris Feld
Browse files

Extract repo stats gathering in its own function

parent 2e0076fa9c33
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment