annotate MoinMoin/action/SyncPages.py @ 1330:df88b475c1f0

Reworked debugging.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Sat, 19 Aug 2006 16:18:19 +0200
parents 4a8c4849d162
children 16a854a172c9
rev   line source
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
2 """
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
3 MoinMoin - SyncPages action
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
4
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
5 This action allows you to synchronise pages of two wikis.
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
6
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
7 @copyright: 2006 MoinMoin:AlexanderSchremmer
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
8 @license: GNU GPL, see COPYING for details.
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
9 """
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
10
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
11 import os
1030
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
12 import re
976
a442ed63b165 Reordered class hierachy of remote wikis, enhanced RemoteWiki interface
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
13 import xmlrpclib
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
14
1041
f9568edf1ff0 Introduced MoinLocalWiki class, added code that compares page lists for testing.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1030
diff changeset
15 # Compatiblity to Python 2.3
f9568edf1ff0 Introduced MoinLocalWiki class, added code that compares page lists for testing.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1030
diff changeset
16 try:
f9568edf1ff0 Introduced MoinLocalWiki class, added code that compares page lists for testing.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1030
diff changeset
17 set
f9568edf1ff0 Introduced MoinLocalWiki class, added code that compares page lists for testing.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1030
diff changeset
18 except NameError:
f9568edf1ff0 Introduced MoinLocalWiki class, added code that compares page lists for testing.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1030
diff changeset
19 from sets import Set as set
f9568edf1ff0 Introduced MoinLocalWiki class, added code that compares page lists for testing.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1030
diff changeset
20
f9568edf1ff0 Introduced MoinLocalWiki class, added code that compares page lists for testing.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1030
diff changeset
21
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
22 from MoinMoin import wikiutil, config, user
1096
33927b0256ce Changed marshalling format of the full IWID, load full IWID into the RemoteWiki object.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1095
diff changeset
23 from MoinMoin.packages import unpackLine, packLine
1141
0390d7857d87 Work on SyncPages, fixed prefix handling, wrote initial merge loop.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1136
diff changeset
24 from MoinMoin.PageEditor import PageEditor, conflict_markers
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
25 from MoinMoin.Page import Page
1092
f80e88b33c9d Added processing of local- and remoteMatch options to the SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1053
diff changeset
26 from MoinMoin.wikidicts import Dict, Group
1296
93ecff3f806f Check for local write permissions early, fixed Python 2.3 incompatiblity.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1272
diff changeset
27 from MoinMoin.wikisync import TagStore, UnsupportedWikiException, SyncPage
1303
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
28 from MoinMoin.wikisync import MoinLocalWiki, MoinRemoteWiki, UP, DOWN, BOTH, MIMETYPE_MOIN
1141
0390d7857d87 Work on SyncPages, fixed prefix handling, wrote initial merge loop.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1136
diff changeset
29 from MoinMoin.util.bdiff import decompress, patch, compress, textdiff
0390d7857d87 Work on SyncPages, fixed prefix handling, wrote initial merge loop.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1136
diff changeset
30 from MoinMoin.util import diff3
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
31
1264
064778edb38c Started integration of direction DOWN support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1263
diff changeset
32
1330
df88b475c1f0 Reworked debugging.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1329
diff changeset
33 debug = True
df88b475c1f0 Reworked debugging.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1329
diff changeset
34
1267
eb9e5e21b0e5 Implemented the DOWN direction, refactored direction handling. The synctags of older syncs are invalid now, you have to delete them.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1266
diff changeset
35 # map sync directions
1119
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
36 directions_map = {"up": UP, "down": DOWN, "both": BOTH}
1041
f9568edf1ff0 Introduced MoinLocalWiki class, added code that compares page lists for testing.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1030
diff changeset
37
1135
bf5f8afacf59 Added prefix handling to SyncPages.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1134
diff changeset
38
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
39 class ActionStatus(Exception): pass
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
40
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
41
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
42 class ActionClass(object):
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
43 INFO, WARN, ERROR = zip(range(3), ("", "<!>", "/!\\")) # used for logging
1158
353c493dfb77 Added local conflict detection, logging support to SyncPages, updated my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1141
diff changeset
44
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
45 def __init__(self, pagename, request):
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
46 self.request = request
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
47 self.pagename = pagename
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
48 self.page = PageEditor(request, pagename)
1158
353c493dfb77 Added local conflict detection, logging support to SyncPages, updated my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1141
diff changeset
49 self.status = []
1267
eb9e5e21b0e5 Implemented the DOWN direction, refactored direction handling. The synctags of older syncs are invalid now, you have to delete them.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1266
diff changeset
50 request.flush()
1158
353c493dfb77 Added local conflict detection, logging support to SyncPages, updated my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1141
diff changeset
51
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
52 def log_status(self, level, message, substitutions=(), raw_suffix=""):
1159
0432e8a9ba2f Added docstrings.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1158
diff changeset
53 """ Appends the message with a given importance level to the internal log. """
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
54 self.status.append((level, message, substitutions, raw_suffix))
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
55
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
56 def generate_log_table(self):
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
57 """ Transforms self.status into a user readable table. """
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
58 table_line = u"|| %(smiley)s || %(message)s%(raw_suffix)s ||"
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
59 table = []
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
60
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
61 for line in self.status:
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
62 macro_args = [line[1]] + list(line[2])
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
63 table.append(table_line % {"smiley": line[0][1], "message":
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
64 u"[[GetText2(|%s)]]" % (packLine(macro_args), ),
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
65 "raw_suffix": line[3]})
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
66
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
67 return "\n".join(table)
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
68
1030
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
69 def parse_page(self):
1159
0432e8a9ba2f Added docstrings.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1158
diff changeset
70 """ Parses the parameter page and returns the read arguments. """
1030
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
71 options = {
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
72 "remotePrefix": "",
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
73 "localPrefix": "",
1030
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
74 "remoteWiki": "",
1119
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
75 "pageMatch": None,
1030
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
76 "pageList": None,
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
77 "groupList": None,
1119
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
78 "direction": "foo", # is defaulted below
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
79 }
1030
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
80
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
81 options.update(Dict(self.request, self.pagename).get_dict())
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
82
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
83 # Convert page and group list strings to lists
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
84 if options["pageList"] is not None:
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
85 options["pageList"] = unpackLine(options["pageList"], ",")
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
86 if options["groupList"] is not None:
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
87 options["groupList"] = unpackLine(options["groupList"], ",")
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
88
1267
eb9e5e21b0e5 Implemented the DOWN direction, refactored direction handling. The synctags of older syncs are invalid now, you have to delete them.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1266
diff changeset
89 options["direction"] = directions_map.get(options["direction"].lower(), BOTH)
1119
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
90
1030
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
91 return options
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
92
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
93 def fix_params(self, params):
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
94 """ Does some fixup on the parameters. """
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
95
1119
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
96 # merge the pageList case into the pageMatch case
1030
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
97 if params["pageList"] is not None:
1119
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
98 params["pageMatch"] = u'|'.join([r'^%s$' % re.escape(name)
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
99 for name in params["pageList"]])
1030
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
100
1119
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
101 if params["pageMatch"] is not None:
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
102 params["pageMatch"] = re.compile(params["pageMatch"], re.U)
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
103
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
104 # we do not support matching or listing pages if there is a group of pages
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
105 if params["groupList"]:
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
106 params["pageMatch"] = None
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1264
diff changeset
107 params["pageList"] = None
1030
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
108
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
109 return params
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
110
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
111 def render(self):
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
112 """ Render action
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
113
1030
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
114 This action returns a status message.
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
115 """
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
116 _ = self.request.getText
1030
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
117
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
118 params = self.fix_params(self.parse_page())
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
119
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
120 # XXX aquire readlock on self.page
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
121 try:
1263
e313c2187271 Show an error message for the direction UP.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
122 if params["direction"] == UP:
e313c2187271 Show an error message for the direction UP.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
123 raise ActionStatus(_("The only supported directions are BOTH and DOWN."))
e313c2187271 Show an error message for the direction UP.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1262
diff changeset
124
976
a442ed63b165 Reordered class hierachy of remote wikis, enhanced RemoteWiki interface
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
125 if not self.request.cfg.interwikiname:
a442ed63b165 Reordered class hierachy of remote wikis, enhanced RemoteWiki interface
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
126 raise ActionStatus(_("Please set an interwikiname in your wikiconfig (see HelpOnConfiguration) to be able to use this action."))
a442ed63b165 Reordered class hierachy of remote wikis, enhanced RemoteWiki interface
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 971
diff changeset
127
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
128 if not params["remoteWiki"]:
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
129 raise ActionStatus(_("Incorrect parameters. Please supply at least the ''remoteWiki'' parameter."))
1030
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
130
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1264
diff changeset
131 local = MoinLocalWiki(self.request, params["localPrefix"], params["pageList"])
1095
e2cc6b5bed96 Added detection of anonymous wikis to the SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1092
diff changeset
132 try:
1330
df88b475c1f0 Reworked debugging.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1329
diff changeset
133 remote = MoinRemoteWiki(self.request, params["remoteWiki"], params["remotePrefix"], params["pageList"], verbose=debug)
1097
e22024151c2c Fixed some bugs in SyncPages.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1096
diff changeset
134 except UnsupportedWikiException, (msg, ):
e22024151c2c Fixed some bugs in SyncPages.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1096
diff changeset
135 raise ActionStatus(msg)
1030
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
136
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
137 if not remote.valid:
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
138 raise ActionStatus(_("The ''remoteWiki'' is unknown."))
1030
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
139
1041
f9568edf1ff0 Introduced MoinLocalWiki class, added code that compares page lists for testing.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1030
diff changeset
140 self.sync(params, local, remote)
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
141 except ActionStatus, e:
1321
d0c171c168a8 Minor cleanup, added entry to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1320
diff changeset
142 msg = u'<p class="error">%s</p>\n' % (e.args[0], )
1164
32c936ab469e Made SyncPages working, first page could be syncronised.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1159
diff changeset
143 else:
1321
d0c171c168a8 Minor cleanup, added entry to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1320
diff changeset
144 msg = u"%s" % (_("Syncronisation finished."), )
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
145
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
146 self.page.saveText(self.page.get_raw_body() + "\n\n" + self.generate_log_table(), 0)
1321
d0c171c168a8 Minor cleanup, added entry to my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1320
diff changeset
147 # XXX release readlock on self.page
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
148
1164
32c936ab469e Made SyncPages working, first page could be syncronised.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1159
diff changeset
149 return self.page.send_page(self.request, msg=msg)
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
150
1041
f9568edf1ff0 Introduced MoinLocalWiki class, added code that compares page lists for testing.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1030
diff changeset
151 def sync(self, params, local, remote):
1271
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
152 """ This method does the syncronisation work.
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
153 Currently, it handles the case where the pages exist on both sides.
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
154 One of the major missing parts is rename handling.
1271
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
155 Now there are a few other cases left that have to be implemented:
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
156 Wiki A | Wiki B | Remark
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
157 ----------+----------+------------------------------
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
158 exists | deleted | In this case, we do a normal merge if there
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
159 | | are no tags. If there were changes in
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
160 | | Wiki A, there is a merge with a conflict.
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
161 | | Otherwise (no changes past last merge),
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
162 | | the page is deleted in Wiki A.
1272
e85ad6a95ae5 Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1271
diff changeset
163 | | This needs static info that could be
e85ad6a95ae5 Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1271
diff changeset
164 | | transferred with the pagelist.
1271
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
165 ----------+----------+-------------------------------
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
166 exists | non- | Now the wiki knows that the page was renamed.
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
167 with tags | existant | There should be an RPC method that asks
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
168 | | for the new name (which could be recorded
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
169 | | on page rename). Then the page is
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
170 | | renamed in Wiki A as well and the sync
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
171 | | is done normally.
1272
e85ad6a95ae5 Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1271
diff changeset
172 | | Every wiki retains a dict that maps
e85ad6a95ae5 Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1271
diff changeset
173 | | (IWID, oldname) => newname and that is
e85ad6a95ae5 Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1271
diff changeset
174 | | updated on every rename. oldname refers
e85ad6a95ae5 Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1271
diff changeset
175 | | to the pagename known by the old wiki (can be
e85ad6a95ae5 Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1271
diff changeset
176 | | gathered from tags).
1271
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
177 ----------+----------+-------------------------------
1272
e85ad6a95ae5 Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1271
diff changeset
178 exists | any case | Try a rename search first, then
e85ad6a95ae5 Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1271
diff changeset
179 | | do a sync without considering tags
1271
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
180 with tags | with non | to ensure data integrity.
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
181 | matching | Hmm, how do we detect this
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
182 | tags | case if the unmatching tags are only on the remote side?
1271
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
183 ----------+----------+-------------------------------
1303
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
184 exists | exists | already handled.
1271
bb2f70fc9734 Have been thinking about a solution for the remaining sync cases, put the thoughts into a docstring."
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1267
diff changeset
185 """
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
186 _ = lambda x: x # we will translate it later
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
187
1264
064778edb38c Started integration of direction DOWN support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1263
diff changeset
188 direction = params["direction"]
1322
cd150467ee30 Minor cleanups.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1321
diff changeset
189 if direction == BOTH:
cd150467ee30 Minor cleanups.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1321
diff changeset
190 match_direction = direction
cd150467ee30 Minor cleanups.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1321
diff changeset
191 else:
cd150467ee30 Minor cleanups.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1321
diff changeset
192 match_direction = None
cd150467ee30 Minor cleanups.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1321
diff changeset
193
1303
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
194 local_full_iwid = packLine([local.get_iwid(), local.get_interwiki_name()])
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
195 remote_full_iwid = packLine([remote.get_iwid(), remote.get_interwiki_name()])
1136
4ba6da7e23a4 Started implementing the merging process. Not working yet.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1135
diff changeset
196
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
197 self.log_status(self.INFO, _("Syncronisation started -"), raw_suffix=" [[DateTime(%s)]]" % self.page._get_local_timestamp())
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
198
1136
4ba6da7e23a4 Started implementing the merging process. Not working yet.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1135
diff changeset
199 l_pages = local.get_pages()
1264
064778edb38c Started integration of direction DOWN support.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1263
diff changeset
200 r_pages = remote.get_pages(exclude_non_writable=direction != DOWN)
1092
f80e88b33c9d Added processing of local- and remoteMatch options to the SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1053
diff changeset
201
f80e88b33c9d Added processing of local- and remoteMatch options to the SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1053
diff changeset
202 if params["groupList"]:
1119
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
203 pages_from_groupList = set(local.getGroupItems(params["groupList"]))
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
204 r_pages = SyncPage.filter(r_pages, pages_from_groupList.__contains__)
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
205 l_pages = SyncPage.filter(l_pages, pages_from_groupList.__contains__)
1041
f9568edf1ff0 Introduced MoinLocalWiki class, added code that compares page lists for testing.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1030
diff changeset
206
1141
0390d7857d87 Work on SyncPages, fixed prefix handling, wrote initial merge loop.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1136
diff changeset
207 m_pages = [elem.add_missing_pagename(local, remote) for elem in SyncPage.merge(l_pages, r_pages)]
1119
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
208
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
209 self.log_status(self.INFO, _("Got a list of %s local and %s remote pages. This results in %s different pages over-all."),
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
210 (str(len(l_pages)), str(len(r_pages)), str(len(m_pages))))
1262
16bed977b054 Added support for underlay page ignore and prefix filtering in getAllPagesEx,
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1261
diff changeset
211
1119
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
212 if params["pageMatch"]:
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
213 m_pages = SyncPage.filter(m_pages, params["pageMatch"].match)
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
214 self.log_status(self.INFO, _("After filtering: %s pages"), (str(len(m_pages)), ))
1119
397b97122ad9 General SyncPages refactoring:
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1099
diff changeset
215
1324
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
216 def handle_page(rp):
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
217 # let's do the simple case first, can be refactored later to match all cases
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
218 # XXX handle deleted pages
1136
4ba6da7e23a4 Started implementing the merging process. Not working yet.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1135
diff changeset
219 # XXX add locking, acquire read-lock on rp
1330
df88b475c1f0 Reworked debugging.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1329
diff changeset
220 if debug:
df88b475c1f0 Reworked debugging.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1329
diff changeset
221 self.log_status(ActionClass.INFO, "Processing %r" % rp)
1136
4ba6da7e23a4 Started implementing the merging process. Not working yet.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1135
diff changeset
222
1164
32c936ab469e Made SyncPages working, first page could be syncronised.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1159
diff changeset
223 local_pagename = rp.local_name
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1264
diff changeset
224 current_page = PageEditor(self.request, local_pagename) # YYY direct access
1141
0390d7857d87 Work on SyncPages, fixed prefix handling, wrote initial merge loop.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1136
diff changeset
225 current_rev = current_page.get_real_rev()
1136
4ba6da7e23a4 Started implementing the merging process. Not working yet.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1135
diff changeset
226
1141
0390d7857d87 Work on SyncPages, fixed prefix handling, wrote initial merge loop.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1136
diff changeset
227 tags = TagStore(current_page)
1322
cd150467ee30 Minor cleanups.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1321
diff changeset
228
cd150467ee30 Minor cleanups.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1321
diff changeset
229 matching_tags = tags.fetch(iwid_full=remote.iwid_full, direction=match_direction)
1136
4ba6da7e23a4 Started implementing the merging process. Not working yet.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1135
diff changeset
230 matching_tags.sort()
1330
df88b475c1f0 Reworked debugging.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1329
diff changeset
231 if debug:
df88b475c1f0 Reworked debugging.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1329
diff changeset
232 self.log_status(ActionClass.INFO, "Tags: %r [[BR]] All: %r" % (matching_tags, tags.tags))
1136
4ba6da7e23a4 Started implementing the merging process. Not working yet.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1135
diff changeset
233
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
234 # some default values for non matching tags
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
235 normalised_name = None
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
236 remote_rev = None
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
237 local_rev = rp.local_rev # merge against the newest version
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
238 old_contents = ""
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
239
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
240 if matching_tags:
1136
4ba6da7e23a4 Started implementing the merging process. Not working yet.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1135
diff changeset
241 newest_tag = matching_tags[-1]
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
242
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
243 # handle some cases where we cannot continue for this page
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
244 if newest_tag.remote_rev == rp.remote_rev and (direction == DOWN or newest_tag.current_rev == current_rev):
1324
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
245 return # no changes done, next page
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
246 if rp.local_mime_type != MIMETYPE_MOIN and not (newest_tag.remote_rev == rp.remote_rev ^ newest_tag.current_rev == current_rev):
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
247 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, ))
1324
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
248 return
1303
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
249 if rp.local_mime_type != rp.remote_mime_type:
1322
cd150467ee30 Minor cleanups.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1321
diff changeset
250 self.log_status(ActionClass.WARN, _("The item %s has different mime types in both wikis and cannot be merged. Please delete it in one of both wikis or unify the mime type, and try again."), (rp.name, ))
1324
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
251 return
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
252 if newest_tag.normalised_name != rp.name:
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
253 self.log_status(ActionClass.WARN, _("The item %s was renamed locally. This is not implemented yet. Therefore all syncronisation history is lost for this page."), (rp.name, )) # XXX implement renames
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
254 else:
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
255 normalised_name = newest_tag.normalised_name
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
256 local_rev = newest_tag.current_rev
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
257 remote_rev = newest_tag.remote_rev
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
258 old_contents = Page(self.request, local_pagename, rev=newest_tag.current_rev).get_raw_body_str() # YYY direct access
1136
4ba6da7e23a4 Started implementing the merging process. Not working yet.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1135
diff changeset
259
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
260 self.log_status(ActionClass.INFO, _("Synchronising page %s with remote page %s ..."), (local_pagename, rp.remote_name))
1158
353c493dfb77 Added local conflict detection, logging support to SyncPages, updated my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1141
diff changeset
261
1267
eb9e5e21b0e5 Implemented the DOWN direction, refactored direction handling. The synctags of older syncs are invalid now, you have to delete them.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1266
diff changeset
262 if direction == DOWN:
eb9e5e21b0e5 Implemented the DOWN direction, refactored direction handling. The synctags of older syncs are invalid now, you have to delete them.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1266
diff changeset
263 remote_rev = None # always fetch the full page, ignore remote conflict check
eb9e5e21b0e5 Implemented the DOWN direction, refactored direction handling. The synctags of older syncs are invalid now, you have to delete them.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1266
diff changeset
264 patch_base_contents = ""
eb9e5e21b0e5 Implemented the DOWN direction, refactored direction handling. The synctags of older syncs are invalid now, you have to delete them.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1266
diff changeset
265 else:
eb9e5e21b0e5 Implemented the DOWN direction, refactored direction handling. The synctags of older syncs are invalid now, you have to delete them.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1266
diff changeset
266 patch_base_contents = old_contents
eb9e5e21b0e5 Implemented the DOWN direction, refactored direction handling. The synctags of older syncs are invalid now, you have to delete them.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1266
diff changeset
267
1259
a76ce7b95190 SyncPages fixes, allow for the case where only the local page is changed.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1254
diff changeset
268 if remote_rev != rp.remote_rev:
1304
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
269 diff_result = remote.get_diff(rp.remote_name, remote_rev, None, normalised_name)
f103cf7c371e Detect renamed pages. Changed the getDiff interface.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1303
diff changeset
270 if diff_result is None:
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
271 self.log_status(ActionClass.ERROR, _("The page %s could not be synced. The remote page was renamed. This is not supported yet. You may want to delete one of the pages to get it synced."), (rp.remote_name, ))
1324
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
272 return
1259
a76ce7b95190 SyncPages fixes, allow for the case where only the local page is changed.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1254
diff changeset
273 is_remote_conflict = diff_result["conflict"]
a76ce7b95190 SyncPages fixes, allow for the case where only the local page is changed.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1254
diff changeset
274 assert diff_result["diffversion"] == 1
a76ce7b95190 SyncPages fixes, allow for the case where only the local page is changed.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1254
diff changeset
275 diff = diff_result["diff"]
a76ce7b95190 SyncPages fixes, allow for the case where only the local page is changed.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1254
diff changeset
276 current_remote_rev = diff_result["current"]
a76ce7b95190 SyncPages fixes, allow for the case where only the local page is changed.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1254
diff changeset
277 else:
a76ce7b95190 SyncPages fixes, allow for the case where only the local page is changed.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1254
diff changeset
278 current_remote_rev = remote_rev
1303
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
279 if rp.local_mime_type == MIMETYPE_MOIN:
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
280 is_remote_conflict = wikiutil.containsConflictMarker(old_contents.decode("utf-8"))
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
281 else:
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
282 is_remote_conflict = NotImplemented
1259
a76ce7b95190 SyncPages fixes, allow for the case where only the local page is changed.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1254
diff changeset
283 diff = None
1141
0390d7857d87 Work on SyncPages, fixed prefix handling, wrote initial merge loop.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1136
diff changeset
284
1251
7b128ea29fc4 Further bug fixes in SyncPages and wikisync
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1164
diff changeset
285 # do not sync if the conflict is remote and local, or if it is local
7b128ea29fc4 Further bug fixes in SyncPages and wikisync
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1164
diff changeset
286 # and the page has never been syncronised
1303
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
287 if (rp.local_mime_type == MIMETYPE_MOIN and wikiutil.containsConflictMarker(current_page.get_raw_body())
1251
7b128ea29fc4 Further bug fixes in SyncPages and wikisync
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1164
diff changeset
288 and (remote_rev is None or is_remote_conflict)):
1320
a36c70e5f0dd Reworked i18n and logging support, from now on, the log is attached to the job page.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1304
diff changeset
289 self.log_status(ActionClass.WARN, _("Skipped page %s because of a locally or remotely unresolved conflict."), (local_pagename, ))
1324
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
290 return
1251
7b128ea29fc4 Further bug fixes in SyncPages and wikisync
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1164
diff changeset
291
1267
eb9e5e21b0e5 Implemented the DOWN direction, refactored direction handling. The synctags of older syncs are invalid now, you have to delete them.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1266
diff changeset
292 if remote_rev is None and direction == BOTH:
1158
353c493dfb77 Added local conflict detection, logging support to SyncPages, updated my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1141
diff changeset
293 self.log_status(ActionClass.INFO, _("This is the first synchronisation between this page and the remote wiki."))
1141
0390d7857d87 Work on SyncPages, fixed prefix handling, wrote initial merge loop.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1136
diff changeset
294
1259
a76ce7b95190 SyncPages fixes, allow for the case where only the local page is changed.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1254
diff changeset
295 if diff is None:
1303
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
296 new_contents = old_contents
1259
a76ce7b95190 SyncPages fixes, allow for the case where only the local page is changed.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1254
diff changeset
297 else:
1303
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
298 new_contents = patch(patch_base_contents, decompress(diff))
1041
f9568edf1ff0 Introduced MoinLocalWiki class, added code that compares page lists for testing.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1030
diff changeset
299
1303
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
300 if rp.local_mime_type == MIMETYPE_MOIN:
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
301 new_contents_unicode = new_contents.decode("utf-8")
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
302 # here, the actual merge happens
1330
df88b475c1f0 Reworked debugging.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1329
diff changeset
303 if debug:
df88b475c1f0 Reworked debugging.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1329
diff changeset
304 self.log_status(ActionClass.INFO, "Merging %r, %r and %r" % (old_contents.decode("utf-8"), new_contents_unicode, current_page.get_raw_body()))
1303
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
305 verynewtext = diff3.text_merge(old_contents.decode("utf-8"), new_contents_unicode, current_page.get_raw_body(), 2, *conflict_markers)
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
306 verynewtext_raw = verynewtext.encode("utf-8")
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
307 else:
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
308 if diff is None:
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
309 verynewtext_raw = new_contents
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
310 else:
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
311 verynewtext_raw = current_page.get_raw_body_str()
1141
0390d7857d87 Work on SyncPages, fixed prefix handling, wrote initial merge loop.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1136
diff changeset
312
1303
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
313 diff = textdiff(new_contents, verynewtext_raw)
1330
df88b475c1f0 Reworked debugging.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1329
diff changeset
314 if debug:
df88b475c1f0 Reworked debugging.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1329
diff changeset
315 self.log_status(ActionClass.INFO, "Diff against %r" % new_contents.encode("utf-8"))
1260
5d555ec6b40a Fixed a bug that was hard to track down in SyncPages (some hours spent :-/).
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1259
diff changeset
316
1141
0390d7857d87 Work on SyncPages, fixed prefix handling, wrote initial merge loop.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1136
diff changeset
317 comment = u"Local Merge - %r" % (remote.get_interwiki_name() or remote.get_iwid())
1158
353c493dfb77 Added local conflict detection, logging support to SyncPages, updated my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1141
diff changeset
318
353c493dfb77 Added local conflict detection, logging support to SyncPages, updated my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1141
diff changeset
319 # XXX upgrade to write lock
1141
0390d7857d87 Work on SyncPages, fixed prefix handling, wrote initial merge loop.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1136
diff changeset
320 try:
1266
ff08338e67fe Filter the pagelists by pageList on both sides (speedup). Marked a few operations as direct API accesses.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1264
diff changeset
321 current_page.saveText(verynewtext, current_rev, comment=comment) # YYY direct access
1259
a76ce7b95190 SyncPages fixes, allow for the case where only the local page is changed.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1254
diff changeset
322 except PageEditor.Unchanged:
a76ce7b95190 SyncPages fixes, allow for the case where only the local page is changed.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1254
diff changeset
323 pass
1141
0390d7857d87 Work on SyncPages, fixed prefix handling, wrote initial merge loop.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1136
diff changeset
324 except PageEditor.EditConflict:
0390d7857d87 Work on SyncPages, fixed prefix handling, wrote initial merge loop.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1136
diff changeset
325 assert False, "You stumbled on a problem with the current storage system - I cannot lock pages"
1261
ae9eb32b6899 Refactored code, cleaned up some parts of the code, moved some classes to wikisync
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1260
diff changeset
326
1259
a76ce7b95190 SyncPages fixes, allow for the case where only the local page is changed.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1254
diff changeset
327 new_local_rev = current_page.get_real_rev()
1261
ae9eb32b6899 Refactored code, cleaned up some parts of the code, moved some classes to wikisync
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1260
diff changeset
328
1267
eb9e5e21b0e5 Implemented the DOWN direction, refactored direction handling. The synctags of older syncs are invalid now, you have to delete them.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1266
diff changeset
329 if direction == BOTH:
eb9e5e21b0e5 Implemented the DOWN direction, refactored direction handling. The synctags of older syncs are invalid now, you have to delete them.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1266
diff changeset
330 try:
1272
e85ad6a95ae5 Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1271
diff changeset
331 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)
1267
eb9e5e21b0e5 Implemented the DOWN direction, refactored direction handling. The synctags of older syncs are invalid now, you have to delete them.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1266
diff changeset
332 except Exception, e:
eb9e5e21b0e5 Implemented the DOWN direction, refactored direction handling. The synctags of older syncs are invalid now, you have to delete them.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1266
diff changeset
333 raise # XXX rollback locally and do not tag locally
1259
a76ce7b95190 SyncPages fixes, allow for the case where only the local page is changed.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1254
diff changeset
334 else:
1267
eb9e5e21b0e5 Implemented the DOWN direction, refactored direction handling. The synctags of older syncs are invalid now, you have to delete them.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1266
diff changeset
335 very_current_remote_rev = current_remote_rev
eb9e5e21b0e5 Implemented the DOWN direction, refactored direction handling. The synctags of older syncs are invalid now, you have to delete them.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1266
diff changeset
336
1272
e85ad6a95ae5 Documented new ideas in the docstring, changed tag format (store normalised name), transmit normalised name in mergeDiff.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1271
diff changeset
337 tags.add(remote_wiki=remote_full_iwid, remote_rev=very_current_remote_rev, current_rev=new_local_rev, direction=direction, normalised_name=rp.name)
1158
353c493dfb77 Added local conflict detection, logging support to SyncPages, updated my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1141
diff changeset
338
1303
a0b8e78621d0 Preliminary support for items of different mime types.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1299
diff changeset
339 if rp.local_mime_type != MIMETYPE_MOIN or not wikiutil.containsConflictMarker(verynewtext):
1158
353c493dfb77 Added local conflict detection, logging support to SyncPages, updated my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1141
diff changeset
340 self.log_status(ActionClass.INFO, _("Page successfully merged."))
353c493dfb77 Added local conflict detection, logging support to SyncPages, updated my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1141
diff changeset
341 else:
353c493dfb77 Added local conflict detection, logging support to SyncPages, updated my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1141
diff changeset
342 self.log_status(ActionClass.WARN, _("Page merged with conflicts."))
353c493dfb77 Added local conflict detection, logging support to SyncPages, updated my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1141
diff changeset
343
353c493dfb77 Added local conflict detection, logging support to SyncPages, updated my CHANGES file.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1141
diff changeset
344 # XXX release lock
1030
807f80c76d81 Work on SyncPages. Fixed a few bugs, added new method to RemoteWiki, build regexes from the RemotePageList.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 977
diff changeset
345
1330
df88b475c1f0 Reworked debugging.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1329
diff changeset
346 # XXX remove?
df88b475c1f0 Reworked debugging.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1329
diff changeset
347 #on_both_sides = SyncPage.iter_local_and_remote(m_pages)
df88b475c1f0 Reworked debugging.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1329
diff changeset
348 #remote_but_not_local = SyncPage.iter_remote_only(m_pages)
df88b475c1f0 Reworked debugging.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1329
diff changeset
349 #local_but_not_remote = SyncPage.iter_local_only(m_pages)
1324
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
350
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
351 # some initial test code (XXX remove)
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
352 #r_new_pages = u", ".join([unicode(x) for x in remote_but_not_local])
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
353 #l_new_pages = u", ".join([unicode(x) for x in local_but_not_remote])
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
354 #raise ActionStatus("These pages are in the remote wiki, but not local: " + wikiutil.escape(r_new_pages) + "<br>These pages are in the local wiki, but not in the remote one: " + wikiutil.escape(l_new_pages))
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
355
1326
0c3927a3b8a2 Getting syncing of pages working that are just on one side, still faulty, though.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1324
diff changeset
356 for rp in m_pages: #on_both_sides:
1324
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
357 handle_page(rp)
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
358
2e29ef86be26 Reordered SyncPages, preparing for new modes.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1322
diff changeset
359
968
3108c8b2597e Add preliminary SyncPages action.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
360 def execute(pagename, request):
971
d24f2b1d606a Refactoring, fixed Fault codes, fixed return format of the getdiff method.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 970
diff changeset
361 ActionClass(pagename, request).render()