diff --git a/kallithea/controllers/feed.py b/kallithea/controllers/feed.py
--- a/kallithea/controllers/feed.py
+++ b/kallithea/controllers/feed.py
@@ -63,8 +63,8 @@ class FeedController(BaseRepoController)
desc_msg = [(_('%s committed on %s')
% (h.person(cs.author), h.fmt_date(cs.date))) + '
']
# branches, tags, bookmarks
- if cs.branch:
- desc_msg.append('branch: %s
' % cs.branch)
+ for branch in cs.branches:
+ desc_msg.append('branch: %s
' % branch)
for book in cs.bookmarks:
desc_msg.append('bookmark: %s
' % book)
for tag in cs.tags:
diff --git a/kallithea/controllers/files.py b/kallithea/controllers/files.py
--- a/kallithea/controllers/files.py
+++ b/kallithea/controllers/files.py
@@ -189,7 +189,7 @@ class FilesController(BaseRepoController
# TODO: tags and bookmarks?
c.revision_options = [(c.changeset.raw_id,
- _('%s at %s') % (c.changeset.branch, h.short_id(c.changeset.raw_id)))] + \
+ _('%s at %s') % (b, h.short_id(c.changeset.raw_id))) for b in c.changeset.branches] + \
[(n, b) for b, n in c.db_repo_scm_instance.branches.items()]
if c.db_repo_scm_instance.closed_branches:
prefix = _('(closed)') + ' '
@@ -755,7 +755,7 @@ class FilesController(BaseRepoController
branches_group = ([], _("Branches"))
tags_group = ([], _("Tags"))
for chs in changesets:
- #_branch = '(%s)' % chs.branch if (cs.repository.alias == 'hg') else ''
+ # TODO: loop over chs.branches ... but that will not give all the bogus None branches for Git ...
_branch = chs.branch
n_desc = '%s (%s)' % (h.show_id(chs), _branch)
changesets_group[0].append((chs.raw_id, n_desc,))
diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py
--- a/kallithea/controllers/pullrequests.py
+++ b/kallithea/controllers/pullrequests.py
@@ -102,11 +102,11 @@ class PullrequestsController(BaseRepoCon
for i in repo._repo.revs(
"sort(parents(branch(id(%s)) and merge()) - branch(id(%s)), -rev)",
branch_rev, branch_rev):
- abranch = repo.get_changeset(i).branch
- if abranch not in peerbranches:
- n = 'branch:%s:%s' % (abranch, repo.get_changeset(abranch).raw_id)
- peers.append((n, abranch))
- peerbranches.add(abranch)
+ for abranch in repo.get_changeset(i).branches:
+ if abranch not in peerbranches:
+ n = 'branch:%s:%s' % (abranch, repo.get_changeset(abranch).raw_id)
+ peers.append((n, abranch))
+ peerbranches.add(abranch)
selected = None
tiprev = repo.tags.get('tip')
diff --git a/kallithea/lib/vcs/backends/base.py b/kallithea/lib/vcs/backends/base.py
--- a/kallithea/lib/vcs/backends/base.py
+++ b/kallithea/lib/vcs/backends/base.py
@@ -1038,6 +1038,11 @@ class EmptyChangeset(BaseChangeset):
return get_backend(self.alias).DEFAULT_BRANCH_NAME
@LazyProperty
+ def branches(self):
+ from kallithea.lib.vcs.backends import get_backend
+ return [get_backend(self.alias).DEFAULT_BRANCH_NAME]
+
+ @LazyProperty
def short_id(self):
return self.raw_id[:12]
diff --git a/kallithea/lib/vcs/backends/git/changeset.py b/kallithea/lib/vcs/backends/git/changeset.py
--- a/kallithea/lib/vcs/backends/git/changeset.py
+++ b/kallithea/lib/vcs/backends/git/changeset.py
@@ -91,13 +91,19 @@ class GitChangeset(BaseChangeset):
@LazyProperty
def branch(self):
-
+ # Note: This function will return one branch name for the changeset -
+ # that might not make sense in Git where branches() is a better match
+ # for the basic model
heads = self.repository._heads(reverse=False)
-
ref = heads.get(self.raw_id)
if ref:
return safe_unicode(ref)
+ @LazyProperty
+ def branches(self):
+ heads = self.repository._heads(reverse=True)
+ return [b for b in heads if heads[b] == self.raw_id] # FIXME: Inefficient ... and returning None!
+
def _fix_path(self, path):
"""
Paths are stored without trailing slash so we need to get rid off it if
diff --git a/kallithea/lib/vcs/backends/hg/changeset.py b/kallithea/lib/vcs/backends/hg/changeset.py
--- a/kallithea/lib/vcs/backends/hg/changeset.py
+++ b/kallithea/lib/vcs/backends/hg/changeset.py
@@ -41,6 +41,10 @@ class MercurialChangeset(BaseChangeset):
return safe_unicode(self._ctx.branch())
@LazyProperty
+ def branches(self):
+ return [safe_unicode(self._ctx.branch())]
+
+ @LazyProperty
def closesbranch(self):
return self._ctx.closesbranch()
diff --git a/kallithea/templates/changelog/changelog_table.html b/kallithea/templates/changelog/changelog_table.html
--- a/kallithea/templates/changelog/changelog_table.html
+++ b/kallithea/templates/changelog/changelog_table.html
@@ -97,8 +97,10 @@
%if cs.phase:
${cs.phase}
%endif
- %if show_branch and cs.branch:
- ${h.link_to(cs.branch,h.url('changelog_home',repo_name=repo_name,branch=cs.branch))}
+ %if show_branch:
+ %for branch in cs.branches:
+ ${h.link_to(branch,h.url('changelog_home',repo_name=repo_name,branch=branch))}
+ %endfor
%endif
diff --git a/kallithea/templates/changeset/changeset.html b/kallithea/templates/changeset/changeset.html
--- a/kallithea/templates/changeset/changeset.html
+++ b/kallithea/templates/changeset/changeset.html
@@ -68,9 +68,9 @@
${h.link_to(tag,h.url('changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}
%endfor
- %if c.changeset.branch:
- ${h.link_to(c.changeset.branch,h.url('changelog_home',repo_name=c.repo_name,branch=c.changeset.branch))}
- %endif
+ %for branch in c.changeset.branches:
+ ${h.link_to(branch,h.url('changelog_home',repo_name=c.repo_name,branch=branch))}
+ %endfor