Mercurial > kallithea
changeset 1768:5610fd9b6803 beta
added line context control to diffs
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 08 Dec 2011 02:25:23 +0200 |
parents | 468afe69f2a8 |
children | 025f3333c769 |
files | rhodecode/controllers/changeset.py rhodecode/controllers/files.py rhodecode/lib/diffs.py |
diffstat | 3 files changed, 21 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/controllers/changeset.py Thu Dec 08 01:47:11 2011 +0200 +++ b/rhodecode/controllers/changeset.py Thu Dec 08 02:25:23 2011 +0200 @@ -60,6 +60,7 @@ def index(self, revision): ignore_whitespace = request.GET.get('ignorews') == '1' + line_context = request.GET.get('context', 3) def wrap_to_table(str): return '''<table class="code-difftable"> @@ -131,7 +132,8 @@ c.sum_added += node.size if c.sum_added < self.cut_off_limit: f_gitdiff = diffs.get_gitdiff(filenode_old, node, - ignore_whitespace=ignore_whitespace) + ignore_whitespace=ignore_whitespace, + context=line_context) d = diffs.DiffProcessor(f_gitdiff, format='gitdiff') st = d.stat() @@ -170,7 +172,8 @@ if c.sum_removed < self.cut_off_limit: f_gitdiff = diffs.get_gitdiff(filenode_old, node, - ignore_whitespace=ignore_whitespace) + ignore_whitespace=ignore_whitespace, + context=line_context) d = diffs.DiffProcessor(f_gitdiff, format='gitdiff') st = d.stat() @@ -222,6 +225,7 @@ method = request.GET.get('diff', 'show') ignore_whitespace = request.GET.get('ignorews') == '1' + line_context = request.GET.get('context', 3) try: c.scm_type = c.rhodecode_repo.alias c.changeset = c.rhodecode_repo.get_changeset(revision) @@ -241,7 +245,8 @@ diff = _('binary file') + '\n' else: f_gitdiff = diffs.get_gitdiff(filenode_old, node, - ignore_whitespace=ignore_whitespace) + ignore_whitespace=ignore_whitespace, + context=line_context) diff = diffs.DiffProcessor(f_gitdiff, format='gitdiff').raw_diff() @@ -255,7 +260,8 @@ diff = _('binary file') else: f_gitdiff = diffs.get_gitdiff(filenode_old, node, - ignore_whitespace=ignore_whitespace) + ignore_whitespace=ignore_whitespace, + context=line_context) diff = diffs.DiffProcessor(f_gitdiff, format='gitdiff').raw_diff()
--- a/rhodecode/controllers/files.py Thu Dec 08 01:47:11 2011 +0200 +++ b/rhodecode/controllers/files.py Thu Dec 08 02:25:23 2011 +0200 @@ -406,6 +406,7 @@ 'repository.admin') def diff(self, repo_name, f_path): ignore_whitespace = request.GET.get('ignorews') == '1' + line_context = request.GET.get('context', 3) diff1 = request.GET.get('diff1') diff2 = request.GET.get('diff2') c.action = request.GET.get('diff') @@ -433,7 +434,8 @@ if c.action == 'download': _diff = diffs.get_gitdiff(node1, node2, - ignore_whitespace=ignore_whitespace) + ignore_whitespace=ignore_whitespace, + context=line_context) diff = diffs.DiffProcessor(_diff,format='gitdiff') diff_name = '%s_vs_%s.diff' % (diff1, diff2) @@ -444,7 +446,8 @@ elif c.action == 'raw': _diff = diffs.get_gitdiff(node1, node2, - ignore_whitespace=ignore_whitespace) + ignore_whitespace=ignore_whitespace, + context=line_context) diff = diffs.DiffProcessor(_diff,format='gitdiff') response.content_type = 'text/plain' return diff.raw_diff() @@ -458,7 +461,8 @@ c.big_diff = True else: _diff = diffs.get_gitdiff(node1, node2, - ignore_whitespace=ignore_whitespace) + ignore_whitespace=ignore_whitespace, + context=line_context) diff = diffs.DiffProcessor(_diff,format='gitdiff') c.cur_diff = diff.as_html() else: @@ -473,7 +477,8 @@ else: _diff = diffs.get_gitdiff(node1, node2, - ignore_whitespace=ignore_whitespace) + ignore_whitespace=ignore_whitespace, + context=line_context) diff = diffs.DiffProcessor(_diff,format='gitdiff') c.cur_diff = diff.as_html()
--- a/rhodecode/lib/diffs.py Thu Dec 08 01:47:11 2011 +0200 +++ b/rhodecode/lib/diffs.py Thu Dec 08 02:25:23 2011 +0200 @@ -35,7 +35,7 @@ from vcs.exceptions import VCSError from vcs.nodes import FileNode -def get_gitdiff(filenode_old, filenode_new, ignore_whitespace=True): +def get_gitdiff(filenode_old, filenode_new, ignore_whitespace=True, context=3): """ Returns git style diff between given ``filenode_old`` and ``filenode_new``. @@ -52,7 +52,7 @@ repo = filenode_new.changeset.repository vcs_gitdiff = repo._get_diff(old_raw_id, new_raw_id, filenode_new.path, - ignore_whitespace) + ignore_whitespace, context) return vcs_gitdiff