diff MoinMoin/action/SyncPages.py @ 1335:2cd1b40ea3e7

Added support for deletion of local pages.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Sat, 19 Aug 2006 22:53:21 +0200
parents 16a854a172c9
children bf59bd23289b
line wrap: on
line diff
--- a/MoinMoin/action/SyncPages.py	Sat Aug 19 22:34:33 2006 +0200
+++ b/MoinMoin/action/SyncPages.py	Sat Aug 19 22:53:21 2006 +0200
@@ -212,6 +212,7 @@
 
             local_pagename = rp.local_name
             current_page = PageEditor(self.request, local_pagename) # YYY direct access
+            comment = u"Local Merge - %r" % (remote.get_interwiki_name() or remote.get_iwid())
 
             tags = TagStore(current_page)
 
@@ -238,12 +239,18 @@
                 if rp.local_deleted and rp.remote_deleted:
                     return
                 if rp.remote_deleted and not local_change:
-                    self.log_status(ActionClass.ERROR, "Nothing done, I should have deleted %r locally" % rp)
-                    # XXX delete rp locally
+                    msg = local.delete_page(rp.local_name, comment)
+                    if not msg:
+                        self.log_status(ActionClass.INFO, _("Deleted page %s locally."), (rp.name, ))
+                    else:
+                        self.log_status(ActionClass.ERROR, _("Error while deleting page %s locally:"), (rp.name, ), msg)
                     return
                 if rp.local_deleted and not remote_change:
-                    self.log_status(ActionClass.ERROR, "Nothing done, I should have deleted %r remotely" % rp)
-                    # XXX delete rp remotely
+                    if direction == DOWN:
+                        return
+                    self.log_status(ActionClass.ERROR, "Nothing done, I should have deleted %r remotely" % rp) # XXX add
+                    msg = remote.delete_page(rp.remote_name)
+                    self.log_status(ActionClass.INFO, _("Deleted page %s remotely."), (rp.name, ))
                     return
                 if rp.local_mime_type != MIMETYPE_MOIN and not (local_change ^ remote_change):
                     self.log_status(ActionClass.WARN, _("The item %s cannot be merged but was changed in both wikis. Please delete it in one of both wikis and try again."), (rp.name, ))
@@ -324,8 +331,6 @@
             if debug:
                 self.log_status(ActionClass.INFO, raw_suffix="Diff against %r" % new_contents)
 
-            comment = u"Local Merge - %r" % (remote.get_interwiki_name() or remote.get_iwid())
-
             # XXX upgrade to write lock
             try:
                 current_page.saveText(verynewtext, rp.local_rev, comment=comment) # YYY direct access