Mercurial > hgsubversion
annotate hgsubversion/svnwrap/svn_swig_wrapper.py @ 717:ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
The way hgsubversion handles URLs that may or may not be quoted is
somewhat fragile. As part of fixing issue 132 in 925ff8c5989c, the
path component of URLs was always quoted. The URL has been attempted
encoded since the initial check-in.
The fix from 925ff8c5989c was incomplete; reverting it allows us to
clone a URL with a '~' in it.[1] Encoding the URL as UTF-8 seldom
works as expected, as the default string encoding is ASCII, causing
Python to be unable to decode any URL containing an 8-bit
character.
The core problem here is that we don't know whether the URL specified
by the user is quoted or not. Rather than trying to deal with this
ourselves, we pass the problem on to Subversion. Then, we obtain the
URL from the RA instance, where it is always quoted. (It's worth
noting that the editor interface, on the other hand, always deals with
unquoted paths...)
Thus, the following invariants should apply to SubversionRepo
attributes:
- svn_url and root will always be quoted.
- subdir will always be unquoted.
Tests are added that verify that it won't affect the conversion
whether a URL is specified in quoted or unquoted form. Furthermore, a
test fixture for this is added *twice*, so that we can thoroughly test
both quoted and unquoted URLs. I'm not adding a test dedicated to
tildes in URLs; it doesn't seem necessary.
[1] Such as <https://svn.kenai.com/svn/winsw~subversion>.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Mon, 04 Oct 2010 21:00:36 -0500 |
parents | 31cd9f41ec09 |
children | e9af7eba88db |
rev | line source |
---|---|
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 import cStringIO |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
2 import getpass |
531
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
511
diff
changeset
|
3 import errno |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 import os |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 import shutil |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 import sys |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
7 import tempfile |
238
e8b3ca865f93
Fix a boneheaded mistake I made when I touched up a previous patch.
Augie Fackler <durin42@gmail.com>
parents:
235
diff
changeset
|
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 |
607
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
18 required_bindings = (1, 5, 0) |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
19 |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
20 try: |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
21 from svn import client |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
22 from svn import core |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
23 from svn import delta |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
24 from svn import ra |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
25 |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
26 current_bindings = (core.SVN_VER_MAJOR, core.SVN_VER_MINOR, |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
27 core.SVN_VER_MICRO) |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
28 except ImportError: |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
29 raise ImportError('Subversion %d.%d.%d or later required, ' |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
30 'but no bindings were found' % required_bindings) |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
31 |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
32 if current_bindings < required_bindings: #pragma: no cover |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
33 raise ImportError('Subversion %d.%d.%d or later required, ' |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
34 'but bindings for %d.%d.%d found' % |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
35 (required_bindings + current_bindings)) |
b5f1b629c629
svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
601
diff
changeset
|
36 |
196
77812f98e250
Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents:
181
diff
changeset
|
37 def version(): |
664
5c94a86ddd73
version: mention bindings type in version
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
649
diff
changeset
|
38 return '%d.%d.%d' % current_bindings, 'SWIG' |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 |
601
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
40 # exported values |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
41 ERR_FS_CONFLICT = core.SVN_ERR_FS_CONFLICT |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
42 ERR_FS_NOT_FOUND = core.SVN_ERR_FS_NOT_FOUND |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
43 ERR_FS_TXN_OUT_OF_DATE = core.SVN_ERR_FS_TXN_OUT_OF_DATE |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
44 ERR_INCOMPLETE_DATA = core.SVN_ERR_INCOMPLETE_DATA |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
45 ERR_RA_DAV_REQUEST_FAILED = core.SVN_ERR_RA_DAV_REQUEST_FAILED |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
46 SubversionException = core.SubversionException |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
47 Editor = delta.Editor |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
48 |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
49 def apply_txdelta(base, target): |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
50 handler, baton = delta.svn_txdelta_apply(cStringIO.StringIO(base), |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
51 target, None) |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
52 return (lambda window: handler(window, baton)) |
0fe490ce2fbb
isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
590
diff
changeset
|
53 |
75
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
54 def optrev(revnum): |
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
55 optrev = core.svn_opt_revision_t() |
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
56 optrev.kind = core.svn_opt_revision_number |
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
57 optrev.value.number = revnum |
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
58 return optrev |
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
59 |
50
80b923ab242b
Drop any pretense of supporting svn 1.4.x.
Augie Fackler <durin42@gmail.com>
parents:
47
diff
changeset
|
60 svn_config = core.svn_config_get_config(None) |
45
ce00e6ffaa90
Change the implementation of the ra_session stuff. Thanks to Ben Collins-Sussman for pointing out the problem with the other method I was using.
Augie Fackler <durin42@gmail.com>
parents:
36
diff
changeset
|
61 class RaCallbacks(ra.Callbacks): |
298
32d3f1716e66
Two minor optimisations/cleanups for svn_swig_wrapper:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
293
diff
changeset
|
62 @staticmethod |
32d3f1716e66
Two minor optimisations/cleanups for svn_swig_wrapper:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
293
diff
changeset
|
63 def open_tmp_file(pool): #pragma: no cover |
46
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
64 (fd, fn) = tempfile.mkstemp() |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
65 os.close(fd) |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
66 return fn |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
67 |
298
32d3f1716e66
Two minor optimisations/cleanups for svn_swig_wrapper:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
293
diff
changeset
|
68 @staticmethod |
32d3f1716e66
Two minor optimisations/cleanups for svn_swig_wrapper:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
293
diff
changeset
|
69 def get_client_string(pool): |
45
ce00e6ffaa90
Change the implementation of the ra_session stuff. Thanks to Ben Collins-Sussman for pointing out the problem with the other method I was using.
Augie Fackler <durin42@gmail.com>
parents:
36
diff
changeset
|
70 return 'hgsubversion' |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
71 |
673
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
72 def ieditor(fn): |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
73 """Helps identify methods used by the SVN editor interface. |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
74 |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
75 Stash any exception raised in the method on self. |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
76 |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
77 This is required because the SWIG bindings just mutate any exception into |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
78 a generic Subversion exception with no way of telling what the original was. |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
79 This allows the editor object to notice when you try and commit and really |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
80 got an exception in the replay process. |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
81 """ |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
82 def fun(self, *args, **kwargs): |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
83 try: |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
84 return fn(self, *args, **kwargs) |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
85 except: #pragma: no cover |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
86 if self.current.exception is not None: |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
87 self.current.exception = sys.exc_info() |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
88 raise |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
89 return fun |
32089d080ff8
editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
672
diff
changeset
|
90 |
63
2e30b59a9c19
Added some coverage pragmas to stop it from trying to cover things we can't test.
Augie Fackler <durin42@gmail.com>
parents:
59
diff
changeset
|
91 def user_pass_prompt(realm, default_username, ms, pool): #pragma: no cover |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
92 # FIXME: should use getpass() and username() from mercurial.ui |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
93 creds = core.svn_auth_cred_simple_t() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
94 creds.may_save = ms |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
95 if default_username: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
96 sys.stderr.write('Auth realm: %s\n' % (realm,)) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
97 creds.username = default_username |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
98 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
99 sys.stderr.write('Auth realm: %s\n' % (realm,)) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
100 sys.stderr.write('Username: ') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
101 sys.stderr.flush() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
102 creds.username = sys.stdin.readline().strip() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
103 creds.password = getpass.getpass('Password for %s: ' % creds.username) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
104 return creds |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
105 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
106 def _create_auth_baton(pool): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
107 """Create a Subversion authentication baton. """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
108 # Give the client context baton a suite of authentication |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
109 # providers.h |
92
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
110 platform_specific = ['svn_auth_get_gnome_keyring_simple_provider', |
272
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
111 'svn_auth_get_gnome_keyring_ssl_client_cert_pw_provider', |
92
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
112 'svn_auth_get_keychain_simple_provider', |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
113 'svn_auth_get_keychain_ssl_client_cert_pw_provider', |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
114 'svn_auth_get_kwallet_simple_provider', |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
115 'svn_auth_get_kwallet_ssl_client_cert_pw_provider', |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
116 'svn_auth_get_ssl_client_cert_file_provider', |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
117 'svn_auth_get_windows_simple_provider', |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
118 'svn_auth_get_windows_ssl_server_trust_provider', |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
119 ] |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
120 |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
121 providers = [] |
272
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
122 # Platform-dependant authentication methods |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
123 getprovider = getattr(core, 'svn_auth_get_platform_specific_provider', |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
124 None) |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
125 if getprovider: |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
126 # Available in svn >= 1.6 |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
127 for name in ('gnome_keyring', 'keychain', 'kwallet', 'windows'): |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
128 for type in ('simple', 'ssl_client_cert_pw', 'ssl_server_trust'): |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
129 p = getprovider(name, type, pool) |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
130 if p: |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
131 providers.append(p) |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
132 else: |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
133 for p in platform_specific: |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
134 if hasattr(core, p): |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
135 try: |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
136 providers.append(getattr(core, p)()) |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
137 except RuntimeError: |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
138 pass |
92
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
139 |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
140 providers += [ |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
141 client.get_simple_provider(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
142 client.get_username_provider(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
143 client.get_ssl_client_cert_file_provider(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
144 client.get_ssl_client_cert_pw_file_provider(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
145 client.get_ssl_server_trust_file_provider(), |
92
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
146 client.get_simple_prompt_provider(user_pass_prompt, 2), |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
147 ] |
92
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
148 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
149 return core.svn_auth_open(providers, pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
150 |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
151 _svntypes = { |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
152 core.svn_node_dir: 'd', |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
153 core.svn_node_file: 'f', |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
154 } |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
155 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
156 class SubversionRepo(object): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
157 """Wrapper for a Subversion repository. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
158 |
675
31cd9f41ec09
svnwrap: improve a docstring & a comment.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
674
diff
changeset
|
159 It uses the SWIG Python bindings, see above for requirements. |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
160 """ |
304
ce676eff002b
First merge, totally untested.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
diff
changeset
|
161 def __init__(self, url='', username='', password='', head=None): |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
162 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
|
163 # --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
|
164 self.username = parsed[0] |
3941d73c262e
svnwrappers: override svn+ssh credentials with supplied ones if any
Patrick Mezard <pmezard@gmail.com>
parents:
392
diff
changeset
|
165 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
|
166 self.svn_url = parsed[2] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
167 self.auth_baton_pool = core.Pool() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
168 self.auth_baton = _create_auth_baton(self.auth_baton_pool) |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
169 # self.init_ra_and_client() assumes that a pool already exists |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
170 self.pool = core.Pool() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
171 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
172 self.init_ra_and_client() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
173 self.uuid = ra.get_uuid(self.ra, self.pool) |
717
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
174 self.svn_url = ra.get_session_url(self.ra, self.pool) |
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
175 self.root = ra.get_repos_root(self.ra, self.pool) |
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
176 assert self.svn_url.startswith(self.root) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
177 # *will* have a leading '/', would not if we used get_repos_root2 |
717
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
178 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
|
179 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
|
180 self.subdir += '/' |
717
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
181 # the RA interface always yields quoted paths, but the editor interface |
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
182 # expects unquoted paths |
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
183 self.subdir = urllib.unquote(self.subdir) |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
184 self.hasdiff3 = True |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
185 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
186 def init_ra_and_client(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
187 """Initializes the RA and client layers, because sometimes getting |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
188 unified diffs runs the remote server out of open files. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
189 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
190 # while we're in here we'll recreate our pool |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
191 self.pool = core.Pool() |
233
80a700398995
Fix SubversionRepo to actually use provided username
Daniel Tang <dytang@cs.purdue.edu>
parents:
228
diff
changeset
|
192 if self.username: |
80a700398995
Fix SubversionRepo to actually use provided username
Daniel Tang <dytang@cs.purdue.edu>
parents:
228
diff
changeset
|
193 core.svn_auth_set_parameter(self.auth_baton, |
80a700398995
Fix SubversionRepo to actually use provided username
Daniel Tang <dytang@cs.purdue.edu>
parents:
228
diff
changeset
|
194 core.SVN_AUTH_PARAM_DEFAULT_USERNAME, |
80a700398995
Fix SubversionRepo to actually use provided username
Daniel Tang <dytang@cs.purdue.edu>
parents:
228
diff
changeset
|
195 self.username) |
234
33e885f5f86a
Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents:
233
diff
changeset
|
196 if self.password: |
33e885f5f86a
Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents:
233
diff
changeset
|
197 core.svn_auth_set_parameter(self.auth_baton, |
33e885f5f86a
Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents:
233
diff
changeset
|
198 core.SVN_AUTH_PARAM_DEFAULT_PASSWORD, |
33e885f5f86a
Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents:
233
diff
changeset
|
199 self.password) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
200 self.client_context = client.create_context() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
201 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
202 self.client_context.auth_baton = self.auth_baton |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
203 self.client_context.config = svn_config |
45
ce00e6ffaa90
Change the implementation of the ra_session stuff. Thanks to Ben Collins-Sussman for pointing out the problem with the other method I was using.
Augie Fackler <durin42@gmail.com>
parents:
36
diff
changeset
|
204 callbacks = RaCallbacks() |
ce00e6ffaa90
Change the implementation of the ra_session stuff. Thanks to Ben Collins-Sussman for pointing out the problem with the other method I was using.
Augie Fackler <durin42@gmail.com>
parents:
36
diff
changeset
|
205 callbacks.auth_baton = self.auth_baton |
ce00e6ffaa90
Change the implementation of the ra_session stuff. Thanks to Ben Collins-Sussman for pointing out the problem with the other method I was using.
Augie Fackler <durin42@gmail.com>
parents:
36
diff
changeset
|
206 self.callbacks = callbacks |
293
fa26c7ef0180
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
196
diff
changeset
|
207 try: |
717
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
208 self.ra = ra.open2(self.svn_url, callbacks, |
667
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
209 svn_config, self.pool) |
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
210 except SubversionException, e: |
611
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
609
diff
changeset
|
211 if e.apr_err == core.SVN_ERR_RA_SERF_SSL_CERT_UNTRUSTED: |
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
609
diff
changeset
|
212 msg = ('Subversion does not trust the SSL certificate for this ' |
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
609
diff
changeset
|
213 'site; please try running \'svn ls %s\' first.' |
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
609
diff
changeset
|
214 % self.svn_url) |
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
609
diff
changeset
|
215 elif e.apr_err == core.SVN_ERR_RA_DAV_REQUEST_FAILED: |
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
609
diff
changeset
|
216 msg = ('Failed to open Subversion repository; please try ' |
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
609
diff
changeset
|
217 'running \'svn ls %s\' for details.' % self.svn_url) |
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
609
diff
changeset
|
218 else: |
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
609
diff
changeset
|
219 msg = e.args[0] |
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
609
diff
changeset
|
220 for k, v in vars(core).iteritems(): |
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
609
diff
changeset
|
221 if k.startswith('SVN_ERR_') and v == e.apr_err: |
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
609
diff
changeset
|
222 msg = '%s (%s)' % (msg, k) |
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
609
diff
changeset
|
223 break |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
224 raise common.SubversionConnectionException(msg) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
225 |
674
a51e50d943b2
svnwrap: use decorator syntax for properties.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
673
diff
changeset
|
226 @property |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
227 def HEAD(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
228 return ra.get_latest_revnum(self.ra, self.pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
229 |
674
a51e50d943b2
svnwrap: use decorator syntax for properties.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
673
diff
changeset
|
230 @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
|
231 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
|
232 try: |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
233 holder = [] |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
234 ra.get_log(self.ra, [''], |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
235 self.HEAD, 1, |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
236 1, #limit of how many log messages to load |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
237 True, # don't need to know changed paths |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
238 True, # stop on copies |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
239 lambda paths, revnum, author, date, message, pool: |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
240 holder.append(revnum), |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
241 self.pool) |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
242 |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
243 return holder[-1] |
667
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
244 except SubversionException, e: |
301
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
245 if e.apr_err not in [core.SVN_ERR_FS_NOT_FOUND]: |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
246 raise |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
247 else: |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
248 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
|
249 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
250 def list_dir(self, dir, revision=None): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
251 """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
|
252 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
253 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
|
254 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
255 Args: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
256 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
|
257 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
|
258 """ |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
491
diff
changeset
|
259 # TODO this should just not accept leading slashes like the docstring says |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
491
diff
changeset
|
260 if dir and dir[-1] == '/': |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
261 dir = dir[:-1] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
262 if revision is None: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
263 revision = self.HEAD |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
264 r = ra.get_dir2(self.ra, dir, revision, core.SVN_DIRENT_KIND, self.pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
265 folders, props, junk = r |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
266 return folders |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
267 |
666
192a3f65837a
svnwrap: remove dead code
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
664
diff
changeset
|
268 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
|
269 chunk_size=common.chunk_size): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
270 """Load the history of this repo. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
271 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
272 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
|
273 of revisions at a time. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
274 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
275 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
|
276 to perform RA calls to get deltas. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
277 """ |
361
cfdd4ec5230a
Merge fetch_history_at_paths() and revisions() in svn wrappers.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
342
diff
changeset
|
278 if paths is None: |
cfdd4ec5230a
Merge fetch_history_at_paths() and revisions() in svn wrappers.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
342
diff
changeset
|
279 paths = [''] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
280 if not stop: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
281 stop = self.HEAD |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
282 while stop > start: |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
283 def callback(paths, revnum, author, date, message, pool): |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
284 r = common.Revision(revnum, author, message, date, paths, |
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
285 strip_path=self.subdir) |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
286 revisions.append(r) |
675
31cd9f41ec09
svnwrap: improve a docstring & a comment.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
674
diff
changeset
|
287 # 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
|
288 revisions = collections.deque() |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
289 |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
290 try: |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
291 # 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
|
292 # 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
|
293 # when converting the 65k+ rev. in LLVM. |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
294 ra.get_log(self.ra, |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
295 paths, |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
296 start+1, |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
297 stop, |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
298 chunk_size, #limit of how many log messages to load |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
299 True, # don't need to know changed paths |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
300 True, # stop on copies |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
301 callback, |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
302 self.pool) |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
303 except core.SubversionException, e: |
590
5e9ab25e0112
handle nonexistant svn repositories, fixes issue 137
Jonathan Kotta <jpkotta@gmail.com>
parents:
572
diff
changeset
|
304 if e.apr_err == core.SVN_ERR_FS_NOT_FOUND: |
609
aafbf0d40dc2
svnwrap: use SubversionConnectionException instead of mercurial.util.Abort
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
607
diff
changeset
|
305 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
|
306 % (self.subdir.rstrip('/'), stop)) |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
307 raise common.SubversionConnectionException(msg) |
590
5e9ab25e0112
handle nonexistant svn repositories, fixes issue 137
Jonathan Kotta <jpkotta@gmail.com>
parents:
572
diff
changeset
|
308 elif e.apr_err == core.SVN_ERR_FS_NO_SUCH_REVISION: |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
309 raise common.SubversionConnectionException(e.message) |
590
5e9ab25e0112
handle nonexistant svn repositories, fixes issue 137
Jonathan Kotta <jpkotta@gmail.com>
parents:
572
diff
changeset
|
310 else: |
5e9ab25e0112
handle nonexistant svn repositories, fixes issue 137
Jonathan Kotta <jpkotta@gmail.com>
parents:
572
diff
changeset
|
311 raise |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
312 |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
313 while len(revisions) > 1: |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
314 yield revisions.popleft() |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
315 |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
316 if len(revisions) == 0: |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
317 # 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
|
318 break |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
319 else: |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
320 r = revisions.popleft() |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
321 start = r.revnum |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
322 yield r |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
323 self.init_ra_and_client() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
324 |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
81
diff
changeset
|
325 def commit(self, paths, message, file_data, base_revision, addeddirs, |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
81
diff
changeset
|
326 deleteddirs, properties, copies): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
327 """Commits the appropriate targets from revision in editor's store. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
328 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
329 self.init_ra_and_client() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
330 commit_info = [] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
331 def commit_cb(_commit_info, pool): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
332 commit_info.append(_commit_info) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
333 editor, edit_baton = ra.get_commit_editor2(self.ra, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
334 message, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
335 commit_cb, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
336 None, |
20
2953c867ca99
Minor fixes to the push command to make it more robust.
Augie Fackler <durin42@gmail.com>
parents:
10
diff
changeset
|
337 False, |
2953c867ca99
Minor fixes to the push command to make it more robust.
Augie Fackler <durin42@gmail.com>
parents:
10
diff
changeset
|
338 self.pool) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
339 checksum = [] |
46
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
340 # internal dir batons can fall out of scope and get GCed before svn is |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
341 # done with them. This prevents that (credit to gvn for the idea). |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
342 batons = [edit_baton, ] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
343 def driver_cb(parent, path, pool): |
46
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
344 if not parent: |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
345 bat = editor.open_root(edit_baton, base_revision, self.pool) |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
346 batons.append(bat) |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
347 return bat |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
81
diff
changeset
|
348 if path in deleteddirs: |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
81
diff
changeset
|
349 bat = editor.delete_entry(path, base_revision, parent, pool) |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
81
diff
changeset
|
350 batons.append(bat) |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
81
diff
changeset
|
351 return bat |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
352 if path not in file_data: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
353 if path in addeddirs: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
354 bat = editor.add_directory(path, parent, None, -1, pool) |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
355 else: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
356 bat = editor.open_directory(path, parent, base_revision, pool) |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
357 batons.append(bat) |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
358 props = properties.get(path, {}) |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
359 if 'svn:externals' in props: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
360 value = props['svn:externals'] |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
361 editor.change_dir_prop(bat, 'svn:externals', value, pool) |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
362 return bat |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
363 base_text, new_text, action = file_data[path] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
364 compute_delta = True |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
365 if action == 'modify': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
366 baton = editor.open_file(path, parent, base_revision, pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
367 elif action == 'add': |
266 | 368 frompath, fromrev = copies.get(path, (None, -1)) |
369 if frompath: | |
544
809c673bdd30
svnwrap: escape copy sources paths in commit handler
Patrick Mezard <pmezard@gmail.com>
parents:
543
diff
changeset
|
370 frompath = self.path2url(frompath) |
266 | 371 baton = editor.add_file(path, parent, frompath, fromrev, pool) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
372 elif action == 'delete': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
373 baton = editor.delete_entry(path, base_revision, parent, pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
374 compute_delta = False |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
375 |
10
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
376 if path in properties: |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
377 if properties[path].get('svn:special', None): |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
378 new_text = 'link %s' % new_text |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
379 for p, v in properties[path].iteritems(): |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
380 editor.change_file_prop(baton, p, v) |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
381 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
382 if compute_delta: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
383 handler, wh_baton = editor.apply_textdelta(baton, None, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
384 self.pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
385 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
386 txdelta_stream = delta.svn_txdelta( |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
387 cStringIO.StringIO(base_text), cStringIO.StringIO(new_text), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
388 self.pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
389 delta.svn_txdelta_send_txstream(txdelta_stream, handler, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
390 wh_baton, pool) |
47
9738a7c4e3dd
fix svn push when there's just a file removal
Valentino Volonghi aka dialtone <valentino@adroll.com>
parents:
46
diff
changeset
|
391 |
9738a7c4e3dd
fix svn push when there's just a file removal
Valentino Volonghi aka dialtone <valentino@adroll.com>
parents:
46
diff
changeset
|
392 # TODO pass md5(new_text) instead of None |
9738a7c4e3dd
fix svn push when there's just a file removal
Valentino Volonghi aka dialtone <valentino@adroll.com>
parents:
46
diff
changeset
|
393 editor.close_file(baton, None, pool) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
394 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
395 delta.path_driver(editor, edit_baton, base_revision, paths, driver_cb, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
396 self.pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
397 editor.close_edit(edit_baton, self.pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
398 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
399 def get_replay(self, revision, editor, oldest_rev_i_have=0): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
400 # this method has a tendency to chew through RAM if you don't re-init |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
401 self.init_ra_and_client() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
402 e_ptr, e_baton = delta.make_editor(editor) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
403 try: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
404 ra.replay(self.ra, revision, oldest_rev_i_have, True, e_ptr, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
405 e_baton, self.pool) |
667
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
406 except SubversionException, e: #pragma: no cover |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
407 # can I depend on this number being constant? |
224
2165461d2dd8
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
196
diff
changeset
|
408 if (e.apr_err == core.SVN_ERR_RA_NOT_IMPLEMENTED or |
2165461d2dd8
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
196
diff
changeset
|
409 e.apr_err == core.SVN_ERR_UNSUPPORTED_FEATURE): |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
410 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
|
411 'cannot satisfy replay requests.') |
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
412 raise common.SubversionRepoCanNotReplay(msg) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
413 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
414 raise |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
415 |
649
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
416 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
|
417 ''' feed the contents of the given revision to the given editor ''' |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
418 |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
419 e_ptr, e_baton = delta.make_editor(editor) |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
420 |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
421 reporter, reporter_baton = ra.do_update(self.ra, revision, "", True, |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
422 e_ptr, e_baton) |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
423 |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
424 reporter.set_path(reporter_baton, "", revision, True, None) |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
425 reporter.finish_report(reporter_baton) |
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
426 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
427 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
|
428 deleted=True, ignore_type=False): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
429 """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
|
430 """ |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
431 if not self.hasdiff3: |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
432 raise common.SubversionRepoCanNotDiff() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
433 # works around an svn server keeping too many open files (observed |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
434 # in an svnserve from the 1.2 era) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
435 self.init_ra_and_client() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
436 |
491
b71507d7becc
svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents:
489
diff
changeset
|
437 url = self.path2url(path) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
438 url2 = url |
491
b71507d7becc
svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents:
489
diff
changeset
|
439 url2 = (other_path and self.path2url(other_path) or url) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
440 if other_rev is None: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
441 other_rev = revision - 1 |
81
85dcea81f22b
SubversionRepo: close files before rmtree() in diff3
Patrick Mezard <pmezard@gmail.com>
parents:
77
diff
changeset
|
442 old_cwd = os.getcwd() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
443 tmpdir = tempfile.mkdtemp('svnwrap_temp') |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
444 out, err = None, None |
66
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
445 try: |
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
446 # hot tip: the swig bridge doesn't like StringIO for these bad boys |
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
447 out_path = os.path.join(tmpdir, 'diffout') |
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
448 error_path = os.path.join(tmpdir, 'differr') |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
449 out = open(out_path, 'w') |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
450 err = open(error_path, 'w') |
81
85dcea81f22b
SubversionRepo: close files before rmtree() in diff3
Patrick Mezard <pmezard@gmail.com>
parents:
77
diff
changeset
|
451 try: |
85dcea81f22b
SubversionRepo: close files before rmtree() in diff3
Patrick Mezard <pmezard@gmail.com>
parents:
77
diff
changeset
|
452 client.diff3([], url2, optrev(other_rev), url, optrev(revision), |
85dcea81f22b
SubversionRepo: close files before rmtree() in diff3
Patrick Mezard <pmezard@gmail.com>
parents:
77
diff
changeset
|
453 True, True, deleted, ignore_type, 'UTF-8', out, err, |
85dcea81f22b
SubversionRepo: close files before rmtree() in diff3
Patrick Mezard <pmezard@gmail.com>
parents:
77
diff
changeset
|
454 self.client_context, self.pool) |
667
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
455 except SubversionException, e: |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
456 # "Can't write to stream: The handle is invalid." |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
457 # This error happens systematically under Windows, possibly |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
458 # related to file handles being non-write shareable by default. |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
459 if e.apr_err != 720006: |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
460 raise |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
461 self.hasdiff3 = False |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
462 raise common.SubversionRepoCanNotDiff() |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
463 out.close() |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
464 err.close() |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
465 out, err = None, None |
66
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
466 assert len(open(error_path).read()) == 0 |
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
467 diff = open(out_path).read() |
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
468 return diff |
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
469 finally: |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
470 if out: out.close() |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
471 if err: err.close() |
66
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
472 shutil.rmtree(tmpdir) |
81
85dcea81f22b
SubversionRepo: close files before rmtree() in diff3
Patrick Mezard <pmezard@gmail.com>
parents:
77
diff
changeset
|
473 os.chdir(old_cwd) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
474 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
475 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
|
476 """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
|
477 |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
478 "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
|
479 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
|
480 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
|
481 IOError. |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
482 """ |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
491
diff
changeset
|
483 assert not path.startswith('/') |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
484 mode = '' |
66
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
485 try: |
122
04c92c2c4501
SubversionRepo: work around ra.get_files() not releasing input buffer
Patrick Mezard <pmezard@gmail.com>
parents:
97
diff
changeset
|
486 out = cStringIO.StringIO() |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
487 info = ra.get_file(self.ra, path, revision, out) |
122
04c92c2c4501
SubversionRepo: work around ra.get_files() not releasing input buffer
Patrick Mezard <pmezard@gmail.com>
parents:
97
diff
changeset
|
488 data = out.getvalue() |
04c92c2c4501
SubversionRepo: work around ra.get_files() not releasing input buffer
Patrick Mezard <pmezard@gmail.com>
parents:
97
diff
changeset
|
489 out.close() |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
490 if isinstance(info, list): |
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
491 info = info[-1] |
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
492 mode = ("svn:executable" in info) and 'x' or '' |
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
493 mode = ("svn:special" in info) and 'l' or mode |
667
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
494 except SubversionException, e: |
74
450d5d9d3b80
SubversionRepo: do not use temporary file in get_file()
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
495 notfound = (core.SVN_ERR_FS_NOT_FOUND, |
450d5d9d3b80
SubversionRepo: do not use temporary file in get_file()
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
496 core.SVN_ERR_RA_DAV_PATH_NOT_FOUND) |
531
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
511
diff
changeset
|
497 if e.args[1] in notfound: # File not found |
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
511
diff
changeset
|
498 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
|
499 raise |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
500 if mode == 'l': |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
501 linkprefix = "link " |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
502 if data.startswith(linkprefix): |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
503 data = data[len(linkprefix):] |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
504 return data, mode |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
505 |
172
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
506 def list_props(self, path, revision): |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
507 """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
|
508 specified path does not exist. |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
509 """ |
180
3f1e8a5ec9dd
svn_swig_wrapper: hacky workaround to prevent running out of files in stupid
Augie Fackler <durin42@gmail.com>
parents:
175
diff
changeset
|
510 self.init_ra_and_client() |
75
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
511 rev = optrev(revision) |
489
cd793ca555af
svnwrap: properly escape URLs before giving them to libsvn_*
Chema Cortes <pych3m4@gmail.com>
parents:
467
diff
changeset
|
512 rpath = self.path2url(path) |
172
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
513 try: |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
514 pl = client.proplist2(rpath, rev, rev, False, |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
515 self.client_context, self.pool) |
667
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
516 except SubversionException, e: |
172
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
517 # Specified path does not exist at this revision |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
518 if e.apr_err == core.SVN_ERR_NODE_UNKNOWN_KIND: |
531
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
511
diff
changeset
|
519 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
|
520 raise |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
521 if not pl: |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
522 return {} |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
523 return pl[0][1] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
524 |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
525 def list_files(self, dirpath, revision): |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
526 """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
|
527 |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
528 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
|
529 '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
|
530 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
|
531 revision. |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
532 """ |
489
cd793ca555af
svnwrap: properly escape URLs before giving them to libsvn_*
Chema Cortes <pych3m4@gmail.com>
parents:
467
diff
changeset
|
533 rpath = self.path2url(dirpath) |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
534 pool = core.Pool() |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
535 rev = optrev(revision) |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
536 try: |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
537 entries = client.ls(rpath, rev, True, self.client_context, pool) |
667
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
538 except SubversionException, e: |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
539 if e.apr_err == core.SVN_ERR_FS_NOT_FOUND: |
531
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
511
diff
changeset
|
540 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
|
541 '%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
|
542 raise |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
543 for path, e in entries.iteritems(): |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
544 kind = _svntypes.get(e.kind) |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
545 yield path, kind |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
546 |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
547 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
|
548 """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
|
549 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
|
550 """ |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
551 kind = ra.check_path(self.ra, path.strip('/'), revision) |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
552 return _svntypes.get(kind) |
489
cd793ca555af
svnwrap: properly escape URLs before giving them to libsvn_*
Chema Cortes <pych3m4@gmail.com>
parents:
467
diff
changeset
|
553 |
491
b71507d7becc
svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents:
489
diff
changeset
|
554 def path2url(self, path): |
b71507d7becc
svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents:
489
diff
changeset
|
555 """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
|
556 """ |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
491
diff
changeset
|
557 if not path or path == '.': |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
491
diff
changeset
|
558 return self.svn_url |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
491
diff
changeset
|
559 assert path[0] != '/', path |
489
cd793ca555af
svnwrap: properly escape URLs before giving them to libsvn_*
Chema Cortes <pych3m4@gmail.com>
parents:
467
diff
changeset
|
560 return '/'.join((self.svn_url, |
491
b71507d7becc
svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents:
489
diff
changeset
|
561 urllib.quote(path).rstrip('/'), |
489
cd793ca555af
svnwrap: properly escape URLs before giving them to libsvn_*
Chema Cortes <pych3m4@gmail.com>
parents:
467
diff
changeset
|
562 )) |