redmine: Add support for the revision argument

refs #1067
This commit is contained in:
Laurent Bachelier 2013-03-10 23:45:25 +01:00
commit f49084a6a9
2 changed files with 25 additions and 20 deletions

View file

@ -57,7 +57,7 @@ class RedmineBackend(BaseBackend, ICapContent, ICapBugTracker, ICapCollection):
def id2path(self, id): def id2path(self, id):
return id.split('/', 2) return id.split('/', 2)
def get_content(self, id): def get_content(self, id, revision=None):
if isinstance(id, basestring): if isinstance(id, basestring):
content = Content(id) content = Content(id)
else: else:
@ -69,8 +69,9 @@ class RedmineBackend(BaseBackend, ICapContent, ICapBugTracker, ICapCollection):
except ValueError: except ValueError:
return None return None
version = revision.id if revision else None
with self.browser: with self.browser:
data = self.browser.get_wiki_source(project, page) data = self.browser.get_wiki_source(project, page, version)
content.content = data content.content = data
return content return content

View file

@ -36,13 +36,14 @@ __all__ = ['RedmineBrowser']
# Browser # Browser
class RedmineBrowser(BaseBrowser): class RedmineBrowser(BaseBrowser):
ENCODING = 'utf-8' ENCODING = 'utf-8'
PAGES = {'https?://[^/]+/': IndexPage, PAGES = {
'https?://[^/]+/': IndexPage,
'https?://[^/]+/login': LoginPage, 'https?://[^/]+/login': LoginPage,
# compatibility with redmine 0.9 # compatibility with redmine 0.9
'https?://[^/]+/login\?back_url.*': MyPage, 'https?://[^/]+/login\?back_url.*': MyPage,
'https?://[^/]+/my/page': MyPage, 'https?://[^/]+/my/page': MyPage,
'https?://[^/]+/projects': ProjectsPage, 'https?://[^/]+/projects': ProjectsPage,
'https?://[^/]+/projects/([\w-]+)/wiki/([^\/]+)/edit': WikiEditPage, 'https?://[^/]+/projects/([\w-]+)/wiki/([^\/]+)/edit(?:\?version=\d+)?': WikiEditPage,
'https?://[^/]+/projects/[\w-]+/wiki/[^\/]*': WikiPage, 'https?://[^/]+/projects/[\w-]+/wiki/[^\/]*': WikiPage,
'https?://[^/]+/projects/[\w-]+/issues/new': NewIssuePage, 'https?://[^/]+/projects/[\w-]+/issues/new': NewIssuePage,
'https?://[^/]+/projects/[\w-]+/issues': IssuesPage, 'https?://[^/]+/projects/[\w-]+/issues': IssuesPage,
@ -86,8 +87,11 @@ class RedmineBrowser(BaseBrowser):
def get_userid(self): def get_userid(self):
return self._userid return self._userid
def get_wiki_source(self, project, page): def get_wiki_source(self, project, page, version=None):
self.location('%s/projects/%s/wiki/%s/edit' % (self.BASEPATH, project, urllib.quote(page.encode('utf-8')))) url = '%s/projects/%s/wiki/%s/edit' % (self.BASEPATH, project, urllib.quote(page.encode('utf-8')))
if version:
url += '?version=%s' % version
self.location(url)
return self.page.get_source() return self.page.get_source()
def set_wiki_source(self, project, page, data, message): def set_wiki_source(self, project, page, data, message):