Changeset - 0a2a10a1912f
[Not reviewed]
beta
0 4 0
Marcin Kuzminski - 15 years ago 2011-04-14 00:43:23
marcin@python-works.com
Implemented --stat for changelog
4 files changed with 100 insertions and 17 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/changeset.py
Show inline comments
 
@@ -86,6 +86,8 @@ class ChangesetController(BaseRepoContro
 
        c.changes = OrderedDict()
 
        c.sum_added = 0
 
        c.sum_removed = 0
 
        c.lines_added = 0
 
        c.lines_deleted = 0
 
        c.cut_off = False
 

	
 
        for changeset in c.cs_ranges:
 
@@ -106,9 +108,8 @@ class ChangesetController(BaseRepoContro
 
                    c.sum_added += node.size
 
                    if c.sum_added < self.cut_off_limit:
 
                        f_gitdiff = differ.get_gitdiff(filenode_old, node)
 
                        diff = differ.DiffProcessor(f_gitdiff,
 
                                                    format='gitdiff').as_html()
 

	
 
                        d = differ.DiffProcessor(f_gitdiff, format='gitdiff')
 
                        diff = d.as_html()
 
                    else:
 
                        diff = wrap_to_table(_('Changeset is to big and '
 
                                               'was cut off, see raw '
 
@@ -118,8 +119,11 @@ class ChangesetController(BaseRepoContro
 

	
 
                cs1 = None
 
                cs2 = node.last_changeset.raw_id
 
                c.changes[changeset.raw_id].append(('added', node,
 
                                                    diff, cs1, cs2))
 
                st = d.stat()
 
                c.lines_added += st[0]
 
                c.lines_deleted += st[1]
 
                c.changes[changeset.raw_id].append(('added', node, diff,
 
                                                    cs1, cs2, st))
 

	
 
            #==================================================================
 
            # CHANGED FILES
 
@@ -138,9 +142,10 @@ class ChangesetController(BaseRepoContro
 

	
 
                        if c.sum_removed < self.cut_off_limit:
 
                            f_gitdiff = differ.get_gitdiff(filenode_old, node)
 
                            diff = differ.DiffProcessor(f_gitdiff,
 
                                                        format='gitdiff')\
 
                                                        .as_html()
 
                            d = differ.DiffProcessor(f_gitdiff,
 
                                                     format='gitdiff')
 
                            diff = d.as_html()
 

	
 
                            if diff:
 
                                c.sum_removed += len(diff)
 
                        else:
 
@@ -152,8 +157,11 @@ class ChangesetController(BaseRepoContro
 

	
 
                    cs1 = filenode_old.last_changeset.raw_id
 
                    cs2 = node.last_changeset.raw_id
 
                    c.changes[changeset.raw_id].append(('changed', node,
 
                                                        diff, cs1, cs2))
 
                    st = d.stat()
 
                    c.lines_added += st[0]
 
                    c.lines_deleted += st[1]
 
                    c.changes[changeset.raw_id].append(('changed', node, diff,
 
                                                        cs1, cs2, st))
 

	
 
            #==================================================================
 
            # REMOVED FILES
 
@@ -161,7 +169,7 @@ class ChangesetController(BaseRepoContro
 
            if not c.cut_off:
 
                for node in changeset.removed:
 
                    c.changes[changeset.raw_id].append(('removed', node, None,
 
                                                        None, None))
 
                                                        None, None, None))
 

	
 
        if len(c.cs_ranges) == 1:
 
            c.changeset = c.cs_ranges[0]
rhodecode/lib/helpers.py
Show inline comments
 
@@ -622,7 +622,8 @@ def changed_tooltip(nodes):
 
        suf = ''
 
        if len(nodes) > 30:
 
            suf = '<br/>' + _(' and %s more') % (len(nodes) - 30)
 
        return literal(pref + '<br/> '.join([safe_unicode(x.path) for x in nodes[:30]]) + suf)
 
        return literal(pref + '<br/> '.join([safe_unicode(x.path)
 
                                             for x in nodes[:30]]) + suf)
 
    else:
 
        return ': ' + _('No Files')
 

	
 
@@ -635,6 +636,56 @@ def repo_link(groups_and_repos):
 
        return repo_name
 
    else:
 
        def make_link(group):
 
            return link_to(group.group_name, url('repos_group', id=group.group_id))
 
            return link_to(group.group_name, url('repos_group',
 
                                                 id=group.group_id))
 
        return literal(' &raquo; '.join(map(make_link, groups)) + \
 
                       " &raquo; " + repo_name)
 

	
 

	
 
def fancy_file_stats(stats):
 
    a, d, t = stats[0], stats[1], stats[0] + stats[1]
 
    width = 100
 
    unit = float(width) / t
 

	
 
    a_p = max(9, unit * a) if a > 0 else 0# needs > 9% to be visible
 
    d_p = max(9, unit * d) if d > 0 else 0 # needs > 9% to be visible
 
    p_sum = a_p + d_p
 

	
 
    if p_sum > width:
 
        #adjust the percentage to be == 100% since we adjusted to 9
 
        if a_p > d_p:
 
            a_p = a_p - (p_sum - width)
 
        else:
 
            d_p = d_p - (p_sum - width)
 

	
 
    a_v = a if a > 0 else ''
 
    d_v = d if d > 0 else ''
 

	
 

	
 
    def cgen(l_type):
 
        mapping = {'tr':'top-right-rounded-corner',
 
                   'tl':'top-left-rounded-corner',
 
                   'br':'bottom-right-rounded-corner',
 
                   'bl':'bottom-left-rounded-corner'}
 
        map_getter = lambda x:mapping[x]
 

	
 
        if l_type == 'a' and d_v:
 
            #case when added and deleted are present
 
            return ' '.join(map(map_getter, ['tl', 'bl']))
 

	
 
        if l_type == 'a' and not d_v:
 
            return ' '.join(map(map_getter, ['tr', 'br', 'tl', 'bl']))
 

	
 
        if l_type == 'd' and a_v:
 
            return ' '.join(map(map_getter, ['tr', 'br']))
 

	
 
        if l_type == 'd' and not a_v:
 
            return ' '.join(map(map_getter, ['tr', 'br', 'tl', 'bl']))
 

	
 

	
 

	
 
    d_a = '<div class="added %s" style="width:%s%%">%s</div>' % (cgen('a'),
 
                                                                 a_p, a_v)
 
    d_d = '<div class="deleted %s" style="width:%s%%">%s</div>' % (cgen('d'),
 
                                                                   d_p, d_v)
 
    return literal('<div style="width:%spx">%s%s</div>' % (width, d_a, d_d))
rhodecode/public/css/style.css
Show inline comments
 
@@ -1546,6 +1546,24 @@ margin:10px 2px;
 
font-weight: bold;
 
}
 
 
.cs_files .node{
 
float: left;
 
}
 
.cs_files .changes{
 
float: right;
 
}
 
.cs_files .changes .added{
 
background-color: #BBFFBB;
 
float: left;
 
text-align: center;
 
font-size: 90%; 
 
}
 
.cs_files .changes .deleted{
 
background-color: #FF8888;
 
float: left;
 
text-align: center;
 
font-size: 90%;
 
}
 
.cs_files .cs_added {
 
background:url("../images/icons/page_white_add.png") no-repeat scroll 3px;
 
height:16px;
rhodecode/templates/changeset/changeset.html
Show inline comments
 
@@ -86,10 +86,16 @@
 
		         </span>                                                                 
 
	                </div>              
 
	        </div>
 
	        <span style="font-size:1.1em;font-weight: bold">${_('Files affected (%s)' % len(c.changeset.affected_files))}</span>
 
	        <span style="font-size:1.1em;font-weight: bold">
 
	        ${_('%s files affected with %s additions and %s deletions.') % (len(c.changeset.affected_files),c.lines_added,c.lines_deleted)}
 
	        </span>
 
	        <div class="cs_files">
 
	                %for change,filenode,diff,cs1,cs2 in c.changes:
 
	                    <div class="cs_${change}">${h.link_to(h.safe_unicode(filenode.path),h.url.current(anchor=h.repo_name_slug('C%s' % h.safe_unicode(filenode.path))))}</div>
 
	                %for change,filenode,diff,cs1,cs2,stat in c.changes:
 
	                    <div class="cs_${change}">
 
		                    <div class="node">${h.link_to(h.safe_unicode(filenode.path),
 
		                                        h.url.current(anchor=h.repo_name_slug('C%s' % h.safe_unicode(filenode.path))))}</div>
 
		                    <div class="changes">${h.fancy_file_stats(stat)}</div>
 
	                    </div>
 
	                %endfor
 
	                % if c.cut_off:
 
	                  ${_('Changeset was to big and was cut off...')}
 
@@ -99,7 +105,7 @@
 
	    
 
    </div>
 
    	
 
	%for change,filenode,diff,cs1,cs2 in c.changes:
 
	%for change,filenode,diff,cs1,cs2,stat in c.changes:
 
		%if change !='removed':
 
		<div style="clear:both;height:10px"></div>
 
		<div class="diffblock">
0 comments (0 inline, 0 general)