metrics/params: show: add hide_workspace flag

This commit is contained in:
Ruslan Kuprieiev
2023-01-09 16:57:18 +02:00
parent 435407185f
commit b25ef5cdfb
4 changed files with 30 additions and 36 deletions
+3 -8
View File
@@ -11,14 +11,9 @@ def diff(repo, *args, a_rev=None, b_rev=None, **kwargs):
a_rev = a_rev or "HEAD"
b_rev = b_rev or "workspace"
metrics = repo.metrics.show(*args, **kwargs, revs=[a_rev, b_rev])
# workspace may have been replaced by active branch
workspace_rev = (a_rev == "workspace") or (b_rev == "workspace")
if workspace_rev and "workspace" not in metrics:
active_branch = repo.scm.active_branch()
if active_branch in metrics:
metrics["workspace"] = metrics[active_branch]
metrics = repo.metrics.show(
*args, **kwargs, revs=[a_rev, b_rev], hide_workspace=False
)
old = metrics.get(a_rev, {}).get("data", {})
new = metrics.get(b_rev, {}).get("data", {})
+12 -10
View File
@@ -124,6 +124,7 @@ def show(
revs=None,
all_commits=False,
onerror=None,
hide_workspace=True,
):
if onerror is None:
onerror = onerror_collect
@@ -142,16 +143,17 @@ def show(
repo, targets, rev, recursive, onerror=onerror
)
# Hide workspace metrics if they are the same as in the active branch
try:
active_branch = repo.scm.active_branch()
except (SCMError, NoSCMError):
# SCMError - detached head
# NoSCMError - no repo case
pass
else:
if res.get("workspace") == res.get(active_branch):
res.pop("workspace", None)
if hide_workspace:
# Hide workspace metrics if they are the same as in the active branch
try:
active_branch = repo.scm.active_branch()
except (SCMError, NoSCMError):
# SCMError - detached head
# NoSCMError - no repo case
pass
else:
if res.get("workspace") == res.get(active_branch):
res.pop("workspace", None)
errored = errored_revisions(res)
if errored:
+3 -8
View File
@@ -11,14 +11,9 @@ def diff(repo, *args, a_rev=None, b_rev=None, **kwargs):
a_rev = a_rev or "HEAD"
b_rev = b_rev or "workspace"
params = repo.params.show(*args, **kwargs, revs=[a_rev, b_rev])
# workspace may have been replaced by active branch
workspace_rev = (a_rev == "workspace") or (b_rev == "workspace")
if workspace_rev and "workspace" not in params:
active_branch = repo.scm.active_branch()
if active_branch in params:
params["workspace"] = params[active_branch]
params = repo.params.show(
*args, **kwargs, revs=[a_rev, b_rev], hide_workspace=False
)
old = params.get(a_rev, {}).get("data", {})
new = params.get(b_rev, {}).get("data", {})
+12 -10
View File
@@ -144,6 +144,7 @@ def show(
deps=False,
onerror: Callable = None,
stages=None,
hide_workspace=True,
):
if onerror is None:
onerror = onerror_collect
@@ -165,16 +166,17 @@ def show(
if params:
res[branch] = params
# Hide workspace params if they are the same as in the active branch
try:
active_branch = repo.scm.active_branch()
except (SCMError, NoSCMError):
# SCMError - detached head
# NoSCMError - no repo case
pass
else:
if res.get("workspace") == res.get(active_branch):
res.pop("workspace", None)
if hide_workspace:
# Hide workspace params if they are the same as in the active branch
try:
active_branch = repo.scm.active_branch()
except (SCMError, NoSCMError):
# SCMError - detached head
# NoSCMError - no repo case
pass
else:
if res.get("workspace") == res.get(active_branch):
res.pop("workspace", None)
errored = errored_revisions(res)
if errored: