Mercurial > hgsubversion
annotate svnwrap/svn_swig_wrapper.py @ 281:8ff0b3261b7f
util: drop 1.2 support in the encoding swap.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Fri, 24 Apr 2009 21:07:59 -0500 |
parents | 25d843281127 |
children | ce676eff002b |
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 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 import os |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 import shutil |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 import sys |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 import tempfile |
235
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
7 import urlparse |
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 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
9 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
10 from svn import client |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
11 from svn import core |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 from svn import delta |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
13 from svn import ra |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 |
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
|
15 def version(): |
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
|
16 return '%d.%d.%d' % (core.SVN_VER_MAJOR, core.SVN_VER_MINOR, core.SVN_VER_MICRO) |
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
|
17 |
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
|
18 if (core.SVN_VER_MAJOR, core.SVN_VER_MINOR, core.SVN_VER_MICRO) < (1, 5, 0): #pragma: no cover |
50
80b923ab242b
Drop any pretense of supporting svn 1.4.x.
Augie Fackler <durin42@gmail.com>
parents:
47
diff
changeset
|
19 raise ImportError, 'You must have Subversion 1.5.0 or newer and matching SWIG bindings.' |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
21 class SubversionRepoCanNotReplay(Exception): |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
22 """Exception raised when the svn server is too old to have replay. |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
23 """ |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
24 |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
25 class SubversionRepoCanNotDiff(Exception): |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
26 """Exception raised when the svn API diff3() command cannot be used |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
27 """ |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
28 |
75
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
29 def optrev(revnum): |
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
30 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
|
31 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
|
32 optrev.value.number = revnum |
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
33 return optrev |
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
34 |
50
80b923ab242b
Drop any pretense of supporting svn 1.4.x.
Augie Fackler <durin42@gmail.com>
parents:
47
diff
changeset
|
35 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
|
36 class RaCallbacks(ra.Callbacks): |
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
|
37 def open_tmp_file(self, 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
|
38 (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
|
39 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
|
40 return fn |
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
41 |
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
|
42 def get_client_string(self, pool): |
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
|
43 return 'hgsubversion' |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 |
50
80b923ab242b
Drop any pretense of supporting svn 1.4.x.
Augie Fackler <durin42@gmail.com>
parents:
47
diff
changeset
|
45 |
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
|
46 def user_pass_prompt(realm, default_username, ms, pool): #pragma: no cover |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
47 creds = core.svn_auth_cred_simple_t() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 creds.may_save = ms |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 if default_username: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
50 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
|
51 creds.username = default_username |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
53 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
|
54 sys.stderr.write('Username: ') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
55 sys.stderr.flush() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
56 creds.username = sys.stdin.readline().strip() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
57 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
|
58 return creds |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
59 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
60 def _create_auth_baton(pool): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
61 """Create a Subversion authentication baton. """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
62 # 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
|
63 # providers.h |
92
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
64 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
|
65 '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
|
66 '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
|
67 '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
|
68 '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
|
69 '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
|
70 '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
|
71 '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
|
72 '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
|
73 ] |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
74 |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
75 providers = [] |
272
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
76 # Platform-dependant authentication methods |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
77 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
|
78 None) |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
79 if getprovider: |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
80 # 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
|
81 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
|
82 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
|
83 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
|
84 if p: |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
85 providers.append(p) |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
86 else: |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
87 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
|
88 if hasattr(core, p): |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
89 try: |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
90 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
|
91 except RuntimeError: |
25d843281127
Use svn 1.6 platform specific auth providers if available
Patrick Mezard <pmezard@gmail.com>
parents:
266
diff
changeset
|
92 pass |
92
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
93 |
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
94 providers += [ |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
95 client.get_simple_provider(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
96 client.get_username_provider(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
97 client.get_ssl_client_cert_file_provider(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
98 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
|
99 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
|
100 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
|
101 ] |
92
7486c6f6cccc
svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents:
89
diff
changeset
|
102 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
103 return core.svn_auth_open(providers, pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
104 |
235
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
105 def parse_url(url): |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
106 """Parse a URL and return a tuple (username, password, url) |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
107 """ |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
108 scheme, netloc, path, params, query, fragment = urlparse.urlparse(url) |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
109 user, passwd = None, None |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
110 if '@' in netloc: |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
111 userpass, netloc = netloc.split('@') |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
112 if ':' in userpass: |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
113 user, passwd = userpass.split(':') |
238
e8b3ca865f93
Fix a boneheaded mistake I made when I touched up a previous patch.
Augie Fackler <durin42@gmail.com>
parents:
235
diff
changeset
|
114 user, passwd = urllib.unquote(user) or None, urllib.unquote(passwd) or None |
235
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
115 else: |
238
e8b3ca865f93
Fix a boneheaded mistake I made when I touched up a previous patch.
Augie Fackler <durin42@gmail.com>
parents:
235
diff
changeset
|
116 user = urllib.unquote(userpass) or None |
235
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
117 url = urlparse.urlunparse((scheme, netloc, path, params, query, fragment)) |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
118 return (user, passwd, url) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
119 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
120 class Revision(object): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
121 """Wrapper for a Subversion revision. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
122 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
123 def __init__(self, revnum, author, message, date, paths, strip_path=''): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
124 self.revnum, self.author, self.message = revnum, author, message |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
125 self.date = date |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
126 self.paths = {} |
20
2953c867ca99
Minor fixes to the push command to make it more robust.
Augie Fackler <durin42@gmail.com>
parents:
10
diff
changeset
|
127 if paths: |
2953c867ca99
Minor fixes to the push command to make it more robust.
Augie Fackler <durin42@gmail.com>
parents:
10
diff
changeset
|
128 for p in paths: |
2953c867ca99
Minor fixes to the push command to make it more robust.
Augie Fackler <durin42@gmail.com>
parents:
10
diff
changeset
|
129 self.paths[p[len(strip_path):]] = paths[p] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
130 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
131 def __str__(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
132 return 'r%d by %s' % (self.revnum, self.author) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
133 |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
134 _svntypes = { |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
135 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
|
136 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
|
137 } |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
138 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
139 class SubversionRepo(object): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
140 """Wrapper for a Subversion repository. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
141 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
142 This uses the SWIG Python bindings, and will only work on svn >= 1.4. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
143 It takes a required param, the URL. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
144 """ |
234
33e885f5f86a
Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents:
233
diff
changeset
|
145 def __init__(self, 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
|
146 parsed = parse_url(url) |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
147 # --username and --password override URL credentials |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
148 self.username = username or parsed[0] |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
149 self.password = password or parsed[1] |
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
234
diff
changeset
|
150 self.svn_url = parsed[2] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
151 self.auth_baton_pool = core.Pool() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
152 self.auth_baton = _create_auth_baton(self.auth_baton_pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
153 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
154 self.init_ra_and_client() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
155 self.uuid = ra.get_uuid(self.ra, self.pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
156 repo_root = ra.get_repos_root(self.ra, self.pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
157 # *will* have a leading '/', would not if we used get_repos_root2 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
158 self.subdir = url[len(repo_root):] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
159 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
|
160 self.subdir += '/' |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
161 self.hasdiff3 = True |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
162 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
163 def init_ra_and_client(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
164 """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
|
165 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
|
166 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
167 # 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
|
168 self.pool = core.Pool() |
233
80a700398995
Fix SubversionRepo to actually use provided username
Daniel Tang <dytang@cs.purdue.edu>
parents:
228
diff
changeset
|
169 if self.username: |
80a700398995
Fix SubversionRepo to actually use provided username
Daniel Tang <dytang@cs.purdue.edu>
parents:
228
diff
changeset
|
170 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
|
171 core.SVN_AUTH_PARAM_DEFAULT_USERNAME, |
80a700398995
Fix SubversionRepo to actually use provided username
Daniel Tang <dytang@cs.purdue.edu>
parents:
228
diff
changeset
|
172 self.username) |
234
33e885f5f86a
Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents:
233
diff
changeset
|
173 if self.password: |
33e885f5f86a
Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents:
233
diff
changeset
|
174 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
|
175 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
|
176 self.password) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
177 self.client_context = client.create_context() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
178 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
179 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
|
180 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
|
181 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
|
182 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
|
183 self.callbacks = callbacks |
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
|
184 self.ra = ra.open2(self.svn_url.encode('utf-8'), callbacks, |
50
80b923ab242b
Drop any pretense of supporting svn 1.4.x.
Augie Fackler <durin42@gmail.com>
parents:
47
diff
changeset
|
185 svn_config, self.pool) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
186 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
187 def HEAD(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
188 return ra.get_latest_revnum(self.ra, self.pool) |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
180
diff
changeset
|
189 HEAD = property(HEAD) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
190 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
191 def START(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
192 return 0 |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
180
diff
changeset
|
193 START = property(START) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
194 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
195 def branches(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
196 """Get the branches defined in this repo assuming a standard layout. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
197 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
198 branches = self.list_dir('branches').keys() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
199 branch_info = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
200 head=self.HEAD |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
201 for b in branches: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
202 b_path = 'branches/%s' %b |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
203 hist_gen = self.fetch_history_at_paths([b_path], stop=head) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
204 hist = hist_gen.next() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
205 source, source_rev = self._get_copy_source(b_path, cached_head=head) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
206 # This if statement guards against projects that have non-ancestral |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
207 # branches by not listing them has branches |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
208 # Note that they probably are really ancestrally related, but there |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
209 # is just no way for us to know how. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
210 if source is not None and source_rev is not None: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
211 branch_info[b] = (source, source_rev, hist.revnum) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
212 return branch_info |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
180
diff
changeset
|
213 branches = property(branches) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
214 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
215 def tags(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
216 """Get the current tags in this repo assuming a standard layout. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
217 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
218 This returns a dictionary of tag: (source path, source rev) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
219 """ |
155
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
122
diff
changeset
|
220 return self.tags_at_rev(self.HEAD) |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
180
diff
changeset
|
221 tags = property(tags) |
155
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
122
diff
changeset
|
222 |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
122
diff
changeset
|
223 def tags_at_rev(self, revision): |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
122
diff
changeset
|
224 try: |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
122
diff
changeset
|
225 tags = self.list_dir('tags', revision=revision).keys() |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
122
diff
changeset
|
226 except core.SubversionException, e: |
224
2165461d2dd8
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
196
diff
changeset
|
227 if e.apr_err == core.SVN_ERR_FS_NOT_FOUND: |
155
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
122
diff
changeset
|
228 return {} |
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
122
diff
changeset
|
229 raise |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
230 tag_info = {} |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
231 for t in tags: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
232 tag_info[t] = self._get_copy_source('tags/%s' % t, |
155
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
122
diff
changeset
|
233 cached_head=revision) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
234 return tag_info |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
235 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
236 def _get_copy_source(self, path, cached_head=None): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
237 """Get copy revision for the given path, assuming it was meant to be |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
238 a copy of the entire tree. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
239 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
240 if not cached_head: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
241 cached_head = self.HEAD |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
242 hist_gen = self.fetch_history_at_paths([path], stop=cached_head) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
243 hist = hist_gen.next() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
244 if hist.paths[path].copyfrom_path is None: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
245 return None, None |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
246 source = hist.paths[path].copyfrom_path |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
247 source_rev = 0 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
248 for p in hist.paths: |
215
b5ef9a404f5d
Stopped idiotic filtering of revisions that did not edit something branches/tags/trunk.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
249 if not p.startswith(path): |
b5ef9a404f5d
Stopped idiotic filtering of revisions that did not edit something branches/tags/trunk.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
250 continue |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
251 if hist.paths[p].copyfrom_rev: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
252 # We assume that the revision of the source tree as it was |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
253 # copied was actually the revision of the highest revision |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
254 # copied item. This could be wrong, but in practice it will |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
255 # *probably* be correct |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
256 if source_rev < hist.paths[p].copyfrom_rev: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
257 source_rev = hist.paths[p].copyfrom_rev |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
258 source = source[len(self.subdir):] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
259 return source, source_rev |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
260 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
261 def list_dir(self, dir, revision=None): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
262 """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
|
263 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
264 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
|
265 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
266 Args: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
267 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
|
268 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
|
269 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
270 if dir[-1] == '/': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
271 dir = dir[:-1] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
272 if revision is None: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
273 revision = self.HEAD |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
274 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
|
275 folders, props, junk = r |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
276 return folders |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
277 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
278 def revisions(self, start=None, chunk_size=1000): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
279 """Load the history of this repo. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
280 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
281 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
|
282 of revisions at a time. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
283 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
284 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
|
285 to perform RA calls to get deltas. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
286 """ |
215
b5ef9a404f5d
Stopped idiotic filtering of revisions that did not edit something branches/tags/trunk.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
287 return self.fetch_history_at_paths([''], start=start, |
b5ef9a404f5d
Stopped idiotic filtering of revisions that did not edit something branches/tags/trunk.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
288 chunk_size=chunk_size) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
289 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
290 def fetch_history_at_paths(self, paths, start=None, stop=None, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
291 chunk_size=1000): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
292 revisions = [] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
293 def callback(paths, revnum, author, date, message, pool): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
294 r = Revision(revnum, author, message, date, paths, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
295 strip_path=self.subdir) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
296 revisions.append(r) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
297 if not start: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
298 start = self.START |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
299 if not stop: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
300 stop = self.HEAD |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
301 while stop > start: |
50
80b923ab242b
Drop any pretense of supporting svn 1.4.x.
Augie Fackler <durin42@gmail.com>
parents:
47
diff
changeset
|
302 ra.get_log(self.ra, |
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
|
303 paths, |
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
|
304 start+1, |
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
|
305 stop, |
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
|
306 chunk_size, #limit of how many log messages to load |
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
|
307 True, # don't need to know changed paths |
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
|
308 True, # stop on copies |
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
|
309 callback, |
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
|
310 self.pool) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
311 if len(revisions) < chunk_size: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
312 # this means there was no history for the path, so force the |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
313 # loop to exit |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
314 start = stop |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
315 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
316 start = revisions[-1].revnum |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
317 while len(revisions) > 0: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
318 yield revisions[0] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
319 revisions.pop(0) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
320 |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
81
diff
changeset
|
321 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
|
322 deleteddirs, properties, copies): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
323 """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
|
324 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
325 self.init_ra_and_client() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
326 commit_info = [] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
327 def commit_cb(_commit_info, pool): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
328 commit_info.append(_commit_info) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
329 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
|
330 message, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
331 commit_cb, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
332 None, |
20
2953c867ca99
Minor fixes to the push command to make it more robust.
Augie Fackler <durin42@gmail.com>
parents:
10
diff
changeset
|
333 False, |
2953c867ca99
Minor fixes to the push command to make it more robust.
Augie Fackler <durin42@gmail.com>
parents:
10
diff
changeset
|
334 self.pool) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
335 checksum = [] |
46
f30cda3389c2
This appears to fix pushing over both the http and svn protocols.
Augie Fackler <durin42@gmail.com>
parents:
45
diff
changeset
|
336 # 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
|
337 # 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
|
338 batons = [edit_baton, ] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
339 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
|
340 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
|
341 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
|
342 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
|
343 return bat |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
81
diff
changeset
|
344 if path in deleteddirs: |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
81
diff
changeset
|
345 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
|
346 batons.append(bat) |
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
81
diff
changeset
|
347 return bat |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
348 if path not in file_data: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
349 if path in addeddirs: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
350 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
|
351 else: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
352 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
|
353 batons.append(bat) |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
354 props = properties.get(path, {}) |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
355 if 'svn:externals' in props: |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
356 value = props['svn:externals'] |
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
357 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
|
358 return bat |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
359 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
|
360 compute_delta = True |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
361 if action == 'modify': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
362 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
|
363 elif action == 'add': |
266 | 364 frompath, fromrev = copies.get(path, (None, -1)) |
365 if frompath: | |
366 frompath = self.svn_url + '/' + frompath | |
367 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
|
368 elif action == 'delete': |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
369 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
|
370 compute_delta = False |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
371 |
10
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
372 if path in properties: |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
373 if properties[path].get('svn:special', None): |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
374 new_text = 'link %s' % new_text |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
375 for p, v in properties[path].iteritems(): |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
376 editor.change_file_prop(baton, p, v) |
dfdc078661db
Auto-set executable, symlink, and auto-props.
Augie Fackler <durin42@gmail.com>
parents:
9
diff
changeset
|
377 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
378 if compute_delta: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
379 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
|
380 self.pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
381 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
382 txdelta_stream = delta.svn_txdelta( |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
383 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
|
384 self.pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
385 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
|
386 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
|
387 |
9738a7c4e3dd
fix svn push when there's just a file removal
Valentino Volonghi aka dialtone <valentino@adroll.com>
parents:
46
diff
changeset
|
388 # 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
|
389 editor.close_file(baton, None, pool) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
390 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
391 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
|
392 self.pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
393 editor.close_edit(edit_baton, self.pool) |
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 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
|
396 # 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
|
397 self.init_ra_and_client() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
398 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
|
399 try: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
400 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
|
401 e_baton, self.pool) |
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
|
402 except core.SubversionException, e: #pragma: no cover |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
403 # 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
|
404 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
|
405 e.apr_err == core.SVN_ERR_UNSUPPORTED_FEATURE): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
406 raise SubversionRepoCanNotReplay, ('This Subversion server ' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
407 'is older than 1.4.0, and cannot satisfy replay requests.') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
408 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
409 raise |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
410 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
411 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
|
412 deleted=True, ignore_type=False): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
413 """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
|
414 """ |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
415 if not self.hasdiff3: |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
416 raise SubversionRepoCanNotDiff() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
417 # 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
|
418 # 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
|
419 self.init_ra_and_client() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
420 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
421 assert path[0] != '/' |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
422 url = self.svn_url + '/' + path |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
423 url2 = url |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
424 if other_path is not None: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
425 url2 = self.svn_url + '/' + other_path |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
426 if other_rev is None: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
427 other_rev = revision - 1 |
81
85dcea81f22b
SubversionRepo: close files before rmtree() in diff3
Patrick Mezard <pmezard@gmail.com>
parents:
77
diff
changeset
|
428 old_cwd = os.getcwd() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
429 tmpdir = tempfile.mkdtemp('svnwrap_temp') |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
430 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
|
431 try: |
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
432 # 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
|
433 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
|
434 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
|
435 out = open(out_path, 'w') |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
436 err = open(error_path, 'w') |
81
85dcea81f22b
SubversionRepo: close files before rmtree() in diff3
Patrick Mezard <pmezard@gmail.com>
parents:
77
diff
changeset
|
437 try: |
85dcea81f22b
SubversionRepo: close files before rmtree() in diff3
Patrick Mezard <pmezard@gmail.com>
parents:
77
diff
changeset
|
438 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
|
439 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
|
440 self.client_context, self.pool) |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
441 except core.SubversionException, e: |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
442 # "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
|
443 # This error happens systematically under Windows, possibly |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
444 # 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
|
445 if e.apr_err != 720006: |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
446 raise |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
447 self.hasdiff3 = False |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
448 raise SubversionRepoCanNotDiff() |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
449 out.close() |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
450 err.close() |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
451 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
|
452 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
|
453 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
|
454 return diff |
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
455 finally: |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
456 if out: out.close() |
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
457 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
|
458 shutil.rmtree(tmpdir) |
81
85dcea81f22b
SubversionRepo: close files before rmtree() in diff3
Patrick Mezard <pmezard@gmail.com>
parents:
77
diff
changeset
|
459 os.chdir(old_cwd) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
460 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
461 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
|
462 """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
|
463 |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
464 "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
|
465 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
|
466 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
|
467 IOError. |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
468 """ |
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
469 mode = '' |
66
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
470 try: |
122
04c92c2c4501
SubversionRepo: work around ra.get_files() not releasing input buffer
Patrick Mezard <pmezard@gmail.com>
parents:
97
diff
changeset
|
471 out = cStringIO.StringIO() |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
472 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
|
473 data = out.getvalue() |
04c92c2c4501
SubversionRepo: work around ra.get_files() not releasing input buffer
Patrick Mezard <pmezard@gmail.com>
parents:
97
diff
changeset
|
474 out.close() |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
475 if isinstance(info, list): |
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
476 info = info[-1] |
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
477 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
|
478 mode = ("svn:special" in info) and 'l' or mode |
74
450d5d9d3b80
SubversionRepo: do not use temporary file in get_file()
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
479 except core.SubversionException, e: |
450d5d9d3b80
SubversionRepo: do not use temporary file in get_file()
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
480 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
|
481 core.SVN_ERR_RA_DAV_PATH_NOT_FOUND) |
450d5d9d3b80
SubversionRepo: do not use temporary file in get_file()
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
482 if e.apr_err in notfound: # File not found |
450d5d9d3b80
SubversionRepo: do not use temporary file in get_file()
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
483 raise IOError() |
450d5d9d3b80
SubversionRepo: do not use temporary file in get_file()
Patrick Mezard <pmezard@gmail.com>
parents:
70
diff
changeset
|
484 raise |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
485 if mode == 'l': |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
486 linkprefix = "link " |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
487 if data.startswith(linkprefix): |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
488 data = data[len(linkprefix):] |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
489 return data, mode |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
490 |
172
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
491 def list_props(self, path, revision): |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
492 """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
|
493 specified path does not exist. |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
494 """ |
180
3f1e8a5ec9dd
svn_swig_wrapper: hacky workaround to prevent running out of files in stupid
Augie Fackler <durin42@gmail.com>
parents:
175
diff
changeset
|
495 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
|
496 rev = optrev(revision) |
172
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
497 rpath = (self.svn_url + '/' + path.strip('/')).strip('/') |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
498 try: |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
499 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
|
500 self.client_context, self.pool) |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
501 except core.SubversionException, e: |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
502 # 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
|
503 if e.apr_err == core.SVN_ERR_NODE_UNKNOWN_KIND: |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
504 raise IOError() |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
505 raise |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
506 if not pl: |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
507 return {} |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
508 return pl[0][1] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
509 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
510 def fetch_all_files_to_dir(self, path, revision, checkout_path): |
75
cca31b6b1318
SubversionRepo: add optrev() to help generate client API revisions
Patrick Mezard <pmezard@gmail.com>
parents:
74
diff
changeset
|
511 rev = optrev(revision) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
512 client.export3(self.svn_url+'/'+path, checkout_path, rev, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
513 rev, True, True, True, 'LF', # should be 'CRLF' on win32 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
514 self.client_context, self.pool) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
515 |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
516 def list_files(self, dirpath, revision): |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
517 """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
|
518 |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
519 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
|
520 '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
|
521 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
|
522 revision. |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
523 """ |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
524 dirpath = dirpath.strip('/') |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
525 pool = core.Pool() |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
526 rpath = '/'.join([self.svn_url, dirpath]).strip('/') |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
527 rev = optrev(revision) |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
528 try: |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
529 entries = client.ls(rpath, rev, True, self.client_context, pool) |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
530 except core.SubversionException, e: |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
531 if e.apr_err == core.SVN_ERR_FS_NOT_FOUND: |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
532 raise IOError('%s cannot be found at r%d' % (dirpath, revision)) |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
533 raise |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
534 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
|
535 kind = _svntypes.get(e.kind) |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
536 yield path, kind |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
537 |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
538 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
|
539 """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
|
540 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
|
541 """ |
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
542 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
|
543 return _svntypes.get(kind) |