##// END OF EJS Templates
convert: Remove unused clone method
Joel Rosdahl -
r6215:cb043479 default
parent child Browse files
Show More
@@ -1,125 +1,118
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Copyright (C) 2007 Daniel Holth <dholth@fastmail.fm>
4 4 # This is a stripped-down version of the original bzr-svn transport.py,
5 5 # Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
6 6
7 7 # This program is free software; you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
9 9 # the Free Software Foundation; either version 2 of the License, or
10 10 # (at your option) any later version.
11 11
12 12 # This program is distributed in the hope that it will be useful,
13 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 15 # GNU General Public License for more details.
16 16
17 17 # You should have received a copy of the GNU General Public License
18 18 # along with this program; if not, write to the Free Software
19 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 20
21 21 from svn.core import SubversionException, Pool
22 22 import svn.ra
23 23 import svn.client
24 24 import svn.core
25 25
26 26 # Some older versions of the Python bindings need to be
27 27 # explicitly initialized. But what we want to do probably
28 28 # won't work worth a darn against those libraries anyway!
29 29 svn.ra.initialize()
30 30
31 31 svn_config = svn.core.svn_config_get_config(None)
32 32
33 33
34 34 def _create_auth_baton(pool):
35 35 """Create a Subversion authentication baton. """
36 36 import svn.client
37 37 # Give the client context baton a suite of authentication
38 38 # providers.h
39 39 providers = [
40 40 svn.client.get_simple_provider(pool),
41 41 svn.client.get_username_provider(pool),
42 42 svn.client.get_ssl_client_cert_file_provider(pool),
43 43 svn.client.get_ssl_client_cert_pw_file_provider(pool),
44 44 svn.client.get_ssl_server_trust_file_provider(pool),
45 45 ]
46 46 # Platform-dependant authentication methods
47 47 if hasattr(svn.client, 'get_windows_simple_provider'):
48 48 providers.append(svn.client.get_windows_simple_provider(pool))
49 49
50 50 return svn.core.svn_auth_open(providers, pool)
51 51
52 52 class NotBranchError(SubversionException):
53 53 pass
54 54
55 55 class SvnRaTransport(object):
56 56 """
57 57 Open an ra connection to a Subversion repository.
58 58 """
59 59 def __init__(self, url="", ra=None):
60 60 self.pool = Pool()
61 61 self.svn_url = url
62 62 self.username = ''
63 63 self.password = ''
64 64
65 65 # Only Subversion 1.4 has reparent()
66 66 if ra is None or not hasattr(svn.ra, 'reparent'):
67 67 self.client = svn.client.create_context(self.pool)
68 68 ab = _create_auth_baton(self.pool)
69 69 if False:
70 70 svn.core.svn_auth_set_parameter(
71 71 ab, svn.core.SVN_AUTH_PARAM_DEFAULT_USERNAME, self.username)
72 72 svn.core.svn_auth_set_parameter(
73 73 ab, svn.core.SVN_AUTH_PARAM_DEFAULT_PASSWORD, self.password)
74 74 self.client.auth_baton = ab
75 75 self.client.config = svn_config
76 76 try:
77 77 self.ra = svn.client.open_ra_session(
78 78 self.svn_url.encode('utf8'),
79 79 self.client, self.pool)
80 80 except SubversionException, (inst, num):
81 81 if num in (svn.core.SVN_ERR_RA_ILLEGAL_URL,
82 82 svn.core.SVN_ERR_RA_LOCAL_REPOS_OPEN_FAILED,
83 83 svn.core.SVN_ERR_BAD_URL):
84 84 raise NotBranchError(url)
85 85 raise
86 86 else:
87 87 self.ra = ra
88 88 svn.ra.reparent(self.ra, self.svn_url.encode('utf8'))
89 89
90 90 class Reporter:
91 91 def __init__(self, (reporter, report_baton)):
92 92 self._reporter = reporter
93 93 self._baton = report_baton
94 94
95 95 def set_path(self, path, revnum, start_empty, lock_token, pool=None):
96 96 svn.ra.reporter2_invoke_set_path(self._reporter, self._baton,
97 97 path, revnum, start_empty, lock_token, pool)
98 98
99 99 def delete_path(self, path, pool=None):
100 100 svn.ra.reporter2_invoke_delete_path(self._reporter, self._baton,
101 101 path, pool)
102 102
103 103 def link_path(self, path, url, revision, start_empty, lock_token,
104 104 pool=None):
105 105 svn.ra.reporter2_invoke_link_path(self._reporter, self._baton,
106 106 path, url, revision, start_empty, lock_token,
107 107 pool)
108 108
109 109 def finish_report(self, pool=None):
110 110 svn.ra.reporter2_invoke_finish_report(self._reporter,
111 111 self._baton, pool)
112 112
113 113 def abort_report(self, pool=None):
114 114 svn.ra.reporter2_invoke_abort_report(self._reporter,
115 115 self._baton, pool)
116 116
117 117 def do_update(self, revnum, path, *args, **kwargs):
118 118 return self.Reporter(svn.ra.do_update(self.ra, revnum, path, *args, **kwargs))
119
120 def clone(self, offset=None):
121 """See Transport.clone()."""
122 if offset is None:
123 return self.__class__(self.base)
124
125 return SvnRaTransport(urlutils.join(self.base, offset), ra=self.ra)
General Comments 0
You need to be logged in to leave comments. Login now