comparison MoinMoin/action/SyncPages.py @ 1264:064778edb38c

Started integration of direction DOWN support.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Sat, 12 Aug 2006 23:54:14 +0200
parents e313c2187271
children ff08338e67fe
comparison
equal deleted inserted replaced
1263:e313c2187271 1264:064778edb38c
25 from MoinMoin.Page import Page 25 from MoinMoin.Page import Page
26 from MoinMoin.wikidicts import Dict, Group 26 from MoinMoin.wikidicts import Dict, Group
27 from MoinMoin.wikisync import TagStore, UnsupportedWikiException, SyncPage, MoinLocalWiki, MoinRemoteWiki 27 from MoinMoin.wikisync import TagStore, UnsupportedWikiException, SyncPage, MoinLocalWiki, MoinRemoteWiki
28 from MoinMoin.util.bdiff import decompress, patch, compress, textdiff 28 from MoinMoin.util.bdiff import decompress, patch, compress, textdiff
29 from MoinMoin.util import diff3 29 from MoinMoin.util import diff3
30
30 31
31 # directions 32 # directions
32 UP, DOWN, BOTH = range(3) 33 UP, DOWN, BOTH = range(3)
33 directions_map = {"up": UP, "down": DOWN, "both": BOTH} 34 directions_map = {"up": UP, "down": DOWN, "both": BOTH}
34 35
129 return self.page.send_page(self.request, msg=msg) 130 return self.page.send_page(self.request, msg=msg)
130 131
131 def sync(self, params, local, remote): 132 def sync(self, params, local, remote):
132 """ This method does the syncronisation work. """ 133 """ This method does the syncronisation work. """
133 _ = self.request.getText 134 _ = self.request.getText
135 direction = params["direction"]
134 136
135 l_pages = local.get_pages() 137 l_pages = local.get_pages()
136 r_pages = remote.get_pages(exclude_non_writable=params["direction"] != DOWN) 138 r_pages = remote.get_pages(exclude_non_writable=direction != DOWN)
137 139
138 if params["groupList"]: 140 if params["groupList"]:
139 pages_from_groupList = set(local.getGroupItems(params["groupList"])) 141 pages_from_groupList = set(local.getGroupItems(params["groupList"]))
140 r_pages = SyncPage.filter(r_pages, pages_from_groupList.__contains__) 142 r_pages = SyncPage.filter(r_pages, pages_from_groupList.__contains__)
141 l_pages = SyncPage.filter(l_pages, pages_from_groupList.__contains__) 143 l_pages = SyncPage.filter(l_pages, pages_from_groupList.__contains__)
178 old_contents = "" 180 old_contents = ""
179 else: 181 else:
180 newest_tag = matching_tags[-1] 182 newest_tag = matching_tags[-1]
181 local_rev = newest_tag.current_rev 183 local_rev = newest_tag.current_rev
182 remote_rev = newest_tag.remote_rev 184 remote_rev = newest_tag.remote_rev
183 if remote_rev == rp.remote_rev and local_rev == current_rev: 185 if remote_rev == rp.remote_rev and (direction == DOWN or local_rev == current_rev):
184 continue # no changes done, next page 186 continue # no changes done, next page
185 old_page = Page(self.request, local_pagename, rev=local_rev) 187 old_page = Page(self.request, local_pagename, rev=local_rev)
186 old_contents = old_page.get_raw_body_str() 188 old_contents = old_page.get_raw_body_str()
187 189
188 self.log_status(ActionClass.INFO, _("Synchronising page %(pagename)s with remote page %(remotepagename)s ...") % {"pagename": local_pagename, "remotepagename": rp.remote_name}) 190 self.log_status(ActionClass.INFO, _("Synchronising page %(pagename)s with remote page %(remotepagename)s ...") % {"pagename": local_pagename, "remotepagename": rp.remote_name})