Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

GitPlugin: ported code from TracMercurial in trac:changeset:6461

  • Loading branch information...
commit ca75505a23f9dcc59e7018e4c0b35b0b1810b5ac 1 parent 86be229
Herbert Valerio Riedel authored March 07, 2010

Showing 1 changed file with 27 additions and 11 deletions. Show diff stats Hide diff stats

  1. 38  tracext/git/git_fs.py
38  tracext/git/git_fs.py
@@ -84,16 +84,32 @@ def __init__(self):
84 84
                                 self.log.error("GIT version %s installed not compatible (need >= %s)" %
85 85
                                                (self._version['v_str'], self._version['v_min_str']))
86 86
 
87  
-        def _format_sha_link(self, formatter, ns, sha, label, fullmatch=None):
88  
-                try:
89  
-                        changeset = self.env.get_repository().get_changeset(sha)
90  
-                        return tag.a(label, class_="changeset",
91  
-                                     title=shorten_line(changeset.message),
92  
-                                     href=formatter.href.changeset(sha))
93  
-                except TracError, e:
94  
-                        return tag.a(label, class_="missing changeset",
95  
-                                     href=formatter.href.changeset(sha),
96  
-                                     title=unicode(e), rel="nofollow")
  87
+        def _format_sha_link(self, formatter, ns, sha, label, context=None):
  88
+		reponame = ''
  89
+		if context is None:
  90
+			context = formatter.context
  91
+		if formatter is None:
  92
+			formatter = context # hack
  93
+		while context:
  94
+			if context.resource.realm in ('source', 'changeset'):
  95
+				reponame = context.resource.parent.id
  96
+				break
  97
+			context = context.parent
  98
+		repos = self.env.get_repository(reponame)
  99
+		if repos:
  100
+			try:
  101
+				changeset = repos.get_changeset(sha)
  102
+				return tag.a(label, class_="changeset",
  103
+					     title=shorten_line(changeset.message),
  104
+					     href=formatter.href.changeset(sha, reponame))
  105
+			except Exception, e:
  106
+				errmsg = to_unicode(e)
  107
+		else:
  108
+			errmsg = "Repository '%s' not found" % reponame
  109
+
  110
+		return tag.a(label, class_="missing changeset",
  111
+			     #href=formatter.href.changeset(sha, reponame),
  112
+			     title=to_unicode(errmsg), rel="nofollow")
97 113
 
98 114
         #######################
99 115
         # IPropertyRenderer
@@ -108,7 +124,7 @@ def match_property(self, name, mode):
108 124
 
109 125
         def render_property(self, name, mode, context, props):
110 126
                 def sha_link(sha):
111  
-                        return self._format_sha_link(context, 'sha', sha, sha)
  127
+                        return self._format_sha_link(None, 'sha', sha, sha, context=context)
112 128
 
113 129
                 if name in ('Parents','Children'):
114 130
                         revs = props[name]

0 notes on commit ca75505

Please sign in to comment.
Something went wrong with that request. Please try again.