changeset 1272:e85ad6a95ae5

Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Mon, 14 Aug 2006 22:26:41 +0200
parents bb2f70fc9734
children 11778954b99c
files MoinMoin/_tests/test_wikisync.py MoinMoin/action/SyncPages.py MoinMoin/wikisync.py MoinMoin/xmlrpc/__init__.py docs/CHANGES.aschremmer
diffstat 5 files changed, 27 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_wikisync.py	Mon Aug 14 22:06:53 2006 +0200
+++ b/MoinMoin/_tests/test_wikisync.py	Mon Aug 14 22:26:41 2006 +0200
@@ -27,7 +27,7 @@
     def testBasicTagThings(self):
         tags = TagStore(self.page)
         self.assert_(not tags.get_all_tags())
-        tags.add(remote_wiki="foo", remote_rev=1, current_rev=2, direction=BOTH)
+        tags.add(remote_wiki="foo", remote_rev=1, current_rev=2, direction=BOTH, normalised_name="FrontPage")
         tags = TagStore(self.page) # reload
         self.assert_(tags.get_all_tags()[0].remote_rev == 1)
     
--- a/MoinMoin/action/SyncPages.py	Mon Aug 14 22:06:53 2006 +0200
+++ b/MoinMoin/action/SyncPages.py	Mon Aug 14 22:26:41 2006 +0200
@@ -141,6 +141,8 @@
                           |          | Wiki A, there is a merge with a conflict.
                           |          | Otherwise (no changes past last merge),
                           |          | the page is deleted in Wiki A.
+                          |          | This needs static info that could be
+                          |          | transferred with the pagelist.
                 ----------+----------+-------------------------------
                 exists    | non-     | Now the wiki knows that the page was renamed.
                 with tags | existant | There should be an RPC method that asks
@@ -148,8 +150,14 @@
                           |          | on page rename). Then the page is
                           |          | renamed in Wiki A as well and the sync
                           |          | is done normally.
+                          |          | Every wiki retains a dict that maps
+                          |          | (IWID, oldname) => newname and that is
+                          |          | updated on every rename. oldname refers
+                          |          | to the pagename known by the old wiki (can be
+                          |          | gathered from tags).
                 ----------+----------+-------------------------------
-                exists    | any case | Do a sync without considering tags
+                exists    | any case | Try a rename search first, then
+                          |          | do a sync without considering tags
                 with tags | with non | to ensure data integrity.
                           | matching |
                           | tags     |
@@ -272,13 +280,13 @@
 
             if direction == BOTH:
                 try:
-                    very_current_remote_rev = remote.merge_diff(rp.remote_name, compress(diff), new_local_rev, current_remote_rev, current_remote_rev, local_full_iwid)
+                    very_current_remote_rev = remote.merge_diff(rp.remote_name, compress(diff), new_local_rev, current_remote_rev, current_remote_rev, local_full_iwid, rp.name)
                 except Exception, e:
                     raise # XXX rollback locally and do not tag locally
             else:
                 very_current_remote_rev = current_remote_rev
 
-            tags.add(remote_wiki=remote_full_iwid, remote_rev=very_current_remote_rev, current_rev=new_local_rev, direction=direction)
+            tags.add(remote_wiki=remote_full_iwid, remote_rev=very_current_remote_rev, current_rev=new_local_rev, direction=direction, normalised_name=rp.name)
 
             if not wikiutil.containsConflictMarker(verynewtext):
                 self.log_status(ActionClass.INFO, _("Page successfully merged."))
--- a/MoinMoin/wikisync.py	Mon Aug 14 22:06:53 2006 +0200
+++ b/MoinMoin/wikisync.py	Mon Aug 14 22:26:41 2006 +0200
@@ -213,9 +213,9 @@
         result["diff"] = str(result["diff"]) # unmarshal Binary object
         return result
 
-    def merge_diff(self, pagename, diff, local_rev, delta_remote_rev, last_remote_rev, interwiki_name):
+    def merge_diff(self, pagename, diff, local_rev, delta_remote_rev, last_remote_rev, interwiki_name, n_name):
         """ Merges the diff into the page on the remote side. """
-        result = self.connection.mergeDiff(pagename, xmlrpclib.Binary(diff), local_rev, delta_remote_rev, last_remote_rev, interwiki_name)
+        result = self.connection.mergeDiff(pagename, xmlrpclib.Binary(diff), local_rev, delta_remote_rev, last_remote_rev, interwiki_name, n_name)
         return result
 
     # Methods implementing the RemoteWiki interface
@@ -303,7 +303,7 @@
 class Tag(object):
     """ This class is used to store information about merging state. """
     
-    def __init__(self, remote_wiki, remote_rev, current_rev, direction):
+    def __init__(self, remote_wiki, remote_rev, current_rev, direction, normalised_name):
         """ Creates a new Tag.
         
         @param remote_wiki: The identifier of the remote wiki.
@@ -311,14 +311,17 @@
         @param current_rev: The related local revision.
         @param direction: The direction of the sync, encoded as an integer.
         """
-        assert isinstance(remote_wiki, str) and isinstance(remote_rev, int) and isinstance(current_rev, int)
+        assert (isinstance(remote_wiki, basestring) and isinstance(remote_rev, int)
+                and isinstance(current_rev, int) and isinstance(direction, int)
+                and isinstance(normalised_name, basestring))
         self.remote_wiki = remote_wiki
         self.remote_rev = remote_rev
         self.current_rev = current_rev
         self.direction = direction
+        self.normalised_name = normalised_name
 
     def __repr__(self):
-        return u"<Tag remote_wiki=%r remote_rev=%r current_rev=%r>" % (self.remote_wiki, self.remote_rev, self.current_rev)
+        return u"<Tag normalised_pagename=%r remote_wiki=%r remote_rev=%r current_rev=%r>" % (self.normalised_name, self.remote_wiki, self.remote_rev, self.current_rev)
 
     def __cmp__(self, other):
         if not isinstance(other, Tag):
--- a/MoinMoin/xmlrpc/__init__.py	Mon Aug 14 22:06:53 2006 +0200
+++ b/MoinMoin/xmlrpc/__init__.py	Mon Aug 14 22:26:41 2006 +0200
@@ -642,7 +642,7 @@
         else:
             return [self._outstr(name), iwid]
 
-    def xmlrpc_mergeDiff(self, pagename, diff, local_rev, delta_remote_rev, last_remote_rev, interwiki_name):
+    def xmlrpc_mergeDiff(self, pagename, diff, local_rev, delta_remote_rev, last_remote_rev, interwiki_name, normalised_name):
         """ Merges a diff sent by the remote machine and returns the number of the new revision.
             Additionally, this method tags the new revision.
             
@@ -652,6 +652,7 @@
             @param delta_remote_rev: The revno that the diff is taken against.
             @param last_remote_rev: The last revno of the page `pagename` that is known by the other wiki site.
             @param interwiki_name: Used to build the interwiki tag.
+            @param normalised_name: The normalised pagename that is common to both wikis.
         """
         from MoinMoin.util.bdiff import decompress, patch
         from MoinMoin.wikisync import TagStore, BOTH
@@ -694,7 +695,7 @@
         current_rev = currentpage.get_real_rev()
         
         tags = TagStore(currentpage)
-        tags.add(remote_wiki=interwiki_name, remote_rev=local_rev, current_rev=current_rev, direction=BOTH)
+        tags.add(remote_wiki=interwiki_name, remote_rev=local_rev, current_rev=current_rev, direction=BOTH, normalised_name=normalised_name)
 
         # XXX unlock page
 
--- a/docs/CHANGES.aschremmer	Mon Aug 14 22:06:53 2006 +0200
+++ b/docs/CHANGES.aschremmer	Mon Aug 14 22:26:41 2006 +0200
@@ -21,6 +21,8 @@
     * Search for XXX
     * Maybe refactor YYY into MoinLocalWiki
     * Remove amount of "very" in the code
+    * Do older tags of one wiki site have to be stored as well? Why don't we
+      keep just one tag?
     * Put author names into the comment field, transmit mimetypes.
 
   New Features:
@@ -103,7 +105,8 @@
          conflicts. Fixed hard to track down bugs in SyncPages. Store full IWIDs and match by
          either of both components when searching for tags. Ignore underlay pages. Filter the remote page list by
          the prefix and the pageList on the remote side. Finished the direction==DOWN mode.
-         Started designing the solutions for the other sync cases.
+         Started designing the solutions for the other sync cases. Store and transmit the
+         normalised name.
 
 2006-07-18: the requested daily entry is missing here, see http://moinmoin.wikiwikiweb.de/GoogleSoc2006/BetterProgress
 2006-07-19: the requested daily entry is missing here, see http://moinmoin.wikiwikiweb.de/GoogleSoc2006/BetterProgress