Files
oddmuse/t/major.t
Alex Schroeder e25a621e6e Big changes to how diffs are generated
The original issue was that looking at all changes (action=rc all=1) the
resulting diff didn't always make sense if you clicked on the diff link.
It showed the difference between that revision and the current revision.
The PrintHtmlDiff sub was changed significantly to make it easier to
understand and to help fix this issue.

The drawback is that it now requires a new key in page and keep files:
lastmajorsummary. It goes with lastmajor and diff-major and records the
summary for that particular edit. As new changes will start recording
this new key, the change will slowly propagate in existing wikis.
Whenever you look at minor diffs, however, the existing summary key is
chosen. Plus, whenever you want to look at differences between
particular revisions, this is equivalent to looking at minor diffs. So
the only situation that is problematic is an edit history like the
following:

A - major change
B - major change (major diff, major summary, last major revision)
C - minor change

When looking at this page with diff=2, we want to show major diff, major
summary, last major revision. If B happened before this commit was
installed, the summary will be missing.
2015-09-06 14:32:36 +02:00

57 lines
3.0 KiB
Perl
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Copyright (C) 20062015 Alex Schroeder <alex@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
require 't/test.pl';
package OddMuse;
use Test::More tests => 60;
# start with minor
update_page('bar', 'one', '', 1); # lastmajor is undef
test_page(get_page('action=browse id=bar diff=1'), 'No diff available', 'one');
test_page(get_page('action=browse id=bar diff=2'), 'No diff available', 'one', 'Last edit');
update_page('bar', 'two', '', 1); # lastmajor is undef
test_page(get_page('action=browse id=bar diff=1'), 'No diff available', 'two');
test_page(get_page('action=browse id=bar diff=2'), 'one', 'two', 'Last edit');
update_page('bar', 'three'); # lastmajor is 3
test_page(get_page('action=browse id=bar diff=1'), 'two', 'three', 'Last edit');
test_page(get_page('action=browse id=bar diff=2'), 'two', 'three', 'Last edit');
update_page('bar', 'four'); # lastmajor is 4
test_page(get_page('action=browse id=bar diff=1'), 'three', 'four', 'Last edit');
test_page(get_page('action=browse id=bar diff=2'), 'three', 'four', 'Last edit');
# start with major
clear_pages();
update_page('bla', 'one'); # lastmajor is 1
test_page(get_page('action=browse id=bla diff=1'), 'No diff available', 'one', 'Last edit');
test_page(get_page('action=browse id=bla diff=2'), 'No diff available', 'one', 'Last edit');
update_page('bla', 'two', '', 1); # lastmajor is 1
test_page(get_page('action=browse id=bla diff=1'), 'No diff available', 'two', 'Last major edit',
'diff=2;id=bla;diffrevision=1');
test_page(get_page('action=browse id=bla diff=2'), 'one', 'two', 'Last edit');
update_page('bla', 'three'); # lastmajor is 3
test_page(get_page('action=browse id=bla diff=1'), 'two', 'three', 'Last edit');
test_page(get_page('action=browse id=bla diff=2'), 'two', 'three', 'Last edit');
update_page('bla', 'four', '', 1); # lastmajor is 3
test_page(get_page('action=browse id=bla diff=1'), 'two', 'three', 'Last major edit',
'diff=2;id=bla;diffrevision=3');
test_page(get_page('action=browse id=bla diff=2'), 'three', 'four', 'Last edit');
update_page('bla', 'five'); # lastmajor is 5
test_page(get_page('action=browse id=bla diff=1'), 'four', 'five', 'Last edit');
test_page(get_page('action=browse id=bla diff=2'), 'four', 'five', 'Last edit');
update_page('bla', 'six'); # lastmajor is 6
test_page(get_page('action=browse id=bla diff=1'), 'five', 'six', 'Last edit');
test_page(get_page('action=browse id=bla diff=2'), 'five', 'six', 'Last edit');