0
|
1 # Copyright (C) 2007 by Intevation GmbH |
|
2 # Authors: |
|
3 # Bernhard Herzog <bh@intevation.de> |
|
4 # |
|
5 # This program is free software under the GPL (>=v2) |
|
6 # Read the file COPYING coming with the software for details. |
|
7 |
|
8 """Collection of subversion utility functions""" |
|
9 |
|
10 import os |
|
11 |
|
12 import run |
|
13 from util import extract_value_for_key |
|
14 |
|
15 |
|
16 def checkout(url, localdir): |
|
17 """Runs svn to checkout the repository at url into the localdir""" |
|
18 run.call(["svn", "checkout", "-q", url, localdir]) |
|
19 |
|
20 def update(localdir): |
|
21 """Runs svn update on the localdir""" |
|
22 run.call(["svn", "update", "-q", localdir]) |
|
23 |
|
24 def export(src, dest): |
|
25 """Runs svn export src dest""" |
|
26 run.call(["svn", "export", "-q", src, dest]) |
|
27 |
|
28 def last_changed_revision(svn_working_copy): |
|
29 """return the last changed revision of an SVN working copy as an int""" |
|
30 # Make sure we run svn under the C locale to avoid localized |
|
31 # messages |
|
32 env = os.environ.copy() |
|
33 env["LANG"] = "C" |
|
34 |
|
35 output = run.capture_output(["svn", "info", svn_working_copy], env=env) |
|
36 return int(extract_value_for_key(output.splitlines(), |
|
37 "Last Changed Rev:")) |