diff --git a/rhodecode/controllers/changeset.py b/rhodecode/controllers/changeset.py
--- a/rhodecode/controllers/changeset.py
+++ b/rhodecode/controllers/changeset.py
@@ -60,6 +60,7 @@ class ChangesetController(BaseRepoContro
def index(self, revision):
ignore_whitespace = request.GET.get('ignorews') == '1'
+ line_context = request.GET.get('context', 3)
def wrap_to_table(str):
return '''
@@ -131,7 +132,8 @@ class ChangesetController(BaseRepoContro
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 @@ class ChangesetController(BaseRepoContro
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 @@ class ChangesetController(BaseRepoContro
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 @@ class ChangesetController(BaseRepoContro
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 @@ class ChangesetController(BaseRepoContro
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()
diff --git a/rhodecode/controllers/files.py b/rhodecode/controllers/files.py
--- a/rhodecode/controllers/files.py
+++ b/rhodecode/controllers/files.py
@@ -406,6 +406,7 @@ class FilesController(BaseRepoController
'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 @@ class FilesController(BaseRepoController
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 @@ class FilesController(BaseRepoController
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 @@ class FilesController(BaseRepoController
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 @@ class FilesController(BaseRepoController
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()
diff --git a/rhodecode/lib/diffs.py b/rhodecode/lib/diffs.py
--- a/rhodecode/lib/diffs.py
+++ b/rhodecode/lib/diffs.py
@@ -35,7 +35,7 @@ from mercurial.match import match
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 @@ def get_gitdiff(filenode_old, filenode_n
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