[patch] multirepos support for GitPlugin ; submodule "support"

179 views
Skip to first unread message

Yann Dirson

unread,
Sep 30, 2009, 11:21:35 AM9/30/09
to trac...@googlegroups.com
Hi guys,

While the GitPlugin worked nearly fine on a multirepos install, it still
required one slight update, which took me more time to track than to steal
the relevant code from the Hg plugin :)

Also included is a small patchlet which, even if it does not provide
proper support for git submodules, prevents trac from bombing out when it
encounters one. It simply causes the submodule to appear as an empty dir
(which otherwise cannot exist in a git repo).

Also included below a small patch to Trac itself (multirepos branch), to
help the user guessing that what happens may be a lack of multirepos
support.

Now hoping the multirepos branch will be part of 0.12 :)

Best regards,
--
Yann

PS: it would be cool to have GitPlugin hosted in a git repo, that
would make collaboration on it much easier :)

diff --git a/tracext/git/git_fs.py b/tracext/git/git_fs.py
index 720aaea..d09f820 100644
--- a/tracext/git/git_fs.py
+++ b/tracext/git/git_fs.py
@@ -76,7 +76,15 @@ class GitConnector(Component):

def _format_sha_link(self, formatter, ns, sha, label,
fullmatch=None):
try:
- changeset =
self.env.get_repository().get_changeset(sha)
+ reponame = ''
+ context = formatter.context
+ while context:
+ if context.resource.realm in ('source',
'changeset'):
+ reponame = context.resource.id[0]
+ break
+ context = context.parent
+ repo = self.env.get_repository(reponame)
+ changeset = repo.get_changeset(sha)
return tag.a(label, class_="changeset",
title=shorten_line(changeset.message),
href=formatter.href.changeset(sha))
@@ -296,7 +304,7 @@ class GitNode(Node):
# fix-up to the last commit-rev that touched this
node
rev = self.git.last_change(rev, p)

- if k=='tree':
+ if k=='tree' or k=='commit':
pass
elif k=='blob':
kind = Node.FILE


diff --git a/trac/versioncontrol/api.py b/trac/versioncontrol/api.py index
3b6728a..36c7210 100644
--- a/trac/versioncontrol/api.py
+++ b/trac/versioncontrol/api.py
@@ -462,14 +462,17 @@ class RepositoryManager(Component):
rdir = repoinfo.get('dir')
rtype = repoinfo.get('type') or self.repository_type
if not rdir:
+ self.log.warning("directory not found for repo '%s'" %
reponame)
return None
elif reponame:
+ self.log.warning("invalid repo name '%s'" % reponame)
return None
else:
reponame = '' # normalize the name for the default repository
rdir, rtype = self.repository_dir, self.repository_type #
don't try to lookup default repository if not set
if not rdir:
+ self.log.warning("no default directory")
return None

# get a Repository for the reponame (use a thread-level cache)


Reply all
Reply to author
Forward
0 new messages