# HG changeset patch # User Andrew Shu # Date 1309888215 14400 # Tue Jul 05 13:50:15 2011 -0400 # Node ID 46c042e1e1596bd5bda69c4a7998d15b76c382cc # Parent 20252f3f8c0dede8e26c076a25e7c7701f4dd6b6 branchtags caching for speedup in repos with many branches diff --git a/compass.py b/compass.py --- a/compass.py +++ b/compass.py @@ -75,6 +75,8 @@ self.repo = repo self.out_closed = not opts["hide_closed"] self.out_inactive = not opts["hide_inactive"] + self.branchtags_cached = None + self.branchtags_repo = None # all head revisions self.head_revs = _csi2rev(repo, repo.heads()) @@ -141,6 +143,13 @@ return tags, bm + def branchtags(self): + """Get branch tags of the repo, using cache if available.""" + if self.repo != self.branchtags_repo: + self.branchtags_cached = self.repo.branchtags() + self.branchtags_repo = self.repo + return self.branchtags_cached + class BranchInfo(object): """Various information about a branch.""" @@ -148,7 +157,7 @@ self.name = name - self.tip_rev = _csi2rev(ri.repo, ri.repo.branchtags()[name]) + self.tip_rev = _csi2rev(ri.repo, ri.branchtags()[name]) self.head_revs = bh_revs self.head_revs_bm = [x for x in self.head_revs if x in ri.bm_revs] self.head_revs_active = [x for x in self.head_revs if x in ri.head_revs]