diff --git a/rhodecode/controllers/branches.py b/rhodecode/controllers/branches.py --- a/rhodecode/controllers/branches.py +++ b/rhodecode/controllers/branches.py @@ -24,14 +24,15 @@ # along with this program. If not, see . import logging +import binascii from pylons import tmpl_context as c -import binascii from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator from rhodecode.lib.base import BaseRepoController, render from rhodecode.lib.compat import OrderedDict from rhodecode.lib.utils2 import safe_unicode + log = logging.getLogger(__name__) diff --git a/rhodecode/controllers/compare.py b/rhodecode/controllers/compare.py --- a/rhodecode/controllers/compare.py +++ b/rhodecode/controllers/compare.py @@ -25,11 +25,13 @@ # along with this program. If not, see . import logging import traceback +import binascii from webob.exc import HTTPNotFound from pylons import request, response, session, tmpl_context as c, url from pylons.controllers.util import abort, redirect +from rhodecode.lib import helpers as h from rhodecode.lib.base import BaseRepoController, render from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator from rhodecode.lib import diffs @@ -89,12 +91,15 @@ class CompareController(BaseRepoControll #case two independent repos if org_repo != other_repo: from mercurial import discovery - import binascii out = discovery.findcommonoutgoing(org_repo._repo, other_repo._repo) for cs in map(binascii.hexlify, out.missing): changesets.append(org_repo.get_changeset(cs)) else: - for cs in map(binascii.hexlify, out): + revs = ['ancestors(%s) and not ancestors(%s)' % (org_ref[1], + other_ref[1])] + from mercurial import scmutil + out = scmutil.revrange(org_repo._repo, revs) + for cs in reversed(out): changesets.append(org_repo.get_changeset(cs)) return changesets @@ -112,19 +117,18 @@ class CompareController(BaseRepoControll c.org_ref = org_ref[1] c.other_ref = other_ref[1] - cs1 = org_repo.scm_instance.get_changeset(org_ref[1]) - cs2 = other_repo.scm_instance.get_changeset(other_ref[1]) _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref) diff_processor = diffs.DiffProcessor(_diff, format='gitdiff') + _parsed = diff_processor.prepare() - diff = diff_processor.as_html(enable_comments=False) - stats = diff_processor.stat() + c.files = [] + c.changes = {} - c.changes = [('change?', None, diff, cs1, cs2, stats,)] + for f in _parsed: + fid = h.FID('', f['filename']) + c.files.append([fid, f['operation'], f['filename'], f['stats']]) + diff = diff_processor.as_html(enable_comments=False, diff_lines=[f]) + c.changes[fid] = [f['operation'], f['filename'], diff] return render('compare/compare_diff.html') - - - - diff --git a/rhodecode/lib/vcs/nodes.py b/rhodecode/lib/vcs/nodes.py --- a/rhodecode/lib/vcs/nodes.py +++ b/rhodecode/lib/vcs/nodes.py @@ -431,8 +431,10 @@ class RemovedFileNode(FileNode): name, kind or state (or methods/attributes checking those two) would raise RemovedFileNodeError. """ - ALLOWED_ATTRIBUTES = ['name', 'path', 'state', 'is_root', 'is_file', - 'is_dir', 'kind', 'added', 'changed', 'not_changed', 'removed'] + ALLOWED_ATTRIBUTES = [ + 'name', 'path', 'state', 'is_root', 'is_file', 'is_dir', 'kind', + 'added', 'changed', 'not_changed', 'removed' + ] def __init__(self, path): """ diff --git a/rhodecode/public/css/style.css b/rhodecode/public/css/style.css --- a/rhodecode/public/css/style.css +++ b/rhodecode/public/css/style.css @@ -2333,7 +2333,7 @@ h3.files_location { padding: 2px 0px 2px 0px; } -.cs_files .cs_added { +.cs_files .cs_added,.cs_files .cs_A { background: url("../images/icons/page_white_add.png") no-repeat scroll 3px; height: 16px; @@ -2342,7 +2342,7 @@ h3.files_location { text-align: left; } -.cs_files .cs_changed { +.cs_files .cs_changed,.cs_files .cs_M { background: url("../images/icons/page_white_edit.png") no-repeat scroll 3px; height: 16px; @@ -2351,7 +2351,7 @@ h3.files_location { text-align: left; } -.cs_files .cs_removed { +.cs_files .cs_removed,.cs_files .cs_D { background: url("../images/icons/page_white_delete.png") no-repeat scroll 3px; height: 16px; diff --git a/rhodecode/templates/changeset/diff_block.html b/rhodecode/templates/changeset/diff_block.html --- a/rhodecode/templates/changeset/diff_block.html +++ b/rhodecode/templates/changeset/diff_block.html @@ -1,12 +1,12 @@ ## -*- coding: utf-8 -*- ##usage: ## <%namespace name="diff_block" file="/changeset/diff_block.html"/> -## ${diff_block.diff_block(changes)} +## ${diff_block.diff_block(change)} ## -<%def name="diff_block(changes)"> +<%def name="diff_block(change)"> -%for change,filenode,diff,cs1,cs2,stat in changes: - %if change !='removed': +%for op,filenode,diff,cs1,cs2,stat in change: + %if op !='removed':
@@ -39,3 +39,23 @@ %endfor + +<%def name="diff_block_simple(change)"> + + %for op,filenode_path,diff in change: +
+
+ +
+
+ ${diff|n} +
+
+ %endfor + \ No newline at end of file diff --git a/rhodecode/templates/compare/compare_diff.html b/rhodecode/templates/compare/compare_diff.html --- a/rhodecode/templates/compare/compare_diff.html +++ b/rhodecode/templates/compare/compare_diff.html @@ -2,7 +2,7 @@ <%inherit file="/base/base.html"/> <%def name="title()"> - TODO FIll this in + ${c.repo_name} ${_('Compare')} ${'%s@%s' % (c.org_repo.repo_name, c.org_ref)} -> ${'%s@%s' % (c.other_repo.repo_name, c.other_ref)} <%def name="breadcrumbs_links()"> @@ -10,7 +10,7 @@ » ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))} » - TODO! + ${_('Compare')} <%def name="page_nav()"> @@ -35,7 +35,7 @@
- %for cnt,cs in enumerate(c.cs_ranges): + %for cnt, cs in enumerate(c.cs_ranges): @@ -53,14 +53,22 @@
${_('Files affected')}
- %for change,filenode,diff,cs1,cs2,st in c.changes[cs.raw_id]: -
${h.link_to(h.safe_unicode(filenode.path),h.url.current(anchor=h.FID(cs.raw_id,filenode.path)))}
+ %for fid, change, f, stat in c.files: +
+
${h.link_to(h.safe_unicode(f),h.url.current(anchor=fid))}
+
${h.fancy_file_stats(stat)}
+
%endfor
- - + + ## diff block + <%namespace name="diff_block" file="/changeset/diff_block.html"/> + %for fid, change, f, stat in c.files: + ${diff_block.diff_block_simple([c.changes[fid]])} + %endfor +
gravatar
${h.link_to('r%s:%s' % (cs.revision,h.short_id(cs.raw_id)),h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))}