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

« back to all changes in this revision

Viewing changes to scripts/diffservice

  • Committer: wagrant
  • Date: 2008-07-08 01:04:03 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:823
diffservice: Refactor and polish. URL revision retrieval is less
             repetitive, and pysvn.Client.diff boilerplate is gone.
             Also removed unneeded imports.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
# run from the trampoline by the Diff application.
26
26
 
27
27
from common import cgirequest
28
 
from cgi import parse_qs
29
28
import cgi
30
 
from os import path
 
29
import os.path
31
30
import pysvn
32
31
import re
33
32
 
76
75
req.write('<div id="ivle_padding">\n')
77
76
req.write('<h1>Diff</h1>\n')
78
77
 
79
 
# Work out the revisions from query
 
78
# Default revisions
 
79
revs = [pysvn.Revision(x) for x in [pysvn.opt_revision_kind.base,
 
80
                                    pysvn.opt_revision_kind.working]]
 
81
# Override revisions from query string
80
82
fields = req.get_fieldstorage()
81
83
field_r = fields.getlist("r")
82
 
# Default revisions
83
 
rev1=pysvn.Revision( pysvn.opt_revision_kind.base )
84
 
rev2=pysvn.Revision( pysvn.opt_revision_kind.working )
85
 
# Override revisions from query string
86
 
if len(field_r) >= 1:
87
 
    r1 = get_revision(field_r[0])
88
 
    if r1 != None:
89
 
        rev1 = r1
90
 
    if len(field_r) >= 2:
91
 
        r2 = get_revision(field_r[1])
92
 
        if r2 != None:
93
 
            rev2 = r2
 
84
for ri in range(len(field_r)):
 
85
    r = get_revision(field_r[ri])
 
86
    if r is not None:
 
87
        revs[ri] = r
94
88
 
95
89
# Attempt to get the diff for these revisons
96
90
try:
97
91
    svnclient = pysvn.Client()
98
92
    diff = svnclient.diff
99
93
    diff_text = diff( '/tmp/svndiff',
100
 
        path.join('/home/', req.path),
101
 
        revision1=rev1,
102
 
        #revision1=pysvn.Revision( pysvn.opt_revision_kind.base ),
103
 
        #url_or_path2=url_or_path,
104
 
        revision2=rev2,
105
 
        #revision2=pysvn.Revision( opt_revision_kind.working ),
106
 
        #recurse=True,
107
 
        #ignore_ancestry=False,
108
 
        #diff_deleted=True,
109
 
        #ignore_content_type=False,
110
 
        #header_encoding="",
111
 
        #diff_options=[]
 
94
        os.path.join('/home', req.path),
 
95
        revision1=revs[0],
 
96
        revision2=revs[1]
112
97
    )
113
98
 
114
99
    # Split up the udiff into individual files