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

« back to all changes in this revision

Viewing changes to scripts/svnlogservice

  • Committer: wagrant
  • Date: 2008-07-17 04:00:04 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:903
svnlogservice: Add the ability to show diff links.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
import common.cgirequest
32
32
import common.util
33
33
import common.date
 
34
import common.svn
34
35
 
35
36
req = common.cgirequest.CGIRequest()
36
37
req.install_error_handler()
38
39
 
39
40
req.write('<h1>Subversion Log</h1>\n')
40
41
 
 
42
r_str = req.get_fieldstorage().getfirst("r")
 
43
sr = common.svn.revision_from_string(r_str)
41
44
 
42
45
def pretty_path(cpath, revno=None):
43
46
    path = cpath['path']
60
63
    return output
61
64
 
62
65
def pretty_log(log):
63
 
    return '''
 
66
    revno = log.revision.number
 
67
    author = cgi.escape(log.author)
 
68
    message = cgi.escape(log.message)
 
69
    result = '''
64
70
<div class="svnlogentry">
65
71
        <div class="svnloginfo">
66
72
                Revision <a href="%s?r=%d" style="font-weight: bold">%d</a>
67
73
                by <strong>%s</strong> on <strong>%s</strong>
 
74
''' % (cgi.escape(common.util.make_path(os.path.join('files', req.path))),
 
75
       revno, revno, author, common.date.make_date_nice(log.date))
 
76
 
 
77
    # Now we get ugly. We need to sometimes present [select] and [diff] links.
 
78
    if sr and sr.kind == pysvn.opt_revision_kind.number and sr.number == revno:
 
79
        result += '[selected]'
 
80
    else:
 
81
        result += '<a href="%s?r=%d">[select]</a>' % (
 
82
              cgi.escape(common.util.make_path(os.path.join('svnlog', req.path))),
 
83
              revno)
 
84
    if sr and sr.kind == pysvn.opt_revision_kind.number:
 
85
        result += ' <a href="%s?r=%d&r=%d">[diff]</a>' % (
 
86
              cgi.escape(common.util.make_path(os.path.join('diff', req.path))),
 
87
              sr.number, revno)
 
88
 
 
89
    result += '''
68
90
        </div>
69
91
        <pre>%s</pre>
70
92
        <hr size="1"/>
72
94
        <div class="svnlogpathlist">
73
95
        %s
74
96
        </div>
75
 
</div>''' % (cgi.escape(common.util.make_path(os.path.join('files', req.path))),
76
 
             log.revision.number, log.revision.number, cgi.escape(log.author),
77
 
             common.date.make_date_nice(log.date), cgi.escape(log.message),
78
 
             pretty_paths(log.changed_paths, log.revision.number))
 
97
</div>''' % (message, pretty_paths(log.changed_paths, log.revision.number))
 
98
    return result
79
99
 
80
100
try:
81
101
    client = pysvn.Client()