~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to tools/server-side/svnpubsub/commit-hook.py

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
PORT=2069
24
24
 
25
25
import sys
26
 
import subprocess
27
26
try:
28
27
    import simplejson as json
29
28
except ImportError:
31
30
 
32
31
import urllib2
33
32
 
34
 
def svncmd(cmd):
35
 
    return subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
36
 
 
37
 
def svncmd_uuid(repo):
38
 
    cmd = "%s uuid %s" % (SVNLOOK, repo)
39
 
    p = svncmd(cmd)
40
 
    return p.stdout.read().strip()
41
 
 
42
 
def svncmd_info(repo, revision):
43
 
    cmd = "%s info -r %s %s" % (SVNLOOK, revision, repo)
44
 
    p = svncmd(cmd)
45
 
    data = p.stdout.read().split("\n")
 
33
import svnpubsub.util
 
34
 
 
35
def svnlook(cmd, **kwargs):
 
36
    args = [SVNLOOK] + cmd
 
37
    return svnpubsub.util.check_output(args, **kwargs)
 
38
 
 
39
def svnlook_uuid(repo):
 
40
    cmd = ["uuid", "--", repo]
 
41
    return svnlook(cmd).strip()
 
42
 
 
43
def svnlook_info(repo, revision):
 
44
    cmd = ["info", "-r", revision, "--", repo]
 
45
    data = svnlook(cmd, universal_newlines=True).split("\n")
46
46
    #print data
47
47
    return {'author': data[0].strip(),
48
48
            'date': data[1].strip(),
49
49
            'log': "\n".join(data[3:]).strip()}
50
50
 
51
 
def svncmd_changed(repo, revision):
52
 
    cmd = "%s changed -r %s %s" % (SVNLOOK, revision, repo)
53
 
    p = svncmd(cmd)
 
51
def svnlook_changed(repo, revision):
 
52
    cmd = ["changed", "-r", revision, "--", repo]
 
53
    lines = svnlook(cmd, universal_newlines=True).split("\n")
54
54
    changed = {}
55
 
    while True:
56
 
        line = p.stdout.readline()
 
55
    for line in lines:
 
56
        line = line.strip()
57
57
        if not line:
58
 
            break
59
 
        line = line.strip()
 
58
            continue
60
59
        (flags, filename) = (line[0:3], line[4:])
61
60
        changed[filename] = {'flags': flags}
62
61
    return changed
71
70
 
72
71
def main(repo, revision):
73
72
    revision = revision.lstrip('r')
74
 
    i = svncmd_info(repo, revision)
 
73
    i = svnlook_info(repo, revision)
75
74
    data = {'type': 'svn',
76
75
            'format': 1,
77
76
            'id': int(revision),
78
77
            'changed': {},
79
 
            'repository': svncmd_uuid(repo),
 
78
            'repository': svnlook_uuid(repo),
80
79
            'committer': i['author'],
81
80
            'log': i['log'],
82
81
            'date': i['date'],
83
82
            }
84
 
    data['changed'].update(svncmd_changed(repo, revision))
 
83
    data['changed'].update(svnlook_changed(repo, revision))
85
84
    body = json.dumps(data)
86
85
    do_put(body)
87
86
 
88
87
if __name__ == "__main__":
89
88
    if len(sys.argv) not in (3, 4):
90
89
        sys.stderr.write("invalid args\n")
91
 
        sys.exit(0)
 
90
        sys.exit(1)
92
91
 
93
92
    main(*sys.argv[1:3])