annotate treepkg/subversion.py @ 79:570ac81865be

Add revision parameter to update so that a checkout can be updated to a specific revision
author Bernhard Herzog <bh@intevation.de>
date Fri, 11 May 2007 12:58:28 +0000
parents 3e610233ccfe
children 1527c37bd7aa
rev   line source
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
1 # Copyright (C) 2007 by Intevation GmbH
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
2 # Authors:
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
3 # Bernhard Herzog <bh@intevation.de>
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
4 #
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
5 # This program is free software under the GPL (>=v2)
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
6 # Read the file COPYING coming with the software for details.
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
7
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
8 """Collection of subversion utility functions"""
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
9
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
10 import os
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
11
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
12 import run
45
3e610233ccfe use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents: 0
diff changeset
13 from cmdexpand import cmdexpand
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
14 from util import extract_value_for_key
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
15
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
16
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
17 def checkout(url, localdir):
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
18 """Runs svn to checkout the repository at url into the localdir"""
45
3e610233ccfe use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents: 0
diff changeset
19 run.call(cmdexpand("svn checkout -q $url $localdir", **locals()))
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
20
79
570ac81865be Add revision parameter to update so that a checkout can be updated to a
Bernhard Herzog <bh@intevation.de>
parents: 45
diff changeset
21 def update(localdir, revision=None):
570ac81865be Add revision parameter to update so that a checkout can be updated to a
Bernhard Herzog <bh@intevation.de>
parents: 45
diff changeset
22 """Runs svn update on the localdir.
570ac81865be Add revision parameter to update so that a checkout can be updated to a
Bernhard Herzog <bh@intevation.de>
parents: 45
diff changeset
23 The parameter revision, if given, is passed to svn as the value of
570ac81865be Add revision parameter to update so that a checkout can be updated to a
Bernhard Herzog <bh@intevation.de>
parents: 45
diff changeset
24 the --revision option.
570ac81865be Add revision parameter to update so that a checkout can be updated to a
Bernhard Herzog <bh@intevation.de>
parents: 45
diff changeset
25 """
570ac81865be Add revision parameter to update so that a checkout can be updated to a
Bernhard Herzog <bh@intevation.de>
parents: 45
diff changeset
26 if revision:
570ac81865be Add revision parameter to update so that a checkout can be updated to a
Bernhard Herzog <bh@intevation.de>
parents: 45
diff changeset
27 revision = ["--revision", revision]
570ac81865be Add revision parameter to update so that a checkout can be updated to a
Bernhard Herzog <bh@intevation.de>
parents: 45
diff changeset
28 else:
570ac81865be Add revision parameter to update so that a checkout can be updated to a
Bernhard Herzog <bh@intevation.de>
parents: 45
diff changeset
29 revision = []
570ac81865be Add revision parameter to update so that a checkout can be updated to a
Bernhard Herzog <bh@intevation.de>
parents: 45
diff changeset
30 run.call(cmdexpand("svn update -q @revision $localdir", **locals()))
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
31
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
32 def export(src, dest):
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
33 """Runs svn export src dest"""
45
3e610233ccfe use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents: 0
diff changeset
34 run.call(cmdexpand("svn export -q $src $dest", **locals()))
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
35
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
36 def last_changed_revision(svn_working_copy):
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
37 """return the last changed revision of an SVN working copy as an int"""
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
38 # Make sure we run svn under the C locale to avoid localized
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
39 # messages
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
40 env = os.environ.copy()
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
41 env["LANG"] = "C"
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
42
45
3e610233ccfe use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents: 0
diff changeset
43 output = run.capture_output(cmdexpand("svn info $svn_working_copy",
3e610233ccfe use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents: 0
diff changeset
44 **locals()),
3e610233ccfe use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents: 0
diff changeset
45 env=env)
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
46 return int(extract_value_for_key(output.splitlines(),
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
47 "Last Changed Rev:"))
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)