annotate MoinMoin/action/diff.py @ 1019:6488692b1eb8

have all diff implementations at one place
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 24 Jul 2006 01:43:02 +0200
parents f5b796658f93
children ecece5db5288
rev   line source
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 """
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 MoinMoin - show diff between 2 page revisions
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 @copyright: 2000-2004 by Jürgen Hermann <jh@web.de>,
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
6 2006 by MoinMoin:ThomasWaldmann
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7 @license: GNU GPL, see COPYING for details.
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
8 """
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
9
1019
6488692b1eb8 have all diff implementations at one place
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1018
diff changeset
10 from MoinMoin import wikiutil
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11 from MoinMoin.logfile import editlog
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12 from MoinMoin.Page import Page
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
14 def execute(pagename, request):
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15 """ Handle "action=diff"
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
16 checking for either a "rev=formerrevision" parameter
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
17 or rev1 and rev2 parameters
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
18 """
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
19 if not request.user.may.read(pagename):
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
20 Page(request, pagename).send_page(request)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
21 return
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
22
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
23 try:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
24 date = request.form['date'][0]
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
25 try:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
26 date = long(date) # must be long for py 2.2.x
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
27 except StandardError:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
28 date = 0
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
29 except KeyError:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30 date = 0
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32 try:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33 rev1 = int(request.form.get('rev1', [-1])[0])
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34 except StandardError:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 rev1 = 0
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36 try:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
37 rev2 = int(request.form.get('rev2', [0])[0])
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
38 except StandardError:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
39 rev1 = 0
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
40
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
41 if rev1 == -1 and rev2 == 0:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
42 try:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
43 rev1 = int(request.form.get('rev', [-1])[0])
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
44 except StandardError:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
45 rev1 = -1
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
46
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
47 # spacing flag?
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
48 ignorews = int(request.form.get('ignorews', [0])[0])
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
49
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
50 _ = request.getText
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
51
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
52 # get a list of old revisions, and back out if none are available
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
53 currentpage = Page(request, pagename)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
54 revisions = currentpage.getRevList()
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
55 if len(revisions) < 2:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
56 currentpage.send_page(request, msg=_("No older revisions available!"))
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
57 return
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
58
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
59 if date: # this is how we get called from RecentChanges
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
60 rev1 = 0
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
61 log = editlog.EditLog(request, rootpagename=pagename)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
62 for line in log.reverse():
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
63 if date >= line.ed_time_usecs and int(line.rev) != 99999999:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
64 rev1 = int(line.rev)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
65 break
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
66 else:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
67 rev1 = 1
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
68 rev2 = 0
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
69
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
70 # Start output
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
71 # This action generate content in the user language
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
72 request.setContentLanguage(request.lang)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
73
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
74 request.http_headers()
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
75 request.theme.send_title(_('Diff for "%s"') % (pagename,), pagename=pagename, allow_doubleclick=1)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
76
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
77 if rev1 > 0 and rev2 > 0 and rev1 > rev2 or rev1 == 0 and rev2 > 0:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
78 rev1, rev2 = rev2, rev1
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
79
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
80 oldrev1, oldcount1 = None, 0
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
81 oldrev2, oldcount2 = None, 0
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
82
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
83 # get the filename of the version to compare to
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
84 edit_count = 0
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
85 for rev in revisions:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
86 edit_count += 1
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
87 if rev <= rev1:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
88 oldrev1, oldcount1 = rev, edit_count
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
89 if rev2 and rev >= rev2:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
90 oldrev2, oldcount2 = rev, edit_count
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
91 if oldrev1 and oldrev2 or oldrev1 and not rev2:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
92 break
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
93
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
94 if rev1 == -1:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
95 oldpage = Page(request, pagename, rev=revisions[1])
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
96 oldcount1 -= 1
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
97 elif rev1 == 0:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
98 oldpage = currentpage
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
99 # oldcount1 is still on init value 0
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
100 else:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
101 if oldrev1:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
102 oldpage = Page(request, pagename, rev=oldrev1)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
103 else:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
104 oldpage = Page(request, "$EmptyPage$") # hack
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
105 oldpage.set_raw_body("") # avoid loading from disk
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
106 oldrev1 = 0 # XXX
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
107
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
108 if rev2 == 0:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
109 newpage = currentpage
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
110 # oldcount2 is still on init value 0
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
111 else:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
112 if oldrev2:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
113 newpage = Page(request, pagename, rev=oldrev2)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
114 else:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
115 newpage = Page(request, "$EmptyPage$") # hack
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
116 newpage.set_raw_body("") # avoid loading from disk
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
117 oldrev2 = 0 # XXX
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
118
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
119 edit_count = abs(oldcount1 - oldcount2)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
120
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
121 # this should use the formatter, but there is none?
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
122 request.write('<div id="content">\n') # start content div
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
123 request.write('<p class="diff-header">')
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
124 request.write(_('Differences between revisions %d and %d') % (oldpage.get_real_rev(), newpage.get_real_rev()))
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
125 if edit_count > 1:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
126 request.write(' ' + _('(spanning %d versions)') % (edit_count,))
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
127 request.write('</p>')
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
128
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
129 if request.user.show_fancy_diff:
1019
6488692b1eb8 have all diff implementations at one place
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1018
diff changeset
130 from MoinMoin.util import diff_html
6488692b1eb8 have all diff implementations at one place
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1018
diff changeset
131 request.write(diff_html.diff(request, oldpage.get_raw_body(), newpage.get_raw_body()))
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
132 newpage.send_page(request, count_hit=0, content_only=1, content_id="content-below-diff")
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
133 else:
1019
6488692b1eb8 have all diff implementations at one place
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1018
diff changeset
134 from MoinMoin.util import diff_text
6488692b1eb8 have all diff implementations at one place
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1018
diff changeset
135 lines = diff_text.diff(oldpage.getlines(), newpage.getlines())
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
136 if not lines:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
137 msg = _("No differences found!")
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
138 if edit_count > 1:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
139 msg = msg + '<p>' + _('The page was saved %(count)d times, though!') % {
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
140 'count': edit_count}
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
141 request.write(msg)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
142 else:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
143 if ignorews:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
144 request.write(_('(ignoring whitespace)') + '<br>')
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
145 else:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
146 qstr = 'action=diff&ignorews=1'
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
147 if rev1: qstr = '%s&rev1=%s' % (qstr, rev1)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
148 if rev2: qstr = '%s&rev2=%s' % (qstr, rev2)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
149 request.write(Page(request, pagename).link_to(request,
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
150 text=_('Ignore changes in the amount of whitespace'),
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
151 querystr=qstr, rel='nofollow') + '<p>')
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
152
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
153 request.write('<pre>')
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
154 for line in lines:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
155 if line[0] == "@":
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
156 request.write('<hr>')
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
157 request.write(wikiutil.escape(line)+'\n')
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
158 request.write('</pre>')
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
159
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
160 request.write('</div>\n') # end content div
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
161 request.theme.send_footer(pagename)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
162 request.theme.send_closing_html()
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
163