##// END OF EJS Templates
convert: remove `if False` block...
Augie Fackler -
r33368:ffb30661 default
parent child Browse files
Show More
@@ -1,137 +1,132 b''
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, see <http://www.gnu.org/licenses/>.
19 19 from __future__ import absolute_import
20 20
21 21 import svn.client
22 22 import svn.core
23 23 import svn.ra
24 24
25 25 Pool = svn.core.Pool
26 26 SubversionException = svn.core.SubversionException
27 27
28 28 from mercurial import (
29 29 util,
30 30 )
31 31
32 32 # Some older versions of the Python bindings need to be
33 33 # explicitly initialized. But what we want to do probably
34 34 # won't work worth a darn against those libraries anyway!
35 35 svn.ra.initialize()
36 36
37 37 svn_config = None
38 38
39 39 def _create_auth_baton(pool):
40 40 """Create a Subversion authentication baton. """
41 41 import svn.client
42 42 # Give the client context baton a suite of authentication
43 43 # providers.h
44 44 providers = [
45 45 svn.client.get_simple_provider(pool),
46 46 svn.client.get_username_provider(pool),
47 47 svn.client.get_ssl_client_cert_file_provider(pool),
48 48 svn.client.get_ssl_client_cert_pw_file_provider(pool),
49 49 svn.client.get_ssl_server_trust_file_provider(pool),
50 50 ]
51 51 # Platform-dependent authentication methods
52 52 getprovider = getattr(svn.core, 'svn_auth_get_platform_specific_provider',
53 53 None)
54 54 if getprovider:
55 55 # Available in svn >= 1.6
56 56 for name in ('gnome_keyring', 'keychain', 'kwallet', 'windows'):
57 57 for type in ('simple', 'ssl_client_cert_pw', 'ssl_server_trust'):
58 58 p = getprovider(name, type, pool)
59 59 if p:
60 60 providers.append(p)
61 61 else:
62 62 if util.safehasattr(svn.client, 'get_windows_simple_provider'):
63 63 providers.append(svn.client.get_windows_simple_provider(pool))
64 64
65 65 return svn.core.svn_auth_open(providers, pool)
66 66
67 67 class NotBranchError(SubversionException):
68 68 pass
69 69
70 70 class SvnRaTransport(object):
71 71 """
72 72 Open an ra connection to a Subversion repository.
73 73 """
74 74 def __init__(self, url="", ra=None):
75 75 self.pool = Pool()
76 76 self.svn_url = url
77 77 self.username = ''
78 78 self.password = ''
79 79
80 80 # Only Subversion 1.4 has reparent()
81 81 if ra is None or not util.safehasattr(svn.ra, 'reparent'):
82 82 self.client = svn.client.create_context(self.pool)
83 83 ab = _create_auth_baton(self.pool)
84 if False:
85 svn.core.svn_auth_set_parameter(
86 ab, svn.core.SVN_AUTH_PARAM_DEFAULT_USERNAME, self.username)
87 svn.core.svn_auth_set_parameter(
88 ab, svn.core.SVN_AUTH_PARAM_DEFAULT_PASSWORD, self.password)
89 84 self.client.auth_baton = ab
90 85 global svn_config
91 86 if svn_config is None:
92 87 svn_config = svn.core.svn_config_get_config(None)
93 88 self.client.config = svn_config
94 89 try:
95 90 self.ra = svn.client.open_ra_session(
96 91 self.svn_url,
97 92 self.client, self.pool)
98 93 except SubversionException as xxx_todo_changeme:
99 94 (inst, num) = xxx_todo_changeme.args
100 95 if num in (svn.core.SVN_ERR_RA_ILLEGAL_URL,
101 96 svn.core.SVN_ERR_RA_LOCAL_REPOS_OPEN_FAILED,
102 97 svn.core.SVN_ERR_BAD_URL):
103 98 raise NotBranchError(url)
104 99 raise
105 100 else:
106 101 self.ra = ra
107 102 svn.ra.reparent(self.ra, self.svn_url.encode('utf8'))
108 103
109 104 class Reporter(object):
110 105 def __init__(self, reporter_data):
111 106 self._reporter, self._baton = reporter_data
112 107
113 108 def set_path(self, path, revnum, start_empty, lock_token, pool=None):
114 109 svn.ra.reporter2_invoke_set_path(self._reporter, self._baton,
115 110 path, revnum, start_empty, lock_token, pool)
116 111
117 112 def delete_path(self, path, pool=None):
118 113 svn.ra.reporter2_invoke_delete_path(self._reporter, self._baton,
119 114 path, pool)
120 115
121 116 def link_path(self, path, url, revision, start_empty, lock_token,
122 117 pool=None):
123 118 svn.ra.reporter2_invoke_link_path(self._reporter, self._baton,
124 119 path, url, revision, start_empty, lock_token,
125 120 pool)
126 121
127 122 def finish_report(self, pool=None):
128 123 svn.ra.reporter2_invoke_finish_report(self._reporter,
129 124 self._baton, pool)
130 125
131 126 def abort_report(self, pool=None):
132 127 svn.ra.reporter2_invoke_abort_report(self._reporter,
133 128 self._baton, pool)
134 129
135 130 def do_update(self, revnum, path, *args, **kwargs):
136 131 return self.Reporter(svn.ra.do_update(self.ra, revnum, path,
137 132 *args, **kwargs))
General Comments 0
You need to be logged in to leave comments. Login now