Browse files

Extend CachedChangeset and modify CachedRepo for get_branches

Trac's CachedChangeset does not implement get_branches, which is
required to show branch information on the timeline.  This commit
creates a CachedChangeset2 which GitPlugin's CachedRepository2
returns when asked for a changeset.  The new class uses GitPlugin's
internal rev_cache to speed up the branch information retrieval
(shamelessly copied from GitChangeset.get_branches)
  • Loading branch information...
1 parent 5cbdfd9 commit 3da8eeacbb6e381748876069d1fcaa1d06a64120 @scbash scbash committed Oct 20, 2010
Showing with 10 additions and 1 deletion.
  1. +10 −1 tracext/git/
@@ -19,7 +19,7 @@
from trac.versioncontrol.api import \
Changeset, Node, Repository, IRepositoryConnector, NoSuchChangeset, NoSuchNode
from import IWikiSyntaxProvider
-from trac.versioncontrol.cache import CachedRepository
+from trac.versioncontrol.cache import CachedRepository, CachedChangeset
from trac.versioncontrol.web_ui import IPropertyRenderer
from trac.config import BoolOption, IntOption, PathOption, Option
from import Chrome
@@ -46,7 +46,16 @@ def normalize_rev(self, rev):
if normrev is None:
raise NoSuchChangeset(rev)
return normrev
+ def get_changeset(self, rev):
+ return CachedChangeset2(self, self.normalize_rev(rev), self.env)
+class CachedChangeset2(CachedChangeset):
+ def get_branches(self):
+ _rev = self.rev
+ return [ (k, v == _rev) for k, v in
+ self.repos.repos.git.get_branch_contains(_rev, resolve=True) ]
def _last_iterable(iterable):
"helper for detecting last iteration in for-loop"

0 comments on commit 3da8eea

Please sign in to comment.