##// END OF EJS Templates
implemented #44 - branch filtering in changelog, aka branch browser...
marcink -
r1656:833f9dec beta
parent child Browse files
Show More
@@ -24,15 +24,22 b''
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25
25
26 import logging
26 import logging
27 import traceback
27
28
28 from mercurial import graphmod
29 from mercurial import graphmod
29 from pylons import request, session, tmpl_context as c
30 from pylons import request, url, session, tmpl_context as c
31 from pylons.controllers.util import redirect
32 from pylons.i18n.translation import _
30
33
34 import rhodecode.lib.helpers as h
31 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
35 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
32 from rhodecode.lib.base import BaseRepoController, render
36 from rhodecode.lib.base import BaseRepoController, render
33 from rhodecode.lib.helpers import RepoPage
37 from rhodecode.lib.helpers import RepoPage
34 from rhodecode.lib.compat import json
38 from rhodecode.lib.compat import json
35
39
40 from vcs.exceptions import RepositoryError, ChangesetError, \
41 ChangesetDoesNotExistError,BranchDoesNotExistError
42
36 log = logging.getLogger(__name__)
43 log = logging.getLogger(__name__)
37
44
38
45
@@ -62,12 +69,30 b' class ChangelogController(BaseRepoContro'
62
69
63 p = int(request.params.get('page', 1))
70 p = int(request.params.get('page', 1))
64 branch_name = request.params.get('branch', None)
71 branch_name = request.params.get('branch', None)
65 c.total_cs = len(c.rhodecode_repo)
72 try:
66 c.pagination = RepoPage(c.rhodecode_repo, page=p,
73 if branch_name:
67 item_count=c.total_cs, items_per_page=c.size,
74 collection = [z for z in
68 branch_name=branch_name)
75 c.rhodecode_repo.get_changesets(start=0,
76 branch_name=branch_name)]
77 c.total_cs = len(collection)
78 else:
79 collection = list(c.rhodecode_repo)
80 c.total_cs = len(c.rhodecode_repo)
69
81
70 self._graph(c.rhodecode_repo, c.total_cs, c.size, p)
82
83 c.pagination = RepoPage(collection, page=p, item_count=c.total_cs,
84 items_per_page=c.size, branch=branch_name)
85 except (RepositoryError, ChangesetDoesNotExistError, Exception), e:
86 log.error(traceback.format_exc())
87 h.flash(str(e), category='warning')
88 return redirect(url('home'))
89
90 self._graph(c.rhodecode_repo, collection, c.total_cs, c.size, p)
91
92 c.branch_name = branch_name
93 c.branch_filters = [('',_('All Branches'))] + \
94 [(k,k) for k in c.rhodecode_repo.branches.keys()]
95
71
96
72 return render('changelog/changelog.html')
97 return render('changelog/changelog.html')
73
98
@@ -76,7 +101,7 b' class ChangelogController(BaseRepoContro'
76 c.cs = c.rhodecode_repo.get_changeset(cs)
101 c.cs = c.rhodecode_repo.get_changeset(cs)
77 return render('changelog/changelog_details.html')
102 return render('changelog/changelog_details.html')
78
103
79 def _graph(self, repo, repo_size, size, p):
104 def _graph(self, repo, collection, repo_size, size, p):
80 """
105 """
81 Generates a DAG graph for mercurial
106 Generates a DAG graph for mercurial
82
107
@@ -84,16 +109,16 b' class ChangelogController(BaseRepoContro'
84 :param size: number of commits to show
109 :param size: number of commits to show
85 :param p: page number
110 :param p: page number
86 """
111 """
87 if not repo.revisions:
112 if not collection:
88 c.jsdata = json.dumps([])
113 c.jsdata = json.dumps([])
89 return
114 return
90
115
91 revcount = min(repo_size, size)
116 revcount = min(repo_size, size)
92 offset = 1 if p == 1 else ((p - 1) * revcount + 1)
117 offset = 1 if p == 1 else ((p - 1) * revcount + 1)
93 try:
118 try:
94 rev_end = repo.revisions.index(repo.revisions[(-1 * offset)])
119 rev_end = collection.index(collection[(-1 * offset)])
95 except IndexError:
120 except IndexError:
96 rev_end = repo.revisions.index(repo.revisions[-1])
121 rev_end = collection.index(collection[-1])
97 rev_start = max(0, rev_end - revcount)
122 rev_start = max(0, rev_end - revcount)
98
123
99 data = []
124 data = []
@@ -114,3 +139,4 b' class ChangelogController(BaseRepoContro'
114 data.append(['', vtx, edges])
139 data.append(['', vtx, edges])
115
140
116 c.jsdata = json.dumps(data)
141 c.jsdata = json.dumps(data)
142
@@ -66,7 +66,7 b' class ChangesetController(BaseRepoContro'
66
66
67 #get ranges of revisions if preset
67 #get ranges of revisions if preset
68 rev_range = revision.split('...')[:2]
68 rev_range = revision.split('...')[:2]
69
69
70 try:
70 try:
71 if len(rev_range) == 2:
71 if len(rev_range) == 2:
72 rev_start = rev_range[0]
72 rev_start = rev_range[0]
@@ -77,6 +77,8 b' class ChangesetController(BaseRepoContro'
77 rev_ranges = [c.rhodecode_repo.get_changeset(revision)]
77 rev_ranges = [c.rhodecode_repo.get_changeset(revision)]
78
78
79 c.cs_ranges = list(rev_ranges)
79 c.cs_ranges = list(rev_ranges)
80 if not c.cs_ranges:
81 raise RepositoryError('Changeset range returned empty result')
80
82
81 except (RepositoryError, ChangesetDoesNotExistError, Exception), e:
83 except (RepositoryError, ChangesetDoesNotExistError, Exception), e:
82 log.error(traceback.format_exc())
84 log.error(traceback.format_exc())
@@ -50,8 +50,8 b' class ShortlogController(BaseRepoControl'
50 return url('shortlog_home', repo_name=repo_name, size=size, **kw)
50 return url('shortlog_home', repo_name=repo_name, size=size, **kw)
51
51
52 c.repo_changesets = RepoPage(c.rhodecode_repo, page=p,
52 c.repo_changesets = RepoPage(c.rhodecode_repo, page=p,
53 items_per_page=size,
53 items_per_page=size, url=url_generator)
54 url=url_generator)
54
55 c.shortlog_data = render('shortlog/shortlog_data.html')
55 c.shortlog_data = render('shortlog/shortlog_data.html')
56 if request.environ.get('HTTP_X_PARTIAL_XHR'):
56 if request.environ.get('HTTP_X_PARTIAL_XHR'):
57 return c.shortlog_data
57 return c.shortlog_data
@@ -37,7 +37,7 b' from webhelpers.html.tags import _set_in'
37
37
38 from vcs.utils.annotate import annotate_highlight
38 from vcs.utils.annotate import annotate_highlight
39 from rhodecode.lib.utils import repo_name_slug
39 from rhodecode.lib.utils import repo_name_slug
40 from rhodecode.lib import str2bool, safe_unicode, safe_str,get_changeset_safe
40 from rhodecode.lib import str2bool, safe_unicode, safe_str, get_changeset_safe
41
41
42 def _reset(name, value=None, id=NotGiven, type="reset", **attrs):
42 def _reset(name, value=None, id=NotGiven, type="reset", **attrs):
43 """
43 """
@@ -480,7 +480,7 b' def gravatar_url(email_address, size=30)'
480 class RepoPage(Page):
480 class RepoPage(Page):
481
481
482 def __init__(self, collection, page=1, items_per_page=20,
482 def __init__(self, collection, page=1, items_per_page=20,
483 item_count=None, url=None, branch_name=None, **kwargs):
483 item_count=None, url=None, **kwargs):
484
484
485 """Create a "RepoPage" instance. special pager for paging
485 """Create a "RepoPage" instance. special pager for paging
486 repository
486 repository
@@ -531,11 +531,8 b' class RepoPage(Page):'
531 self.last_item = ((self.item_count - 1) - items_per_page *
531 self.last_item = ((self.item_count - 1) - items_per_page *
532 (self.page - 1))
532 (self.page - 1))
533
533
534 iterator = self.collection.get_changesets(start=self.first_item,
534 self.items = list(self.collection[self.first_item:self.last_item+1])
535 end=self.last_item,
535
536 reverse=True,
537 branch_name=branch_name)
538 self.items = list(iterator)
539
536
540 # Links to previous and next page
537 # Links to previous and next page
541 if self.page > self.first_page:
538 if self.page > self.first_page:
@@ -560,7 +557,7 b' class RepoPage(Page):'
560 self.items = []
557 self.items = []
561
558
562 # This is a subclass of the 'list' type. Initialise the list now.
559 # This is a subclass of the 'list' type. Initialise the list now.
563 list.__init__(self, self.items)
560 list.__init__(self, reversed(self.items))
564
561
565
562
566 def changed_tooltip(nodes):
563 def changed_tooltip(nodes):
@@ -670,3 +667,4 b' def urlify_text(text):'
670 return '<a href="%(url)s">%(url)s</a>' % ({'url':url_full})
667 return '<a href="%(url)s">%(url)s</a>' % ({'url':url_full})
671
668
672 return literal(url_pat.sub(url_func, text))
669 return literal(url_pat.sub(url_func, text))
670
@@ -1914,10 +1914,12 b' h3.files_location {'
1914 #graph_content .container_header {
1914 #graph_content .container_header {
1915 border: 1px solid #CCC;
1915 border: 1px solid #CCC;
1916 padding: 10px;
1916 padding: 10px;
1917 height: 45px;
1917 }
1918 }
1918
1919
1919 #graph_content #rev_range_container {
1920 #graph_content #rev_range_container {
1920 padding: 10px 0px;
1921 padding: 10px 0px;
1922 clear: both;
1921 }
1923 }
1922
1924
1923 #graph_content .container {
1925 #graph_content .container {
@@ -2022,23 +2024,42 b' h3.files_location {'
2022 .right .parent {
2024 .right .parent {
2023 font-size: 90%;
2025 font-size: 90%;
2024 font-family: monospace;
2026 font-family: monospace;
2025 }
2027 padding: 2px 2px 2px 2px;
2026
2028 }
2027 .right .logtags .branchtag {
2029 .right .logtags{
2028 background: #FFF url("../images/icons/arrow_branch.png") no-repeat right
2030 padding: 2px 2px 2px 2px;
2029 6px;
2031 }
2030 display: block;
2032 .right .logtags .branchtag,.logtags .branchtag {
2031 font-size: 0.8em;
2033 padding: 1px 3px 2px;
2032 padding: 11px 16px 0 0;
2034 background-color: #bfbfbf;
2033 }
2035 font-size: 9.75px;
2034
2036 font-weight: bold;
2035 .right .logtags .tagtag {
2037 color: #ffffff;
2036 background: #FFF url("../images/icons/tag_blue.png") no-repeat right 6px;
2038 text-transform: uppercase;
2037 display: block;
2039 white-space: nowrap;
2038 font-size: 0.8em;
2040 -webkit-border-radius: 3px;
2039 padding: 11px 16px 0 0;
2041 -moz-border-radius: 3px;
2040 }
2042 border-radius: 3px;
2041
2043 padding-left:4px;
2044 }
2045 .right .logtags .branchtag a:hover,.logtags .branchtag a:hover{
2046 text-decoration: none;
2047 }
2048 .right .logtags .tagtag,.logtags .tagtag {
2049 padding: 1px 3px 2px;
2050 background-color: #62cffc;
2051 font-size: 9.75px;
2052 font-weight: bold;
2053 color: #ffffff;
2054 text-transform: uppercase;
2055 white-space: nowrap;
2056 -webkit-border-radius: 3px;
2057 -moz-border-radius: 3px;
2058 border-radius: 3px;
2059 }
2060 .right .logtags .tagtag a:hover,.logtags .tagtag a:hover{
2061 text-decoration: none;
2062 }
2042 div.browserblock {
2063 div.browserblock {
2043 overflow: hidden;
2064 overflow: hidden;
2044 border: 1px solid #ccc;
2065 border: 1px solid #ccc;
@@ -3095,22 +3116,22 b' div.readme .readme_box code {'
3095 }
3116 }
3096
3117
3097 div.readme .readme_box pre code {
3118 div.readme .readme_box pre code {
3098 padding: 0 !important;
3119 padding: 0 !important;
3099 font-size: 12px !important;
3120 font-size: 12px !important;
3100 background-color: #eee !important;
3121 background-color: #eee !important;
3101 border: none !important;
3122 border: none !important;
3102 }
3123 }
3103
3124
3104 div.readme .readme_box pre {
3125 div.readme .readme_box pre {
3105 margin: 1em 0;
3126 margin: 1em 0;
3106 font-size: 12px;
3127 font-size: 12px;
3107 background-color: #eee;
3128 background-color: #eee;
3108 border: 1px solid #ddd;
3129 border: 1px solid #ddd;
3109 padding: 5px;
3130 padding: 5px;
3110 color: #444;
3131 color: #444;
3111 overflow: auto;
3132 overflow: auto;
3112 -webkit-box-shadow: rgba(0,0,0,0.07) 0 1px 2px inset;
3133 -webkit-box-shadow: rgba(0,0,0,0.07) 0 1px 2px inset;
3113 -webkit-border-radius: 3px;
3134 -webkit-border-radius: 3px;
3114 -moz-border-radius: 3px;
3135 -moz-border-radius: 3px;
3115 border-radius: 3px;
3136 border-radius: 3px;
3116 }
3137 }
@@ -19,11 +19,11 b''
19 </td>
19 </td>
20 <td title="${branch[1].author}">${h.person(branch[1].author)}</td>
20 <td title="${branch[1].author}">${h.person(branch[1].author)}</td>
21 <td>r${branch[1].revision}:${h.short_id(branch[1].raw_id)}</td>
21 <td>r${branch[1].revision}:${h.short_id(branch[1].raw_id)}</td>
22 <td class="nowrap">
22 <td class="nowrap">
23 ${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
23 ${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id),class_="ui-button-small")}
24 |
24 <span style="color:#515151">|</span>
25 ${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
25 ${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=branch[1].raw_id),class_="ui-button-small")}
26 </td>
26 </td>
27 </tr>
27 </tr>
28 %endfor
28 %endfor
29 % if hasattr(c,'repo_closed_branches') and c.repo_closed_branches:
29 % if hasattr(c,'repo_closed_branches') and c.repo_closed_branches:
@@ -40,9 +40,9 b''
40 <td title="${branch[1].author}">${h.person(branch[1].author)}</td>
40 <td title="${branch[1].author}">${h.person(branch[1].author)}</td>
41 <td>r${branch[1].revision}:${h.short_id(branch[1].raw_id)}</td>
41 <td>r${branch[1].revision}:${h.short_id(branch[1].raw_id)}</td>
42 <td class="nowrap">
42 <td class="nowrap">
43 ${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
43 ${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id),class_="ui-button-small")}
44 |
44 <span style="color:#515151">|</span>
45 ${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
45 ${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=branch[1].raw_id),class_="ui-button-small")}
46 </td>
46 </td>
47 </tr>
47 </tr>
48 %endfor
48 %endfor
@@ -33,12 +33,13 b''
33 <div id="graph_content">
33 <div id="graph_content">
34 <div class="container_header">
34 <div class="container_header">
35 ${h.form(h.url.current(),method='get')}
35 ${h.form(h.url.current(),method='get')}
36 <div class="info_box">
36 <div class="info_box" style="float:left">
37 ${h.submit('set',_('Show'),class_="ui-button-small")}
37 ${h.submit('set',_('Show'),class_="ui-button-small")}
38 ${h.text('size',size=1,value=c.size)}
38 ${h.text('size',size=1,value=c.size)}
39 <span class="rev">${_('revisions')}</span>
39 <span class="rev">${_('revisions')}</span>
40 </div>
40 </div>
41 ${h.end_form()}
41 ${h.end_form()}
42 <div style="float:right">${h.select('branch_filter',c.branch_name,c.branch_filters)}</div>
42 <div id="rev_range_container" style="display:none"></div>
43 <div id="rev_range_container" style="display:none"></div>
43 </div>
44 </div>
44
45
@@ -63,9 +64,7 b''
63 <span id="${cs.raw_id}" class="changed_total tooltip" title="${_('Affected number of files, click to show more details')}">${len(cs.affected_files)}</span>
64 <span id="${cs.raw_id}" class="changed_total tooltip" title="${_('Affected number of files, click to show more details')}">${len(cs.affected_files)}</span>
64 </div>
65 </div>
65 %if len(cs.parents)>1:
66 %if len(cs.parents)>1:
66 <div class="merge">
67 <div class="merge">${_('merge')}</div>
67 ${_('merge')}<img alt="merge" src="${h.url('/images/icons/arrow_join.png')}"/>
68 </div>
69 %endif
68 %endif
70 %if cs.parents:
69 %if cs.parents:
71 %for p_cs in reversed(cs.parents):
70 %for p_cs in reversed(cs.parents):
@@ -131,7 +130,7 b''
131 }
130 }
132 });
131 });
133
132
134 //Fetch changeset details
133 // Fetch changeset details
135 YUE.on(YUD.getElementsByClassName('changed_total'),'click',function(e){
134 YUE.on(YUD.getElementsByClassName('changed_total'),'click',function(e){
136 var id = e.currentTarget.id
135 var id = e.currentTarget.id
137 var url = "${h.url('changelog_details',repo_name=c.repo_name,cs='__CS__')}"
136 var url = "${h.url('changelog_details',repo_name=c.repo_name,cs='__CS__')}"
@@ -139,6 +138,20 b''
139 ypjax(url,id+'_changes_info',function(){tooltip_activate()});
138 ypjax(url,id+'_changes_info',function(){tooltip_activate()});
140 });
139 });
141
140
141 // change branch filter
142 YUE.on(YUD.get('branch_filter'),'change',function(e){
143 var selected_branch = e.currentTarget.options[e.currentTarget.selectedIndex].value;
144 console.log(selected_branch);
145 var url_main = "${h.url('changelog_home',repo_name=c.repo_name)}";
146 var url = "${h.url('changelog_home',repo_name=c.repo_name,branch='__BRANCH__')}";
147 var url = url.replace('__BRANCH__',selected_branch);
148 if(selected_branch != ''){
149 window.location = url;
150 }else{
151 window.location = url_main;
152 }
153
154 });
142
155
143 function set_canvas(heads) {
156 function set_canvas(heads) {
144 var c = document.getElementById('graph_nodes');
157 var c = document.getElementById('graph_nodes');
@@ -165,7 +178,7 b''
165
178
166 var r = new BranchRenderer();
179 var r = new BranchRenderer();
167 r.render(jsdata,max_w);
180 r.render(jsdata,max_w);
168
181
169 });
182 });
170 </script>
183 </script>
171 %else:
184 %else:
@@ -36,9 +36,9 b''
36 </span>
36 </span>
37 </td>
37 </td>
38 <td class="nowrap">
38 <td class="nowrap">
39 ${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))}
39 ${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id),class_="ui-button-small")}
40 |
40 <span style="color:#515151">|</span>
41 ${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}
41 ${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id),class_="ui-button-small")}
42 </td>
42 </td>
43 </tr>
43 </tr>
44 %endfor
44 %endfor
@@ -21,9 +21,9 b''
21 <td title="${tag[1].author}">${h.person(tag[1].author)}</td>
21 <td title="${tag[1].author}">${h.person(tag[1].author)}</td>
22 <td>r${tag[1].revision}:${h.short_id(tag[1].raw_id)}</td>
22 <td>r${tag[1].revision}:${h.short_id(tag[1].raw_id)}</td>
23 <td class="nowrap">
23 <td class="nowrap">
24 ${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=tag[1].raw_id))}
24 ${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=tag[1].raw_id),class_="ui-button-small")}
25 |
25 <span style="color:#515151">|</span>
26 ${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=tag[1].raw_id))}
26 ${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=tag[1].raw_id),class_="ui-button-small")}
27 </td>
27 </td>
28 </tr>
28 </tr>
29 %endfor
29 %endfor
General Comments 0
You need to be logged in to leave comments. Login now