comparison MoinMoin/action/SyncPages.py @ 1251:7b128ea29fc4

Further bug fixes in SyncPages and wikisync
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Wed, 09 Aug 2006 17:44:02 +0200
parents 32c936ab469e
children 9721b9e2a074
comparison
equal deleted inserted replaced
1250:97e9866e82c7 1251:7b128ea29fc4
218 # Public methods 218 # Public methods
219 def get_diff(self, pagename, from_rev, to_rev): 219 def get_diff(self, pagename, from_rev, to_rev):
220 """ Returns the binary diff of the remote page named pagename, given 220 """ Returns the binary diff of the remote page named pagename, given
221 from_rev and to_rev. """ 221 from_rev and to_rev. """
222 result = self.connection.getDiff(pagename, from_rev, to_rev) 222 result = self.connection.getDiff(pagename, from_rev, to_rev)
223 if isinstance(result, xmlrpclib.Fault):
224 raise Exception(result)
225 result["diff"] = str(result["diff"]) # unmarshal Binary object 223 result["diff"] = str(result["diff"]) # unmarshal Binary object
226 return result 224 return result
227 225
228 def merge_diff(self, pagename, diff, local_rev, delta_remote_rev, last_remote_rev, interwiki_name): 226 def merge_diff(self, pagename, diff, local_rev, delta_remote_rev, last_remote_rev, interwiki_name):
229 """ Merges the diff into the page on the remote side. """ 227 """ Merges the diff into the page on the remote side. """
230 result = self.connection.mergeDiff(pagename, xmlrpclib.Binary(diff), local_rev, delta_remote_rev, last_remote_rev, interwiki_name) 228 result = self.connection.mergeDiff(pagename, xmlrpclib.Binary(diff), local_rev, delta_remote_rev, last_remote_rev, interwiki_name)
231 print result
232 if isinstance(result, xmlrpclib.Fault):
233 raise Exception(result)
234 return result 229 return result
235 230
236 # Methods implementing the RemoteWiki interface 231 # Methods implementing the RemoteWiki interface
237 def get_interwiki_name(self): 232 def get_interwiki_name(self):
238 return self.connection.interwikiName()[0] 233 return self.connection.interwikiName()[0]
416 # XXX add locking, acquire read-lock on rp 411 # XXX add locking, acquire read-lock on rp
417 print "Processing %r" % rp 412 print "Processing %r" % rp
418 413
419 local_pagename = rp.local_name 414 local_pagename = rp.local_name
420 current_page = PageEditor(self.request, local_pagename) 415 current_page = PageEditor(self.request, local_pagename)
421 if wikiutil.containsConflictMarker(current_page.get_raw_body()):
422 self.log_status(ActionClass.WARN, _("Skipped page %(pagename)s because of a local unresolved conflict.") % {"pagename": local_pagename})
423 continue
424 current_rev = current_page.get_real_rev() 416 current_rev = current_page.get_real_rev()
425 417
426 tags = TagStore(current_page) 418 tags = TagStore(current_page)
427 matching_tags = tags.fetch(iwid_full=remote.iwid_full) 419 matching_tags = tags.fetch(iwid_full=remote.iwid_full)
428 matching_tags.sort() 420 matching_tags.sort()
421 #print "------ TAGS: " + repr(matching_tags) + repr(tags.tags)
429 422
430 if not matching_tags: 423 if not matching_tags:
431 remote_rev = None 424 remote_rev = None
432 local_rev = rp.local_rev # merge against the newest version 425 local_rev = rp.local_rev # merge against the newest version
433 old_contents = "" 426 old_contents = ""
446 is_remote_conflict = diff_result["conflict"] 439 is_remote_conflict = diff_result["conflict"]
447 assert diff_result["diffversion"] == 1 440 assert diff_result["diffversion"] == 1
448 diff = diff_result["diff"] 441 diff = diff_result["diff"]
449 current_remote_rev = diff_result["current"] 442 current_remote_rev = diff_result["current"]
450 443
444 # do not sync if the conflict is remote and local, or if it is local
445 # and the page has never been syncronised
446 if (wikiutil.containsConflictMarker(current_page.get_raw_body())
447 and (remote_rev is None or is_remote_conflict)):
448 self.log_status(ActionClass.WARN, _("Skipped page %(pagename)s because of a locally or remotely unresolved conflict.") % {"pagename": local_pagename})
449 continue
450
451 if remote_rev is None: # set the remote_rev for the case without any tags 451 if remote_rev is None: # set the remote_rev for the case without any tags
452 self.log_status(ActionClass.INFO, _("This is the first synchronisation between this page and the remote wiki.")) 452 self.log_status(ActionClass.INFO, _("This is the first synchronisation between this page and the remote wiki."))
453 remote_rev = current_remote_rev 453 remote_rev = current_remote_rev
454 454
455 new_contents = patch(old_contents, decompress(diff)).decode("utf-8") 455 new_contents = patch(old_contents, decompress(diff)).decode("utf-8")