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

830 by wagrant
Add an svnlog app. It nicely displays all log entries for a path,
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
from common import cgirequest
31
32
req = cgirequest.CGIRequest()
33
req.content_type = "text/html"
34
35
req.write('<h1>Subversion Log</h1>\n')
36
37
38
def pretty_time(epochtime):
39
    return time.asctime(time.localtime(epochtime))
40
41
def pretty_path(path):
42
    return '%s %s' % (path['action'], path['path'])
43
44
def pretty_paths(paths):
45
    output = '<ul>'
46
    for path in paths:
47
        output += '<li>' + pretty_path(path) + '</li>'
48
    output += '</ul>'
49
    return output
50
51
def pretty_log(log):
52
    return '''
53
<div class="svnlogentry">
54
	<div class="svnloginfo">
55
		Revision <strong>%d</strong> by <strong>%s</strong> on <strong>%s</strong>
56
	</div>
57
	<pre>%s</pre>
58
        <hr size="1"/>
59
        <h2>Changed paths:</h2>
60
        <div class="svnlogpathlist">
61
	%s
62
        </div>
63
</div>''' % (log.revision.number, log.author, pretty_time(log.date),
64
             log.message, pretty_paths(log.changed_paths))
65
66
try:
67
    client = pysvn.Client()
68
    logs = client.log(os.path.join('/home', req.path), discover_changed_paths=True)
69
    [req.write(pretty_log(log)) for log in logs]
70
except pysvn.ClientError, e:
71
    req.write('<p><b>Error:</b></p>\n')
72
    req.write('<pre>%s</pre>\n' % cgi.escape(str(e)))