diff --git a/hgext3rd/perftweaks.py b/hgext3rd/perftweaks.py --- a/hgext3rd/perftweaks.py +++ b/hgext3rd/perftweaks.py @@ -79,6 +79,27 @@ if repo.local() is not None: _preloadrevs(repo) + # developer config: perftweaks.disableupdatebranchcacheoncommit + if repo.ui.configbool('perftweaks', 'disableupdatebranchcacheoncommit'): + class perftweaksrepo(repo.__class__): + @localrepo.unfilteredmethod + def updatecaches(self, tr=None): + # Disable "branchmap.updatecache(self.filtered('served'))" + # code path guarded by "if tr.changes['revs']". First, we + # don't have on-disk branchmap. Second, accessing + # "repo.filtered('served')" alone is not very cheap. + bakrevs = None + if tr and 'revs' in tr.changes: + bakrevs = tr.changes['revs'] + tr.changes['revs'] = frozenset() + try: + super(perftweaksrepo, self).updatecaches(tr) + finally: + if bakrevs: + tr.changes['revs'] = bakrevs + + repo.__class__ = perftweaksrepo + def _singlenode(orig, self, repo, name): """Skips reading branches namespace if unnecessary""" # developer config: perftweaks.disableresolvingbranches diff --git a/tests/test-perftweaks.t b/tests/test-perftweaks.t --- a/tests/test-perftweaks.t +++ b/tests/test-perftweaks.t @@ -120,6 +120,23 @@ $ echo D > D $ hg commit -m D -A D --config perftweaks.disableheaddetection=1 +Test disabling updating branchcache during commit + + $ $TESTDIR/ls-l.py .hg/cache | grep branch + -rw-r--r-- 196 branch2-served + + $ rm -f .hg/cache/branch* + $ echo D >> D + $ hg commit -m D2 + $ $TESTDIR/ls-l.py .hg/cache | grep branch + -rw-r--r-- 196 branch2-served + + $ rm -f .hg/cache/branch* + $ echo D >> D + $ hg commit -m D3 --config perftweaks.disableupdatebranchcacheoncommit=1 --config perftweaks.disableheaddetection=1 + $ $TESTDIR/ls-l.py .hg/cache | grep branch + [1] + $ cd .. Test changing the delta heuristic