Mercurial > treepkg > treepkg
annotate treepkg/subversion.py @ 269:97fd2584df5f
Make treepkg.subversion.last_changed_revision raise SubversionError if
the last changed revision cannot be determined.
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Wed, 06 May 2009 13:54:04 +0000 |
parents | e201ea1f6d0e |
children | 4b700b39c32f |
rev | line source |
---|---|
224
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
1 # Copyright (C) 2007, 2008, 2009 by Intevation GmbH |
0 | 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 | |
224
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
8 """Collection of subversion utility code""" |
0 | 9 |
10 import os | |
230
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
11 import shutil |
0 | 12 |
13 import run | |
45
3e610233ccfe
use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
14 from cmdexpand import cmdexpand |
0 | 15 from util import extract_value_for_key |
16 | |
17 | |
269
97fd2584df5f
Make treepkg.subversion.last_changed_revision raise SubversionError if
Bernhard Herzog <bh@intevation.de>
parents:
266
diff
changeset
|
18 class SubversionError(Exception): |
97fd2584df5f
Make treepkg.subversion.last_changed_revision raise SubversionError if
Bernhard Herzog <bh@intevation.de>
parents:
266
diff
changeset
|
19 pass |
97fd2584df5f
Make treepkg.subversion.last_changed_revision raise SubversionError if
Bernhard Herzog <bh@intevation.de>
parents:
266
diff
changeset
|
20 |
262
81ba86662cbd
Add treepkg/subversion.list_url function, a wrapper for "svn list"
Bernhard Herzog <bh@intevation.de>
parents:
230
diff
changeset
|
21 def list_url(url): |
81ba86662cbd
Add treepkg/subversion.list_url function, a wrapper for "svn list"
Bernhard Herzog <bh@intevation.de>
parents:
230
diff
changeset
|
22 """Runs svn list with the given url and returns files listed as a list""" |
81ba86662cbd
Add treepkg/subversion.list_url function, a wrapper for "svn list"
Bernhard Herzog <bh@intevation.de>
parents:
230
diff
changeset
|
23 output = run.capture_output(cmdexpand("svn list $url", **locals())) |
81ba86662cbd
Add treepkg/subversion.list_url function, a wrapper for "svn list"
Bernhard Herzog <bh@intevation.de>
parents:
230
diff
changeset
|
24 return output.splitlines() |
81ba86662cbd
Add treepkg/subversion.list_url function, a wrapper for "svn list"
Bernhard Herzog <bh@intevation.de>
parents:
230
diff
changeset
|
25 |
208
1527c37bd7aa
Allow checkouts of specific revision and to prohibit recursion during
Bernhard Herzog <bh@intevation.de>
parents:
79
diff
changeset
|
26 def checkout(url, localdir, revision=None, recurse=True): |
0 | 27 """Runs svn to checkout the repository at url into the localdir""" |
208
1527c37bd7aa
Allow checkouts of specific revision and to prohibit recursion during
Bernhard Herzog <bh@intevation.de>
parents:
79
diff
changeset
|
28 args = [] |
1527c37bd7aa
Allow checkouts of specific revision and to prohibit recursion during
Bernhard Herzog <bh@intevation.de>
parents:
79
diff
changeset
|
29 if revision: |
1527c37bd7aa
Allow checkouts of specific revision and to prohibit recursion during
Bernhard Herzog <bh@intevation.de>
parents:
79
diff
changeset
|
30 args.extend(["--revision", revision]) |
1527c37bd7aa
Allow checkouts of specific revision and to prohibit recursion during
Bernhard Herzog <bh@intevation.de>
parents:
79
diff
changeset
|
31 if not recurse: |
1527c37bd7aa
Allow checkouts of specific revision and to prohibit recursion during
Bernhard Herzog <bh@intevation.de>
parents:
79
diff
changeset
|
32 args.append("-N") |
1527c37bd7aa
Allow checkouts of specific revision and to prohibit recursion during
Bernhard Herzog <bh@intevation.de>
parents:
79
diff
changeset
|
33 run.call(cmdexpand("svn checkout -q @args $url $localdir", **locals())) |
0 | 34 |
208
1527c37bd7aa
Allow checkouts of specific revision and to prohibit recursion during
Bernhard Herzog <bh@intevation.de>
parents:
79
diff
changeset
|
35 def update(localdir, revision=None, recurse=True): |
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
|
36 """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
|
37 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
|
38 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
|
39 """ |
208
1527c37bd7aa
Allow checkouts of specific revision and to prohibit recursion during
Bernhard Herzog <bh@intevation.de>
parents:
79
diff
changeset
|
40 args = [] |
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
|
41 if revision: |
208
1527c37bd7aa
Allow checkouts of specific revision and to prohibit recursion during
Bernhard Herzog <bh@intevation.de>
parents:
79
diff
changeset
|
42 args.extend(["--revision", revision]) |
1527c37bd7aa
Allow checkouts of specific revision and to prohibit recursion during
Bernhard Herzog <bh@intevation.de>
parents:
79
diff
changeset
|
43 if not recurse: |
1527c37bd7aa
Allow checkouts of specific revision and to prohibit recursion during
Bernhard Herzog <bh@intevation.de>
parents:
79
diff
changeset
|
44 args.append("-N") |
1527c37bd7aa
Allow checkouts of specific revision and to prohibit recursion during
Bernhard Herzog <bh@intevation.de>
parents:
79
diff
changeset
|
45 run.call(cmdexpand("svn update -q @args $localdir", **locals())) |
0 | 46 |
266
e201ea1f6d0e
Add revision and recurse parameters to treepkg.subversion.export
Bernhard Herzog <bh@intevation.de>
parents:
262
diff
changeset
|
47 def export(src, dest, revision=None, recurse=True): |
0 | 48 """Runs svn export src dest""" |
266
e201ea1f6d0e
Add revision and recurse parameters to treepkg.subversion.export
Bernhard Herzog <bh@intevation.de>
parents:
262
diff
changeset
|
49 args = [] |
e201ea1f6d0e
Add revision and recurse parameters to treepkg.subversion.export
Bernhard Herzog <bh@intevation.de>
parents:
262
diff
changeset
|
50 if revision: |
e201ea1f6d0e
Add revision and recurse parameters to treepkg.subversion.export
Bernhard Herzog <bh@intevation.de>
parents:
262
diff
changeset
|
51 args.extend(["--revision", revision]) |
e201ea1f6d0e
Add revision and recurse parameters to treepkg.subversion.export
Bernhard Herzog <bh@intevation.de>
parents:
262
diff
changeset
|
52 if not recurse: |
e201ea1f6d0e
Add revision and recurse parameters to treepkg.subversion.export
Bernhard Herzog <bh@intevation.de>
parents:
262
diff
changeset
|
53 args.append("-N") |
e201ea1f6d0e
Add revision and recurse parameters to treepkg.subversion.export
Bernhard Herzog <bh@intevation.de>
parents:
262
diff
changeset
|
54 run.call(cmdexpand("svn export -q @args $src $dest", **locals())) |
0 | 55 |
56 def last_changed_revision(svn_working_copy): | |
57 """return the last changed revision of an SVN working copy as an int""" | |
58 # Make sure we run svn under the C locale to avoid localized | |
59 # messages | |
60 env = os.environ.copy() | |
61 env["LANG"] = "C" | |
62 | |
45
3e610233ccfe
use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
63 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
|
64 **locals()), |
3e610233ccfe
use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents:
0
diff
changeset
|
65 env=env) |
269
97fd2584df5f
Make treepkg.subversion.last_changed_revision raise SubversionError if
Bernhard Herzog <bh@intevation.de>
parents:
266
diff
changeset
|
66 str_rev = extract_value_for_key(output.splitlines(), "Last Changed Rev:") |
97fd2584df5f
Make treepkg.subversion.last_changed_revision raise SubversionError if
Bernhard Herzog <bh@intevation.de>
parents:
266
diff
changeset
|
67 if str_rev is None: |
97fd2584df5f
Make treepkg.subversion.last_changed_revision raise SubversionError if
Bernhard Herzog <bh@intevation.de>
parents:
266
diff
changeset
|
68 raise SubversionError("Cannot determine last changed revision for %r" |
97fd2584df5f
Make treepkg.subversion.last_changed_revision raise SubversionError if
Bernhard Herzog <bh@intevation.de>
parents:
266
diff
changeset
|
69 % svn_working_copy) |
97fd2584df5f
Make treepkg.subversion.last_changed_revision raise SubversionError if
Bernhard Herzog <bh@intevation.de>
parents:
266
diff
changeset
|
70 return int(str_rev) |
224
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
71 |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
72 |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
73 class SvnRepository(object): |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
74 |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
75 """Describes a subversion repository""" |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
76 |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
77 def __init__(self, url, external_subdirs=()): |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
78 """Initialize the subversion repository description |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
79 Parameters: |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
80 url -- The url of the repository |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
81 external_subdirs -- A list of subdirectories which are managed |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
82 by svn externals definitions |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
83 """ |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
84 self.url = url |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
85 self.external_subdirs = external_subdirs |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
86 |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
87 def checkout(self, localdir, revision=None): |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
88 """Checks out the repository into localdir. The revision |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
89 parameter should be an and indicates the revision to check out. |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
90 """ |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
91 checkout(self.url, localdir, revision=revision) |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
92 |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
93 def export(self, localdir, destdir): |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
94 """Exports the working copy in localdir to destdir""" |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
95 export(localdir, destdir) |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
96 for subdir in self.external_subdirs: |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
97 absdir = os.path.join(destdir, subdir) |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
98 if not os.path.isdir(absdir): |
228
d2ddd037ddaf
Fix a bug introduced by the subversion interface reorganization
Bernhard Herzog <bh@intevation.de>
parents:
224
diff
changeset
|
99 export(os.path.join(localdir, subdir), absdir) |
224
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
100 |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
101 def last_changed_revision(self, localdir): |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
102 """Returns the last changed revision of the working copy in localdir""" |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
103 return max([last_changed_revision(os.path.join(localdir, d)) |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
104 for d in [localdir] + list(self.external_subdirs)]) |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
105 |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
106 |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
107 class SvnWorkingCopy(object): |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
108 |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
109 """Represents a checkout of a subversion repository""" |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
110 |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
111 def __init__(self, repository, localdir, logger=None): |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
112 """ |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
113 Initialize the working copy. |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
114 Parameters: |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
115 repository -- The SvnRepository instance describing the |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
116 repository |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
117 localdir -- The directory for the working copy |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
118 logger -- logging object to use for some info/debug messages |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
119 """ |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
120 self.repository = repository |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
121 self.localdir = localdir |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
122 self.logger = logger |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
123 |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
124 def log_info(self, *args): |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
125 if self.logger is not None: |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
126 self.logger.info(*args) |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
127 |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
128 def update_or_checkout(self, revision=None): |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
129 """Updates the working copy or creates by checking out the repository""" |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
130 if os.path.exists(self.localdir): |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
131 self.log_info("Updating the working copy in %r", self.localdir) |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
132 update(self.localdir, revision=revision) |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
133 else: |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
134 self.log_info("The working copy in %r doesn't exist yet." |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
135 " Checking out from %r", |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
136 self.localdir, self.repository.url) |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
137 self.repository.checkout(self.localdir, revision=revision) |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
138 |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
139 def export(self, destdir): |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
140 """Exports the working copy to destdir""" |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
141 self.repository.export(self.localdir, destdir) |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
142 |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
143 def last_changed_revision(self): |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
144 """Returns the last changed rev of the working copy""" |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
208
diff
changeset
|
145 return self.repository.last_changed_revision(self.localdir) |
230
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
146 |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
147 |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
148 class ManualWorkingCopy(object): |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
149 |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
150 """A manually managed working copy""" |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
151 |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
152 def __init__(self, directory): |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
153 self.directory = directory |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
154 |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
155 def update_or_checkout(self, revision=None, recurse=True): |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
156 """This method does nothing""" |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
157 pass |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
158 |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
159 def export(self, destdir): |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
160 """Copies the entire working copy to destdir""" |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
161 shutil.copytree(self.directory, destdir) |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
162 |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
163 def last_changed_revision(self): |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
164 """Always returns 0""" |
e387b879fd38
Add treepkg.subversion.ManualWorkingCopy. Same interface as
Bernhard Herzog <bh@intevation.de>
parents:
228
diff
changeset
|
165 return 0 |