[PATCH 2 of 2] summary: add subrepository list (to mercurial repositories only)
Angel Ezquerra
angel.ezquerra at gmail.com
Mon Feb 29 01:38:07 UTC 2016
# HG changeset patch
# User Angel Ezquerra <angel.ezquerra at gmail.com>
# Date 1456704273 -3600
# Mon Feb 29 01:04:33 2016 +0100
# Branch stable
# Node ID f9da7a3d92ad5dd9971b51aba7347787320fa60c
# Parent e16bf58e69344c32cfec314efe6d27cd77596e59
summary: add subrepository list (to mercurial repositories only)
Add a list of subrepos to the summary page of mercurial repositories. The list
is presented as a simple table of links to the corresponding repositories. If a
given subrepo is not found on the file system the repository path (with not
link) is shown instead.
The code is prepared to add support for git submodules, but for now only
mercurial repositories are supported.
diff --git a/kallithea/controllers/changelog.py b/kallithea/controllers/changelog.py
--- a/kallithea/controllers/changelog.py
+++ b/kallithea/controllers/changelog.py
@@ -27,6 +27,8 @@
import logging
import traceback
+import os
+from collections import namedtuple
from pylons import request, url, session, tmpl_context as c
from pylons.controllers.util import redirect
@@ -65,6 +67,16 @@
c.statuses = c.db_repo.statuses(page_revisions)
c.comment_counts = c.db_repo.count_comments(c.comments)
+ # get the nested repo information (only mercurial is supported for now)
+ c.nested_repos = []
+ if collection.scm == 'hg':
+ def nested_repo_exists(repo_path):
+ return os.path.exists(os.path.join(collection.path, repo_path))
+ nested_repo = namedtuple('nested_repo', ['path', 'exists'])
+ c.nested_repos = [
+ nested_repo(path=repo_name,
+ exists=nested_repo_exists(repo_name))
+ for repo_name in collection.subrepos()]
class ChangelogController(BaseRepoController):
diff --git a/kallithea/templates/summary/summary.html b/kallithea/templates/summary/summary.html
--- a/kallithea/templates/summary/summary.html
+++ b/kallithea/templates/summary/summary.html
@@ -179,6 +179,40 @@
</div>
+%if c.nested_repos:
+ <%
+ if h.is_hg(c.db_repo_scm_instance):
+ nested_repo_title = _("Subrepository list")
+ nested_repo_tooltip = _('Subrepository %s')
+ else:
+ nested_repo_title = _("Submodule list")
+ nested_repo_tooltip = _('Submodule %s')
+ %>
+ <div class="box">
+ <div class="title">
+ <div class="breadcrumbs">
+ ${nested_repo_title}
+ </div>
+ </div>
+ <div class="table">
+ <table>
+ %for nested_repo in c.nested_repos:
+ <tr><td>
+ <div class="shortlog_data" title="${nested_repo_tooltip % nested_repo.path}">
+ %if nested_repo.exists:
+ ${h.link_to(nested_repo.path, h.url('changelog_home', repo_name=c.repo_name + '/' + nested_repo.path))}
+ %else:
+ ${nested_repo.path}
+ %endif
+ </div>
+ </td></tr>
+ %endfor
+ </table>
+ </div>
+ </div>
+%endif
+
+
<div class="box">
<div class="title">
<div class="breadcrumbs">
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kallithea-2.patch
Type: text/x-patch
Size: 3180 bytes
Desc: not available
URL: <http://lists.sfconservancy.org/pipermail/kallithea-general/attachments/20160229/8bec6577/attachment.bin>
More information about the kallithea-general
mailing list