##// END OF EJS Templates
added line context control to diffs
marcink -
r1768:5610fd9b beta
parent child Browse files
Show More
@@ -60,6 +60,7 b' class ChangesetController(BaseRepoContro'
60
60
61 def index(self, revision):
61 def index(self, revision):
62 ignore_whitespace = request.GET.get('ignorews') == '1'
62 ignore_whitespace = request.GET.get('ignorews') == '1'
63 line_context = request.GET.get('context', 3)
63 def wrap_to_table(str):
64 def wrap_to_table(str):
64
65
65 return '''<table class="code-difftable">
66 return '''<table class="code-difftable">
@@ -131,7 +132,8 b' class ChangesetController(BaseRepoContro'
131 c.sum_added += node.size
132 c.sum_added += node.size
132 if c.sum_added < self.cut_off_limit:
133 if c.sum_added < self.cut_off_limit:
133 f_gitdiff = diffs.get_gitdiff(filenode_old, node,
134 f_gitdiff = diffs.get_gitdiff(filenode_old, node,
134 ignore_whitespace=ignore_whitespace)
135 ignore_whitespace=ignore_whitespace,
136 context=line_context)
135 d = diffs.DiffProcessor(f_gitdiff, format='gitdiff')
137 d = diffs.DiffProcessor(f_gitdiff, format='gitdiff')
136
138
137 st = d.stat()
139 st = d.stat()
@@ -170,7 +172,8 b' class ChangesetController(BaseRepoContro'
170
172
171 if c.sum_removed < self.cut_off_limit:
173 if c.sum_removed < self.cut_off_limit:
172 f_gitdiff = diffs.get_gitdiff(filenode_old, node,
174 f_gitdiff = diffs.get_gitdiff(filenode_old, node,
173 ignore_whitespace=ignore_whitespace)
175 ignore_whitespace=ignore_whitespace,
176 context=line_context)
174 d = diffs.DiffProcessor(f_gitdiff,
177 d = diffs.DiffProcessor(f_gitdiff,
175 format='gitdiff')
178 format='gitdiff')
176 st = d.stat()
179 st = d.stat()
@@ -222,6 +225,7 b' class ChangesetController(BaseRepoContro'
222
225
223 method = request.GET.get('diff', 'show')
226 method = request.GET.get('diff', 'show')
224 ignore_whitespace = request.GET.get('ignorews') == '1'
227 ignore_whitespace = request.GET.get('ignorews') == '1'
228 line_context = request.GET.get('context', 3)
225 try:
229 try:
226 c.scm_type = c.rhodecode_repo.alias
230 c.scm_type = c.rhodecode_repo.alias
227 c.changeset = c.rhodecode_repo.get_changeset(revision)
231 c.changeset = c.rhodecode_repo.get_changeset(revision)
@@ -241,7 +245,8 b' class ChangesetController(BaseRepoContro'
241 diff = _('binary file') + '\n'
245 diff = _('binary file') + '\n'
242 else:
246 else:
243 f_gitdiff = diffs.get_gitdiff(filenode_old, node,
247 f_gitdiff = diffs.get_gitdiff(filenode_old, node,
244 ignore_whitespace=ignore_whitespace)
248 ignore_whitespace=ignore_whitespace,
249 context=line_context)
245 diff = diffs.DiffProcessor(f_gitdiff,
250 diff = diffs.DiffProcessor(f_gitdiff,
246 format='gitdiff').raw_diff()
251 format='gitdiff').raw_diff()
247
252
@@ -255,7 +260,8 b' class ChangesetController(BaseRepoContro'
255 diff = _('binary file')
260 diff = _('binary file')
256 else:
261 else:
257 f_gitdiff = diffs.get_gitdiff(filenode_old, node,
262 f_gitdiff = diffs.get_gitdiff(filenode_old, node,
258 ignore_whitespace=ignore_whitespace)
263 ignore_whitespace=ignore_whitespace,
264 context=line_context)
259 diff = diffs.DiffProcessor(f_gitdiff,
265 diff = diffs.DiffProcessor(f_gitdiff,
260 format='gitdiff').raw_diff()
266 format='gitdiff').raw_diff()
261
267
@@ -406,6 +406,7 b' class FilesController(BaseRepoController'
406 'repository.admin')
406 'repository.admin')
407 def diff(self, repo_name, f_path):
407 def diff(self, repo_name, f_path):
408 ignore_whitespace = request.GET.get('ignorews') == '1'
408 ignore_whitespace = request.GET.get('ignorews') == '1'
409 line_context = request.GET.get('context', 3)
409 diff1 = request.GET.get('diff1')
410 diff1 = request.GET.get('diff1')
410 diff2 = request.GET.get('diff2')
411 diff2 = request.GET.get('diff2')
411 c.action = request.GET.get('diff')
412 c.action = request.GET.get('diff')
@@ -433,7 +434,8 b' class FilesController(BaseRepoController'
433
434
434 if c.action == 'download':
435 if c.action == 'download':
435 _diff = diffs.get_gitdiff(node1, node2,
436 _diff = diffs.get_gitdiff(node1, node2,
436 ignore_whitespace=ignore_whitespace)
437 ignore_whitespace=ignore_whitespace,
438 context=line_context)
437 diff = diffs.DiffProcessor(_diff,format='gitdiff')
439 diff = diffs.DiffProcessor(_diff,format='gitdiff')
438
440
439 diff_name = '%s_vs_%s.diff' % (diff1, diff2)
441 diff_name = '%s_vs_%s.diff' % (diff1, diff2)
@@ -444,7 +446,8 b' class FilesController(BaseRepoController'
444
446
445 elif c.action == 'raw':
447 elif c.action == 'raw':
446 _diff = diffs.get_gitdiff(node1, node2,
448 _diff = diffs.get_gitdiff(node1, node2,
447 ignore_whitespace=ignore_whitespace)
449 ignore_whitespace=ignore_whitespace,
450 context=line_context)
448 diff = diffs.DiffProcessor(_diff,format='gitdiff')
451 diff = diffs.DiffProcessor(_diff,format='gitdiff')
449 response.content_type = 'text/plain'
452 response.content_type = 'text/plain'
450 return diff.raw_diff()
453 return diff.raw_diff()
@@ -458,7 +461,8 b' class FilesController(BaseRepoController'
458 c.big_diff = True
461 c.big_diff = True
459 else:
462 else:
460 _diff = diffs.get_gitdiff(node1, node2,
463 _diff = diffs.get_gitdiff(node1, node2,
461 ignore_whitespace=ignore_whitespace)
464 ignore_whitespace=ignore_whitespace,
465 context=line_context)
462 diff = diffs.DiffProcessor(_diff,format='gitdiff')
466 diff = diffs.DiffProcessor(_diff,format='gitdiff')
463 c.cur_diff = diff.as_html()
467 c.cur_diff = diff.as_html()
464 else:
468 else:
@@ -473,7 +477,8 b' class FilesController(BaseRepoController'
473
477
474 else:
478 else:
475 _diff = diffs.get_gitdiff(node1, node2,
479 _diff = diffs.get_gitdiff(node1, node2,
476 ignore_whitespace=ignore_whitespace)
480 ignore_whitespace=ignore_whitespace,
481 context=line_context)
477 diff = diffs.DiffProcessor(_diff,format='gitdiff')
482 diff = diffs.DiffProcessor(_diff,format='gitdiff')
478 c.cur_diff = diff.as_html()
483 c.cur_diff = diff.as_html()
479
484
@@ -35,7 +35,7 b' from mercurial.match import match'
35 from vcs.exceptions import VCSError
35 from vcs.exceptions import VCSError
36 from vcs.nodes import FileNode
36 from vcs.nodes import FileNode
37
37
38 def get_gitdiff(filenode_old, filenode_new, ignore_whitespace=True):
38 def get_gitdiff(filenode_old, filenode_new, ignore_whitespace=True, context=3):
39 """
39 """
40 Returns git style diff between given ``filenode_old`` and ``filenode_new``.
40 Returns git style diff between given ``filenode_old`` and ``filenode_new``.
41
41
@@ -52,7 +52,7 b' def get_gitdiff(filenode_old, filenode_n'
52
52
53 repo = filenode_new.changeset.repository
53 repo = filenode_new.changeset.repository
54 vcs_gitdiff = repo._get_diff(old_raw_id, new_raw_id, filenode_new.path,
54 vcs_gitdiff = repo._get_diff(old_raw_id, new_raw_id, filenode_new.path,
55 ignore_whitespace)
55 ignore_whitespace, context)
56
56
57 return vcs_gitdiff
57 return vcs_gitdiff
58
58
General Comments 0
You need to be logged in to leave comments. Login now