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