mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 17:27:53 +03:00
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:
parent
df5ae52c75
commit
b97edbc86f
@ -46,8 +46,6 @@ def extsetup(ui):
|
|||||||
wrapfunction(branchmap, "replacecache", _branchmapreplacecache)
|
wrapfunction(branchmap, "replacecache", _branchmapreplacecache)
|
||||||
wrapfunction(branchmap, "updatecache", _branchmapupdatecache)
|
wrapfunction(branchmap, "updatecache", _branchmapupdatecache)
|
||||||
|
|
||||||
wrapfunction(merge, "update", _trackupdatesize)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rebase = extensions.find("rebase")
|
rebase = extensions.find("rebase")
|
||||||
wrapfunction(rebase.rebaseruntime, "_preparenewrebase", _trackrebasesize)
|
wrapfunction(rebase.rebaseruntime, "_preparenewrebase", _trackrebasesize)
|
||||||
@ -304,20 +302,6 @@ def _savepreloadrevs(repo, name, revs):
|
|||||||
pass
|
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):
|
def _trackrebasesize(orig, self, destmap):
|
||||||
result = orig(self, destmap)
|
result = orig(self, destmap)
|
||||||
if not destmap:
|
if not destmap:
|
||||||
|
@ -1905,6 +1905,23 @@ def recordupdates(repo, actions, branchmerge):
|
|||||||
prog.value += 1
|
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")
|
@util.timefunction("mergeupdate", 0, "ui")
|
||||||
def update(
|
def update(
|
||||||
repo,
|
repo,
|
||||||
@ -1991,6 +2008,9 @@ def update(
|
|||||||
partial = False
|
partial = False
|
||||||
else:
|
else:
|
||||||
partial = True
|
partial = True
|
||||||
|
|
||||||
|
_logupdatedistance(repo.ui, repo, node, branchmerge)
|
||||||
|
|
||||||
with repo.wlock():
|
with repo.wlock():
|
||||||
if wc is None:
|
if wc is None:
|
||||||
wc = repo[None]
|
wc = repo[None]
|
||||||
@ -2245,6 +2265,10 @@ def update(
|
|||||||
|
|
||||||
if not partial:
|
if not partial:
|
||||||
repo.hook("update", parent1=xp1, parent2=xp2, error=stats[3])
|
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
|
return stats
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user