Mercurial > moin > 1.9
changeset 2610:ffe8c2d9a4ba
1.6 converter: only convert current rev of a page, added commented failing test cases
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Mon, 06 Aug 2007 01:40:09 +0200 |
parents | 7aac9e2ecb3a |
children | 7ed38f2af242 9e899085df6e |
files | MoinMoin/script/migration/_conv160.py MoinMoin/script/migration/_conv160_wiki.py MoinMoin/script/migration/_tests/test_conv160_wiki.py |
diffstat | 3 files changed, 33 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/script/migration/_conv160.py Sun Aug 05 23:05:13 2007 +0200 +++ b/MoinMoin/script/migration/_conv160.py Mon Aug 06 01:40:09 2007 +0200 @@ -30,7 +30,9 @@ d) users: generate new name[] for lists and name{} for dicts TODO: - * process page content / convert markup + * currently it converts the last pagerev (good for diff -r) + * after debugging/testing is finished and it works perfect, + change this to create a new revision with the conversion results DONE: pass 1 @@ -49,6 +51,7 @@ * renamed attachment names in local edit-log * migrate separate user bookmark files into user profiles * support new dict/list syntax in user profiles + * process page content / convert markup @copyright: 2007 by Thomas Waldmann @license: GNU GPL, see COPYING for details. @@ -186,20 +189,20 @@ data = data.decode(config.charset) return data - def write(self, data, rev_dir, rev=None): - if rev is None: - rev = self.rev - data = markup_converter(self.request, self.pagename, data, self.renames) + def write(self, data, rev_dir, convert): + rev = self.rev + if convert: + data = markup_converter(self.request, self.pagename, data, self.renames) fname = opj(rev_dir, '%08d' % rev) data = data.encode(config.charset) f = file(fname, "wb") f.write(data) f.close() - def copy(self, rev_dir, renames): + def copy(self, rev_dir, renames, convert): self.renames = renames data = self.read() - self.write(data, rev_dir) + self.write(data, rev_dir, convert) class Attachment: @@ -290,7 +293,10 @@ rev_dir = opj(page_dir, 'revisions') os.makedirs(rev_dir) for rev in self.revlist: - self.revisions[rev].copy(rev_dir, self.renames) + if int(rev) == self.current: + self.revisions[rev].copy(rev_dir, self.renames, convert=True) + else: + self.revisions[rev].copy(rev_dir, self.renames, convert=False) # copy attachments if self.attachments is not None: attach_dir = opj(page_dir, 'attachments')
--- a/MoinMoin/script/migration/_conv160_wiki.py Sun Aug 05 23:05:13 2007 +0200 +++ b/MoinMoin/script/migration/_conv160_wiki.py Mon Aug 06 01:40:09 2007 +0200 @@ -77,7 +77,6 @@ _ent_symbolic_repl = return_word _heading_repl = return_word _email_repl = return_word - _macro_repl = return_word _word_repl = return_word _indent_repl = return_word _li_none_repl = return_word @@ -108,9 +107,13 @@ self.in_pre = True return origw + def _macro_repl(self, word): + # XXX later check whether some to be renamed pagename is used as macro param + return word + # LINKS ------------------------------------------------------------------ def _intelli_quote(self, name): - quote_triggers = u''' "\'}]|:,.()?!''' # see also wiki parser + quote_triggers = u''' "'()[]''' # u''' "\'}]|:,.()?!''' # see also wiki parser quote_it = [True for c in quote_triggers if c in name] if quote_it: return wikiutil.quoteName(name)
--- a/MoinMoin/script/migration/_tests/test_conv160_wiki.py Sun Aug 05 23:05:13 2007 +0200 +++ b/MoinMoin/script/migration/_tests/test_conv160_wiki.py Mon Aug 06 01:40:09 2007 +0200 @@ -5,7 +5,6 @@ TODO: * add some ../some_page test * add some /some_page test - * add more quote_triggers * fix parser/converter anchor link handling * emit a warning if we find some page name that was renamed as a macro argument? * shall we support camelcase renaming? @@ -16,21 +15,6 @@ * converter does not touch macro arguments, they will have to get handled manually -Remaining problems: - - [wiki:/RecommendPage] - [wiki:/farms farms] - - [wiki:MacroMarket/EmbedObject EO] - [wiki:SeaPig/BrianDorsey] ambiguity!!! can be resolved with some interwiki map lookup - and transformed to wiki:SeaPig:BrianDorsey if SeaPig is in - interwiki map, but no page SeaPig exists. - - [:MeatBall:CleanLinking meatball-wiki: clean linking] - [:Infrastructure:Infrastructure] optimize to ["Infrastructure"] - [attachment:My%20Attachment.jpg:it works] - [wiki:LinuxWiki: LinuxWiki.de] - @copyright: 2007 MoinMoin:ThomasWaldmann @license: GNU GPL, see COPYING for details. """ @@ -52,6 +36,20 @@ # FAILS ('RenameThis', rename_some_page, 'ThisRenamed'), # NEEDED? ('!RenameThis', {}, '!RenameThis'), # not a link + # FAILING tests: + #('[wiki:/OtherPage]', rename_some_page, '[wiki:/OtherPage]'), + #('[wiki:/OtherPage other page]', rename_some_page, '[wiki:/OtherPage other page]'), + # ('[:Something:Something]', {}, '["Something"]'), + #('[attachment:My%20Attachment.jpg:it works]', {}, '[attachment:"My Attachment.jpg" it works]'), + #('[wiki:LinuxWiki: LinuxWiki.de]', {}, '[wiki:LinuxWiki: LinuxWiki.de]'), + #('[:MeatBall:CleanLinking meatball-wiki: clean linking]', {}, '[:MeatBall:CleanLinking meatball-wiki: clean linking]'), + + # ambiguity!!! can be resolved with some interwiki map lookup + # and transformed to wiki:SeaPig:BrianDorsey if SeaPig is in + # interwiki map, but no page SeaPig exists. + #('[wiki:MacroMarket/EmbedObject EO]', {}, '["MacroMarket/EmbedObject" EO]'), + ('[wiki:SeaPig/BrianDorsey]', {}, '[wiki:SeaPig:BrianDorsey]'), + # "nothing changed" checks ('', {}, ''), ('MoinMaster:CamelCase', {}, 'MoinMaster:CamelCase'),