Opened 6 years ago
Last modified 6 years ago
#13083 new enhancement
Unified diff with contextall
Reported by: | anonymous | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | undecided |
Component: | version control/changeset view | Version: | |
Severity: | normal | Keywords: | diff |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description (last modified by )
The changeset view (example 3: changeset:16824) allows to "Show the changes in full context" via ?contextall=1
(example 2: changeset:16824?contextall=1).
It also has a link to "Download in other formats: Unified Diff" (example 3: changeset:16824?format=diff&new=16824).
But combining these two features is not currently possible. On the example 2 page the contextall=1
parameter is not included in the Unified Diff link.
And even if it is manually added it does not seem to have any effect (example 4: changeset:16824?format=diff&new=16824&contextall=1).
Would it be possible to make this work? This is very useful for people that prefer using an offline diff viewer tool.
Attachments (0)
Change History (3)
comment:1 by , 6 years ago
Description: | modified (diff) |
---|---|
Milestone: | → undecided |
comment:2 by , 6 years ago
-
trac/versioncontrol/web_ui/changeset.py
diff -r ec566f6d999f trac/versioncontrol/web_ui/changeset.py
a b 349 349 self._render_html(req, repos, chgset, restricted, data) 350 350 351 351 if chgset: 352 diff_params = 'new=%s' % new352 diff_params = {'new': new} 353 353 else: 354 diff_params = unicode_urlencode({354 diff_params = { 355 355 'new_path': full_new_path, 'new': new, 356 'old_path': full_old_path, 'old': old}) 357 add_link(req, 'alternate', '?format=diff&' + diff_params, 356 'old_path': full_old_path, 'old': old} 357 diff_params_without_opts = unicode_urlencode(diff_params) 358 diff_params.update(diff_opts) 359 diff_params_with_opts = unicode_urlencode(diff_params) 360 add_link(req, 'alternate', '?format=diff&' + diff_params_with_opts, 358 361 _('Unified Diff'), 'text/plain', 'diff') 359 add_link(req, 'alternate', '?format=zip&' + diff_params, 362 if diff_params_with_opts != diff_params_without_opts: 363 add_link(req, 'alternate', '?format=diff&' + diff_params_without_opts, 364 _('Plain Unified Diff'), 'text/plain', 'diff') 365 add_link(req, 'alternate', '?format=zip&' + diff_params_without_opts, 360 366 _('Zip Archive'), 'application/zip', 'zip') 361 367 add_script(req, 'common/js/diff.js') 362 368 add_stylesheet(req, 'common/css/changeset.css') … … 747 753 options = data['diff']['options'] 748 754 context = options.get('contextlines', 3) 749 755 if context < 0 or options.get('contextall'): 750 context = 3 # FIXME: unified_diff bugs with context=None756 context = None 751 757 ignore_blank_lines = options.get('ignoreblanklines') 752 758 ignore_case = options.get('ignorecase') 753 759 ignore_space = options.get('ignorewhitespace')
This seems to work. Does anyone know what that FIXME comment refers to? It is very old: It was first(?) added here and then (via this move) here. This and this may also be related. But I see no hint about what the "bug" is or was. Is it still relevant?
comment:3 by , 6 years ago
Thanks for the patch and investigation.
I re-investigated the unified diff link.
The context lines, ignore blank lines, ignore case changes and ignore white space changes options are saved in the user session when prefs form is submitted and the unified diff link uses the saved options. However, context all option is not saved in the user session. The behavior is introduced in r9322 and comment:2:ticket:6423.
Then, I consider the unified diff link should respect contextall=1
parameter.
[d87e6dc3c/jomae.git] (I'll add unit tests).
Another thing, I noticed, after submitting negative integer or non-digits in context lines textbox, showing all
in the textbox and the changeset view shows contextall diff. I think we should remove the weird behavior or Show the changes in full context radio should be selected.
Currently, Unified diff link in Download in other formats doesn't respect all options of prefs form in changeset view (e.g. Blank lines, …).
I think we should keep it but it might be a bit nice to show another unified diff link respected the options.