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

« back to all changes in this revision

Viewing changes to services/svnlogservice

  • Committer: William Grant
  • Date: 2010-07-28 04:12:08 UTC
  • mfrom: (1790.1.8 codemirror-srsly)
  • Revision ID: grantw@unimelb.edu.au-20100728041208-mciagtog1785oje4
Move from CodePress to CodeMirror. It's now an external dependency, too, so you'll need to install it yourself.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
import os
28
28
import sys
 
29
import locale
29
30
 
30
31
import cjson
31
32
import pysvn
32
33
 
 
34
import ivle.conf
33
35
import ivle.svn
34
36
 
 
37
# Set locale to UTF-8
 
38
locale.setlocale(locale.LC_CTYPE, "en_US.UTF-8")
 
39
 
35
40
try:
36
 
    client = pysvn.Client()
 
41
    client = ivle.svn.create_auth_svn_client(username=ivle.conf.login,
 
42
                                             password=ivle.conf.svn_pass)
37
43
    client.exception_style = 1
38
 
    logs = client.log(os.path.join('/home', sys.argv[1]),
 
44
    logs = client.log(os.path.join('/home', sys.argv[1].decode('utf-8')),
39
45
                      discover_changed_paths=True)
40
46
    print cjson.encode({'logs': [{'revno': log.revision.number,
41
 
                                  'author': log.author,
42
 
                                  'message': log.message,
 
47
                                  'author': log.author.decode('utf-8'),
 
48
                                  'message': log.message.decode('utf-8'),
43
49
                                  'date': log.date,
44
 
                                  'paths': [(p.path, p.action)
 
50
                                  'paths': [(p.path.decode('utf-8'), p.action)
45
51
                                            for p in log.changed_paths]}
46
52
                                 for log in logs]})
47
53
except pysvn.ClientError, e:
50
56
    try:
51
57
        code = e[1][0][1]
52
58
        # See subversion/include/svn_error_codes.h.
 
59
        # 150000: ERR_ENTRY_NOT_FOUND
53
60
        # 155007: WC_NOT_DIRECTORY.
 
61
        # 160006: FS_NO_SUCH_REVISION
54
62
        # 160013: FS_NOT_FOUND
55
63
        # 200005: UNVERSIONED_RESOURCE
56
 
        if code in (155007, 160013, 200005):
 
64
        if code in (150000, 155007, 160006, 160013, 200005):
57
65
            error = 'notfound'
58
66
        else:
59
 
            error = '%s (code %d)' % (error, code) 
 
67
            error = '%s (code %d)' % (error, code)
60
68
    except IndexError:
61
69
        pass
62
70