| 1 | # svntrac
|
|---|
| 2 | #
|
|---|
| 3 | # Copyright (C) 2003 Jonas Borgström <jonas@xyche.com>
|
|---|
| 4 | #
|
|---|
| 5 | # svntrac is free software; you can redistribute it and/or
|
|---|
| 6 | # modify it under the terms of the GNU General Public License as
|
|---|
| 7 | # published by the Free Software Foundation; either version 2 of the
|
|---|
| 8 | # License, or (at your option) any later version.
|
|---|
| 9 | #
|
|---|
| 10 | # svntrac is distributed in the hope that it will be useful,
|
|---|
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 13 | # General Public License for more details.
|
|---|
| 14 | #
|
|---|
| 15 | # You should have received a copy of the GNU General Public License
|
|---|
| 16 | # along with this program; if not, write to the Free Software
|
|---|
| 17 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|---|
| 18 | #
|
|---|
| 19 | # Author: Jonas Borgström <jonas@xyche.com>
|
|---|
| 20 |
|
|---|
| 21 | from util import *
|
|---|
| 22 | from Module import Module
|
|---|
| 23 | import perm
|
|---|
| 24 |
|
|---|
| 25 | import StringIO
|
|---|
| 26 | from svn import util, repos
|
|---|
| 27 |
|
|---|
| 28 | class Log (Module):
|
|---|
| 29 | template_key = 'log_template'
|
|---|
| 30 |
|
|---|
| 31 | def __init__(self, config, args, pool):
|
|---|
| 32 | Module.__init__(self, config, args, pool)
|
|---|
| 33 |
|
|---|
| 34 | if args.has_key('path'):
|
|---|
| 35 | self.path = args['path']
|
|---|
| 36 | else:
|
|---|
| 37 | self.path = '/'
|
|---|
| 38 |
|
|---|
| 39 | def log_receiver (self, baton, rev, author, date, log, pool):
|
|---|
| 40 | item = {
|
|---|
| 41 | 'rev' : rev,
|
|---|
| 42 | 'author' : author,
|
|---|
| 43 | 'date' : format_date (date, pool),
|
|---|
| 44 | 'log' : log
|
|---|
| 45 | }
|
|---|
| 46 | self.log_info.insert (0, item)
|
|---|
| 47 |
|
|---|
| 48 | def get_info (self, path):
|
|---|
| 49 | self.log_info = []
|
|---|
| 50 | repos.svn_repos_get_logs (self.repos, [path],
|
|---|
| 51 | 0, -1, 0, 1, self.log_receiver,
|
|---|
| 52 | self.pool)
|
|---|
| 53 | return self.log_info
|
|---|
| 54 |
|
|---|
| 55 | def print_item (self, out, item, idx):
|
|---|
| 56 | if idx % 2:
|
|---|
| 57 | out.write ('<tr class="item-row-even">\n')
|
|---|
| 58 | else:
|
|---|
| 59 | out.write ('<tr class="item-row-odd">\n')
|
|---|
| 60 |
|
|---|
| 61 | out.write ('<td class="date-column">%s</td>' % (item['date']))
|
|---|
| 62 | out.write ('<td class="rev-column"><a href="%s">%s</a></td>'
|
|---|
| 63 | % (file_href (self.path, item['rev']), item['rev']))
|
|---|
| 64 | out.write ('<td class="rev-column"><a href="%s">%s</a></td>'
|
|---|
| 65 | % (changeset_href (item['rev']), item['rev']))
|
|---|
| 66 | out.write ('<td>%s</td>' % (item['log']))
|
|---|
| 67 | out.write ('\n</tr>\n')
|
|---|
| 68 |
|
|---|
| 69 | def render (self):
|
|---|
| 70 | perm.assert_permission (perm.LOG_VIEW)
|
|---|
| 71 |
|
|---|
| 72 | info = self.get_info (self.path)
|
|---|
| 73 |
|
|---|
| 74 | out = StringIO.StringIO()
|
|---|
| 75 | idx = 0
|
|---|
| 76 | for item in info:
|
|---|
| 77 | self.print_item (out, item, idx)
|
|---|
| 78 | idx = idx + 1
|
|---|
| 79 |
|
|---|
| 80 | self.namespace['path'] = self.path
|
|---|
| 81 | self.namespace['log_entries'] = out.getvalue()
|
|---|