perftweaks: fold the logging of merge.update size/distance to core

Reviewed By: quark-zju

Differential Revision: D10414507

fbshipit-source-id: c0ba6d211b9c6906d4d559c7950e02db60d9ea40
This commit is contained in:
Phil Cohen 2018-10-17 12:00:50 -07:00 committed by Facebook Github Bot
parent df5ae52c75
commit b97edbc86f
2 changed files with 24 additions and 16 deletions

View File

@ -46,8 +46,6 @@ def extsetup(ui):
wrapfunction(branchmap, "replacecache", _branchmapreplacecache)
wrapfunction(branchmap, "updatecache", _branchmapupdatecache)
wrapfunction(merge, "update", _trackupdatesize)
try:
rebase = extensions.find("rebase")
wrapfunction(rebase.rebaseruntime, "_preparenewrebase", _trackrebasesize)
@ -304,20 +302,6 @@ def _savepreloadrevs(repo, name, revs):
pass
def _trackupdatesize(orig, repo, node, branchmerge, *args, **kwargs):
if not branchmerge:
try:
distance = len(repo.revs("(%s %% .) + (. %% %s)", node, node))
repo.ui.log("update_size", "", update_distance=distance)
except Exception:
# error may happen like: RepoLookupError: unknown revision '-1'
pass
stats = orig(repo, node, branchmerge, *args, **kwargs)
repo.ui.log("update_size", "", update_filecount=sum(stats))
return stats
def _trackrebasesize(orig, self, destmap):
result = orig(self, destmap)
if not destmap:

View File

@ -1905,6 +1905,23 @@ def recordupdates(repo, actions, branchmerge):
prog.value += 1
def _logupdatedistance(ui, repo, node, branchmerge):
"""Logs the update distance, if configured"""
# internal config: merge.recordupdatedistance
if not ui.configbool("merge", "recordupdatedistance", default=True):
return
if branchmerge:
return
try:
distance = len(repo.revs("(%s %% .) + (. %% %s)", node, node))
repo.ui.log("update_size", "", update_distance=distance)
except Exception:
# error may happen like: RepoLookupError: unknown revision '-1'
pass
@util.timefunction("mergeupdate", 0, "ui")
def update(
repo,
@ -1991,6 +2008,9 @@ def update(
partial = False
else:
partial = True
_logupdatedistance(repo.ui, repo, node, branchmerge)
with repo.wlock():
if wc is None:
wc = repo[None]
@ -2245,6 +2265,10 @@ def update(
if not partial:
repo.hook("update", parent1=xp1, parent2=xp2, error=stats[3])
# Log the number of files updated.
repo.ui.log("update_size", "", update_filecount=sum(stats))
return stats