##// END OF EJS Templates
convert: transport use absolute_import
timeless -
r28412:1e03b741 default
parent child Browse files
Show More
@@ -1,129 +1,135
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2007 Daniel Holth <dholth@fastmail.fm>
3 # Copyright (C) 2007 Daniel Holth <dholth@fastmail.fm>
4 # This is a stripped-down version of the original bzr-svn transport.py,
4 # This is a stripped-down version of the original bzr-svn transport.py,
5 # Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
5 # Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
6
6
7 # This program is free software; you can redistribute it and/or modify
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
10 # (at your option) any later version.
11
11
12 # This program is distributed in the hope that it will be useful,
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
15 # GNU General Public License for more details.
16
16
17 # You should have received a copy of the GNU General Public License
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, see <http://www.gnu.org/licenses/>.
18 # along with this program; if not, see <http://www.gnu.org/licenses/>.
19 from __future__ import absolute_import
19
20
20 from mercurial import util
21 from mercurial import (
21 from svn.core import SubversionException, Pool
22 util,
22 import svn.ra
23 )
24
23 import svn.client
25 import svn.client
24 import svn.core
26 import svn.core
27 import svn.ra
28
29 Pool = svn.core.Pool
30 SubversionException = svn.core.SubversionException
25
31
26 # Some older versions of the Python bindings need to be
32 # Some older versions of the Python bindings need to be
27 # explicitly initialized. But what we want to do probably
33 # explicitly initialized. But what we want to do probably
28 # won't work worth a darn against those libraries anyway!
34 # won't work worth a darn against those libraries anyway!
29 svn.ra.initialize()
35 svn.ra.initialize()
30
36
31 svn_config = svn.core.svn_config_get_config(None)
37 svn_config = svn.core.svn_config_get_config(None)
32
38
33
39
34 def _create_auth_baton(pool):
40 def _create_auth_baton(pool):
35 """Create a Subversion authentication baton. """
41 """Create a Subversion authentication baton. """
36 import svn.client
42 import svn.client
37 # Give the client context baton a suite of authentication
43 # Give the client context baton a suite of authentication
38 # providers.h
44 # providers.h
39 providers = [
45 providers = [
40 svn.client.get_simple_provider(pool),
46 svn.client.get_simple_provider(pool),
41 svn.client.get_username_provider(pool),
47 svn.client.get_username_provider(pool),
42 svn.client.get_ssl_client_cert_file_provider(pool),
48 svn.client.get_ssl_client_cert_file_provider(pool),
43 svn.client.get_ssl_client_cert_pw_file_provider(pool),
49 svn.client.get_ssl_client_cert_pw_file_provider(pool),
44 svn.client.get_ssl_server_trust_file_provider(pool),
50 svn.client.get_ssl_server_trust_file_provider(pool),
45 ]
51 ]
46 # Platform-dependent authentication methods
52 # Platform-dependent authentication methods
47 getprovider = getattr(svn.core, 'svn_auth_get_platform_specific_provider',
53 getprovider = getattr(svn.core, 'svn_auth_get_platform_specific_provider',
48 None)
54 None)
49 if getprovider:
55 if getprovider:
50 # Available in svn >= 1.6
56 # Available in svn >= 1.6
51 for name in ('gnome_keyring', 'keychain', 'kwallet', 'windows'):
57 for name in ('gnome_keyring', 'keychain', 'kwallet', 'windows'):
52 for type in ('simple', 'ssl_client_cert_pw', 'ssl_server_trust'):
58 for type in ('simple', 'ssl_client_cert_pw', 'ssl_server_trust'):
53 p = getprovider(name, type, pool)
59 p = getprovider(name, type, pool)
54 if p:
60 if p:
55 providers.append(p)
61 providers.append(p)
56 else:
62 else:
57 if util.safehasattr(svn.client, 'get_windows_simple_provider'):
63 if util.safehasattr(svn.client, 'get_windows_simple_provider'):
58 providers.append(svn.client.get_windows_simple_provider(pool))
64 providers.append(svn.client.get_windows_simple_provider(pool))
59
65
60 return svn.core.svn_auth_open(providers, pool)
66 return svn.core.svn_auth_open(providers, pool)
61
67
62 class NotBranchError(SubversionException):
68 class NotBranchError(SubversionException):
63 pass
69 pass
64
70
65 class SvnRaTransport(object):
71 class SvnRaTransport(object):
66 """
72 """
67 Open an ra connection to a Subversion repository.
73 Open an ra connection to a Subversion repository.
68 """
74 """
69 def __init__(self, url="", ra=None):
75 def __init__(self, url="", ra=None):
70 self.pool = Pool()
76 self.pool = Pool()
71 self.svn_url = url
77 self.svn_url = url
72 self.username = ''
78 self.username = ''
73 self.password = ''
79 self.password = ''
74
80
75 # Only Subversion 1.4 has reparent()
81 # Only Subversion 1.4 has reparent()
76 if ra is None or not util.safehasattr(svn.ra, 'reparent'):
82 if ra is None or not util.safehasattr(svn.ra, 'reparent'):
77 self.client = svn.client.create_context(self.pool)
83 self.client = svn.client.create_context(self.pool)
78 ab = _create_auth_baton(self.pool)
84 ab = _create_auth_baton(self.pool)
79 if False:
85 if False:
80 svn.core.svn_auth_set_parameter(
86 svn.core.svn_auth_set_parameter(
81 ab, svn.core.SVN_AUTH_PARAM_DEFAULT_USERNAME, self.username)
87 ab, svn.core.SVN_AUTH_PARAM_DEFAULT_USERNAME, self.username)
82 svn.core.svn_auth_set_parameter(
88 svn.core.svn_auth_set_parameter(
83 ab, svn.core.SVN_AUTH_PARAM_DEFAULT_PASSWORD, self.password)
89 ab, svn.core.SVN_AUTH_PARAM_DEFAULT_PASSWORD, self.password)
84 self.client.auth_baton = ab
90 self.client.auth_baton = ab
85 self.client.config = svn_config
91 self.client.config = svn_config
86 try:
92 try:
87 self.ra = svn.client.open_ra_session(
93 self.ra = svn.client.open_ra_session(
88 self.svn_url,
94 self.svn_url,
89 self.client, self.pool)
95 self.client, self.pool)
90 except SubversionException as xxx_todo_changeme:
96 except SubversionException as xxx_todo_changeme:
91 (inst, num) = xxx_todo_changeme.args
97 (inst, num) = xxx_todo_changeme.args
92 if num in (svn.core.SVN_ERR_RA_ILLEGAL_URL,
98 if num in (svn.core.SVN_ERR_RA_ILLEGAL_URL,
93 svn.core.SVN_ERR_RA_LOCAL_REPOS_OPEN_FAILED,
99 svn.core.SVN_ERR_RA_LOCAL_REPOS_OPEN_FAILED,
94 svn.core.SVN_ERR_BAD_URL):
100 svn.core.SVN_ERR_BAD_URL):
95 raise NotBranchError(url)
101 raise NotBranchError(url)
96 raise
102 raise
97 else:
103 else:
98 self.ra = ra
104 self.ra = ra
99 svn.ra.reparent(self.ra, self.svn_url.encode('utf8'))
105 svn.ra.reparent(self.ra, self.svn_url.encode('utf8'))
100
106
101 class Reporter(object):
107 class Reporter(object):
102 def __init__(self, reporter_data):
108 def __init__(self, reporter_data):
103 self._reporter, self._baton = reporter_data
109 self._reporter, self._baton = reporter_data
104
110
105 def set_path(self, path, revnum, start_empty, lock_token, pool=None):
111 def set_path(self, path, revnum, start_empty, lock_token, pool=None):
106 svn.ra.reporter2_invoke_set_path(self._reporter, self._baton,
112 svn.ra.reporter2_invoke_set_path(self._reporter, self._baton,
107 path, revnum, start_empty, lock_token, pool)
113 path, revnum, start_empty, lock_token, pool)
108
114
109 def delete_path(self, path, pool=None):
115 def delete_path(self, path, pool=None):
110 svn.ra.reporter2_invoke_delete_path(self._reporter, self._baton,
116 svn.ra.reporter2_invoke_delete_path(self._reporter, self._baton,
111 path, pool)
117 path, pool)
112
118
113 def link_path(self, path, url, revision, start_empty, lock_token,
119 def link_path(self, path, url, revision, start_empty, lock_token,
114 pool=None):
120 pool=None):
115 svn.ra.reporter2_invoke_link_path(self._reporter, self._baton,
121 svn.ra.reporter2_invoke_link_path(self._reporter, self._baton,
116 path, url, revision, start_empty, lock_token,
122 path, url, revision, start_empty, lock_token,
117 pool)
123 pool)
118
124
119 def finish_report(self, pool=None):
125 def finish_report(self, pool=None):
120 svn.ra.reporter2_invoke_finish_report(self._reporter,
126 svn.ra.reporter2_invoke_finish_report(self._reporter,
121 self._baton, pool)
127 self._baton, pool)
122
128
123 def abort_report(self, pool=None):
129 def abort_report(self, pool=None):
124 svn.ra.reporter2_invoke_abort_report(self._reporter,
130 svn.ra.reporter2_invoke_abort_report(self._reporter,
125 self._baton, pool)
131 self._baton, pool)
126
132
127 def do_update(self, revnum, path, *args, **kwargs):
133 def do_update(self, revnum, path, *args, **kwargs):
128 return self.Reporter(svn.ra.do_update(self.ra, revnum, path,
134 return self.Reporter(svn.ra.do_update(self.ra, revnum, path,
129 *args, **kwargs))
135 *args, **kwargs))
@@ -1,135 +1,134
1 #require test-repo
1 #require test-repo
2
2
3 $ cd "$TESTDIR"/..
3 $ cd "$TESTDIR"/..
4
4
5 $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py
5 $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py
6 contrib/check-code.py not using absolute_import
6 contrib/check-code.py not using absolute_import
7 contrib/check-code.py requires print_function
7 contrib/check-code.py requires print_function
8 contrib/debugshell.py not using absolute_import
8 contrib/debugshell.py not using absolute_import
9 contrib/import-checker.py not using absolute_import
9 contrib/import-checker.py not using absolute_import
10 contrib/import-checker.py requires print_function
10 contrib/import-checker.py requires print_function
11 contrib/memory.py not using absolute_import
11 contrib/memory.py not using absolute_import
12 contrib/perf.py not using absolute_import
12 contrib/perf.py not using absolute_import
13 contrib/python-hook-examples.py not using absolute_import
13 contrib/python-hook-examples.py not using absolute_import
14 contrib/revsetbenchmarks.py not using absolute_import
14 contrib/revsetbenchmarks.py not using absolute_import
15 contrib/revsetbenchmarks.py requires print_function
15 contrib/revsetbenchmarks.py requires print_function
16 contrib/showstack.py not using absolute_import
16 contrib/showstack.py not using absolute_import
17 contrib/synthrepo.py not using absolute_import
17 contrib/synthrepo.py not using absolute_import
18 contrib/win32/hgwebdir_wsgi.py not using absolute_import
18 contrib/win32/hgwebdir_wsgi.py not using absolute_import
19 doc/check-seclevel.py not using absolute_import
19 doc/check-seclevel.py not using absolute_import
20 doc/gendoc.py not using absolute_import
20 doc/gendoc.py not using absolute_import
21 doc/hgmanpage.py not using absolute_import
21 doc/hgmanpage.py not using absolute_import
22 hgext/__init__.py not using absolute_import
22 hgext/__init__.py not using absolute_import
23 hgext/color.py not using absolute_import
23 hgext/color.py not using absolute_import
24 hgext/convert/__init__.py not using absolute_import
24 hgext/convert/__init__.py not using absolute_import
25 hgext/convert/cvs.py not using absolute_import
25 hgext/convert/cvs.py not using absolute_import
26 hgext/convert/transport.py not using absolute_import
27 hgext/eol.py not using absolute_import
26 hgext/eol.py not using absolute_import
28 hgext/extdiff.py not using absolute_import
27 hgext/extdiff.py not using absolute_import
29 hgext/factotum.py not using absolute_import
28 hgext/factotum.py not using absolute_import
30 hgext/fetch.py not using absolute_import
29 hgext/fetch.py not using absolute_import
31 hgext/gpg.py not using absolute_import
30 hgext/gpg.py not using absolute_import
32 hgext/graphlog.py not using absolute_import
31 hgext/graphlog.py not using absolute_import
33 hgext/hgcia.py not using absolute_import
32 hgext/hgcia.py not using absolute_import
34 hgext/hgk.py not using absolute_import
33 hgext/hgk.py not using absolute_import
35 hgext/highlight/__init__.py not using absolute_import
34 hgext/highlight/__init__.py not using absolute_import
36 hgext/highlight/highlight.py not using absolute_import
35 hgext/highlight/highlight.py not using absolute_import
37 hgext/histedit.py not using absolute_import
36 hgext/histedit.py not using absolute_import
38 hgext/largefiles/__init__.py not using absolute_import
37 hgext/largefiles/__init__.py not using absolute_import
39 hgext/largefiles/basestore.py not using absolute_import
38 hgext/largefiles/basestore.py not using absolute_import
40 hgext/largefiles/lfcommands.py not using absolute_import
39 hgext/largefiles/lfcommands.py not using absolute_import
41 hgext/largefiles/lfutil.py not using absolute_import
40 hgext/largefiles/lfutil.py not using absolute_import
42 hgext/largefiles/localstore.py not using absolute_import
41 hgext/largefiles/localstore.py not using absolute_import
43 hgext/largefiles/overrides.py not using absolute_import
42 hgext/largefiles/overrides.py not using absolute_import
44 hgext/largefiles/proto.py not using absolute_import
43 hgext/largefiles/proto.py not using absolute_import
45 hgext/largefiles/remotestore.py not using absolute_import
44 hgext/largefiles/remotestore.py not using absolute_import
46 hgext/largefiles/reposetup.py not using absolute_import
45 hgext/largefiles/reposetup.py not using absolute_import
47 hgext/largefiles/uisetup.py not using absolute_import
46 hgext/largefiles/uisetup.py not using absolute_import
48 hgext/largefiles/wirestore.py not using absolute_import
47 hgext/largefiles/wirestore.py not using absolute_import
49 hgext/mq.py not using absolute_import
48 hgext/mq.py not using absolute_import
50 hgext/notify.py not using absolute_import
49 hgext/notify.py not using absolute_import
51 hgext/patchbomb.py not using absolute_import
50 hgext/patchbomb.py not using absolute_import
52 hgext/rebase.py not using absolute_import
51 hgext/rebase.py not using absolute_import
53 hgext/share.py not using absolute_import
52 hgext/share.py not using absolute_import
54 hgext/transplant.py not using absolute_import
53 hgext/transplant.py not using absolute_import
55 hgext/win32mbcs.py not using absolute_import
54 hgext/win32mbcs.py not using absolute_import
56 hgext/win32text.py not using absolute_import
55 hgext/win32text.py not using absolute_import
57 i18n/check-translation.py not using absolute_import
56 i18n/check-translation.py not using absolute_import
58 i18n/polib.py not using absolute_import
57 i18n/polib.py not using absolute_import
59 setup.py not using absolute_import
58 setup.py not using absolute_import
60 tests/filterpyflakes.py requires print_function
59 tests/filterpyflakes.py requires print_function
61 tests/generate-working-copy-states.py requires print_function
60 tests/generate-working-copy-states.py requires print_function
62 tests/get-with-headers.py requires print_function
61 tests/get-with-headers.py requires print_function
63 tests/heredoctest.py requires print_function
62 tests/heredoctest.py requires print_function
64 tests/hypothesishelpers.py not using absolute_import
63 tests/hypothesishelpers.py not using absolute_import
65 tests/hypothesishelpers.py requires print_function
64 tests/hypothesishelpers.py requires print_function
66 tests/killdaemons.py not using absolute_import
65 tests/killdaemons.py not using absolute_import
67 tests/md5sum.py not using absolute_import
66 tests/md5sum.py not using absolute_import
68 tests/mockblackbox.py not using absolute_import
67 tests/mockblackbox.py not using absolute_import
69 tests/printenv.py not using absolute_import
68 tests/printenv.py not using absolute_import
70 tests/readlink.py not using absolute_import
69 tests/readlink.py not using absolute_import
71 tests/readlink.py requires print_function
70 tests/readlink.py requires print_function
72 tests/revlog-formatv0.py not using absolute_import
71 tests/revlog-formatv0.py not using absolute_import
73 tests/run-tests.py not using absolute_import
72 tests/run-tests.py not using absolute_import
74 tests/seq.py not using absolute_import
73 tests/seq.py not using absolute_import
75 tests/seq.py requires print_function
74 tests/seq.py requires print_function
76 tests/silenttestrunner.py not using absolute_import
75 tests/silenttestrunner.py not using absolute_import
77 tests/silenttestrunner.py requires print_function
76 tests/silenttestrunner.py requires print_function
78 tests/sitecustomize.py not using absolute_import
77 tests/sitecustomize.py not using absolute_import
79 tests/svn-safe-append.py not using absolute_import
78 tests/svn-safe-append.py not using absolute_import
80 tests/svnxml.py not using absolute_import
79 tests/svnxml.py not using absolute_import
81 tests/test-ancestor.py requires print_function
80 tests/test-ancestor.py requires print_function
82 tests/test-atomictempfile.py not using absolute_import
81 tests/test-atomictempfile.py not using absolute_import
83 tests/test-batching.py not using absolute_import
82 tests/test-batching.py not using absolute_import
84 tests/test-batching.py requires print_function
83 tests/test-batching.py requires print_function
85 tests/test-bdiff.py not using absolute_import
84 tests/test-bdiff.py not using absolute_import
86 tests/test-bdiff.py requires print_function
85 tests/test-bdiff.py requires print_function
87 tests/test-context.py not using absolute_import
86 tests/test-context.py not using absolute_import
88 tests/test-context.py requires print_function
87 tests/test-context.py requires print_function
89 tests/test-demandimport.py not using absolute_import
88 tests/test-demandimport.py not using absolute_import
90 tests/test-demandimport.py requires print_function
89 tests/test-demandimport.py requires print_function
91 tests/test-doctest.py not using absolute_import
90 tests/test-doctest.py not using absolute_import
92 tests/test-duplicateoptions.py not using absolute_import
91 tests/test-duplicateoptions.py not using absolute_import
93 tests/test-duplicateoptions.py requires print_function
92 tests/test-duplicateoptions.py requires print_function
94 tests/test-filecache.py not using absolute_import
93 tests/test-filecache.py not using absolute_import
95 tests/test-filecache.py requires print_function
94 tests/test-filecache.py requires print_function
96 tests/test-filelog.py not using absolute_import
95 tests/test-filelog.py not using absolute_import
97 tests/test-filelog.py requires print_function
96 tests/test-filelog.py requires print_function
98 tests/test-hg-parseurl.py not using absolute_import
97 tests/test-hg-parseurl.py not using absolute_import
99 tests/test-hg-parseurl.py requires print_function
98 tests/test-hg-parseurl.py requires print_function
100 tests/test-hgweb-auth.py not using absolute_import
99 tests/test-hgweb-auth.py not using absolute_import
101 tests/test-hgweb-auth.py requires print_function
100 tests/test-hgweb-auth.py requires print_function
102 tests/test-hgwebdir-paths.py not using absolute_import
101 tests/test-hgwebdir-paths.py not using absolute_import
103 tests/test-hybridencode.py not using absolute_import
102 tests/test-hybridencode.py not using absolute_import
104 tests/test-hybridencode.py requires print_function
103 tests/test-hybridencode.py requires print_function
105 tests/test-lrucachedict.py not using absolute_import
104 tests/test-lrucachedict.py not using absolute_import
106 tests/test-lrucachedict.py requires print_function
105 tests/test-lrucachedict.py requires print_function
107 tests/test-manifest.py not using absolute_import
106 tests/test-manifest.py not using absolute_import
108 tests/test-minirst.py not using absolute_import
107 tests/test-minirst.py not using absolute_import
109 tests/test-minirst.py requires print_function
108 tests/test-minirst.py requires print_function
110 tests/test-parseindex2.py not using absolute_import
109 tests/test-parseindex2.py not using absolute_import
111 tests/test-parseindex2.py requires print_function
110 tests/test-parseindex2.py requires print_function
112 tests/test-pathencode.py not using absolute_import
111 tests/test-pathencode.py not using absolute_import
113 tests/test-pathencode.py requires print_function
112 tests/test-pathencode.py requires print_function
114 tests/test-propertycache.py not using absolute_import
113 tests/test-propertycache.py not using absolute_import
115 tests/test-propertycache.py requires print_function
114 tests/test-propertycache.py requires print_function
116 tests/test-revlog-ancestry.py not using absolute_import
115 tests/test-revlog-ancestry.py not using absolute_import
117 tests/test-revlog-ancestry.py requires print_function
116 tests/test-revlog-ancestry.py requires print_function
118 tests/test-run-tests.py not using absolute_import
117 tests/test-run-tests.py not using absolute_import
119 tests/test-simplemerge.py not using absolute_import
118 tests/test-simplemerge.py not using absolute_import
120 tests/test-status-inprocess.py not using absolute_import
119 tests/test-status-inprocess.py not using absolute_import
121 tests/test-status-inprocess.py requires print_function
120 tests/test-status-inprocess.py requires print_function
122 tests/test-symlink-os-yes-fs-no.py not using absolute_import
121 tests/test-symlink-os-yes-fs-no.py not using absolute_import
123 tests/test-trusted.py not using absolute_import
122 tests/test-trusted.py not using absolute_import
124 tests/test-trusted.py requires print_function
123 tests/test-trusted.py requires print_function
125 tests/test-ui-color.py not using absolute_import
124 tests/test-ui-color.py not using absolute_import
126 tests/test-ui-color.py requires print_function
125 tests/test-ui-color.py requires print_function
127 tests/test-ui-config.py not using absolute_import
126 tests/test-ui-config.py not using absolute_import
128 tests/test-ui-config.py requires print_function
127 tests/test-ui-config.py requires print_function
129 tests/test-ui-verbosity.py not using absolute_import
128 tests/test-ui-verbosity.py not using absolute_import
130 tests/test-ui-verbosity.py requires print_function
129 tests/test-ui-verbosity.py requires print_function
131 tests/test-url.py not using absolute_import
130 tests/test-url.py not using absolute_import
132 tests/test-url.py requires print_function
131 tests/test-url.py requires print_function
133 tests/test-walkrepo.py requires print_function
132 tests/test-walkrepo.py requires print_function
134 tests/test-wireproto.py requires print_function
133 tests/test-wireproto.py requires print_function
135 tests/tinyproxy.py requires print_function
134 tests/tinyproxy.py requires print_function
General Comments 0
You need to be logged in to leave comments. Login now