##// END OF EJS Templates
vcs: introduce 'branches' attribute on changesets, making it possible for Git to show multiple branches for a changeset...
Mads Kiilerich -
r7067:3dbb625d default
parent child Browse files
Show More
@@ -63,8 +63,8 b' class FeedController(BaseRepoController)'
63 63 desc_msg = [(_('%s committed on %s')
64 64 % (h.person(cs.author), h.fmt_date(cs.date))) + '<br/>']
65 65 # branches, tags, bookmarks
66 if cs.branch:
67 desc_msg.append('branch: %s<br/>' % cs.branch)
66 for branch in cs.branches:
67 desc_msg.append('branch: %s<br/>' % branch)
68 68 for book in cs.bookmarks:
69 69 desc_msg.append('bookmark: %s<br/>' % book)
70 70 for tag in cs.tags:
@@ -189,7 +189,7 b' class FilesController(BaseRepoController'
189 189
190 190 # TODO: tags and bookmarks?
191 191 c.revision_options = [(c.changeset.raw_id,
192 _('%s at %s') % (c.changeset.branch, h.short_id(c.changeset.raw_id)))] + \
192 _('%s at %s') % (b, h.short_id(c.changeset.raw_id))) for b in c.changeset.branches] + \
193 193 [(n, b) for b, n in c.db_repo_scm_instance.branches.items()]
194 194 if c.db_repo_scm_instance.closed_branches:
195 195 prefix = _('(closed)') + ' '
@@ -755,7 +755,7 b' class FilesController(BaseRepoController'
755 755 branches_group = ([], _("Branches"))
756 756 tags_group = ([], _("Tags"))
757 757 for chs in changesets:
758 #_branch = '(%s)' % chs.branch if (cs.repository.alias == 'hg') else ''
758 # TODO: loop over chs.branches ... but that will not give all the bogus None branches for Git ...
759 759 _branch = chs.branch
760 760 n_desc = '%s (%s)' % (h.show_id(chs), _branch)
761 761 changesets_group[0].append((chs.raw_id, n_desc,))
@@ -102,11 +102,11 b' class PullrequestsController(BaseRepoCon'
102 102 for i in repo._repo.revs(
103 103 "sort(parents(branch(id(%s)) and merge()) - branch(id(%s)), -rev)",
104 104 branch_rev, branch_rev):
105 abranch = repo.get_changeset(i).branch
106 if abranch not in peerbranches:
107 n = 'branch:%s:%s' % (abranch, repo.get_changeset(abranch).raw_id)
108 peers.append((n, abranch))
109 peerbranches.add(abranch)
105 for abranch in repo.get_changeset(i).branches:
106 if abranch not in peerbranches:
107 n = 'branch:%s:%s' % (abranch, repo.get_changeset(abranch).raw_id)
108 peers.append((n, abranch))
109 peerbranches.add(abranch)
110 110
111 111 selected = None
112 112 tiprev = repo.tags.get('tip')
@@ -1038,6 +1038,11 b' class EmptyChangeset(BaseChangeset):'
1038 1038 return get_backend(self.alias).DEFAULT_BRANCH_NAME
1039 1039
1040 1040 @LazyProperty
1041 def branches(self):
1042 from kallithea.lib.vcs.backends import get_backend
1043 return [get_backend(self.alias).DEFAULT_BRANCH_NAME]
1044
1045 @LazyProperty
1041 1046 def short_id(self):
1042 1047 return self.raw_id[:12]
1043 1048
@@ -91,13 +91,19 b' class GitChangeset(BaseChangeset):'
91 91
92 92 @LazyProperty
93 93 def branch(self):
94
94 # Note: This function will return one branch name for the changeset -
95 # that might not make sense in Git where branches() is a better match
96 # for the basic model
95 97 heads = self.repository._heads(reverse=False)
96
97 98 ref = heads.get(self.raw_id)
98 99 if ref:
99 100 return safe_unicode(ref)
100 101
102 @LazyProperty
103 def branches(self):
104 heads = self.repository._heads(reverse=True)
105 return [b for b in heads if heads[b] == self.raw_id] # FIXME: Inefficient ... and returning None!
106
101 107 def _fix_path(self, path):
102 108 """
103 109 Paths are stored without trailing slash so we need to get rid off it if
@@ -41,6 +41,10 b' class MercurialChangeset(BaseChangeset):'
41 41 return safe_unicode(self._ctx.branch())
42 42
43 43 @LazyProperty
44 def branches(self):
45 return [safe_unicode(self._ctx.branch())]
46
47 @LazyProperty
44 48 def closesbranch(self):
45 49 return self._ctx.closesbranch()
46 50
@@ -97,8 +97,10 b''
97 97 %if cs.phase:
98 98 <span class="label label-phase" title="Phase">${cs.phase}</span>
99 99 %endif
100 %if show_branch and cs.branch:
101 <span class="label label-branch" title="${_('Branch %s' % cs.branch)}">${h.link_to(cs.branch,h.url('changelog_home',repo_name=repo_name,branch=cs.branch))}</span>
100 %if show_branch:
101 %for branch in cs.branches:
102 <span class="label label-branch" title="${_('Branch %s' % branch)}">${h.link_to(branch,h.url('changelog_home',repo_name=repo_name,branch=branch))}</span>
103 %endfor
102 104 %endif
103 105 </div>
104 106 </div>
@@ -68,9 +68,9 b''
68 68 <span class="label label-tag" title="${_('Tag %s') % tag}">${h.link_to(tag,h.url('changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</span>
69 69 %endfor
70 70
71 %if c.changeset.branch:
72 <span class="label label-branch" title="${_('Branch %s') % c.changeset.branch}">${h.link_to(c.changeset.branch,h.url('changelog_home',repo_name=c.repo_name,branch=c.changeset.branch))}</span>
73 %endif
71 %for branch in c.changeset.branches:
72 <span class="label label-branch" title="${_('Branch %s') % branch}">${h.link_to(branch,h.url('changelog_home',repo_name=c.repo_name,branch=branch))}</span>
73 %endfor
74 74 </span>
75 75
76 76 <div class="changes">
@@ -90,11 +90,11 b''
90 90 <span class="label label-tag" title="${_('Tag %s') % tag}">
91 91 ${h.link_to(tag,h.url('changeset_home',repo_name=c.cs_repo.repo_name,revision=cs.raw_id))}</span>
92 92 %endfor
93 %if cs.branch:
94 <span class="label label-branch" title="${_('Branch %s') % cs.branch}">
95 ${h.link_to(cs.branch,h.url('changeset_home',repo_name=c.cs_repo.repo_name,revision=cs.raw_id))}
96 </span>
97 %endif
93 %for branch in cs.branches:
94 <span class="label label-branch" title="${_('Branch %s') % branch}">
95 ${h.link_to(branch,h.url('changeset_home',repo_name=c.cs_repo.repo_name,revision=cs.raw_id))}
96 </span>
97 %endfor
98 98 </span>
99 99 </div>
100 100 </div>
@@ -53,6 +53,7 b' class BranchesTestCaseMixin(_BackendTest'
53 53 )
54 54 assert 'foobar' in self.repo.branches
55 55 assert foobar_tip.branch == 'foobar'
56 assert foobar_tip.branches == ['foobar']
56 57
57 58 def test_new_head(self):
58 59 tip = self.repo.get_changeset()
@@ -81,6 +82,7 b' class BranchesTestCaseMixin(_BackendTest'
81 82 )
82 83
83 84 assert newest_tip.branch == self.backend_class.DEFAULT_BRANCH_NAME
85 assert newest_tip.branches == [self.backend_class.DEFAULT_BRANCH_NAME]
84 86
85 87 def test_branch_with_slash_in_name(self):
86 88 self.imc.add(vcs.nodes.FileNode('extrafile', content='Some data\n'))
@@ -78,6 +78,7 b' class _ChangesetsWithCommitsTestCaseixin'
78 78 )
79 79 assert 'foobar' in self.repo.branches
80 80 assert foobar_tip.branch == 'foobar'
81 assert foobar_tip.branches == ['foobar']
81 82 # 'foobar' should be the only branch that contains the new commit
82 83 branch_tips = self.repo.branches.values()
83 84 assert branch_tips.count(str(foobar_tip.raw_id)) == 1
@@ -109,6 +110,7 b' class _ChangesetsWithCommitsTestCaseixin'
109 110 )
110 111
111 112 assert newest_tip.branch == self.backend_class.DEFAULT_BRANCH_NAME
113 assert newest_tip.branches == [self.backend_class.DEFAULT_BRANCH_NAME]
112 114
113 115 def test_get_changesets_respects_branch_name(self):
114 116 tip = self.repo.get_changeset()
@@ -309,16 +309,19 b' class TestGitChangeset(object):'
309 309 rev0 = self.repo.revisions[0]
310 310 chset0 = self.repo.get_changeset(rev0)
311 311 assert chset0.branch is None # should be 'master'?
312 assert chset0.branches == [] # should be 'master'?
312 313 assert chset0.tags == []
313 314
314 315 rev10 = self.repo.revisions[10]
315 316 chset10 = self.repo.get_changeset(rev10)
316 317 assert chset10.branch is None # should be 'master'?
318 assert chset10.branches == [] # should be 'master'?
317 319 assert chset10.tags == []
318 320
319 321 rev44 = self.repo.revisions[44]
320 322 chset44 = self.repo.get_changeset(rev44)
321 323 assert chset44.branch is None # should be 'web-branch'?
324 assert chset44.branches == [] # should be 'web-branch'?
322 325
323 326 tip = self.repo.get_changeset('tip')
324 327 assert 'tip' not in tip.tags # it should be?
@@ -320,14 +320,17 b' class TestMercurialChangeset(object):'
320 320 def test_branch_and_tags(self):
321 321 chset0 = self.repo.get_changeset(0)
322 322 assert chset0.branch == 'default'
323 assert chset0.branches == ['default']
323 324 assert chset0.tags == []
324 325
325 326 chset10 = self.repo.get_changeset(10)
326 327 assert chset10.branch == 'default'
328 assert chset10.branches == ['default']
327 329 assert chset10.tags == []
328 330
329 331 chset44 = self.repo.get_changeset(44)
330 332 assert chset44.branch == 'web'
333 assert chset44.branches == ['web']
331 334
332 335 tip = self.repo.get_changeset('tip')
333 336 assert 'tip' in tip.tags
General Comments 0
You need to be logged in to leave comments. Login now