comparison MoinMoin/action/SyncPages.py @ 1350:650a2dc16b19

Renamed some variables in SyncPages, added more YYY markers.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Sun, 20 Aug 2006 16:19:11 +0200
parents 4d2dd952a513
children dfed953d5e9f
comparison
equal deleted inserted replaced
1349:4d2dd952a513 1350:650a2dc16b19
299 is_remote_conflict = NotImplemented 299 is_remote_conflict = NotImplemented
300 diff = None 300 diff = None
301 301
302 # do not sync if the conflict is remote and local, or if it is local 302 # do not sync if the conflict is remote and local, or if it is local
303 # and the page has never been syncronised 303 # and the page has never been syncronised
304 if (sp.local_mime_type == MIMETYPE_MOIN and wikiutil.containsConflictMarker(current_page.get_raw_body()) 304 if (sp.local_mime_type == MIMETYPE_MOIN and wikiutil.containsConflictMarker(current_page.get_raw_body()) # YYY direct access
305 and (remote_rev is None or is_remote_conflict)): 305 and (remote_rev is None or is_remote_conflict)):
306 self.log_status(ActionClass.WARN, _("Skipped page %s because of a locally or remotely unresolved conflict."), (local_pagename, )) 306 self.log_status(ActionClass.WARN, _("Skipped page %s because of a locally or remotely unresolved conflict."), (local_pagename, ))
307 return 307 return
308 308
309 if remote_rev is None and direction == BOTH: 309 if remote_rev is None and direction == BOTH:
310 self.log_status(ActionClass.INFO, _("This is the first synchronisation between this page and the remote wiki.")) 310 self.log_status(ActionClass.INFO, _("This is the first synchronisation between this page and the remote wiki."))
311 311
312 if sp.remote_deleted: 312 if sp.remote_deleted:
313 new_contents = "" 313 remote_contents = ""
314 elif diff is None: 314 elif diff is None:
315 new_contents = old_contents 315 remote_contents = old_contents
316 else: 316 else:
317 new_contents = patch(patch_base_contents, decompress(diff)) 317 remote_contents = patch(patch_base_contents, decompress(diff))
318 318
319 if sp.local_mime_type == MIMETYPE_MOIN: 319 if sp.local_mime_type == MIMETYPE_MOIN:
320 new_contents_unicode = new_contents.decode("utf-8") 320 remote_contents_unicode = remote_contents.decode("utf-8")
321 # here, the actual 3-way merge happens 321 # here, the actual 3-way merge happens
322 if debug: 322 if debug:
323 self.log_status(ActionClass.INFO, raw_suffix="Merging %r, %r and %r" % (old_contents.decode("utf-8"), new_contents_unicode, current_page.get_raw_body())) 323 self.log_status(ActionClass.INFO, raw_suffix="Merging %r, %r and %r" % (old_contents.decode("utf-8"), remote_contents_unicode, current_page.get_raw_body()))
324 verynewtext = diff3.text_merge(old_contents.decode("utf-8"), new_contents_unicode, current_page.get_raw_body(), 2, *conflict_markers) 324 merged_text = diff3.text_merge(old_contents.decode("utf-8"), remote_contents_unicode, current_page.get_raw_body(), 2, *conflict_markers) # YYY direct access
325 verynewtext_raw = verynewtext.encode("utf-8") 325 merged_text_raw = merged_text.encode("utf-8")
326 else: 326 else:
327 if diff is None: 327 if diff is None:
328 verynewtext_raw = new_contents 328 merged_text_raw = remote_contents
329 else: 329 else:
330 verynewtext_raw = current_page.get_raw_body_str() 330 merged_text_raw = current_page.get_raw_body_str() # YYY direct access
331 331
332 diff = textdiff(new_contents, verynewtext_raw) 332 diff = textdiff(remote_contents, merged_text_raw)
333 if debug: 333 if debug:
334 self.log_status(ActionClass.INFO, raw_suffix="Diff against %r" % new_contents) 334 self.log_status(ActionClass.INFO, raw_suffix="Diff against %r" % remote_contents)
335 335
336 # XXX upgrade to write lock 336 # XXX upgrade to write lock
337 try: 337 try:
338 current_page.saveText(verynewtext, sp.local_rev, comment=comment) # YYY direct access 338 current_page.saveText(merged_text, sp.local_rev, comment=comment) # YYY direct access
339 except PageEditor.Unchanged: 339 except PageEditor.Unchanged:
340 pass 340 pass
341 except PageEditor.EditConflict: 341 except PageEditor.EditConflict:
342 assert False, "You stumbled on a problem with the current storage system - I cannot lock pages" 342 assert False, "You stumbled on a problem with the current storage system - I cannot lock pages"
343 343
344 new_local_rev = current_page.get_real_rev() 344 new_local_rev = current_page.get_real_rev() # YYY direct access
345 345
346 if direction == BOTH: 346 if direction == BOTH:
347 try: 347 try:
348 very_current_remote_rev = remote.merge_diff(sp.remote_name, compress(diff), new_local_rev, current_remote_rev, current_remote_rev, local_full_iwid, sp.name) 348 very_current_remote_rev = remote.merge_diff(sp.remote_name, compress(diff), new_local_rev, current_remote_rev, current_remote_rev, local_full_iwid, sp.name)
349 except Exception, e: 349 except Exception, e:
351 else: 351 else:
352 very_current_remote_rev = current_remote_rev 352 very_current_remote_rev = current_remote_rev
353 353
354 tags.add(remote_wiki=remote_full_iwid, remote_rev=very_current_remote_rev, current_rev=new_local_rev, direction=direction, normalised_name=sp.name) 354 tags.add(remote_wiki=remote_full_iwid, remote_rev=very_current_remote_rev, current_rev=new_local_rev, direction=direction, normalised_name=sp.name)
355 355
356 if sp.local_mime_type != MIMETYPE_MOIN or not wikiutil.containsConflictMarker(verynewtext): 356 if sp.local_mime_type != MIMETYPE_MOIN or not wikiutil.containsConflictMarker(merged_text):
357 self.log_status(ActionClass.INFO, _("Page successfully merged.")) 357 self.log_status(ActionClass.INFO, _("Page successfully merged."))
358 else: 358 else:
359 self.log_status(ActionClass.WARN, _("Page merged with conflicts.")) 359 self.log_status(ActionClass.WARN, _("Page merged with conflicts."))
360 360
361 # XXX release lock 361 # XXX release lock