Skip to content
This repository has been archived by the owner on May 22, 2019. It is now read-only.

Commit

Permalink
GitPlugin: ported code from TracMercurial in trac:changeset:6461
Browse files Browse the repository at this point in the history
  • Loading branch information
hvr committed Mar 7, 2010
1 parent 86be229 commit ca75505
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions tracext/git/git_fs.py
Expand Up @@ -84,16 +84,32 @@ def __init__(self):
self.log.error("GIT version %s installed not compatible (need >= %s)" % self.log.error("GIT version %s installed not compatible (need >= %s)" %
(self._version['v_str'], self._version['v_min_str'])) (self._version['v_str'], self._version['v_min_str']))


def _format_sha_link(self, formatter, ns, sha, label, fullmatch=None): def _format_sha_link(self, formatter, ns, sha, label, context=None):
try: reponame = ''
changeset = self.env.get_repository().get_changeset(sha) if context is None:
return tag.a(label, class_="changeset", context = formatter.context
title=shorten_line(changeset.message), if formatter is None:
href=formatter.href.changeset(sha)) formatter = context # hack
except TracError, e: while context:
return tag.a(label, class_="missing changeset", if context.resource.realm in ('source', 'changeset'):
href=formatter.href.changeset(sha), reponame = context.resource.parent.id
title=unicode(e), rel="nofollow") break
context = context.parent
repos = self.env.get_repository(reponame)
if repos:
try:
changeset = repos.get_changeset(sha)
return tag.a(label, class_="changeset",
title=shorten_line(changeset.message),
href=formatter.href.changeset(sha, reponame))
except Exception, e:
errmsg = to_unicode(e)
else:
errmsg = "Repository '%s' not found" % reponame

return tag.a(label, class_="missing changeset",
#href=formatter.href.changeset(sha, reponame),
title=to_unicode(errmsg), rel="nofollow")


####################### #######################
# IPropertyRenderer # IPropertyRenderer
Expand All @@ -108,7 +124,7 @@ def match_property(self, name, mode):


def render_property(self, name, mode, context, props): def render_property(self, name, mode, context, props):
def sha_link(sha): def sha_link(sha):
return self._format_sha_link(context, 'sha', sha, sha) return self._format_sha_link(None, 'sha', sha, sha, context=context)


if name in ('Parents','Children'): if name in ('Parents','Children'):
revs = props[name] revs = props[name]
Expand Down

0 comments on commit ca75505

Please sign in to comment.