annotate hgsubversion/svnwrap/subvertpy_wrapper.py @ 1561:b303c9414190 1.9.1

subvertpy: same tweak to fsfs configuration as in swig
author Augie Fackler <raf@durin42.com>
date Sat, 24 Mar 2018 18:23:08 -0400
parents dee572a4e30b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
1561
b303c9414190 subvertpy: same tweak to fsfs configuration as in swig
Augie Fackler <raf@durin42.com>
parents: 1529
diff changeset
7 import textwrap
238
e8b3ca865f93 Fix a boneheaded mistake I made when I touched up a previous patch.
Augie Fackler <durin42@gmail.com>
parents: 235
diff changeset
8 import urllib
300
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
9 import collections
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10
672
2cc1342d4476 svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 668
diff changeset
11 import common
2cc1342d4476 svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 668
diff changeset
12
324
c4061e57974c svnwrap: Filter out deprecation warnings on 2.6.
Augie Fackler <durin42@gmail.com>
parents: 305
diff changeset
13 import warnings
c4061e57974c svnwrap: Filter out deprecation warnings on 2.6.
Augie Fackler <durin42@gmail.com>
parents: 305
diff changeset
14 warnings.filterwarnings('ignore',
c4061e57974c svnwrap: Filter out deprecation warnings on 2.6.
Augie Fackler <durin42@gmail.com>
parents: 305
diff changeset
15 module='svn.core',
c4061e57974c svnwrap: Filter out deprecation warnings on 2.6.
Augie Fackler <durin42@gmail.com>
parents: 305
diff changeset
16 category=DeprecationWarning)
c4061e57974c svnwrap: Filter out deprecation warnings on 2.6.
Augie Fackler <durin42@gmail.com>
parents: 305
diff changeset
17
708
f28c6d5d73fd subvertpy wrapper: bump version requirement to 0.7.4.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 695
diff changeset
18 subvertpy_required = (0, 7, 4)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
19 subversion_required = (1, 5, 0)
607
b5f1b629c629 svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 601
diff changeset
20
b5f1b629c629 svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 601
diff changeset
21 try:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
22 from subvertpy import client
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
23 from subvertpy import delta
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
24 from subvertpy import properties
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
25 from subvertpy import ra
1457
019c3e194fba tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1353
diff changeset
26 from subvertpy import repos
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
27 import subvertpy
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:
695
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
29 raise ImportError('Subvertpy %d.%d.%d or later required, but not found'
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
30 % subvertpy_required)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
31
695
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
32 def _versionstr(v):
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
33 return '.'.join(str(d) for d in v)
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
34
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 832
diff changeset
35 if subvertpy.__version__ < subvertpy_required: # pragma: no cover
695
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
36 raise ImportError('Subvertpy %s or later required, '
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
37 'but %s found'
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
38 % (_versionstr(subvertpy_required),
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
39 _versionstr(subvertpy.__version__)))
607
b5f1b629c629 svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 601
diff changeset
40
718
db0eb6237420 wrapper: fail properly with unsupported versions of Subvertpy (fixes #212)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 717
diff changeset
41 subversion_version = subvertpy.wc.api_version()
db0eb6237420 wrapper: fail properly with unsupported versions of Subvertpy (fixes #212)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 717
diff changeset
42
709
2c278d71b73d subvertpy wrapper: check against Subversion version compiled against.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 708
diff changeset
43 if subversion_version[:3] < subversion_required:
695
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
44 raise ImportError('Subversion %s or later required, '
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
45 'but Subvertpy is using %s'
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
46 % (_versionstr(subversion_required),
709
2c278d71b73d subvertpy wrapper: check against Subversion version compiled against.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 708
diff changeset
47 _versionstr(subversion_version[:3])))
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
48
607
b5f1b629c629 svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 601
diff changeset
49
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
50 def version():
709
2c278d71b73d subvertpy wrapper: check against Subversion version compiled against.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 708
diff changeset
51 svnvers = _versionstr(subversion_version[:3])
2c278d71b73d subvertpy wrapper: check against Subversion version compiled against.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 708
diff changeset
52 if subversion_version[3]:
2c278d71b73d subvertpy wrapper: check against Subversion version compiled against.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 708
diff changeset
53 svnvers += '-' + subversion_version[3]
695
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
54 return (svnvers, 'Subvertpy ' + _versionstr(subvertpy.__version__))
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
55
1457
019c3e194fba tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1353
diff changeset
56 def create_and_load(repopath, dumpfd):
019c3e194fba tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1353
diff changeset
57 ''' 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: 1353
diff changeset
58 repo = repos.create(repopath)
019c3e194fba tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1353
diff changeset
59
1561
b303c9414190 subvertpy: same tweak to fsfs configuration as in swig
Augie Fackler <raf@durin42.com>
parents: 1529
diff changeset
60 with open(os.path.join(repopath, 'db', 'fsfs.conf'), 'w') as f:
b303c9414190 subvertpy: same tweak to fsfs configuration as in swig
Augie Fackler <raf@durin42.com>
parents: 1529
diff changeset
61 f.write(textwrap.dedent("""\
b303c9414190 subvertpy: same tweak to fsfs configuration as in swig
Augie Fackler <raf@durin42.com>
parents: 1529
diff changeset
62 # config settings for svn repos to try and speed up the testsuite
b303c9414190 subvertpy: same tweak to fsfs configuration as in swig
Augie Fackler <raf@durin42.com>
parents: 1529
diff changeset
63 [rep-sharing]
b303c9414190 subvertpy: same tweak to fsfs configuration as in swig
Augie Fackler <raf@durin42.com>
parents: 1529
diff changeset
64 enable-rep-sharing = false
b303c9414190 subvertpy: same tweak to fsfs configuration as in swig
Augie Fackler <raf@durin42.com>
parents: 1529
diff changeset
65 [deltification]
b303c9414190 subvertpy: same tweak to fsfs configuration as in swig
Augie Fackler <raf@durin42.com>
parents: 1529
diff changeset
66 enable-dir-deltification = false
b303c9414190 subvertpy: same tweak to fsfs configuration as in swig
Augie Fackler <raf@durin42.com>
parents: 1529
diff changeset
67 enable-props-deltification = false
b303c9414190 subvertpy: same tweak to fsfs configuration as in swig
Augie Fackler <raf@durin42.com>
parents: 1529
diff changeset
68 [compression]
b303c9414190 subvertpy: same tweak to fsfs configuration as in swig
Augie Fackler <raf@durin42.com>
parents: 1529
diff changeset
69 compression-level=1
b303c9414190 subvertpy: same tweak to fsfs configuration as in swig
Augie Fackler <raf@durin42.com>
parents: 1529
diff changeset
70 """))
b303c9414190 subvertpy: same tweak to fsfs configuration as in swig
Augie Fackler <raf@durin42.com>
parents: 1529
diff changeset
71
1457
019c3e194fba tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1353
diff changeset
72 nullfd = open(os.devnull, 'w')
019c3e194fba tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1353
diff changeset
73
019c3e194fba tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1353
diff changeset
74 try:
019c3e194fba tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1353
diff changeset
75 repo.load_fs(dumpfd, nullfd, repos.LOAD_UUID_FORCE)
019c3e194fba tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1353
diff changeset
76 finally:
019c3e194fba tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1353
diff changeset
77 dumpfd.close()
019c3e194fba tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1353
diff changeset
78 nullfd.close()
019c3e194fba tests: optimise creating repositories and loading dumps
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1353
diff changeset
79
601
0fe490ce2fbb isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 590
diff changeset
80 # exported values
1036
e775ffbcb359 push: also suggest user rebase if we get SVN_ERR_FS_ALREADY_EXISTS
Augie Fackler <raf@durin42.com>
parents: 1011
diff changeset
81 ERR_FS_ALREADY_EXISTS = subvertpy.ERR_FS_ALREADY_EXISTS
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
82 ERR_FS_CONFLICT = subvertpy.ERR_FS_CONFLICT
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
83 ERR_FS_NOT_FOUND = subvertpy.ERR_FS_NOT_FOUND
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
84 ERR_FS_TXN_OUT_OF_DATE = subvertpy.ERR_FS_TXN_OUT_OF_DATE
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
85 ERR_INCOMPLETE_DATA = subvertpy.ERR_INCOMPLETE_DATA
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
86 ERR_RA_DAV_PATH_NOT_FOUND = subvertpy.ERR_RA_DAV_PATH_NOT_FOUND
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
87 ERR_RA_DAV_REQUEST_FAILED = subvertpy.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: 986
diff changeset
88 ERR_REPOS_HOOK_FAILURE = subvertpy.ERR_REPOS_HOOK_FAILURE
964
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
89 SSL_CNMISMATCH = subvertpy.SSL_CNMISMATCH
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
90 SSL_EXPIRED = subvertpy.SSL_EXPIRED
1036
e775ffbcb359 push: also suggest user rebase if we get SVN_ERR_FS_ALREADY_EXISTS
Augie Fackler <raf@durin42.com>
parents: 1011
diff changeset
91 SSL_NOTYETVALID = subvertpy.SSL_NOTYETVALID
964
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
92 SSL_OTHER = subvertpy.SSL_OTHER
1036
e775ffbcb359 push: also suggest user rebase if we get SVN_ERR_FS_ALREADY_EXISTS
Augie Fackler <raf@durin42.com>
parents: 1011
diff changeset
93 SSL_UNKNOWNCA = subvertpy.SSL_UNKNOWNCA
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
94 SubversionException = subvertpy.SubversionException
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
95 apply_txdelta = delta.apply_txdelta_handler
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
96 # superclass for editor.HgEditor
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
97 Editor = object
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
98
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 672
diff changeset
99 def ieditor(fn):
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
100 """No-op decorator to identify methods used by the SVN editor interface.
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 672
diff changeset
101
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
102 This decorator is not needed for Subvertpy, but is retained for
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
103 compatibility with the SWIG bindings.
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 672
diff changeset
104 """
92
7486c6f6cccc svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents: 89
diff changeset
105
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
106 return fn
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
107
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
108 _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
109 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
110 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
111 _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
112
87
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 83
diff changeset
113 _svntypes = {
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
114 subvertpy.NODE_DIR: 'd',
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
115 subvertpy.NODE_FILE: 'f',
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
116 }
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
117
1529
dee572a4e30b subvertpy: ensure paths are really always bytes
Augie Fackler <raf@durin42.com>
parents: 1460
diff changeset
118 _unitype = type(u'')
dee572a4e30b subvertpy: ensure paths are really always bytes
Augie Fackler <raf@durin42.com>
parents: 1460
diff changeset
119 def _forceutf8(s):
dee572a4e30b subvertpy: ensure paths are really always bytes
Augie Fackler <raf@durin42.com>
parents: 1460
diff changeset
120 if isinstance(s, _unitype):
dee572a4e30b subvertpy: ensure paths are really always bytes
Augie Fackler <raf@durin42.com>
parents: 1460
diff changeset
121 return s.encode('utf-8')
dee572a4e30b subvertpy: ensure paths are really always bytes
Augie Fackler <raf@durin42.com>
parents: 1460
diff changeset
122 return s
dee572a4e30b subvertpy: ensure paths are really always bytes
Augie Fackler <raf@durin42.com>
parents: 1460
diff changeset
123
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
124 class PathAdapter(object):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
125 __slots__ = ('action', 'copyfrom_path', 'copyfrom_rev')
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
126
1083
8087267d0805 subvertpy wrapper: printable path adapter
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1054
diff changeset
127 def __init__(self, action, copyfrom_path, copyfrom_rev):
8087267d0805 subvertpy wrapper: printable path adapter
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1054
diff changeset
128 self.action = action
8087267d0805 subvertpy wrapper: printable path adapter
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1054
diff changeset
129 self.copyfrom_path = copyfrom_path
8087267d0805 subvertpy wrapper: printable path adapter
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1054
diff changeset
130 self.copyfrom_rev = copyfrom_rev
8087267d0805 subvertpy wrapper: printable path adapter
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1054
diff changeset
131
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
132 if self.copyfrom_path:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
133 self.copyfrom_path = intern(self.copyfrom_path)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
134
1083
8087267d0805 subvertpy wrapper: printable path adapter
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1054
diff changeset
135 def __repr__(self):
8087267d0805 subvertpy wrapper: printable path adapter
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1054
diff changeset
136 return '%s(%r, %r, %r)' % (type(self).__name__, self.action,
8087267d0805 subvertpy wrapper: printable path adapter
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1054
diff changeset
137 self.copyfrom_path, self.copyfrom_rev)
8087267d0805 subvertpy wrapper: printable path adapter
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1054
diff changeset
138
8087267d0805 subvertpy wrapper: printable path adapter
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1054
diff changeset
139
978
70aa5bf7a760 subvertpy wrapper: rename AbstractEditor to BaseEditor
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 969
diff changeset
140 class BaseEditor(object):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
141 __slots__ = ('editor', 'baton')
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
142
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
143 def __init__(self, editor, baton=None):
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
144 self.editor = editor
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
145 self.baton = baton
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
146
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
147 def set_target_revision(self, rev):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
148 pass
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
149
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
150 def open_root(self, base_revnum):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
151 baton = self.editor.open_root(None, base_revnum)
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
152 return DirectoryEditor(self.editor, baton)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
153
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
154 def abort(self):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
155 # TODO: should we do something special here?
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
156 self.close()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
157
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
158 def close(self):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
159 del self.editor
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
160
978
70aa5bf7a760 subvertpy wrapper: rename AbstractEditor to BaseEditor
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 969
diff changeset
161 class FileEditor(BaseEditor):
70aa5bf7a760 subvertpy wrapper: rename AbstractEditor to BaseEditor
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 969
diff changeset
162 __slots__ = ()
70aa5bf7a760 subvertpy wrapper: rename AbstractEditor to BaseEditor
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 969
diff changeset
163
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
164 def __init__(self, editor, baton):
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
165 super(FileEditor, self).__init__(editor, baton)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
166
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
167 def change_prop(self, name, value):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
168 self.editor.change_file_prop(self.baton, name, value, pool=None)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
169
936
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
170 def apply_textdelta(self, base_checksum):
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
171 return self.editor.apply_textdelta(self.baton, base_checksum)
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
172
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
173 def close(self, checksum=None):
939
997de286ba0c editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents: 936
diff changeset
174 self.editor.close_file(self.baton, checksum)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
175 super(FileEditor, self).close()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
176
978
70aa5bf7a760 subvertpy wrapper: rename AbstractEditor to BaseEditor
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 969
diff changeset
177 class DirectoryEditor(BaseEditor):
70aa5bf7a760 subvertpy wrapper: rename AbstractEditor to BaseEditor
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 969
diff changeset
178 __slots__ = ()
70aa5bf7a760 subvertpy wrapper: rename AbstractEditor to BaseEditor
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 969
diff changeset
179
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
180 def __init__(self, editor, baton):
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
181 super(DirectoryEditor, self).__init__(editor, baton)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
182
936
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
183 def delete_entry(self, path, revnum):
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
184 self.editor.delete_entry(path, revnum, self.baton)
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
185
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
186 def open_directory(self, path, base_revnum):
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
187 baton = self.editor.open_directory(path, self.baton, base_revnum)
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
188 return DirectoryEditor(self.editor, baton)
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
189
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
190 def add_directory(self, path, copyfrom_path=None, copyfrom_rev=-1):
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
191 baton = self.editor.add_directory(
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
192 path, self.baton, copyfrom_path, copyfrom_rev)
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
193 return DirectoryEditor(self.editor, baton)
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
194
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
195 def open_file(self, path, base_revnum):
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
196 baton = self.editor.open_file(path, self.baton, base_revnum)
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
197 return FileEditor(self.editor, baton)
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
198
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
199 def add_file(self, path, copyfrom_path=None, copyfrom_rev=-1):
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
200 baton = self.editor.add_file(
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
201 path, self.baton, copyfrom_path, copyfrom_rev)
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
202 return FileEditor(self.editor, baton)
bb599a47a9d0 subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents: 935
diff changeset
203
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
204 def change_prop(self, name, value):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
205 self.editor.change_dir_prop(self.baton, name, value, pool=None)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
206
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
207 def close(self):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
208 self.editor.close_directory(self.baton)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
209 super(DirectoryEditor, self).close()
87
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 83
diff changeset
210
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
211 class SubversionRepo(object):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
212 """Wrapper for a Subversion repository.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
213
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
214 This wrapper uses Subvertpy, an alternate set of bindings for Subversion
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
215 that's more pythonic and sucks less. See earlier in this file for version
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
216 requirements.
844
95d040755254 Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents: 837
diff changeset
217
95d040755254 Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents: 837
diff changeset
218 Note that password stores do not work, the parameter is only here
95d040755254 Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents: 837
diff changeset
219 to ensure that the API is the same as for the SWIG wrapper.
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
220 """
1329
4cb76904c001 subvertpy_wrapper: add a member to store reference to meta object
Sean Farley <sean.michael.farley@gmail.com>
parents: 1083
diff changeset
221 def __init__(self, url='', username='', password='', head=None,
1353
63a29df4f661 subvertpy_wrapper: remove meta attribute
Sean Farley <sean@farley.io>
parents: 1329
diff changeset
222 password_stores=None):
672
2cc1342d4476 svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 668
diff changeset
223 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
224 # --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
225 self.username = parsed[0]
3941d73c262e svnwrappers: override svn+ssh credentials with supplied ones if any
Patrick Mezard <pmezard@gmail.com>
parents: 392
diff changeset
226 self.password = parsed[1]
235
2969a20e0eef Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents: 234
diff changeset
227 self.svn_url = parsed[2]
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
228
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
229 self.init_ra_and_client()
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
230
717
ae5968ffe6fe svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 709
diff changeset
231 self.svn_url = self.remote.get_url()
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
232 self.uuid = self.remote.get_uuid()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
233 self.root = self.remote.get_repos_root()
717
ae5968ffe6fe svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 709
diff changeset
234 assert self.svn_url.startswith(self.root)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
235
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
236 # *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: 709
diff changeset
237 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
238 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
239 self.subdir += '/'
717
ae5968ffe6fe svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 709
diff changeset
240 # 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: 709
diff changeset
241 # expects unquoted paths
ae5968ffe6fe svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 709
diff changeset
242 self.subdir = urllib.unquote(self.subdir)
89
edeec6829d80 SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents: 87
diff changeset
243 self.hasdiff3 = True
911
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents: 906
diff changeset
244 self.autoprops_config = common.AutoPropsConfig()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
245
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
246 def init_ra_and_client(self):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
247 """
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
248 Initializes the RA and client layers.
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
249
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
250 With the SWIG bindings, getting unified diffs runs the remote server
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
251 sometimes runs out of open files. It is not known whether the Subvertpy
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
252 is affected by this.
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
253 """
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
254 def getclientstring():
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
255 return 'hgsubversion'
964
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
256
966
7561aef55a4b svnwrap: Improved handling of simple_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 965
diff changeset
257 def simple(realm, username, may_save):
7561aef55a4b svnwrap: Improved handling of simple_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 965
diff changeset
258 return _prompt.simple(realm, username, may_save)
7561aef55a4b svnwrap: Improved handling of simple_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 965
diff changeset
259
967
0b6a6a7c26f3 svnwrap: Improved handling of username_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 966
diff changeset
260 def username(realm, may_save):
0b6a6a7c26f3 svnwrap: Improved handling of username_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 966
diff changeset
261 return _prompt.username(realm, may_save)
0b6a6a7c26f3 svnwrap: Improved handling of username_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 966
diff changeset
262
968
c500bc862215 svnwrap: Implement handling of ssl_client_cert_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 967
diff changeset
263 def ssl_client_cert(realm, may_save):
c500bc862215 svnwrap: Implement handling of ssl_client_cert_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 967
diff changeset
264 return _prompt.ssl_client_cert(realm, may_save)
c500bc862215 svnwrap: Implement handling of ssl_client_cert_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 967
diff changeset
265
969
145611306f8a svnwrap: Implement handling of ssl_client_cert_pw_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 968
diff changeset
266 def ssl_client_cert_pw(realm, may_save):
145611306f8a svnwrap: Implement handling of ssl_client_cert_pw_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 968
diff changeset
267 return _prompt.ssl_client_cert_pw(realm, may_save)
145611306f8a svnwrap: Implement handling of ssl_client_cert_pw_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 968
diff changeset
268
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
269 def ssl_server_trust(realm, failures, cert_info, may_save):
b748a0eed09a svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 964
diff changeset
270 creds = _prompt.ssl_server_trust(realm, failures, cert_info, may_save)
b748a0eed09a svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 964
diff changeset
271 if creds is 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
272 # We need to reject the certificate, but subvertpy doesn'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
273 # handle None as a return value here, and requires
b748a0eed09a svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 964
diff changeset
274 # we instead return a tuple of (int, bool). Because of that,
b748a0eed09a svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 964
diff changeset
275 # we return (0, False) instead.
b748a0eed09a svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 964
diff changeset
276 creds = (0, False)
964
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
277 return creds
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
278
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
279 providers = ra.get_platform_specific_client_providers()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
280 providers += [
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
281 ra.get_simple_provider(),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
282 ra.get_username_provider(),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
283 ra.get_ssl_client_cert_file_provider(),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
284 ra.get_ssl_client_cert_pw_file_provider(),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
285 ra.get_ssl_server_trust_file_provider(),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
286 ]
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
287 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
288 providers += [
966
7561aef55a4b svnwrap: Improved handling of simple_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 965
diff changeset
289 ra.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
290 ra.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
291 ra.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
292 ra.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
293 ra.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
294 ]
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
295
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
296 auth = ra.Auth(providers)
694
e32ed1802478 subvertpy: set default username/pwd as with swig
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 676
diff changeset
297 if self.username:
e32ed1802478 subvertpy: set default username/pwd as with swig
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 676
diff changeset
298 auth.set_parameter(subvertpy.AUTH_PARAM_DEFAULT_USERNAME, self.username)
e32ed1802478 subvertpy: set default username/pwd as with swig
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 676
diff changeset
299 if self.password:
e32ed1802478 subvertpy: set default username/pwd as with swig
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 676
diff changeset
300 auth.set_parameter(subvertpy.AUTH_PARAM_DEFAULT_PASSWORD, self.password)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
301
964
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
302 try:
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
303 self.remote = ra.RemoteAccess(url=self.svn_url,
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
304 client_string_func=getclientstring,
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
305 auth=auth)
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
306 except SubversionException, e:
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
307 # 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: 939
diff changeset
308 msglist = []
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
309 svn_exc = e
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
310 while svn_exc:
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
311 if svn_exc.args[0]:
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
312 msglist.append(svn_exc.args[0])
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
313 svn_exc = svn_exc.child
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
314 msg = '\n'.join(msglist)
27fec8bf9273 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
Mitsuhiro Koga <shiena.jp@gmail.com>
parents: 939
diff changeset
315 raise common.SubversionConnectionException(msg)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
316
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
317 self.client = client.Client()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
318 self.client.auth = auth
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
319
674
a51e50d943b2 svnwrap: use decorator syntax for properties.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 673
diff changeset
320 @property
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
321 def HEAD(self):
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
322 return self.remote.get_latest_revnum()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
323
674
a51e50d943b2 svnwrap: use decorator syntax for properties.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 673
diff changeset
324 @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
325 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
326 try:
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 300
diff changeset
327 holder = []
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
328 def callback(paths, revnum, props, haschildren):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
329 holder.append(revnum)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
330
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
331 self.remote.get_log(paths=[''],
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
332 start=self.HEAD, end=1, limit=1,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
333 discover_changed_paths=False,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
334 callback=callback)
301
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 300
diff changeset
335
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 300
diff changeset
336 return holder[-1]
667
e872f549e42f svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 666
diff changeset
337 except SubversionException, e:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
338 if e.args[0] == ERR_FS_NOT_FOUND:
301
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 300
diff changeset
339 raise
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 300
diff changeset
340 else:
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 300
diff changeset
341 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
342
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
343 def list_dir(self, path, revision=None):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
344 """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
345
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
346 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
347
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
348 Args:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
349 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
350 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
351 """
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
352 # TODO: reject leading slashes like the docstring says
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
353 if path:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
354 path = path.rstrip('/') + '/'
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
355
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
356 r = self.remote.get_dir(path, revision or self.HEAD, ra.DIRENT_ALL)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
357 dirents, fetched_rev, properties = r
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
358 return dirents
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
359
666
192a3f65837a svnwrap: remove dead code
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 664
diff changeset
360 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
361 chunk_size=common.chunk_size):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
362 """Load the history of this repo.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
363
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
364 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
365 of revisions at a time.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
366
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
367 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
368 to perform RA calls to get deltas.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
369 """
361
cfdd4ec5230a Merge fetch_history_at_paths() and revisions() in svn wrappers.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
370 if paths is None:
cfdd4ec5230a Merge fetch_history_at_paths() and revisions() in svn wrappers.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
371 paths = ['']
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
372 if not stop:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
373 stop = self.HEAD
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
374 while stop > start:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
375 def callback(paths, revnum, props, haschildren):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
376 if paths is None:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
377 return
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
378 r = common.Revision(revnum,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
379 props.get(properties.PROP_REVISION_AUTHOR),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
380 props.get(properties.PROP_REVISION_LOG),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
381 props.get(properties.PROP_REVISION_DATE),
1529
dee572a4e30b subvertpy: ensure paths are really always bytes
Augie Fackler <raf@durin42.com>
parents: 1460
diff changeset
382 dict([(_forceutf8(k), PathAdapter(*v))
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
383 for k, v in paths.iteritems()]),
1529
dee572a4e30b subvertpy: ensure paths are really always bytes
Augie Fackler <raf@durin42.com>
parents: 1460
diff changeset
384 strip_path=_forceutf8(self.subdir))
300
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
385 revisions.append(r)
675
31cd9f41ec09 svnwrap: improve a docstring & a comment.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 674
diff changeset
386 # 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
387 revisions = collections.deque()
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
388
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
389 revprops = [properties.PROP_REVISION_AUTHOR,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
390 properties.PROP_REVISION_DATE,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
391 properties.PROP_REVISION_LOG]
300
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
392 try:
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
393 # 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
394 # 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
395 # when converting the 65k+ rev. in LLVM.
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
396 self.remote.get_log(paths=paths, revprops=revprops,
832
e9af7eba88db globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents: 796
diff changeset
397 start=start + 1, end=stop, limit=chunk_size,
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
398 discover_changed_paths=True,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
399 callback=callback)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
400 except SubversionException, e:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
401 if e.args[1] == 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
402 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
403 % (self.subdir.rstrip('/'), stop))
672
2cc1342d4476 svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 668
diff changeset
404 raise common.SubversionConnectionException(msg)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
405 elif e.args[1] == subvertpy.ERR_FS_NO_SUCH_REVISION:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
406 raise common.SubversionConnectionException(e.args[0])
590
5e9ab25e0112 handle nonexistant svn repositories, fixes issue 137
Jonathan Kotta <jpkotta@gmail.com>
parents: 572
diff changeset
407 else:
5e9ab25e0112 handle nonexistant svn repositories, fixes issue 137
Jonathan Kotta <jpkotta@gmail.com>
parents: 572
diff changeset
408 raise
300
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
409
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
410 while len(revisions) > 1:
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
411 yield revisions.popleft()
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
412
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
413 if len(revisions) == 0:
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
414 # 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
415 break
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
416 else:
300
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
417 r = revisions.popleft()
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
418 start = r.revnum
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
419 yield r
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
420
83
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents: 81
diff changeset
421 def commit(self, paths, message, file_data, base_revision, addeddirs,
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
422 deleteddirs, props, copies):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
423 """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
424
131cb06dca76 svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1036
diff changeset
425 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
426 """
1054
131cb06dca76 svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1036
diff changeset
427 def commitcb(rev, date, author):
131cb06dca76 svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1036
diff changeset
428 r = common.Revision(rev, author, message, date)
131cb06dca76 svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1036
diff changeset
429 committedrev.append(r)
131cb06dca76 svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1036
diff changeset
430
131cb06dca76 svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1036
diff changeset
431 committedrev = []
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
432 revprops = { properties.PROP_REVISION_LOG: message }
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 832
diff changeset
433 # revprops.update(props)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
434 commiteditor = self.remote.get_commit_editor(revprops, commitcb)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
435
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
436 paths = set(paths)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
437 paths.update(addeddirs)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
438 paths.update(deleteddirs)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
439
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
440 # ensure that all parents are visited too; this may be slow
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
441 for path in paths.copy():
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
442 for i in xrange(path.count('/'), -1, -1):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
443 p = path.rsplit('/', i)[0]
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
444 if p in paths:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
445 continue
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
446 paths.add(p)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
447 paths = sorted(paths)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
448
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
449 def visitdir(editor, directory, paths, pathidx):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
450 while pathidx < len(paths):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
451 path = paths[pathidx]
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
452 if directory and not path.startswith(directory + '/'):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
453 return pathidx
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
454
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
455 pathidx += 1
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
456
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
457 if path in file_data:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
458 # visiting a file
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
459 base_text, new_text, action = file_data[path]
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
460 if action == 'modify':
730
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 718
diff changeset
461 fileeditor = editor.open_file(path, base_revision)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
462 elif action == 'add':
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
463 frompath, fromrev = copies.get(path, (None, -1))
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
464 if frompath:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
465 frompath = self.path2url(frompath)
730
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 718
diff changeset
466 fileeditor = editor.add_file(path, frompath, fromrev)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
467 elif action == 'delete':
730
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 718
diff changeset
468 editor.delete_entry(path, base_revision)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
469 continue
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
470 else:
986
1bdd075a490a cleanup: avoid \' in strings where easy
Augie Fackler <raf@durin42.com>
parents: 978
diff changeset
471 assert False, "invalid action '%s'" % action
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
472
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
473 if path in props:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
474 if props[path].get('svn:special', None):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
475 new_text = 'link %s' % new_text
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
476 for p, v in props[path].iteritems():
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
477 fileeditor.change_prop(p, v)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
478
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
479
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
480 handler = fileeditor.apply_textdelta()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
481 delta.send_stream(cStringIO.StringIO(new_text), handler)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
482 fileeditor.close()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
483
175
2412800b1258 Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents: 172
diff changeset
484 else:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
485 # visiting a directory
1460
e31c288e5059 svnwrap: allow overwriting directories in one revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1459
diff changeset
486 if path in deleteddirs:
e31c288e5059 svnwrap: allow overwriting directories in one revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1459
diff changeset
487 direditor = editor.delete_entry(path, base_revision)
e31c288e5059 svnwrap: allow overwriting directories in one revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1459
diff changeset
488
e31c288e5059 svnwrap: allow overwriting directories in one revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1459
diff changeset
489 if path not in addeddirs:
e31c288e5059 svnwrap: allow overwriting directories in one revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1459
diff changeset
490 continue
e31c288e5059 svnwrap: allow overwriting directories in one revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1459
diff changeset
491
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
492 if path in addeddirs:
1459
b95fa72c74ae svnwrap: allow committing directory copies
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1457
diff changeset
493 frompath, fromrev = copies.get(path, (None, -1))
b95fa72c74ae svnwrap: allow committing directory copies
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1457
diff changeset
494 if frompath:
b95fa72c74ae svnwrap: allow committing directory copies
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1457
diff changeset
495 frompath = self.path2url(frompath)
b95fa72c74ae svnwrap: allow committing directory copies
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1457
diff changeset
496 direditor = editor.add_directory(path, frompath, fromrev)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
497 else:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
498 direditor = editor.open_directory(path)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
499
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
500 if path in props:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
501 for p, v in props[path].iteritems():
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
502 direditor.change_prop(p, v)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
503
730
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 718
diff changeset
504 pathidx = visitdir(direditor, path, paths, pathidx)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
505 direditor.close()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
506
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
507 return pathidx
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
508
906
757d6a862c83 subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents: 844
diff changeset
509 try:
757d6a862c83 subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents: 844
diff changeset
510 rooteditor = commiteditor.open_root()
757d6a862c83 subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents: 844
diff changeset
511 visitdir(rooteditor, '', paths, 0)
757d6a862c83 subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents: 844
diff changeset
512 rooteditor.close()
757d6a862c83 subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents: 844
diff changeset
513 except:
757d6a862c83 subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents: 844
diff changeset
514 commiteditor.abort()
757d6a862c83 subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents: 844
diff changeset
515 raise
1011
cc774e975aed commit: fix exception handling on transaction close
Matt Mackall <mpm@selenic.com>
parents: 987
diff changeset
516 commiteditor.close()
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
517
1054
131cb06dca76 svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1036
diff changeset
518 return committedrev.pop()
131cb06dca76 svnwrap & pushmod: return a Revision when committing
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 1036
diff changeset
519
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
520 def get_replay(self, revision, editor, oldestrev=0):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
521
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
522 try:
978
70aa5bf7a760 subvertpy wrapper: rename AbstractEditor to BaseEditor
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 969
diff changeset
523 self.remote.replay(revision, oldestrev, BaseEditor(editor))
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 832
diff changeset
524 except (SubversionException, NotImplementedError), e: # pragma: no cover
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
525 # can I depend on this number being constant?
796
22f0c50c29a6 subvertpy wrapper: handle NotImplementedError from Subvertpy on missing replay
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 730
diff changeset
526 if (isinstance(e, NotImplementedError) or
22f0c50c29a6 subvertpy wrapper: handle NotImplementedError from Subvertpy on missing replay
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 730
diff changeset
527 e.args[1] == subvertpy.ERR_RA_NOT_IMPLEMENTED or
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
528 e.args[1] == subvertpy.ERR_UNSUPPORTED_FEATURE):
672
2cc1342d4476 svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 668
diff changeset
529 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
530 'cannot satisfy replay requests.')
2cc1342d4476 svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 668
diff changeset
531 raise common.SubversionRepoCanNotReplay(msg)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
532 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
533 raise
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
534
649
2060e0ca8dd5 svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 611
diff changeset
535 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
536 ''' feed the contents of the given revision to the given editor '''
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
537 reporter = self.remote.do_update(revision, '', True,
978
70aa5bf7a760 subvertpy wrapper: rename AbstractEditor to BaseEditor
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 969
diff changeset
538 BaseEditor(editor))
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
539 reporter.set_path('', revision, True)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
540 reporter.finish()
649
2060e0ca8dd5 svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 611
diff changeset
541
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
542 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
543 deleted=True, ignore_type=False):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
544 """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
545 """
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
546
491
b71507d7becc svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents: 489
diff changeset
547 url = self.path2url(path)
b71507d7becc svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents: 489
diff changeset
548 url2 = (other_path and self.path2url(other_path) or url)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
549
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
550 if other_rev is None:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
551 other_rev = revision - 1
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
552
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
553 outfile, errfile = self.client.diff(other_rev, revision, url2, url,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
554 no_diff_deleted=deleted,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
555 ignore_content_type=ignore_type)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
556 error = errfile.read()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
557 assert not error, error
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
558
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
559 return outfile.read()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
560
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
561 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
562 """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
563
97
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 92
diff changeset
564 "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
565 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
566 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
567 IOError.
76
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 75
diff changeset
568 """
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 75
diff changeset
569 mode = ''
66
a31968146f3c svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
570 try:
931
e1dbd9646d6a svnwrap: use custom StringIO class in get_file()
Patrick Mezard <patrick@mezard.eu>
parents: 911
diff changeset
571 out = common.SimpleStringIO()
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
572 rev, info = self.remote.get_file(path, out, revision)
122
04c92c2c4501 SubversionRepo: work around ra.get_files() not releasing input buffer
Patrick Mezard <pmezard@gmail.com>
parents: 97
diff changeset
573 data = out.getvalue()
04c92c2c4501 SubversionRepo: work around ra.get_files() not releasing input buffer
Patrick Mezard <pmezard@gmail.com>
parents: 97
diff changeset
574 out.close()
76
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 75
diff changeset
575 if isinstance(info, list):
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 75
diff changeset
576 info = info[-1]
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
577 mode = (properties.PROP_EXECUTABLE in info) and 'x' or ''
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
578 mode = (properties.PROP_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
579 except SubversionException, e:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
580 if e.args[1] in (ERR_FS_NOT_FOUND, ERR_RA_DAV_PATH_NOT_FOUND):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
581 # File 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
582 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
583 raise
832
e9af7eba88db globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents: 796
diff changeset
584 if mode == 'l':
97
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 92
diff changeset
585 linkprefix = "link "
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 92
diff changeset
586 if data.startswith(linkprefix):
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 92
diff changeset
587 data = data[len(linkprefix):]
76
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 75
diff changeset
588 return data, mode
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
589
172
84fbf1469a31 SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents: 155
diff changeset
590 def list_props(self, path, revision):
84fbf1469a31 SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents: 155
diff changeset
591 """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
592 specified path does not exist.
84fbf1469a31 SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents: 155
diff changeset
593 """
84fbf1469a31 SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents: 155
diff changeset
594 try:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
595 pl = self.client.proplist(self.path2url(path), revision,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
596 client.depth_empty)
667
e872f549e42f svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 666
diff changeset
597 except SubversionException, e:
172
84fbf1469a31 SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents: 155
diff changeset
598 # Specified path does not exist at this revision
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
599 if e.args[1] == subvertpy.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
600 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
601 raise
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
602 return pl and pl[0][1] or {}
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
603
77
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
604 def list_files(self, dirpath, revision):
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
605 """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
606
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
607 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
608 '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
609 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
610 revision.
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
611 """
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
612 try:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
613 entries = self.client.list(self.path2url(dirpath), revision,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
614 client.depth_infinity, ra.DIRENT_KIND)
667
e872f549e42f svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 666
diff changeset
615 except SubversionException, e:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
616 if e.args[1] == subvertpy.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
617 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
618 '%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
619 raise
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
620 for path, e in entries.iteritems():
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
621 if not path: continue
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
622 kind = _svntypes.get(e['kind'])
77
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
623 yield path, kind
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
624
87
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 83
diff changeset
625 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
626 """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
627 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
628 """
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
629 kind = self.remote.check_path(path, revision)
87
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 83
diff changeset
630 return _svntypes.get(kind)
489
cd793ca555af svnwrap: properly escape URLs before giving them to libsvn_*
Chema Cortes <pych3m4@gmail.com>
parents: 467
diff changeset
631
491
b71507d7becc svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents: 489
diff changeset
632 def path2url(self, path):
b71507d7becc svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents: 489
diff changeset
633 """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
634 """
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 491
diff changeset
635 if not path or path == '.':
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 491
diff changeset
636 return self.svn_url
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 491
diff changeset
637 assert path[0] != '/', path
832
e9af7eba88db globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents: 796
diff changeset
638 return '/'.join((self.svn_url, urllib.quote(path).rstrip('/'),))