Mercurial > hgsubversion
annotate hgsubversion/svnwrap/svn_swig_wrapper.py @ 1524:c5de1adc3092
svnwrap: clean up whitespace in common
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Wed, 30 Aug 2017 23:57:42 -0400 |
parents | e31c288e5059 |
children | d717b4de5f1e |
rev | line source |
---|---|
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 import cStringIO |
531
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
511
diff
changeset
|
2 import errno |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 import os |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 import shutil |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 import sys |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 import tempfile |
238
e8b3ca865f93
Fix a boneheaded mistake I made when I touched up a previous patch.
Augie Fackler <durin42@gmail.com>
parents:
235
diff
changeset
|
7 import urllib |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
8 import collections |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
9 |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
10 import common |
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
11 |
324
c4061e57974c
svnwrap: Filter out deprecation warnings on 2.6.
Augie Fackler <durin42@gmail.com>
parents:
305
diff
changeset
|
12 import warnings |
c4061e57974c
svnwrap: Filter out deprecation warnings on 2.6.
Augie Fackler <durin42@gmail.com>
parents:
305
diff
changeset
|
13 warnings.filterwarnings('ignore', |
c4061e57974c
svnwrap: Filter out deprecation warnings on 2.6.
Augie Fackler <durin42@gmail.com>
parents:
305
diff
changeset
|
14 module='svn.core', |
c4061e57974c
svnwrap: Filter out deprecation warnings on 2.6.
Augie Fackler <durin42@gmail.com>
parents:
305
diff
changeset
|
15 category=DeprecationWarning) |
c4061e57974c
svnwrap: Filter out deprecation warnings on 2.6.
Augie Fackler <durin42@gmail.com>
parents:
305
diff
changeset
|
16 |
607
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
17 required_bindings = (1, 5, 0) |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
18 |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
19 try: |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
20 from svn import client |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
21 from svn import core |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
22 from svn import delta |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
23 from svn import ra |
1457
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1404
diff
changeset
|
24 from svn import repos |
607
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
25 |
1364
460332aafe7d
swig: change current_bindings to subversion_version
Augie Fackler <raf@durin42.com>
parents:
1054
diff
changeset
|
26 subversion_version = (core.SVN_VER_MAJOR, core.SVN_VER_MINOR, |
460332aafe7d
swig: change current_bindings to subversion_version
Augie Fackler <raf@durin42.com>
parents:
1054
diff
changeset
|
27 core.SVN_VER_MICRO) |
607
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
28 except ImportError: |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
29 raise ImportError('Subversion %d.%d.%d or later required, ' |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
30 'but no bindings were found' % required_bindings) |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
31 |
1364
460332aafe7d
swig: change current_bindings to subversion_version
Augie Fackler <raf@durin42.com>
parents:
1054
diff
changeset
|
32 if subversion_version < required_bindings: # pragma: no cover |
607
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
33 raise ImportError('Subversion %d.%d.%d or later required, ' |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
34 'but bindings for %d.%d.%d found' % |
1364
460332aafe7d
swig: change current_bindings to subversion_version
Augie Fackler <raf@durin42.com>
parents:
1054
diff
changeset
|
35 (required_bindings + subversion_version)) |
607
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
36 |
196
77812f98e250
Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents:
181
diff
changeset
|
37 def version(): |
1364
460332aafe7d
swig: change current_bindings to subversion_version
Augie Fackler <raf@durin42.com>
parents:
1054
diff
changeset
|
38 return '%d.%d.%d' % subversion_version, 'SWIG' |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 |
1457
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1404
diff
changeset
|
40 def create_and_load(repopath, dumpfd): |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1404
diff
changeset
|
41 ''' create a new repository at repopath and load the given dump into it ''' |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1404
diff
changeset
|
42 pool = core.Pool() |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1404
diff
changeset
|
43 r = repos.svn_repos_create(repopath, '', '', None, None, pool) |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1404
diff
changeset
|
44 |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1404
diff
changeset
|
45 try: |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1404
diff
changeset
|
46 repos.svn_repos_load_fs2(r, dumpfd, None, |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1404
diff
changeset
|
47 repos.svn_repos_load_uuid_force, |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1404
diff
changeset
|
48 '', False, False, None, pool) |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1404
diff
changeset
|
49 finally: |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1404
diff
changeset
|
50 dumpfd.close() |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1404
diff
changeset
|
51 |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1404
diff
changeset
|
52 pool.destroy() |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1404
diff
changeset
|
53 |
019c3e194fba
tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1404
diff
changeset
|
54 |
601
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
55 # exported values |
1036
e775ffbcb359
push: also suggest user rebase if we get SVN_ERR_FS_ALREADY_EXISTS
Augie Fackler <raf@durin42.com>
parents:
1023
diff
changeset
|
56 ERR_FS_ALREADY_EXISTS = core.SVN_ERR_FS_ALREADY_EXISTS |
601
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
57 ERR_FS_CONFLICT = core.SVN_ERR_FS_CONFLICT |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
58 ERR_FS_NOT_FOUND = core.SVN_ERR_FS_NOT_FOUND |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
59 ERR_FS_TXN_OUT_OF_DATE = core.SVN_ERR_FS_TXN_OUT_OF_DATE |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
60 ERR_INCOMPLETE_DATA = core.SVN_ERR_INCOMPLETE_DATA |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
61 ERR_RA_DAV_REQUEST_FAILED = core.SVN_ERR_RA_DAV_REQUEST_FAILED |
987
cf53cfaaa050
Fixes bug #358. Display correct error message if a svn pre-commit hook blocks the push
Anton Agafonov <equeny@fb.com>
parents:
971
diff
changeset
|
62 ERR_REPOS_HOOK_FAILURE = core.SVN_ERR_REPOS_HOOK_FAILURE |
964
27fec8bf9273
svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
931
diff
changeset
|
63 SSL_CNMISMATCH = core.SVN_AUTH_SSL_CNMISMATCH |
27fec8bf9273
svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
931
diff
changeset
|
64 SSL_EXPIRED = core.SVN_AUTH_SSL_EXPIRED |
1036
e775ffbcb359
push: also suggest user rebase if we get SVN_ERR_FS_ALREADY_EXISTS
Augie Fackler <raf@durin42.com>
parents:
1023
diff
changeset
|
65 SSL_NOTYETVALID = core.SVN_AUTH_SSL_NOTYETVALID |
964
27fec8bf9273
svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
931
diff
changeset
|
66 SSL_OTHER = core.SVN_AUTH_SSL_OTHER |
1036
e775ffbcb359
push: also suggest user rebase if we get SVN_ERR_FS_ALREADY_EXISTS
Augie Fackler <raf@durin42.com>
parents:
1023
diff
changeset
|
67 SSL_UNKNOWNCA = core.SVN_AUTH_SSL_UNKNOWNCA |
601
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
68 SubversionException = core.SubversionException |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
69 Editor = delta.Editor |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
70 |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
71 def apply_txdelta(base, target): |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
72 handler, baton = delta.svn_txdelta_apply(cStringIO.StringIO(base), |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
73 target, None) |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
74 return (lambda window: handler(window, baton)) |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
75 |
75
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
76 def optrev(revnum): |
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
77 optrev = core.svn_opt_revision_t() |
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
78 optrev.kind = core.svn_opt_revision_number |
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
79 optrev.value.number = revnum |
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
80 return optrev |
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
81 |
971
77b22e5b4ea6
svn_swig_wrapper: Ensure subversion config files
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
969
diff
changeset
|
82 core.svn_config_ensure(None) |
50
80b923ab242b
Drop any pretense of supporting svn 1.4.x.
Augie Fackler <durin42@gmail.com>
parents:
47
diff
changeset
|
83 svn_config = core.svn_config_get_config(None) |
45
ce00e6ffaa90
Change the implementation of the ra_session stuff. Thanks to Ben Collins-Sussman for pointing out the problem with the other method I was using.
Augie Fackler <durin42@gmail.com>
parents:
36
diff
changeset
|
84 class RaCallbacks(ra.Callbacks): |
298
32d3f1716e66
Two minor optimisations/cleanups for svn_swig_wrapper:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
293
diff
changeset
|
85 @staticmethod |
837
805ef27fbcbe
hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents:
832
diff
changeset
|
86 def open_tmp_file(pool): # pragma: no cover |
46
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
87 (fd, fn) = tempfile.mkstemp() |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
88 os.close(fd) |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
89 return fn |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
90 |
298
32d3f1716e66
Two minor optimisations/cleanups for svn_swig_wrapper:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
293
diff
changeset
|
91 @staticmethod |
32d3f1716e66
Two minor optimisations/cleanups for svn_swig_wrapper:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
293
diff
changeset
|
92 def get_client_string(pool): |
45
ce00e6ffaa90
Change the implementation of the ra_session stuff. Thanks to Ben Collins-Sussman for pointing out the problem with the other method I was using.
Augie Fackler <durin42@gmail.com>
parents:
36
diff
changeset
|
93 return 'hgsubversion' |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
94 |
673
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
95 def ieditor(fn): |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
96 """Helps identify methods used by the SVN editor interface. |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
97 |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
98 Stash any exception raised in the method on self. |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
99 |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
100 This is required because the SWIG bindings just mutate any exception into |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
101 a generic Subversion exception with no way of telling what the original was. |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
102 This allows the editor object to notice when you try and commit and really |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
103 got an exception in the replay process. |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
104 """ |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
105 def fun(self, *args, **kwargs): |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
106 try: |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
107 return fn(self, *args, **kwargs) |
837
805ef27fbcbe
hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents:
832
diff
changeset
|
108 except: # pragma: no cover |
673
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
109 if self.current.exception is not None: |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
110 self.current.exception = sys.exc_info() |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
111 raise |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
112 return fun |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
113 |
965
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
114 _prompt = None |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
115 def prompt_callback(callback): |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
116 global _prompt |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
117 _prompt = callback |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
118 |
966
7561aef55a4b
svnwrap: Improved handling of simple_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
965
diff
changeset
|
119 def _simple(realm, default_username, ms, pool): |
7561aef55a4b
svnwrap: Improved handling of simple_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
965
diff
changeset
|
120 ret = _prompt.simple(realm, default_username, ms, pool) |
7561aef55a4b
svnwrap: Improved handling of simple_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
965
diff
changeset
|
121 creds = core.svn_auth_cred_simple_t() |
7561aef55a4b
svnwrap: Improved handling of simple_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
965
diff
changeset
|
122 (creds.username, creds.password, creds.may_save) = ret |
7561aef55a4b
svnwrap: Improved handling of simple_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
965
diff
changeset
|
123 return creds |
7561aef55a4b
svnwrap: Improved handling of simple_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
965
diff
changeset
|
124 |
967
0b6a6a7c26f3
svnwrap: Improved handling of username_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
966
diff
changeset
|
125 def _username(realm, ms, pool): |
0b6a6a7c26f3
svnwrap: Improved handling of username_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
966
diff
changeset
|
126 ret = _prompt.username(realm, ms, pool) |
0b6a6a7c26f3
svnwrap: Improved handling of username_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
966
diff
changeset
|
127 creds = core.svn_auth_cred_username_t() |
0b6a6a7c26f3
svnwrap: Improved handling of username_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
966
diff
changeset
|
128 (creds.username, creds.may_save) = ret |
0b6a6a7c26f3
svnwrap: Improved handling of username_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
966
diff
changeset
|
129 return creds |
0b6a6a7c26f3
svnwrap: Improved handling of username_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
966
diff
changeset
|
130 |
968
c500bc862215
svnwrap: Implement handling of ssl_client_cert_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
967
diff
changeset
|
131 def _ssl_client_cert(realm, may_save, pool): |
c500bc862215
svnwrap: Implement handling of ssl_client_cert_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
967
diff
changeset
|
132 ret = _prompt.ssl_client_cert(realm, may_save, pool) |
c500bc862215
svnwrap: Implement handling of ssl_client_cert_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
967
diff
changeset
|
133 creds = core.svn_auth_cred_ssl_client_cert_t() |
c500bc862215
svnwrap: Implement handling of ssl_client_cert_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
967
diff
changeset
|
134 (creds.cert_file, creds.may_save) = ret |
c500bc862215
svnwrap: Implement handling of ssl_client_cert_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
967
diff
changeset
|
135 return creds |
c500bc862215
svnwrap: Implement handling of ssl_client_cert_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
967
diff
changeset
|
136 |
969
145611306f8a
svnwrap: Implement handling of ssl_client_cert_pw_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
968
diff
changeset
|
137 def _ssl_client_cert_pw(realm, may_save, pool): |
145611306f8a
svnwrap: Implement handling of ssl_client_cert_pw_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
968
diff
changeset
|
138 ret = _prompt.ssl_client_cert_pw(realm, may_save, pool) |
145611306f8a
svnwrap: Implement handling of ssl_client_cert_pw_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
968
diff
changeset
|
139 creds = core.svn_auth_cred_ssl_client_cert_pw_t() |
145611306f8a
svnwrap: Implement handling of ssl_client_cert_pw_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
968
diff
changeset
|
140 (creds.password, creds.may_save) = ret |
145611306f8a
svnwrap: Implement handling of ssl_client_cert_pw_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
968
diff
changeset
|
141 return creds |
145611306f8a
svnwrap: Implement handling of ssl_client_cert_pw_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
968
diff
changeset
|
142 |
965
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
143 def _ssl_server_trust(realm, failures, cert_info, may_save, pool): |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
144 cert = [ |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
145 cert_info.hostname, |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
146 cert_info.fingerprint, |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
147 cert_info.valid_from, |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
148 cert_info.valid_until, |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
149 cert_info.issuer_dname, |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
150 ] |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
151 ret = _prompt.ssl_server_trust(realm, failures, cert, may_save, pool) |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
152 if ret: |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
153 creds = core.svn_auth_cred_ssl_server_trust_t() |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
154 (creds.accepted_failures, creds.may_save) = ret |
964
27fec8bf9273
svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
931
diff
changeset
|
155 else: |
27fec8bf9273
svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
931
diff
changeset
|
156 creds = None |
27fec8bf9273
svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
931
diff
changeset
|
157 return creds |
27fec8bf9273
svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
931
diff
changeset
|
158 |
844
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
837
diff
changeset
|
159 def _create_auth_baton(pool, password_stores): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
160 """Create a Subversion authentication baton. """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
161 # Give the client context baton a suite of authentication |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
162 # providers.h |
92
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
163 platform_specific = ['svn_auth_get_gnome_keyring_simple_provider', |
272
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
164 'svn_auth_get_gnome_keyring_ssl_client_cert_pw_provider', |
92
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
165 'svn_auth_get_keychain_simple_provider', |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
166 'svn_auth_get_keychain_ssl_client_cert_pw_provider', |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
167 'svn_auth_get_kwallet_simple_provider', |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
168 'svn_auth_get_kwallet_ssl_client_cert_pw_provider', |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
169 'svn_auth_get_ssl_client_cert_file_provider', |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
170 'svn_auth_get_windows_simple_provider', |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
171 'svn_auth_get_windows_ssl_server_trust_provider', |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
172 ] |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
173 |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
174 providers = [] |
272
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
175 # Platform-dependant authentication methods |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
176 getprovider = getattr(core, 'svn_auth_get_platform_specific_provider', |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
177 None) |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
178 if getprovider: |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
179 # Available in svn >= 1.6 |
844
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
837
diff
changeset
|
180 if password_stores is None: |
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
837
diff
changeset
|
181 password_stores = ('gnome_keyring', 'keychain', 'kwallet', 'windows') |
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
837
diff
changeset
|
182 for name in password_stores: |
272
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
183 for type in ('simple', 'ssl_client_cert_pw', 'ssl_server_trust'): |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
184 p = getprovider(name, type, pool) |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
185 if p: |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
186 providers.append(p) |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
187 else: |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
188 for p in platform_specific: |
1404
c79fdd5f615d
cleanup: stop using hasattr
Augie Fackler <raf@durin42.com>
parents:
1367
diff
changeset
|
189 if getattr(core, p, None) is not None: |
272
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
190 try: |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
191 providers.append(getattr(core, p)()) |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
192 except RuntimeError: |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
193 pass |
92
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
194 |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
195 providers += [ |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
196 client.get_simple_provider(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
197 client.get_username_provider(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
198 client.get_ssl_client_cert_file_provider(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
199 client.get_ssl_client_cert_pw_file_provider(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
200 client.get_ssl_server_trust_file_provider(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
201 ] |
92
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
202 |
965
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
203 if _prompt: |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
204 providers += [ |
966
7561aef55a4b
svnwrap: Improved handling of simple_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
965
diff
changeset
|
205 client.get_simple_prompt_provider(_simple, 2), |
967
0b6a6a7c26f3
svnwrap: Improved handling of username_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
966
diff
changeset
|
206 client.get_username_prompt_provider(_username, 2), |
968
c500bc862215
svnwrap: Implement handling of ssl_client_cert_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
967
diff
changeset
|
207 client.get_ssl_client_cert_prompt_provider(_ssl_client_cert, 2), |
969
145611306f8a
svnwrap: Implement handling of ssl_client_cert_pw_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
968
diff
changeset
|
208 client.get_ssl_client_cert_pw_prompt_provider(_ssl_client_cert_pw, 2), |
965
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
209 client.get_ssl_server_trust_prompt_provider(_ssl_server_trust), |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
210 ] |
b748a0eed09a
svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
964
diff
changeset
|
211 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
212 return core.svn_auth_open(providers, pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
213 |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
214 _svntypes = { |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
215 core.svn_node_dir: 'd', |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
216 core.svn_node_file: 'f', |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
217 } |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
218 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
219 class SubversionRepo(object): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
220 """Wrapper for a Subversion repository. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
221 |
675
31cd9f41ec09
svnwrap: improve a docstring & a comment.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
674
diff
changeset
|
222 It uses the SWIG Python bindings, see above for requirements. |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
223 """ |
1330
2fb0f3c377c9
svn_swig_wrapper: add a member to store reference to meta object
Sean Farley <sean.michael.farley@gmail.com>
parents:
1054
diff
changeset
|
224 def __init__(self, url='', username='', password='', head=None, |
1354
b803ef977748
svn_swig_wrapper: remove meta attribute
Sean Farley <sean@farley.io>
parents:
1330
diff
changeset
|
225 password_stores=None): |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
226 parsed = common.parse_url(url, username, password) |
235
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
227 # --username and --password override URL credentials |
467
3941d73c262e
svnwrappers: override svn+ssh credentials with supplied ones if any
Patrick Mezard <pmezard@gmail.com>
parents:
392
diff
changeset
|
228 self.username = parsed[0] |
3941d73c262e
svnwrappers: override svn+ssh credentials with supplied ones if any
Patrick Mezard <pmezard@gmail.com>
parents:
392
diff
changeset
|
229 self.password = parsed[1] |
900
abd8f2f2c58a
svn_swig_wrapper: canonicalize path
Bryan O'Sullivan <bryano@fb.com>
parents:
844
diff
changeset
|
230 self.svn_url = core.svn_path_canonicalize(parsed[2]) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
231 self.auth_baton_pool = core.Pool() |
844
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
837
diff
changeset
|
232 self.auth_baton = _create_auth_baton(self.auth_baton_pool, password_stores) |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
233 # self.init_ra_and_client() assumes that a pool already exists |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
234 self.pool = core.Pool() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
235 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
236 self.init_ra_and_client() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
237 self.uuid = ra.get_uuid(self.ra, self.pool) |
717
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
238 self.svn_url = ra.get_session_url(self.ra, self.pool) |
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
239 self.root = ra.get_repos_root(self.ra, self.pool) |
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
240 assert self.svn_url.startswith(self.root) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
241 # *will* have a leading '/', would not if we used get_repos_root2 |
717
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
242 self.subdir = self.svn_url[len(self.root):] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
243 if not self.subdir or self.subdir[-1] != '/': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
244 self.subdir += '/' |
717
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
245 # the RA interface always yields quoted paths, but the editor interface |
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
246 # expects unquoted paths |
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
247 self.subdir = urllib.unquote(self.subdir) |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
248 self.hasdiff3 = True |
911
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
905
diff
changeset
|
249 self.autoprops_config = common.AutoPropsConfig() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
250 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
251 def init_ra_and_client(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
252 """Initializes the RA and client layers, because sometimes getting |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
253 unified diffs runs the remote server out of open files. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
254 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
255 # while we're in here we'll recreate our pool |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
256 self.pool = core.Pool() |
233
80a700398995
Fix SubversionRepo to actually use provided username
Daniel Tang <dytang@cs.purdue.edu>
parents:
228
diff
changeset
|
257 if self.username: |
80a700398995
Fix SubversionRepo to actually use provided username
Daniel Tang <dytang@cs.purdue.edu>
parents:
228
diff
changeset
|
258 core.svn_auth_set_parameter(self.auth_baton, |
80a700398995
Fix SubversionRepo to actually use provided username
Daniel Tang <dytang@cs.purdue.edu>
parents:
228
diff
changeset
|
259 core.SVN_AUTH_PARAM_DEFAULT_USERNAME, |
80a700398995
Fix SubversionRepo to actually use provided username
Daniel Tang <dytang@cs.purdue.edu>
parents:
228
diff
changeset
|
260 self.username) |
234
33e885f5f86a
Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents:
233
diff
changeset
|
261 if self.password: |
33e885f5f86a
Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents:
233
diff
changeset
|
262 core.svn_auth_set_parameter(self.auth_baton, |
33e885f5f86a
Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents:
233
diff
changeset
|
263 core.SVN_AUTH_PARAM_DEFAULT_PASSWORD, |
33e885f5f86a
Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents:
233
diff
changeset
|
264 self.password) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
265 self.client_context = client.create_context() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
266 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
267 self.client_context.auth_baton = self.auth_baton |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
268 self.client_context.config = svn_config |
45
ce00e6ffaa90
Change the implementation of the ra_session stuff. Thanks to Ben Collins-Sussman for pointing out the problem with the other method I was using.
Augie Fackler <durin42@gmail.com>
parents:
36
diff
changeset
|
269 callbacks = RaCallbacks() |
ce00e6ffaa90
Change the implementation of the ra_session stuff. Thanks to Ben Collins-Sussman for pointing out the problem with the other method I was using.
Augie Fackler <durin42@gmail.com>
parents:
36
diff
changeset
|
270 callbacks.auth_baton = self.auth_baton |
ce00e6ffaa90
Change the implementation of the ra_session stuff. Thanks to Ben Collins-Sussman for pointing out the problem with the other method I was using.
Augie Fackler <durin42@gmail.com>
parents:
36
diff
changeset
|
271 self.callbacks = callbacks |
293
fa26c7ef0180
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
196
diff
changeset
|
272 try: |
717
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
273 self.ra = ra.open2(self.svn_url, callbacks, |
667
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
274 svn_config, self.pool) |
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
275 except SubversionException, e: |
964
27fec8bf9273
svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
931
diff
changeset
|
276 # e.child contains a detailed error messages |
27fec8bf9273
svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
931
diff
changeset
|
277 msglist = [] |
27fec8bf9273
svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
931
diff
changeset
|
278 svn_exc = e |
27fec8bf9273
svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
931
diff
changeset
|
279 while svn_exc: |
27fec8bf9273
svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
931
diff
changeset
|
280 if svn_exc.args[0]: |
27fec8bf9273
svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
931
diff
changeset
|
281 msglist.append(svn_exc.args[0]) |
27fec8bf9273
svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
931
diff
changeset
|
282 svn_exc = svn_exc.child |
27fec8bf9273
svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents:
931
diff
changeset
|
283 msg = '\n'.join(msglist) |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
284 raise common.SubversionConnectionException(msg) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
285 |
674
a51e50d943b2
svnwrap: use decorator syntax for properties.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
673
diff
changeset
|
286 @property |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
287 def HEAD(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
288 return ra.get_latest_revnum(self.ra, self.pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
289 |
674
a51e50d943b2
svnwrap: use decorator syntax for properties.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
673
diff
changeset
|
290 @property |
301
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
291 def last_changed_rev(self): |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
292 try: |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
293 holder = [] |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
294 ra.get_log(self.ra, [''], |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
295 self.HEAD, 1, |
837
805ef27fbcbe
hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents:
832
diff
changeset
|
296 1, # limit of how many log messages to load |
301
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
297 True, # don't need to know changed paths |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
298 True, # stop on copies |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
299 lambda paths, revnum, author, date, message, pool: |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
300 holder.append(revnum), |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
301 self.pool) |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
302 |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
303 return holder[-1] |
667
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
304 except SubversionException, e: |
301
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
305 if e.apr_err not in [core.SVN_ERR_FS_NOT_FOUND]: |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
306 raise |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
307 else: |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
308 return self.HEAD |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
309 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
310 def list_dir(self, dir, revision=None): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
311 """List the contents of a server-side directory. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
312 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
313 Returns a dict-like object with one dict key per directory entry. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
314 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
315 Args: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
316 dir: the directory to list, no leading slash |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
317 rev: the revision at which to list the directory, defaults to HEAD |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
318 """ |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
491
diff
changeset
|
319 # TODO this should just not accept leading slashes like the docstring says |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
491
diff
changeset
|
320 if dir and dir[-1] == '/': |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
321 dir = dir[:-1] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
322 if revision is None: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
323 revision = self.HEAD |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
324 r = ra.get_dir2(self.ra, dir, revision, core.SVN_DIRENT_KIND, self.pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
325 folders, props, junk = r |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
326 return folders |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
327 |
666
192a3f65837a
svnwrap: remove dead code
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
664
diff
changeset
|
328 def revisions(self, paths=None, start=0, stop=0, |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
329 chunk_size=common.chunk_size): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
330 """Load the history of this repo. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
331 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
332 This is LAZY. It returns a generator, and fetches a small number |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
333 of revisions at a time. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
334 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
335 The reason this is lazy is so that you can use the same repo object |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
336 to perform RA calls to get deltas. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
337 """ |
361
cfdd4ec5230a
Merge fetch_history_at_paths() and revisions() in svn wrappers.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
342
diff
changeset
|
338 if paths is None: |
cfdd4ec5230a
Merge fetch_history_at_paths() and revisions() in svn wrappers.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
342
diff
changeset
|
339 paths = [''] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
340 if not stop: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
341 stop = self.HEAD |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
342 while stop > start: |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
343 def callback(paths, revnum, author, date, message, pool): |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
344 r = common.Revision(revnum, author, message, date, paths, |
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
345 strip_path=self.subdir) |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
346 revisions.append(r) |
675
31cd9f41ec09
svnwrap: improve a docstring & a comment.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
674
diff
changeset
|
347 # we only access revisions in a FIFO manner |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
348 revisions = collections.deque() |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
349 |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
350 try: |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
351 # TODO: using min(start + chunk_size, stop) may be preferable; |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
352 # ra.get_log(), even with chunk_size set, takes a while |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
353 # when converting the 65k+ rev. in LLVM. |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
354 ra.get_log(self.ra, |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
355 paths, |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
717
diff
changeset
|
356 start + 1, |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
357 stop, |
837
805ef27fbcbe
hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents:
832
diff
changeset
|
358 chunk_size, # limit of how many log messages to load |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
359 True, # don't need to know changed paths |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
360 True, # stop on copies |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
361 callback, |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
362 self.pool) |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
363 except core.SubversionException, e: |
590
5e9ab25e0112
handle nonexistant svn repositories, fixes issue 137
Jonathan Kotta <jpkotta@gmail.com>
parents:
572
diff
changeset
|
364 if e.apr_err == core.SVN_ERR_FS_NOT_FOUND: |
609
aafbf0d40dc2
svnwrap: use SubversionConnectionException instead of mercurial.util.Abort
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
607
diff
changeset
|
365 msg = ('%s not found at revision %d!' |
aafbf0d40dc2
svnwrap: use SubversionConnectionException instead of mercurial.util.Abort
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
607
diff
changeset
|
366 % (self.subdir.rstrip('/'), stop)) |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
367 raise common.SubversionConnectionException(msg) |
590
5e9ab25e0112
handle nonexistant svn repositories, fixes issue 137
Jonathan Kotta <jpkotta@gmail.com>
parents:
572
diff
changeset
|
368 elif e.apr_err == core.SVN_ERR_FS_NO_SUCH_REVISION: |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
369 raise common.SubversionConnectionException(e.message) |
590
5e9ab25e0112
handle nonexistant svn repositories, fixes issue 137
Jonathan Kotta <jpkotta@gmail.com>
parents:
572
diff
changeset
|
370 else: |
5e9ab25e0112
handle nonexistant svn repositories, fixes issue 137
Jonathan Kotta <jpkotta@gmail.com>
parents:
572
diff
changeset
|
371 raise |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
372 |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
373 while len(revisions) > 1: |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
374 yield revisions.popleft() |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
375 |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
376 if len(revisions) == 0: |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
377 # exit the loop; there is no history for the path. |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
378 break |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
379 else: |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
380 r = revisions.popleft() |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
381 start = r.revnum |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
382 yield r |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
383 self.init_ra_and_client() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
384 |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
81
diff
changeset
|
385 def commit(self, paths, message, file_data, base_revision, addeddirs, |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
81
diff
changeset
|
386 deleteddirs, properties, copies): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
387 """Commits the appropriate targets from revision in editor's store. |
1054
131cb06dca76
svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1036
diff
changeset
|
388 |
131cb06dca76
svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1036
diff
changeset
|
389 Return the committed revision as a common.Revision instance. |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
390 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
391 self.init_ra_and_client() |
1054
131cb06dca76
svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1036
diff
changeset
|
392 |
131cb06dca76
svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1036
diff
changeset
|
393 def commit_cb(commit_info, pool): |
131cb06dca76
svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1036
diff
changeset
|
394 # disregard commit_info.post_commit_err for now |
131cb06dca76
svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1036
diff
changeset
|
395 r = common.Revision(commit_info.revision, commit_info.author, |
131cb06dca76
svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1036
diff
changeset
|
396 message, commit_info.date) |
131cb06dca76
svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1036
diff
changeset
|
397 |
131cb06dca76
svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1036
diff
changeset
|
398 committedrev.append(r) |
131cb06dca76
svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1036
diff
changeset
|
399 |
131cb06dca76
svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1036
diff
changeset
|
400 committedrev = [] |
131cb06dca76
svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1036
diff
changeset
|
401 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
402 editor, edit_baton = ra.get_commit_editor2(self.ra, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
403 message, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
404 commit_cb, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
405 None, |
20
2953c867ca99
Minor fixes to the push command to make it more robust.
Augie Fackler <durin42@gmail.com>
parents:
10
diff
changeset
|
406 False, |
2953c867ca99
Minor fixes to the push command to make it more robust.
Augie Fackler <durin42@gmail.com>
parents:
10
diff
changeset
|
407 self.pool) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
408 checksum = [] |
46
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
409 # internal dir batons can fall out of scope and get GCed before svn is |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
410 # done with them. This prevents that (credit to gvn for the idea). |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
411 batons = [edit_baton, ] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
412 def driver_cb(parent, path, pool): |
46
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
413 if not parent: |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
414 bat = editor.open_root(edit_baton, base_revision, self.pool) |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
415 batons.append(bat) |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
416 return bat |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
81
diff
changeset
|
417 if path in deleteddirs: |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
81
diff
changeset
|
418 bat = editor.delete_entry(path, base_revision, parent, pool) |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
81
diff
changeset
|
419 batons.append(bat) |
1460
e31c288e5059
svnwrap: allow overwriting directories in one revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1459
diff
changeset
|
420 |
e31c288e5059
svnwrap: allow overwriting directories in one revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1459
diff
changeset
|
421 if path not in addeddirs: |
e31c288e5059
svnwrap: allow overwriting directories in one revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1459
diff
changeset
|
422 return bat |
e31c288e5059
svnwrap: allow overwriting directories in one revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1459
diff
changeset
|
423 |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
424 if path not in file_data: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
425 if path in addeddirs: |
1459
b95fa72c74ae
svnwrap: allow committing directory copies
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1457
diff
changeset
|
426 frompath, fromrev = copies.get(path, (None, -1)) |
b95fa72c74ae
svnwrap: allow committing directory copies
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1457
diff
changeset
|
427 if frompath: |
b95fa72c74ae
svnwrap: allow committing directory copies
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1457
diff
changeset
|
428 frompath = self.path2url(frompath) |
b95fa72c74ae
svnwrap: allow committing directory copies
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1457
diff
changeset
|
429 bat = editor.add_directory(path, parent, frompath, fromrev, pool) |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
430 else: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
431 bat = editor.open_directory(path, parent, base_revision, pool) |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
432 batons.append(bat) |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
433 props = properties.get(path, {}) |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
434 if 'svn:externals' in props: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
435 value = props['svn:externals'] |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
436 editor.change_dir_prop(bat, 'svn:externals', value, pool) |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
437 return bat |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
438 base_text, new_text, action = file_data[path] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
439 compute_delta = True |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
440 if action == 'modify': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
441 baton = editor.open_file(path, parent, base_revision, pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
442 elif action == 'add': |
266 | 443 frompath, fromrev = copies.get(path, (None, -1)) |
444 if frompath: | |
544
809c673bdd30
svnwrap: escape copy sources paths in commit handler
Patrick Mezard <pmezard@gmail.com>
parents:
543
diff
changeset
|
445 frompath = self.path2url(frompath) |
266 | 446 baton = editor.add_file(path, parent, frompath, fromrev, pool) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
447 elif action == 'delete': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
448 baton = editor.delete_entry(path, base_revision, parent, pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
449 compute_delta = False |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
450 |
10
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
451 if path in properties: |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
452 if properties[path].get('svn:special', None): |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
453 new_text = 'link %s' % new_text |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
454 for p, v in properties[path].iteritems(): |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
455 editor.change_file_prop(baton, p, v) |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
456 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
457 if compute_delta: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
458 handler, wh_baton = editor.apply_textdelta(baton, None, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
459 self.pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
460 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
461 txdelta_stream = delta.svn_txdelta( |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
462 cStringIO.StringIO(base_text), cStringIO.StringIO(new_text), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
463 self.pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
464 delta.svn_txdelta_send_txstream(txdelta_stream, handler, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
465 wh_baton, pool) |
47
9738a7c4e3dd
fix svn push when there's just a file removal
Valentino Volonghi aka dialtone <valentino@adroll.com>
parents:
46
diff
changeset
|
466 |
9738a7c4e3dd
fix svn push when there's just a file removal
Valentino Volonghi aka dialtone <valentino@adroll.com>
parents:
46
diff
changeset
|
467 # TODO pass md5(new_text) instead of None |
9738a7c4e3dd
fix svn push when there's just a file removal
Valentino Volonghi aka dialtone <valentino@adroll.com>
parents:
46
diff
changeset
|
468 editor.close_file(baton, None, pool) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
469 |
905
04ded06ea517
swig bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents:
904
diff
changeset
|
470 try: |
04ded06ea517
swig bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents:
904
diff
changeset
|
471 delta.path_driver(editor, edit_baton, base_revision, paths, driver_cb, |
04ded06ea517
swig bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents:
904
diff
changeset
|
472 self.pool) |
04ded06ea517
swig bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents:
904
diff
changeset
|
473 except: |
04ded06ea517
swig bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents:
904
diff
changeset
|
474 # If anything went wrong on the preceding lines, we should |
04ded06ea517
swig bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents:
904
diff
changeset
|
475 # abort the in-progress transaction. |
04ded06ea517
swig bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents:
904
diff
changeset
|
476 editor.abort_edit(edit_baton, self.pool) |
04ded06ea517
swig bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents:
904
diff
changeset
|
477 raise |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
478 |
1011
cc774e975aed
commit: fix exception handling on transaction close
Matt Mackall <mpm@selenic.com>
parents:
987
diff
changeset
|
479 editor.close_edit(edit_baton, self.pool) |
cc774e975aed
commit: fix exception handling on transaction close
Matt Mackall <mpm@selenic.com>
parents:
987
diff
changeset
|
480 |
1054
131cb06dca76
svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1036
diff
changeset
|
481 return committedrev.pop() |
131cb06dca76
svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1036
diff
changeset
|
482 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
483 def get_replay(self, revision, editor, oldest_rev_i_have=0): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
484 # this method has a tendency to chew through RAM if you don't re-init |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
485 self.init_ra_and_client() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
486 e_ptr, e_baton = delta.make_editor(editor) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
487 try: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
488 ra.replay(self.ra, revision, oldest_rev_i_have, True, e_ptr, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
489 e_baton, self.pool) |
837
805ef27fbcbe
hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents:
832
diff
changeset
|
490 except SubversionException, e: # pragma: no cover |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
491 # can I depend on this number being constant? |
224
2165461d2dd8
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
196
diff
changeset
|
492 if (e.apr_err == core.SVN_ERR_RA_NOT_IMPLEMENTED or |
2165461d2dd8
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
196
diff
changeset
|
493 e.apr_err == core.SVN_ERR_UNSUPPORTED_FEATURE): |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
494 msg = ('This Subversion server is older than 1.4.0, and ' |
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
495 'cannot satisfy replay requests.') |
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
496 raise common.SubversionRepoCanNotReplay(msg) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
497 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
498 raise |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
499 |
901
bd12a4da0f35
replay: workaround svn not telling us about x/l flags (issue346)
Bryan O'Sullivan <bryano@fb.com>
parents:
900
diff
changeset
|
500 # if we're not pulling the whole repo, svn fails to report |
bd12a4da0f35
replay: workaround svn not telling us about x/l flags (issue346)
Bryan O'Sullivan <bryano@fb.com>
parents:
900
diff
changeset
|
501 # file properties for files merged from subtrees outside ours |
bd12a4da0f35
replay: workaround svn not telling us about x/l flags (issue346)
Bryan O'Sullivan <bryano@fb.com>
parents:
900
diff
changeset
|
502 if self.svn_url != self.root: |
bd12a4da0f35
replay: workaround svn not telling us about x/l flags (issue346)
Bryan O'Sullivan <bryano@fb.com>
parents:
900
diff
changeset
|
503 links, execs = editor.current.symlinks, editor.current.execfiles |
bd12a4da0f35
replay: workaround svn not telling us about x/l flags (issue346)
Bryan O'Sullivan <bryano@fb.com>
parents:
900
diff
changeset
|
504 l = len(self.subdir) - 1 |
bd12a4da0f35
replay: workaround svn not telling us about x/l flags (issue346)
Bryan O'Sullivan <bryano@fb.com>
parents:
900
diff
changeset
|
505 for f in editor.current.added: |
bd12a4da0f35
replay: workaround svn not telling us about x/l flags (issue346)
Bryan O'Sullivan <bryano@fb.com>
parents:
900
diff
changeset
|
506 sf = f[l:] |
bd12a4da0f35
replay: workaround svn not telling us about x/l flags (issue346)
Bryan O'Sullivan <bryano@fb.com>
parents:
900
diff
changeset
|
507 if links[f] or execs[f]: |
bd12a4da0f35
replay: workaround svn not telling us about x/l flags (issue346)
Bryan O'Sullivan <bryano@fb.com>
parents:
900
diff
changeset
|
508 continue |
1023
7a262ecae4f3
svnwrap: use get_file instead of list_props during replay
David Schleimer <dschleimer@fb.com>
parents:
1011
diff
changeset
|
509 # The list_props API creates a new connection and then |
7a262ecae4f3
svnwrap: use get_file instead of list_props during replay
David Schleimer <dschleimer@fb.com>
parents:
1011
diff
changeset
|
510 # calls get_file for the remote file case. It also |
7a262ecae4f3
svnwrap: use get_file instead of list_props during replay
David Schleimer <dschleimer@fb.com>
parents:
1011
diff
changeset
|
511 # creates a new connection to the subversion server |
7a262ecae4f3
svnwrap: use get_file instead of list_props during replay
David Schleimer <dschleimer@fb.com>
parents:
1011
diff
changeset
|
512 # every time it's called. As a result, it's actually |
7a262ecae4f3
svnwrap: use get_file instead of list_props during replay
David Schleimer <dschleimer@fb.com>
parents:
1011
diff
changeset
|
513 # *cheaper* to call get_file than list_props here |
7a262ecae4f3
svnwrap: use get_file instead of list_props during replay
David Schleimer <dschleimer@fb.com>
parents:
1011
diff
changeset
|
514 data, mode = self.get_file(sf, revision) |
7a262ecae4f3
svnwrap: use get_file instead of list_props during replay
David Schleimer <dschleimer@fb.com>
parents:
1011
diff
changeset
|
515 links[f] = mode == 'l' |
7a262ecae4f3
svnwrap: use get_file instead of list_props during replay
David Schleimer <dschleimer@fb.com>
parents:
1011
diff
changeset
|
516 execs[f] = mode == 'x' |
901
bd12a4da0f35
replay: workaround svn not telling us about x/l flags (issue346)
Bryan O'Sullivan <bryano@fb.com>
parents:
900
diff
changeset
|
517 |
649
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
518 def get_revision(self, revision, editor): |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
519 ''' feed the contents of the given revision to the given editor ''' |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
520 |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
521 e_ptr, e_baton = delta.make_editor(editor) |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
522 |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
523 reporter, reporter_baton = ra.do_update(self.ra, revision, "", True, |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
524 e_ptr, e_baton) |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
525 |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
526 reporter.set_path(reporter_baton, "", revision, True, None) |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
527 reporter.finish_report(reporter_baton) |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
528 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
529 def get_unified_diff(self, path, revision, other_path=None, other_rev=None, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
530 deleted=True, ignore_type=False): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
531 """Gets a unidiff of path at revision against revision-1. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
532 """ |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
533 if not self.hasdiff3: |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
534 raise common.SubversionRepoCanNotDiff() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
535 # works around an svn server keeping too many open files (observed |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
536 # in an svnserve from the 1.2 era) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
537 self.init_ra_and_client() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
538 |
491
b71507d7becc
svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents:
489
diff
changeset
|
539 url = self.path2url(path) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
540 url2 = url |
491
b71507d7becc
svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents:
489
diff
changeset
|
541 url2 = (other_path and self.path2url(other_path) or url) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
542 if other_rev is None: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
543 other_rev = revision - 1 |
81
85dcea81f22b
SubversionRepo: close files before rmtree() in diff3
Patrick Mezard <pmezard@gmail.com>
parents:
77
diff
changeset
|
544 old_cwd = os.getcwd() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
545 tmpdir = tempfile.mkdtemp('svnwrap_temp') |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
546 out, err = None, None |
66
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
547 try: |
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
548 # hot tip: the swig bridge doesn't like StringIO for these bad boys |
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
549 out_path = os.path.join(tmpdir, 'diffout') |
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
550 error_path = os.path.join(tmpdir, 'differr') |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
551 out = open(out_path, 'w') |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
552 err = open(error_path, 'w') |
81
85dcea81f22b
SubversionRepo: close files before rmtree() in diff3
Patrick Mezard <pmezard@gmail.com>
parents:
77
diff
changeset
|
553 try: |
85dcea81f22b
SubversionRepo: close files before rmtree() in diff3
Patrick Mezard <pmezard@gmail.com>
parents:
77
diff
changeset
|
554 client.diff3([], url2, optrev(other_rev), url, optrev(revision), |
85dcea81f22b
SubversionRepo: close files before rmtree() in diff3
Patrick Mezard <pmezard@gmail.com>
parents:
77
diff
changeset
|
555 True, True, deleted, ignore_type, 'UTF-8', out, err, |
85dcea81f22b
SubversionRepo: close files before rmtree() in diff3
Patrick Mezard <pmezard@gmail.com>
parents:
77
diff
changeset
|
556 self.client_context, self.pool) |
667
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
557 except SubversionException, e: |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
558 # "Can't write to stream: The handle is invalid." |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
559 # This error happens systematically under Windows, possibly |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
560 # related to file handles being non-write shareable by default. |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
561 if e.apr_err != 720006: |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
562 raise |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
563 self.hasdiff3 = False |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
564 raise common.SubversionRepoCanNotDiff() |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
565 out.close() |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
566 err.close() |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
567 out, err = None, None |
66
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
568 assert len(open(error_path).read()) == 0 |
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
569 diff = open(out_path).read() |
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
570 return diff |
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
571 finally: |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
572 if out: out.close() |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
573 if err: err.close() |
66
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
574 shutil.rmtree(tmpdir) |
81
85dcea81f22b
SubversionRepo: close files before rmtree() in diff3
Patrick Mezard <pmezard@gmail.com>
parents:
77
diff
changeset
|
575 os.chdir(old_cwd) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
576 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
577 def get_file(self, path, revision): |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
578 """Return content and mode of file at given path and revision. |
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
579 |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
580 "link " prefix is dropped from symlink content. Mode is 'x' if |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
581 file is executable, 'l' if a symlink, the empty string |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
582 otherwise. If the file does not exist at this revision, raise |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
583 IOError. |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
584 """ |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
491
diff
changeset
|
585 assert not path.startswith('/') |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
586 mode = '' |
66
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
587 try: |
931
e1dbd9646d6a
svnwrap: use custom StringIO class in get_file()
Patrick Mezard <patrick@mezard.eu>
parents:
911
diff
changeset
|
588 out = common.SimpleStringIO() |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
589 info = ra.get_file(self.ra, path, revision, out) |
122
04c92c2c4501
SubversionRepo: work around ra.get_files() not releasing input buffer
Patrick Mezard <pmezard@gmail.com>
parents:
97
diff
changeset
|
590 data = out.getvalue() |
04c92c2c4501
SubversionRepo: work around ra.get_files() not releasing input buffer
Patrick Mezard <pmezard@gmail.com>
parents:
97
diff
changeset
|
591 out.close() |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
592 if isinstance(info, list): |
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
593 info = info[-1] |
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
594 mode = ("svn:executable" in info) and 'x' or '' |
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
595 mode = ("svn:special" in info) and 'l' or mode |
667
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
596 except SubversionException, e: |
74
450d5d9d3b80
SubversionRepo: do not use temporary file in get_file()
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
597 notfound = (core.SVN_ERR_FS_NOT_FOUND, |
450d5d9d3b80
SubversionRepo: do not use temporary file in get_file()
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
598 core.SVN_ERR_RA_DAV_PATH_NOT_FOUND) |
531
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
511
diff
changeset
|
599 if e.args[1] in notfound: # File not found |
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
511
diff
changeset
|
600 raise IOError(errno.ENOENT, e.args[0]) |
74
450d5d9d3b80
SubversionRepo: do not use temporary file in get_file()
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
601 raise |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
717
diff
changeset
|
602 if mode == 'l': |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
603 linkprefix = "link " |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
604 if data.startswith(linkprefix): |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
605 data = data[len(linkprefix):] |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
606 return data, mode |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
607 |
172
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
608 def list_props(self, path, revision): |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
609 """Return a mapping of property names to values, raise IOError if |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
610 specified path does not exist. |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
611 """ |
180
3f1e8a5ec9dd
svn_swig_wrapper: hacky workaround to prevent running out of files in stupid
Augie Fackler <durin42@gmail.com>
parents:
175
diff
changeset
|
612 self.init_ra_and_client() |
75
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
613 rev = optrev(revision) |
489
cd793ca555af
svnwrap: properly escape URLs before giving them to libsvn_*
Chema Cortes <pych3m4@gmail.com>
parents:
467
diff
changeset
|
614 rpath = self.path2url(path) |
172
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
615 try: |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
616 pl = client.proplist2(rpath, rev, rev, False, |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
617 self.client_context, self.pool) |
667
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
618 except SubversionException, e: |
172
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
619 # Specified path does not exist at this revision |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
620 if e.apr_err == core.SVN_ERR_NODE_UNKNOWN_KIND: |
531
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
511
diff
changeset
|
621 raise IOError(errno.ENOENT, e.args[0]) |
172
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
622 raise |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
623 if not pl: |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
624 return {} |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
625 return pl[0][1] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
626 |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
627 def list_files(self, dirpath, revision): |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
628 """List the content of a directory at a given revision, recursively. |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
629 |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
630 Yield tuples (path, kind) where 'path' is the entry path relatively to |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
631 'dirpath' and 'kind' is 'f' if the entry is a file, 'd' if it is a |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
632 directory. Raise IOError if the directory cannot be found at given |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
633 revision. |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
634 """ |
489
cd793ca555af
svnwrap: properly escape URLs before giving them to libsvn_*
Chema Cortes <pych3m4@gmail.com>
parents:
467
diff
changeset
|
635 rpath = self.path2url(dirpath) |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
636 pool = core.Pool() |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
637 rev = optrev(revision) |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
638 try: |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
639 entries = client.ls(rpath, rev, True, self.client_context, pool) |
667
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
640 except SubversionException, e: |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
641 if e.apr_err == core.SVN_ERR_FS_NOT_FOUND: |
531
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
511
diff
changeset
|
642 raise IOError(errno.ENOENT, |
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
511
diff
changeset
|
643 '%s cannot be found at r%d' % (dirpath, revision)) |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
644 raise |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
645 for path, e in entries.iteritems(): |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
646 kind = _svntypes.get(e.kind) |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
647 yield path, kind |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
648 |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
649 def checkpath(self, path, revision): |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
650 """Return the entry type at the given revision, 'f', 'd' or None |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
651 if the entry does not exist. |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
652 """ |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
653 kind = ra.check_path(self.ra, path.strip('/'), revision) |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
654 return _svntypes.get(kind) |
489
cd793ca555af
svnwrap: properly escape URLs before giving them to libsvn_*
Chema Cortes <pych3m4@gmail.com>
parents:
467
diff
changeset
|
655 |
491
b71507d7becc
svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents:
489
diff
changeset
|
656 def path2url(self, path): |
b71507d7becc
svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents:
489
diff
changeset
|
657 """Build svn URL for path, URL-escaping path. |
489
cd793ca555af
svnwrap: properly escape URLs before giving them to libsvn_*
Chema Cortes <pych3m4@gmail.com>
parents:
467
diff
changeset
|
658 """ |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
491
diff
changeset
|
659 if not path or path == '.': |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
491
diff
changeset
|
660 return self.svn_url |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
491
diff
changeset
|
661 assert path[0] != '/', path |
904
b6b1365e3489
canonicalize svn paths even more awesomely
Bryan O'Sullivan <bryano@fb.com>
parents:
901
diff
changeset
|
662 path = path.rstrip('/') |
b6b1365e3489
canonicalize svn paths even more awesomely
Bryan O'Sullivan <bryano@fb.com>
parents:
901
diff
changeset
|
663 try: |
b6b1365e3489
canonicalize svn paths even more awesomely
Bryan O'Sullivan <bryano@fb.com>
parents:
901
diff
changeset
|
664 # new in svn 1.7 |
b6b1365e3489
canonicalize svn paths even more awesomely
Bryan O'Sullivan <bryano@fb.com>
parents:
901
diff
changeset
|
665 return core.svn_uri_canonicalize(self.svn_url + '/' + path) |
b6b1365e3489
canonicalize svn paths even more awesomely
Bryan O'Sullivan <bryano@fb.com>
parents:
901
diff
changeset
|
666 except AttributeError: |
b6b1365e3489
canonicalize svn paths even more awesomely
Bryan O'Sullivan <bryano@fb.com>
parents:
901
diff
changeset
|
667 return self.svn_url + '/' + urllib.quote(path) |