changeset 2237:4238e46245d4

fixed diff action for deleted pages
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 10 Jun 2007 01:08:15 +0200
parents ee8beeddd28d
children 529a3c5e6d0e
files MoinMoin/action/diff.py
diffstat 1 files changed, 12 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/diff.py	Thu Jun 21 09:45:16 2007 +0200
+++ b/MoinMoin/action/diff.py	Sun Jun 10 01:08:15 2007 +0200
@@ -50,8 +50,8 @@
 
     # get a list of old revisions, and back out if none are available
     currentpage = Page(request, pagename)
-    revisions = currentpage.getRevList()
-    if len(revisions) < 2:
+    currentrev = currentpage.current_rev()
+    if currentrev < 2:
         currentpage.send_page(msg=_("No older revisions available!"))
         return
 
@@ -76,46 +76,25 @@
     if rev1 > 0 and rev2 > 0 and rev1 > rev2 or rev1 == 0 and rev2 > 0:
         rev1, rev2 = rev2, rev1
 
-    oldrev1, oldcount1 = None, 0
-    oldrev2, oldcount2 = None, 0
-
-    # get the filename of the version to compare to
-    edit_count = 0
-    for rev in revisions:
-        edit_count += 1
-        if rev <= rev1:
-            oldrev1, oldcount1 = rev, edit_count
-        if rev2 and rev >= rev2:
-            oldrev2, oldcount2 = rev, edit_count
-        if oldrev1 and oldrev2 or oldrev1 and not rev2:
-            break
-
     if rev1 == -1:
-        oldpage = Page(request, pagename, rev=revisions[1])
-        oldcount1 -= 1
+        oldrev = currentrev - 1
+        oldpage = Page(request, pagename, rev=oldrev)
     elif rev1 == 0:
+        oldrev = currentrev
         oldpage = currentpage
-        # oldcount1 is still on init value 0
     else:
-        if oldrev1:
-            oldpage = Page(request, pagename, rev=oldrev1)
-        else:
-            oldpage = Page(request, "$EmptyPage$") # hack
-            oldpage.set_raw_body("")    # avoid loading from disk
-            oldrev1 = 0 # XXX
+        oldrev = rev1
+        oldpage = Page(request, pagename, rev=oldrev)
 
     if rev2 == 0:
+        newrev = currentrev
         newpage = currentpage
-        # oldcount2 is still on init value 0
     else:
-        if oldrev2:
-            newpage = Page(request, pagename, rev=oldrev2)
-        else:
-            newpage = Page(request, "$EmptyPage$") # hack
-            newpage.set_raw_body("")    # avoid loading from disk
-            oldrev2 = 0 # XXX
+        newrev = rev2
+        newpage = Page(request, pagename, rev=newrev)
 
-    edit_count = abs(oldcount1 - oldcount2)
+    edit_count = abs(newrev - oldrev)
+
     f = request.formatter
     request.write(f.div(1, id="content"))
     request.write(f.paragraph(1, css_class="diff-header"))