changeset 1330:df88b475c1f0

Reworked debugging.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Sat, 19 Aug 2006 16:18:19 +0200
parents 4a8c4849d162
children b7352ce35900
files MoinMoin/action/SyncPages.py MoinMoin/wikisync.py
diffstat 2 files changed, 18 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/SyncPages.py	Sat Aug 19 16:06:52 2006 +0200
+++ b/MoinMoin/action/SyncPages.py	Sat Aug 19 16:18:19 2006 +0200
@@ -30,6 +30,8 @@
 from MoinMoin.util import diff3
 
 
+debug = True
+
 # map sync directions
 directions_map = {"up": UP, "down": DOWN, "both": BOTH}
 
@@ -128,7 +130,7 @@
 
             local = MoinLocalWiki(self.request, params["localPrefix"], params["pageList"])
             try:
-                remote = MoinRemoteWiki(self.request, params["remoteWiki"], params["remotePrefix"], params["pageList"])
+                remote = MoinRemoteWiki(self.request, params["remoteWiki"], params["remotePrefix"], params["pageList"], verbose=debug)
             except UnsupportedWikiException, (msg, ):
                 raise ActionStatus(msg)
 
@@ -215,7 +217,8 @@
             # let's do the simple case first, can be refactored later to match all cases
             # XXX handle deleted pages
             # XXX add locking, acquire read-lock on rp
-            # XXX print "Processing %r" % rp
+            if debug:
+                self.log_status(ActionClass.INFO, "Processing %r" % rp)
 
             local_pagename = rp.local_name
             current_page = PageEditor(self.request, local_pagename) # YYY direct access
@@ -225,7 +228,8 @@
 
             matching_tags = tags.fetch(iwid_full=remote.iwid_full, direction=match_direction)
             matching_tags.sort()
-            # print "------ TAGS: " + repr(matching_tags) + repr(tags.tags) XXX
+            if debug:
+                self.log_status(ActionClass.INFO, "Tags: %r [[BR]] All: %r" % (matching_tags, tags.tags))
 
             # some default values for non matching tags
             normalised_name = None
@@ -296,8 +300,8 @@
             if rp.local_mime_type == MIMETYPE_MOIN:
                 new_contents_unicode = new_contents.decode("utf-8")
                 # here, the actual merge happens
-                # XXX
-                # print "Merging %r, %r and %r" % (old_contents.decode("utf-8"), new_contents, current_page.get_raw_body())
+                if debug:
+                    self.log_status(ActionClass.INFO, "Merging %r, %r and %r" % (old_contents.decode("utf-8"), new_contents_unicode, current_page.get_raw_body()))
                 verynewtext = diff3.text_merge(old_contents.decode("utf-8"), new_contents_unicode, current_page.get_raw_body(), 2, *conflict_markers)
                 verynewtext_raw = verynewtext.encode("utf-8")
             else:
@@ -307,7 +311,8 @@
                     verynewtext_raw = current_page.get_raw_body_str()
 
             diff = textdiff(new_contents, verynewtext_raw)
-            # print "Diff against %r" % new_contents.encode("utf-8") # XXX
+            if debug:
+                self.log_status(ActionClass.INFO, "Diff against %r" % new_contents.encode("utf-8"))
 
             comment = u"Local Merge - %r" % (remote.get_interwiki_name() or remote.get_iwid())
 
@@ -338,9 +343,10 @@
 
             # XXX release lock
 
-        on_both_sides = list(SyncPage.iter_local_and_remote(m_pages))
-        remote_but_not_local = list(SyncPage.iter_remote_only(m_pages))
-        local_but_not_remote = list(SyncPage.iter_local_only(m_pages))
+        # XXX remove?
+        #on_both_sides = SyncPage.iter_local_and_remote(m_pages)
+        #remote_but_not_local = SyncPage.iter_remote_only(m_pages)
+        #local_but_not_remote = SyncPage.iter_local_only(m_pages)
 
         # some initial test code (XXX remove)
         #r_new_pages = u", ".join([unicode(x) for x in remote_but_not_local])
--- a/MoinMoin/wikisync.py	Sat Aug 19 16:06:52 2006 +0200
+++ b/MoinMoin/wikisync.py	Sat Aug 19 16:18:19 2006 +0200
@@ -177,10 +177,11 @@
 
 class MoinRemoteWiki(RemoteWiki):
     """ Used for MoinMoin wikis reachable via XMLRPC. """
-    def __init__(self, request, interwikiname, prefix, pagelist):
+    def __init__(self, request, interwikiname, prefix, pagelist, verbose=False):
         self.request = request
         self.prefix = prefix
         self.pagelist = pagelist
+        self.verbose = verbose
         _ = self.request.getText
 
         wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, '%s:""' % (interwikiname, ))
@@ -212,7 +213,7 @@
             self.iwid_full = packLine([remote_iwid, interwikiname])
 
     def createConnection(self):
-        return xmlrpclib.ServerProxy(self.xmlrpc_url, allow_none=True, verbose=True)
+        return xmlrpclib.ServerProxy(self.xmlrpc_url, allow_none=True, verbose=self.verbose)
 
     # Public methods
     def get_diff(self, pagename, from_rev, to_rev, n_name=None):