On Thu, Aug 15, 2013 at 1:23 AM, <[email protected]> wrote: > Author: rjollos > Date: Thu Aug 15 08:23:29 2013 > New Revision: 1514197 > > URL: http://svn.apache.org/r1514197 > Log: > Replace `TracGuideToc` with `UserGuideToc` on bh wiki upgrade. Refs #555. > > A regression introduced in [1496686], which fixed unintended replacement > of `TracIni` macro markup, also broke the ability to intentionally replace > macro markup. `_do_wiki_rename_links` now supports replacement of macro > markup by using the macro syntax when specifying the word to replace (i.e. > wrapping the !CamelCase word in double brackets). > > Modified: > bloodhound/trunk/bloodhound_dashboard/bhdashboard/admin.py > > Modified: bloodhound/trunk/bloodhound_dashboard/bhdashboard/admin.py > URL: > http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_dashboard/bhdashboard/admin.py?rev=1514197&r1=1514196&r2=1514197&view=diff > > ============================================================================== > --- bloodhound/trunk/bloodhound_dashboard/bhdashboard/admin.py (original) > +++ bloodhound/trunk/bloodhound_dashboard/bhdashboard/admin.py Thu Aug 15 > 08:23:29 2013 > @@ -24,6 +24,7 @@ r"""Project dashboard for Apache(TM) Blo > Administration commands for Bloodhound Dashboard. > """ > import json > +import re > from sys import stdout > > from trac.admin.api import IAdminCommandProvider, AdminCommandError > @@ -116,21 +117,24 @@ class BloodhoundAdmin(Component): > redirection.text = _('See [wiki:"%(name)s"].', > name=new_name) > comment = 'Bloodhound guide update' > redirection.save('bloodhound', comment, '0.0.0.0') > - self._do_wiki_rename_links('TracGuideToc', 'UserGuideToc') > + self._do_wiki_rename_links('[[TracGuideToc]]', '[[UserGuideToc]]') > > def _do_wiki_rename_links(self, old_name, new_name): > - import re > + if old_name.startswith('[[') and old_name.endswith(']]'): > + pattern = r'%s' > + else: > + pattern = r'\b%s\b' > with self.env.db_transaction as db: > pages = db("""SELECT name, text FROM wiki > WHERE text %s > """ % db.like(), > ('%' + db.like_escape(old_name) + '%',)) > for name, text in pages: > - res = db("""UPDATE wiki > - SET text=%s > - WHERE name=%s > - """, > - (re.sub(r'(?!\[\[)\b%s\b(?!\]\])' % old_name, > new_name, text), name)) > + db("""UPDATE wiki > + SET text=%s > + WHERE name=%s > + """, (re.sub(pattern % re.escape(old_name), > + new_name, text), name)) > > def _get_tdump(self, db, table, fields): > """Dumps all the data from a table for a known set of fields""" > > > I believe this fixes the issue mentioned in (1), and brought up by a user recently on the mailing list. It might be good if someone else did some quick testing to be sure I didn't miss anything (like last time).
An issue that remains though is that the fix will only apply to new installs. For existing installs, we need to apply the wiki upgrade again, or at least the "rename links" part of the upgrade. Simply calling `trac-admin $env wiki bh-upgrade` doesn't succeed in applying the fix because all of the pages are skipped as already existing. This might be another upgrade step that should be handled by `bloodhound_setup`. (1) http://issues.apache.org/bloodhound/ticket/555#comment:3
