diff --git a/hgext3rd/perftweaks.py b/hgext3rd/perftweaks.py --- a/hgext3rd/perftweaks.py +++ b/hgext3rd/perftweaks.py @@ -25,6 +25,9 @@ tags, util, ) +from hgext import ( + rebase, +) from mercurial.extensions import wrapfunction from mercurial.node import bin, nullid, nullrev import errno @@ -42,6 +45,7 @@ wrapfunction(dispatch, 'runcommand', _trackdirstatesizes) wrapfunction(dispatch, 'runcommand', _tracksparseprofiles) wrapfunction(merge, 'update', _trackupdatesize) + wrapfunction(rebase.rebaseruntime, '_preparenewrebase', _trackrebasesize) # noderev cache creation # The node rev cache is a cache of rev numbers that we are likely to do a @@ -277,3 +281,19 @@ stats = orig(repo, node, branchmerge, *args, **kwargs) repo.ui.log('update_size', '', update_filecount=sum(stats)) return stats + +def _trackrebasesize(orig, self, dest, rebaseset): + result = orig(self, dest, rebaseset) + + repo = self.repo + destrev = dest.rev() + commitcount = len(rebaseset) + distance = len(repo.revs('(%ld %% %d) + (%d %% %ld)', + rebaseset, destrev, destrev, rebaseset)) + repo.ui.log('rebase_size', '', rebase_commitcount=commitcount) + # Distance includes the commits being rebased, so subtract them to get the + # actual distance being traveled. Even though we log update_distance above, + # a rebase may run multiple updates, so that value might be not be accurate. + repo.ui.log('rebase_size', '', rebase_distance=distance - commitcount) + + return result