comparison 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
comparison
equal deleted inserted replaced
1334:a4efeab7a10f 1335:2cd1b40ea3e7
210 if debug: 210 if debug:
211 self.log_status(ActionClass.INFO, raw_suffix="Processing %r" % rp) 211 self.log_status(ActionClass.INFO, raw_suffix="Processing %r" % rp)
212 212
213 local_pagename = rp.local_name 213 local_pagename = rp.local_name
214 current_page = PageEditor(self.request, local_pagename) # YYY direct access 214 current_page = PageEditor(self.request, local_pagename) # YYY direct access
215 comment = u"Local Merge - %r" % (remote.get_interwiki_name() or remote.get_iwid())
215 216
216 tags = TagStore(current_page) 217 tags = TagStore(current_page)
217 218
218 matching_tags = tags.fetch(iwid_full=remote.iwid_full, direction=match_direction) 219 matching_tags = tags.fetch(iwid_full=remote.iwid_full, direction=match_direction)
219 matching_tags.sort() 220 matching_tags.sort()
236 if not remote_change and (direction == DOWN or not local_change): 237 if not remote_change and (direction == DOWN or not local_change):
237 return # no changes done, next page 238 return # no changes done, next page
238 if rp.local_deleted and rp.remote_deleted: 239 if rp.local_deleted and rp.remote_deleted:
239 return 240 return
240 if rp.remote_deleted and not local_change: 241 if rp.remote_deleted and not local_change:
241 self.log_status(ActionClass.ERROR, "Nothing done, I should have deleted %r locally" % rp) 242 msg = local.delete_page(rp.local_name, comment)
242 # XXX delete rp locally 243 if not msg:
244 self.log_status(ActionClass.INFO, _("Deleted page %s locally."), (rp.name, ))
245 else:
246 self.log_status(ActionClass.ERROR, _("Error while deleting page %s locally:"), (rp.name, ), msg)
243 return 247 return
244 if rp.local_deleted and not remote_change: 248 if rp.local_deleted and not remote_change:
245 self.log_status(ActionClass.ERROR, "Nothing done, I should have deleted %r remotely" % rp) 249 if direction == DOWN:
246 # XXX delete rp remotely 250 return
251 self.log_status(ActionClass.ERROR, "Nothing done, I should have deleted %r remotely" % rp) # XXX add
252 msg = remote.delete_page(rp.remote_name)
253 self.log_status(ActionClass.INFO, _("Deleted page %s remotely."), (rp.name, ))
247 return 254 return
248 if rp.local_mime_type != MIMETYPE_MOIN and not (local_change ^ remote_change): 255 if rp.local_mime_type != MIMETYPE_MOIN and not (local_change ^ remote_change):
249 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, )) 256 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, ))
250 return 257 return
251 if rp.local_mime_type != rp.remote_mime_type: 258 if rp.local_mime_type != rp.remote_mime_type:
322 329
323 diff = textdiff(new_contents, verynewtext_raw) 330 diff = textdiff(new_contents, verynewtext_raw)
324 if debug: 331 if debug:
325 self.log_status(ActionClass.INFO, raw_suffix="Diff against %r" % new_contents) 332 self.log_status(ActionClass.INFO, raw_suffix="Diff against %r" % new_contents)
326 333
327 comment = u"Local Merge - %r" % (remote.get_interwiki_name() or remote.get_iwid())
328
329 # XXX upgrade to write lock 334 # XXX upgrade to write lock
330 try: 335 try:
331 current_page.saveText(verynewtext, rp.local_rev, comment=comment) # YYY direct access 336 current_page.saveText(verynewtext, rp.local_rev, comment=comment) # YYY direct access
332 except PageEditor.Unchanged: 337 except PageEditor.Unchanged:
333 pass 338 pass