author | Todd Larsen <tlarsen@google.com> |
Fri, 23 May 2008 03:35:33 +0000 | |
changeset 36 | e2f03be8ced9 |
parent 30 | 636baa95715c |
child 44 | 9d3a0f98df34 |
permissions | -rwxr-xr-x |
30
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2 |
# |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
4 |
# |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
8 |
# |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
10 |
# |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
16 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
17 |
"""Helper functions that wrap the pysvn Python svn bindings. |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
18 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
19 |
ls(): returns list of selected directory entries from an SVN repository |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
20 |
lsDirs(): wrapper around ls() that only returns node_kind.dir entries |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
21 |
lsFiles(): wrapper around ls() that only returns node_kind.files entries |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
22 |
exists(): returns True if repo_path exists in the svn repository |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
23 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
24 |
DEF_SVN_REPO: default HTTPS path to the SoC project SVN repo |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
25 |
PYSVN_ALL_NODE_KINDS: all directory entry node_kinds supported by pysvn |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
26 |
PYSVN_FILE_DIR_NODE_KINDS: actual file and directory node_kinds |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
27 |
""" |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
28 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
29 |
__authors__ = [ |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
30 |
# alphabetical order by last name, please |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
31 |
'"Todd Larsen" <tlarsen@google.com>', |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
32 |
] |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
33 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
34 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
35 |
import pysvn |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
36 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
37 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
38 |
#: default HTTPS path to the SoC project SVN repo |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
39 |
DEF_SVN_REPO = 'https://soc.googlecode.com/svn/' |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
40 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
41 |
#: all of the directory entry node_kinds supported py pysvn |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
42 |
PYSVN_ALL_NODE_KINDS = set([pysvn.node_kind.none, pysvn.node_kind.dir, |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
43 |
pysvn.node_kind.file, pysvn.node_kind.unknown]) |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
44 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
45 |
#: actual file and directory node_kinds (includes dir and file, but excludes |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
46 |
#: the "non-file" none and unknown) |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
47 |
PYSVN_FILE_DIR_NODE_KINDS = set([pysvn.node_kind.dir, pysvn.node_kind.file]) |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
48 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
49 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
50 |
def ls(client, repo_path, keep_kinds=PYSVN_FILE_DIR_NODE_KINDS, **kwargs): |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
51 |
"""Returns a list of (possibly recursive) svn repo directory entries. |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
52 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
53 |
Args: |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
54 |
client: pysvn Client instance |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
55 |
repo_path: absolute svn repository path URL, including the server and |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
56 |
directory path within the repo |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
57 |
keep_kinds: types of directory entries to keep in the returned list; a |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
58 |
collection of pysvn.node_kind objects; default is |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
59 |
PYSVN_FILE_DIR_NODE_KINDS |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
60 |
**kwargs: keyword arguments passed on to Client.list(), including: |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
61 |
recurse: indicates if return results should include entries from |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
62 |
subdirectories of repo_path as well; default is False |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
63 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
64 |
Returns: |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
65 |
list of (Unicode, coming from pysvn) strings representing the entries |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
66 |
of types indicated by keep_kinds; strings are altered to match the |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
67 |
output of the actual 'svn ls' command: repo_path prefix is removed, |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
68 |
directories end with the / separator. |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
69 |
""" |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
70 |
raw_entries = client.list(repo_path, **kwargs) |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
71 |
entries = [] |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
72 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
73 |
# Find shortest repos_path that is a 'dir' entry; will be prefix of all |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
74 |
# other entries, since Client.list() always returns repo_path as one of |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
75 |
# the entries. It is easier and more reliable to do this search than to |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
76 |
# try to manipulate repo_path into the prefix (since the user could supply |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
77 |
# any number of valid, but different, formats). |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
78 |
shortest_path = raw_entries[0][0].repos_path |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
79 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
80 |
for svn_list, _ in raw_entries: |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
81 |
if svn_list.kind == pysvn.node_kind.dir: |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
82 |
entry_path = svn_list.repos_path |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
83 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
84 |
if len(entry_path) < len(shortest_path): |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
85 |
shortest_path = entry_path |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
86 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
87 |
# normalize the path name of entry_prefix to include a trailing separator |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
88 |
entry_prefix = shortest_path |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
89 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
90 |
if not entry_prefix.endswith('/'): |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
91 |
entry_prefix = entry_prefix + '/' |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
92 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
93 |
for svn_list,_ in raw_entries: |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
94 |
# only include requested node kinds (dir, file, etc.) |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
95 |
if svn_list.kind not in keep_kinds: |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
96 |
continue |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
97 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
98 |
entry_path = svn_list.repos_path |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
99 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
100 |
# omit the repo_path directory entry itself (simiilar to omitting '.' as |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
101 |
# is done by the actual 'svn ls' command) |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
102 |
if entry_path == shortest_path: |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
103 |
continue |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
104 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
105 |
# all entry_paths except for the shortest should start with that |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
106 |
# shortest entry_prefix, so assert that and remove the prefix |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
107 |
assert entry_path.startswith(entry_prefix) |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
108 |
entry_path = entry_path[len(entry_prefix):] |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
109 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
110 |
# normalize directory entry_paths to include a trailing separator |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
111 |
if ((svn_list.kind == pysvn.node_kind.dir) |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
112 |
and (not entry_path.endswith('/'))): |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
113 |
entry_path = entry_path + '/' |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
114 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
115 |
entries.append(entry_path) |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
116 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
117 |
return entries |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
118 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
119 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
120 |
def lsDirs(client, repo_path, **kwargs): |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
121 |
"""Wrapper around ls() that only returns node_kind.dir entries. |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
122 |
""" |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
123 |
return ls(client, repo_path, keep_kinds=(pysvn.node_kind.dir,), **kwargs) |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
124 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
125 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
126 |
def lsFiles(client, repo_path, **kwargs): |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
127 |
"""Wrapper around ls() that only returns node_kind.files entries. |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
128 |
""" |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
129 |
return ls(client, repo_path, keep_kinds=(pysvn.node_kind.file,), **kwargs) |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
130 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
131 |
|
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
132 |
def exists(client, repo_path): |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
133 |
"""Returns True if repo_path exists in the svn repository.""" |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
134 |
try: |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
135 |
raw_entries = client.list(repo_path) |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
136 |
return True |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
137 |
except pysvn._pysvn.ClientError: |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
138 |
# Client.list() raises an exception if the path is not present in the repo |
636baa95715c
Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
139 |
return False |