diff --git a/hgext3rd/perftweaks.py b/hgext3rd/perftweaks.py --- a/hgext3rd/perftweaks.py +++ b/hgext3rd/perftweaks.py @@ -19,6 +19,7 @@ dispatch, extensions, merge, + namespaces, phases, revlog, scmutil, @@ -64,10 +65,29 @@ except KeyError: pass + wrapfunction(namespaces.namespaces, 'singlenode', _singlenode) + def reposetup(ui, repo): if repo.local() is not None: _preloadrevs(repo) +def _singlenode(orig, self, repo, name): + """Skips reading branches namespace if unnecessary""" + if ui.configbool('tweakdefaults', 'allowbranch', True): + return orig(self, repo, name) + + # If branches are disabled, only resolve the 'default' branch. Loading + # 'branches' is O(len(changelog)) time complexity because it calls + # headrevs() which scans the entire changelog. + names = self._names + namesbak = names.copy() + if name != 'default' and 'branches' in names: + del names['branches'] + try: + return orig(self, repo, name) + finally: + self.names = namesbak + def _readtagcache(orig, ui, repo): """Disables reading tags if the repo is known to not contain any.""" if ui.configbool('perftweaks', 'disabletags'):