~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to scripts/svnlogservice

  • Committer: dcoles
  • Date: 2008-07-16 07:12:28 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:895
Dispatch: Remove diagnostic print

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
# IVLE - Informatics Virtual Learning Environment
 
4
# Copyright (C) 2008 The University of Melbourne
 
5
#
 
6
# This program is free software; you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation; either version 2 of the License, or
 
9
# (at your option) any later version.
 
10
#
 
11
# This program is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
# GNU General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with this program; if not, write to the Free Software
 
18
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 
 
20
# Script: logservice
 
21
# Author: William Grant
 
22
# Date:   08/07/2008
 
23
 
 
24
# A CGI script for viewing a Subversion log. Used by the svnlog app.
 
25
 
 
26
import os
 
27
import time
 
28
import pysvn
 
29
 
 
30
import common.cgirequest
 
31
import common.util
 
32
import common.date
 
33
 
 
34
req = common.cgirequest.CGIRequest()
 
35
req.install_error_handler()
 
36
req.content_type = "text/html"
 
37
 
 
38
req.write('<h1>Subversion Log</h1>\n')
 
39
 
 
40
 
 
41
def pretty_path(cpath, revno=None):
 
42
    path = cpath['path']
 
43
    # XXX: We can't assume that the repository root is always equivalent to
 
44
    #      the current user's home directory, although it does work for our
 
45
    #      current setup.
 
46
    url = common.util.make_path(os.path.join('files',
 
47
                                    common.util.split_path(req.path)[0],
 
48
                                    path[1:]))
 
49
    if revno:
 
50
        url += '?r=%d' % revno
 
51
    return '%s <a href="%s">%s</a>' % (cpath['action'], url, path)
 
52
 
 
53
def pretty_paths(paths, revno=None):
 
54
    output = '<ul>'
 
55
    for path in paths:
 
56
        output += '<li>' + pretty_path(path, revno) + '</li>'
 
57
    output += '</ul>'
 
58
    return output
 
59
 
 
60
def pretty_log(log):
 
61
    return '''
 
62
<div class="svnlogentry">
 
63
        <div class="svnloginfo">
 
64
                Revision <a href="%s?r=%d" style="font-weight: bold">%d</a>
 
65
                by <strong>%s</strong> on <strong>%s</strong>
 
66
        </div>
 
67
        <pre>%s</pre>
 
68
        <hr size="1"/>
 
69
        <h2>Changed paths:</h2>
 
70
        <div class="svnlogpathlist">
 
71
        %s
 
72
        </div>
 
73
</div>''' % (common.util.make_path(os.path.join('files', req.path)),
 
74
             log.revision.number, log.revision.number, log.author,
 
75
             common.date.make_date_nice(log.date), log.message,
 
76
             pretty_paths(log.changed_paths, log.revision.number))
 
77
 
 
78
try:
 
79
    client = pysvn.Client()
 
80
    logs = client.log(os.path.join('/home', req.path), discover_changed_paths=True)
 
81
    [req.write(pretty_log(log)) for log in logs]
 
82
except pysvn.ClientError, e:
 
83
    req.write('<p><b>Error:</b></p>\n')
 
84
    req.write('<pre>%s</pre>\n' % cgi.escape(str(e)))