Changeset - 833f9dec0a06
[Not reviewed]
beta
0 9 0
Marcin Kuzminski - 14 years ago 2011-11-05 13:38:26
marcin@python-works.com
implemented #44 - branch filtering in changelog, aka branch browser
- changed GUI on tags/branches to not use images.
9 files changed with 134 insertions and 74 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/changelog.py
Show inline comments
 
@@ -24,15 +24,22 @@
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 

	
 
import logging
 
import traceback
 

	
 
from mercurial import graphmod
 
from pylons import request, session, tmpl_context as c
 
from pylons import request, url, session, tmpl_context as c
 
from pylons.controllers.util import redirect
 
from pylons.i18n.translation import _
 

	
 
import rhodecode.lib.helpers as h
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 
from rhodecode.lib.base import BaseRepoController, render
 
from rhodecode.lib.helpers import RepoPage
 
from rhodecode.lib.compat import json
 

	
 
from vcs.exceptions import RepositoryError, ChangesetError, \
 
ChangesetDoesNotExistError,BranchDoesNotExistError
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
@@ -62,12 +69,30 @@ class ChangelogController(BaseRepoContro
 

	
 
        p = int(request.params.get('page', 1))
 
        branch_name = request.params.get('branch', None)
 
        c.total_cs = len(c.rhodecode_repo)
 
        c.pagination = RepoPage(c.rhodecode_repo, page=p,
 
                                item_count=c.total_cs, items_per_page=c.size,
 
                                branch_name=branch_name)
 
        try:
 
            if branch_name:
 
                collection = [z for z in 
 
                              c.rhodecode_repo.get_changesets(start=0, 
 
                                                    branch_name=branch_name)]
 
                c.total_cs = len(collection)
 
            else:
 
                collection = list(c.rhodecode_repo)
 
                c.total_cs = len(c.rhodecode_repo)
 

	
 
        self._graph(c.rhodecode_repo, c.total_cs, c.size, p)
 
        
 
            c.pagination = RepoPage(collection, page=p, item_count=c.total_cs,
 
                                    items_per_page=c.size, branch=branch_name)
 
        except (RepositoryError, ChangesetDoesNotExistError, Exception), e:
 
            log.error(traceback.format_exc())
 
            h.flash(str(e), category='warning')
 
            return redirect(url('home'))        
 

	
 
        self._graph(c.rhodecode_repo, collection, c.total_cs, c.size, p)
 

	
 
        c.branch_name = branch_name
 
        c.branch_filters = [('',_('All Branches'))] + \
 
            [(k,k) for k in c.rhodecode_repo.branches.keys()]
 

	
 

	
 
        return render('changelog/changelog.html')
 

	
 
@@ -76,7 +101,7 @@ class ChangelogController(BaseRepoContro
 
            c.cs = c.rhodecode_repo.get_changeset(cs)
 
            return render('changelog/changelog_details.html')
 

	
 
    def _graph(self, repo, repo_size, size, p):
 
    def _graph(self, repo, collection, repo_size, size, p):
 
        """
 
        Generates a DAG graph for mercurial
 

	
 
@@ -84,16 +109,16 @@ class ChangelogController(BaseRepoContro
 
        :param size: number of commits to show
 
        :param p: page number
 
        """
 
        if not repo.revisions:
 
        if not collection:
 
            c.jsdata = json.dumps([])
 
            return
 

	
 
        revcount = min(repo_size, size)
 
        offset = 1 if p == 1 else  ((p - 1) * revcount + 1)
 
        try:
 
            rev_end = repo.revisions.index(repo.revisions[(-1 * offset)])
 
            rev_end = collection.index(collection[(-1 * offset)])
 
        except IndexError:
 
            rev_end = repo.revisions.index(repo.revisions[-1])
 
            rev_end = collection.index(collection[-1])
 
        rev_start = max(0, rev_end - revcount)
 

	
 
        data = []
 
@@ -114,3 +139,4 @@ class ChangelogController(BaseRepoContro
 
                data.append(['', vtx, edges])
 

	
 
        c.jsdata = json.dumps(data)
 

	
rhodecode/controllers/changeset.py
Show inline comments
 
@@ -66,7 +66,7 @@ class ChangesetController(BaseRepoContro
 

	
 
        #get ranges of revisions if preset
 
        rev_range = revision.split('...')[:2]
 

	
 
        
 
        try:
 
            if len(rev_range) == 2:
 
                rev_start = rev_range[0]
 
@@ -77,6 +77,8 @@ class ChangesetController(BaseRepoContro
 
                rev_ranges = [c.rhodecode_repo.get_changeset(revision)]
 

	
 
            c.cs_ranges = list(rev_ranges)
 
            if not c.cs_ranges:
 
                raise RepositoryError('Changeset range returned empty result')
 

	
 
        except (RepositoryError, ChangesetDoesNotExistError, Exception), e:
 
            log.error(traceback.format_exc())
rhodecode/controllers/shortlog.py
Show inline comments
 
@@ -50,8 +50,8 @@ class ShortlogController(BaseRepoControl
 
            return url('shortlog_home', repo_name=repo_name, size=size, **kw)
 

	
 
        c.repo_changesets = RepoPage(c.rhodecode_repo, page=p,
 
                                                       items_per_page=size,
 
                                                       url=url_generator)
 
                                    items_per_page=size, url=url_generator)
 
        
 
        c.shortlog_data = render('shortlog/shortlog_data.html')
 
        if request.environ.get('HTTP_X_PARTIAL_XHR'):
 
            return c.shortlog_data
rhodecode/lib/helpers.py
Show inline comments
 
@@ -37,7 +37,7 @@ from webhelpers.html.tags import _set_in
 

	
 
from vcs.utils.annotate import annotate_highlight
 
from rhodecode.lib.utils import repo_name_slug
 
from rhodecode.lib import str2bool, safe_unicode, safe_str,get_changeset_safe
 
from rhodecode.lib import str2bool, safe_unicode, safe_str, get_changeset_safe
 

	
 
def _reset(name, value=None, id=NotGiven, type="reset", **attrs):
 
    """
 
@@ -480,7 +480,7 @@ def gravatar_url(email_address, size=30)
 
class RepoPage(Page):
 

	
 
    def __init__(self, collection, page=1, items_per_page=20,
 
        item_count=None, url=None, branch_name=None, **kwargs):
 
                 item_count=None, url=None, **kwargs):
 

	
 
        """Create a "RepoPage" instance. special pager for paging
 
        repository
 
@@ -531,11 +531,8 @@ class RepoPage(Page):
 
            self.last_item = ((self.item_count - 1) - items_per_page *
 
                              (self.page - 1))
 

	
 
            iterator = self.collection.get_changesets(start=self.first_item,
 
                                                      end=self.last_item,
 
                                                      reverse=True,
 
                                                      branch_name=branch_name)
 
            self.items = list(iterator)
 
            self.items = list(self.collection[self.first_item:self.last_item+1])
 

	
 

	
 
            # Links to previous and next page
 
            if self.page > self.first_page:
 
@@ -560,7 +557,7 @@ class RepoPage(Page):
 
            self.items = []
 

	
 
        # This is a subclass of the 'list' type. Initialise the list now.
 
        list.__init__(self, self.items)
 
        list.__init__(self, reversed(self.items))
 

	
 

	
 
def changed_tooltip(nodes):
 
@@ -670,3 +667,4 @@ def urlify_text(text):
 
        return '<a href="%(url)s">%(url)s</a>' % ({'url':url_full})
 

	
 
    return literal(url_pat.sub(url_func, text))
 

	
rhodecode/public/css/style.css
Show inline comments
 
@@ -1914,10 +1914,12 @@ h3.files_location {
 
#graph_content .container_header {
 
	border: 1px solid #CCC;
 
	padding: 10px;
 
	height: 45px;
 
}
 
 
#graph_content #rev_range_container {
 
	padding: 10px 0px;
 
	clear: both;
 
}
 
 
#graph_content .container {
 
@@ -2022,23 +2024,42 @@ h3.files_location {
 
.right .parent {
 
	font-size: 90%;
 
	font-family: monospace;
 
}
 
 
.right .logtags .branchtag {
 
	background: #FFF url("../images/icons/arrow_branch.png") no-repeat right
 
		6px;
 
	display: block;
 
	font-size: 0.8em;
 
	padding: 11px 16px 0 0;
 
}
 
 
.right .logtags .tagtag {
 
	background: #FFF url("../images/icons/tag_blue.png") no-repeat right 6px;
 
	display: block;
 
	font-size: 0.8em;
 
	padding: 11px 16px 0 0;
 
}
 
 
	padding: 2px 2px 2px 2px;
 
}
 
.right .logtags{
 
	padding: 2px 2px 2px 2px;
 
}
 
.right .logtags .branchtag,.logtags .branchtag {
 
  padding: 1px 3px 2px;
 
  background-color: #bfbfbf;
 
  font-size: 9.75px;
 
  font-weight: bold;
 
  color: #ffffff;
 
  text-transform: uppercase;
 
  white-space: nowrap;
 
  -webkit-border-radius: 3px;
 
  -moz-border-radius: 3px;
 
  border-radius: 3px;
 
  padding-left:4px;
 
}
 
.right .logtags .branchtag a:hover,.logtags .branchtag a:hover{
 
	text-decoration: none;
 
}
 
.right .logtags .tagtag,.logtags .tagtag {
 
  padding: 1px 3px 2px;
 
  background-color: #62cffc;
 
  font-size: 9.75px;
 
  font-weight: bold;
 
  color: #ffffff;
 
  text-transform: uppercase;
 
  white-space: nowrap;
 
  -webkit-border-radius: 3px;
 
  -moz-border-radius: 3px;
 
  border-radius: 3px;
 
}
 
.right .logtags .tagtag a:hover,.logtags .tagtag a:hover{
 
    text-decoration: none;
 
}
 
div.browserblock {
 
	overflow: hidden;
 
	border: 1px solid #ccc;
 
@@ -3095,22 +3116,22 @@ div.readme .readme_box code {
 
}
 
 
div.readme .readme_box pre code {
 
padding: 0 !important;
 
font-size: 12px !important;
 
background-color: #eee !important;
 
border: none !important;
 
	padding: 0 !important;
 
	font-size: 12px !important;
 
	background-color: #eee !important;
 
	border: none !important;
 
}
 
 
div.readme .readme_box pre {
 
margin: 1em 0;
 
font-size: 12px;
 
background-color: #eee;
 
border: 1px solid #ddd;
 
padding: 5px;
 
color: #444;
 
overflow: auto;
 
-webkit-box-shadow: rgba(0,0,0,0.07) 0 1px 2px inset;
 
-webkit-border-radius: 3px;
 
-moz-border-radius: 3px;
 
border-radius: 3px;
 
}
 
	margin: 1em 0;
 
	font-size: 12px;
 
	background-color: #eee;
 
	border: 1px solid #ddd;
 
	padding: 5px;
 
	color: #444;
 
	overflow: auto;
 
	-webkit-box-shadow: rgba(0,0,0,0.07) 0 1px 2px inset;
 
	-webkit-border-radius: 3px;
 
	-moz-border-radius: 3px;
 
	border-radius: 3px;
 
}
rhodecode/templates/branches/branches_data.html
Show inline comments
 
@@ -19,11 +19,11 @@
 
            </td>		
 
            <td title="${branch[1].author}">${h.person(branch[1].author)}</td>
 
            <td>r${branch[1].revision}:${h.short_id(branch[1].raw_id)}</td>
 
			<td class="nowrap">
 
			${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
 
			|
 
			${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
 
			</td>
 
            <td class="nowrap">
 
            ${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id),class_="ui-button-small")}
 
            <span style="color:#515151">|</span>
 
            ${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=branch[1].raw_id),class_="ui-button-small")}
 
            </td>
 
		</tr>	
 
		%endfor
 
        % if hasattr(c,'repo_closed_branches') and c.repo_closed_branches:
 
@@ -40,9 +40,9 @@
 
              <td title="${branch[1].author}">${h.person(branch[1].author)}</td>
 
              <td>r${branch[1].revision}:${h.short_id(branch[1].raw_id)}</td>
 
              <td class="nowrap">
 
              ${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
 
              |
 
              ${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
 
              ${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id),class_="ui-button-small")}
 
              <span style="color:#515151">|</span>
 
              ${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=branch[1].raw_id),class_="ui-button-small")}
 
              </td>
 
          </tr>   
 
          %endfor
rhodecode/templates/changelog/changelog.html
Show inline comments
 
@@ -33,12 +33,13 @@ ${c.repo_name} ${_('Changelog')} - ${c.r
 
				<div id="graph_content">
 
					<div class="container_header">
 
				        ${h.form(h.url.current(),method='get')}
 
				        <div class="info_box">
 
				        <div class="info_box" style="float:left">
 
				          ${h.submit('set',_('Show'),class_="ui-button-small")}
 
				          ${h.text('size',size=1,value=c.size)}
 
				          <span class="rev">${_('revisions')}</span>
 
				        </div>
 
				        ${h.end_form()}
 
                    <div style="float:right">${h.select('branch_filter',c.branch_name,c.branch_filters)}</div>
 
					<div id="rev_range_container" style="display:none"></div>
 
					</div>
 
					
 
@@ -63,9 +64,7 @@ ${c.repo_name} ${_('Changelog')} - ${c.r
 
                                        <span id="${cs.raw_id}" class="changed_total tooltip" title="${_('Affected number of files, click to show more details')}">${len(cs.affected_files)}</span>
 
									</div>					
 
										%if len(cs.parents)>1:
 
										<div class="merge">
 
											${_('merge')}<img alt="merge" src="${h.url('/images/icons/arrow_join.png')}"/>
 
										</div>
 
										<div class="merge">${_('merge')}</div>
 
										%endif
 
								   %if cs.parents:							
 
									%for p_cs in reversed(cs.parents):
 
@@ -131,7 +130,7 @@ ${c.repo_name} ${_('Changelog')} - ${c.r
 
                        }
 
                    });					
 
					
 
                    //Fetch changeset details 
 
                    // Fetch changeset details 
 
                    YUE.on(YUD.getElementsByClassName('changed_total'),'click',function(e){
 
                    	var id = e.currentTarget.id
 
                    	var url = "${h.url('changelog_details',repo_name=c.repo_name,cs='__CS__')}"
 
@@ -139,6 +138,20 @@ ${c.repo_name} ${_('Changelog')} - ${c.r
 
                    	ypjax(url,id+'_changes_info',function(){tooltip_activate()});
 
                    });
 
                    
 
                    // change branch filter
 
                    YUE.on(YUD.get('branch_filter'),'change',function(e){
 
                    	var selected_branch = e.currentTarget.options[e.currentTarget.selectedIndex].value;
 
                    	console.log(selected_branch);
 
                    	var url_main = "${h.url('changelog_home',repo_name=c.repo_name)}";
 
                    	var url = "${h.url('changelog_home',repo_name=c.repo_name,branch='__BRANCH__')}";
 
                    	var url = url.replace('__BRANCH__',selected_branch);
 
                    	if(selected_branch != ''){
 
                    		window.location = url;
 
                    	}else{
 
                    		window.location = url_main;
 
                    	}
 
                        
 
                    });
 
                    
 
					function set_canvas(heads) {
 
						var c = document.getElementById('graph_nodes');
 
@@ -165,7 +178,7 @@ ${c.repo_name} ${_('Changelog')} - ${c.r
 
					
 
					var r = new BranchRenderer();
 
					r.render(jsdata,max_w);
 
					
 
										
 
				});
 
			</script>
 
		%else:
rhodecode/templates/shortlog/shortlog_data.html
Show inline comments
 
@@ -36,9 +36,9 @@
 
			</span>
 
		</td>
 
		<td class="nowrap">
 
		${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))}
 
		|
 
		${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}
 
		${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id),class_="ui-button-small")}
 
		<span style="color:#515151">|</span>
 
		${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id),class_="ui-button-small")}
 
		</td>
 
	</tr>
 
%endfor
rhodecode/templates/tags/tags_data.html
Show inline comments
 
@@ -21,9 +21,9 @@
 
	        <td title="${tag[1].author}">${h.person(tag[1].author)}</td>
 
	        <td>r${tag[1].revision}:${h.short_id(tag[1].raw_id)}</td>
 
			<td class="nowrap">
 
			${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=tag[1].raw_id))}
 
			|
 
			${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=tag[1].raw_id))}
 
			${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=tag[1].raw_id),class_="ui-button-small")}
 
			<span style="color:#515151">|</span>
 
			${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=tag[1].raw_id),class_="ui-button-small")}
 
			</td>
 
		</tr>	
 
		%endfor
0 comments (0 inline, 0 general)