~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix/SvnClient.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
using MonoDevelop.VersionControl.Subversion.Gui;
10
10
using System.Text;
11
11
 
 
12
using svn_revnum_t = System.Int32;
 
13
using size_t = System.Int32;
 
14
 
12
15
namespace MonoDevelop.VersionControl.Subversion.Unix
13
16
{
14
17
        class SvnClient : SubversionVersionControl
15
18
        {
16
 
                static LibSvnClient svn;
17
 
                static LibApr apr;
18
 
                static bool isInstallChecked;
19
 
                
20
 
                bool disposed  = false;
21
 
                IntPtr auth_baton;
22
 
                IntPtr pool;
23
 
                IntPtr ctx;
24
 
                
25
 
                object sync = new object();
26
 
                bool inProgress = false;
27
 
                
28
 
                IProgressMonitor updatemonitor;
29
 
                ArrayList updateFileList;
30
 
                string commitmessage = null;
31
 
                
32
 
                ArrayList lockFileList;
33
 
                LibSvnClient.NotifyLockState requiredLockState;
34
 
                
35
 
                // retain this so the delegates aren't GC'ed
36
 
                LibSvnClient.svn_client_ctx_t ctxstruct;
37
 
                
38
 
                static void CheckInstalled ()
39
 
                {
40
 
                        isInstallChecked = true;
41
 
                        
 
19
                internal static LibApr apr;
 
20
                static Lazy<bool> isInstalled;
 
21
                internal static LibSvnClient svn;
 
22
 
 
23
                internal static void CheckError (IntPtr error)
 
24
                {
 
25
                        CheckError (error, null);
 
26
                }
 
27
 
 
28
                public static void CheckError (IntPtr error, int? allowedError)
 
29
                {
 
30
                        string msg = null;
 
31
                        while (error != IntPtr.Zero) {
 
32
                                LibSvnClient.svn_error_t error_t = (LibSvnClient.svn_error_t) Marshal.PtrToStructure (error, typeof (LibSvnClient.svn_error_t));
 
33
                                if (allowedError.HasValue && error_t.apr_err == allowedError.Value)
 
34
                                        return;
 
35
 
 
36
                                if (msg != null)
 
37
                                        msg += "\n" + GetErrorMessage (error_t);
 
38
                                else
 
39
                                        msg = GetErrorMessage (error_t);
 
40
                                error = error_t.svn_error_t_child;
 
41
 
 
42
                                if (msg == null)
 
43
                                        msg = GettextCatalog.GetString ("Unknown error");
 
44
 
 
45
                                throw new SubversionException (msg);
 
46
                        }
 
47
                }
 
48
                
 
49
                static string GetErrorMessage (LibSvnClient.svn_error_t error)
 
50
                {
 
51
                        if (error.message != null)
 
52
                                return error.message;
 
53
                        else {
 
54
                                byte[] buf = new byte [300];
 
55
                                svn.strerror (error.apr_err, buf, buf.Length);
 
56
                                return Encoding.UTF8.GetString (buf);
 
57
                        }
 
58
                }
 
59
 
 
60
                internal static IntPtr newpool (IntPtr parent)
 
61
                {
 
62
                        IntPtr p;
 
63
                        apr.pool_create_ex (out p, parent, IntPtr.Zero, IntPtr.Zero);
 
64
                        if (p == IntPtr.Zero)
 
65
                                throw new InvalidOperationException ("Could not create an APR pool.");
 
66
                        return p;
 
67
                }
 
68
                
 
69
                public static string NormalizePath (string pathOrUrl, IntPtr localpool)
 
70
                {
 
71
                        if (pathOrUrl == null)
 
72
                                return null;
 
73
                        IntPtr res = svn.path_internal_style (pathOrUrl, localpool);
 
74
                        return Marshal.PtrToStringAnsi (res);
 
75
                }
 
76
 
 
77
                static bool CheckInstalled ()
 
78
                {
42
79
                        // libsvn_client may be linked to libapr-0 or libapr-1, and we need to bind the LibApr class
43
80
                        // the the same library. The following code detects the required libapr version and loads it. 
44
81
                        int aprver = GetLoadAprLib (-1);
45
82
                        svn = LibSvnClient.GetLib ();
46
83
                        if (svn == null) {
47
84
                                LoggingService.LogWarning ("Subversion addin could not load libsvn_client, so it will be disabled.");
48
 
                                return;
 
85
                                return false;
49
86
                        }
50
87
                        aprver = GetLoadAprLib (aprver);
51
88
                        if (aprver != -1)
54
91
                        if (apr == null) {
55
92
                                svn = null;
56
93
                                LoggingService.LogInfo ("Subversion addin could not load libapr, so it will be disabled.");
57
 
                        }
58
 
                }
59
 
                
60
 
                public override bool IsInstalled {
61
 
                        get {
62
 
                                if (!isInstallChecked)
63
 
                                        CheckInstalled ();
64
 
                                return svn != null;
65
 
                        }
 
94
                                return false;
 
95
                        }
 
96
                        return true;
66
97
                }
67
98
                
68
99
                static int GetLoadAprLib (int oldVersion)
84
115
                                return oldVersion;
85
116
                        }
86
117
                }
87
 
                
88
 
                private static IntPtr newpool (IntPtr parent)
89
 
                {
90
 
                        IntPtr p;
91
 
                        apr.pool_create_ex (out p, parent, IntPtr.Zero, IntPtr.Zero);
92
 
                        if (p == IntPtr.Zero)
93
 
                                throw new InvalidOperationException ("Could not create an APR pool.");
94
 
                        return p;
95
 
                }
96
 
                
 
118
 
97
119
                public override string Id {
98
120
                        get {
99
121
                                return "MonoDevelop.VersionControl.Subversion.SubversionVersionControl";
100
122
                        }
101
123
                }
102
124
 
 
125
                public override bool IsInstalled {
 
126
                        get { return isInstalled.Value; }
 
127
                }
 
128
 
 
129
                static SvnClient ()
 
130
                {
 
131
                        isInstalled = new Lazy<bool> (CheckInstalled);
 
132
                }
 
133
 
 
134
                public override SubversionBackend CreateBackend ()
 
135
                {
 
136
                        return new UnixSvnBackend ();
 
137
                }
 
138
 
 
139
                public override string GetPathUrl (FilePath path)
 
140
                {
 
141
                        if (path == FilePath.Null)
 
142
                                throw new ArgumentNullException();
 
143
 
 
144
                        IntPtr ret = IntPtr.Zero;
 
145
                        IntPtr localpool = newpool (IntPtr.Zero);
 
146
                        try {
 
147
                                string npath = NormalizePath (path, localpool);
 
148
                                CheckError (svn.client_url_from_path (ref ret, npath, localpool));
 
149
                        } finally {
 
150
                                apr.pool_destroy (localpool);
 
151
                        }
 
152
 
 
153
                        if (ret == IntPtr.Zero)
 
154
                                return null;
 
155
 
 
156
                        return Marshal.PtrToStringAnsi (ret);
 
157
                }
 
158
        }
 
159
 
 
160
        class UnixSvnBackend : SubversionBackend
 
161
        {
 
162
                protected static LibApr apr {
 
163
                        get { return SvnClient.apr; }
 
164
                }
103
165
                
104
 
                public SvnClient ()
105
 
                {
106
 
                        if (!IsInstalled)
107
 
                                return;
108
 
                        
 
166
                protected static LibSvnClient svn {
 
167
                        get { return SvnClient.svn; }
 
168
                }
 
169
 
 
170
                static void CheckError (IntPtr error)
 
171
                {
 
172
                        SvnClient.CheckError (error);
 
173
                }
 
174
 
 
175
                static void CheckError (IntPtr error, int? allowedError)
 
176
                {
 
177
                        SvnClient.CheckError (error, allowedError);
 
178
                }
 
179
 
 
180
                static IntPtr newpool (IntPtr parent)
 
181
                {
 
182
                        return SvnClient.newpool (parent);
 
183
                }
 
184
 
 
185
                bool disposed  = false;
 
186
                IntPtr auth_baton;
 
187
                IntPtr pool;
 
188
                IntPtr ctx;
 
189
 
 
190
                object sync = new object();
 
191
                bool inProgress = false;
 
192
 
 
193
                IProgressMonitor updatemonitor;
 
194
                ArrayList updateFileList;
 
195
                string commitmessage = null;
 
196
 
 
197
                ArrayList lockFileList;
 
198
                LibSvnClient.NotifyLockState requiredLockState;
 
199
 
 
200
                // retain this so the delegates aren't GC'ed
 
201
                LibSvnClient.svn_client_ctx_t ctxstruct;
 
202
 
 
203
                static bool IsBinary (byte[] buffer, long length)
 
204
                {
 
205
                        length = (int)Math.Min (50 * 1024, length);
 
206
                        for (int i = 0; i < length; i ++)
 
207
                                if (buffer [i] == 0)
 
208
                                        return true;
 
209
                        return false;
 
210
                }
 
211
 
 
212
                public UnixSvnBackend ()
 
213
                {
109
214
                        // Allocate the APR pool and the SVN client context.
110
215
                        pool = newpool (IntPtr.Zero);
111
216
 
138
243
                        // Load user and system configuration
139
244
                        svn.config_get_config (ref ctxstruct.config, null, pool);
140
245
                        
141
 
                        IntPtr providers = apr.array_make (pool, 1, IntPtr.Size);
 
246
                        IntPtr providers = apr.array_make (pool, 16, IntPtr.Size);
142
247
                        IntPtr item;
143
248
                        
144
249
                        // The main disk-caching auth providers, for both
146
251
                        
147
252
                        item = apr.array_push (providers);
148
253
                        svn.client_get_simple_provider (item, pool);
149
 
                        
 
254
 
150
255
                        item = apr.array_push (providers);
151
256
                        svn.client_get_username_provider (item, pool);
152
257
                        
164
269
                        // Two basic prompt providers: username/password, and just username.
165
270
 
166
271
                        item = apr.array_push (providers);
167
 
                        svn.client_get_simple_prompt_provider (item, new LibSvnClient.svn_auth_simple_prompt_func_t (OnAuthSimplePrompt), IntPtr.Zero, 2, pool);
 
272
                        svn.client_get_simple_prompt_provider (item, OnAuthSimplePromptCallback, IntPtr.Zero, 2, pool);
168
273
                        
169
274
                        item = apr.array_push (providers);
170
 
                        svn.client_get_username_prompt_provider (item, new LibSvnClient.svn_auth_username_prompt_func_t (OnAuthUsernamePrompt), IntPtr.Zero, 2, pool);
 
275
                        svn.client_get_username_prompt_provider (item, OnAuthUsernamePromptCallback, IntPtr.Zero, 2, pool);
171
276
                        
172
277
                        // Three ssl prompt providers, for server-certs, client-certs,
173
278
                        // and client-cert-passphrases.
174
279
                        
175
280
                        item = apr.array_push (providers);
176
 
                        svn.client_get_ssl_server_trust_prompt_provider (item, new LibSvnClient.svn_auth_ssl_server_trust_prompt_func_t (OnAuthSslServerTrustPrompt), IntPtr.Zero, pool);
177
 
                        
178
 
                        item = apr.array_push (providers);
179
 
                        svn.client_get_ssl_client_cert_prompt_provider (item, new LibSvnClient.svn_auth_ssl_client_cert_prompt_func_t (OnAuthSslClientCertPrompt), IntPtr.Zero, 2, pool);
180
 
                        
181
 
                        item = apr.array_push (providers);
182
 
                        svn.client_get_ssl_client_cert_pw_prompt_provider (item, new LibSvnClient.svn_auth_ssl_client_cert_pw_prompt_func_t (OnAuthSslClientCertPwPrompt), IntPtr.Zero, 2, pool);
 
281
                        svn.client_get_ssl_server_trust_prompt_provider (item, OnAuthSslServerTrustPromptCallback, IntPtr.Zero, pool);
 
282
                        
 
283
                        item = apr.array_push (providers);
 
284
                        svn.client_get_ssl_client_cert_prompt_provider (item, OnAuthSslClientCertPromptCallback, IntPtr.Zero, 2, pool);
 
285
                        
 
286
                        item = apr.array_push (providers);
 
287
                        svn.client_get_ssl_client_cert_pw_prompt_provider (item, OnAuthSslClientCertPwPromptCallback, IntPtr.Zero, 2, pool);
183
288
                        
184
289
                        // Create the authentication baton                      
185
290
                        
198
303
                        }
199
304
                }
200
305
                
201
 
                ~SvnClient ()
 
306
                ~UnixSvnBackend ()
202
307
                {
203
308
                        Dispose ();
204
309
                }
215
320
                        error.pool = localpool;
216
321
                        return apr.pcalloc (localpool, error);
217
322
                }
218
 
                
219
 
                static IntPtr OnAuthSimplePrompt (ref IntPtr cred, IntPtr baton, [MarshalAs (UnmanagedType.LPStr)] string realm, [MarshalAs (UnmanagedType.LPStr)] string user_name, [MarshalAs (UnmanagedType.SysInt)] int may_save, IntPtr pool)
 
323
 
 
324
                static LibSvnClient.svn_auth_simple_prompt_func_t OnAuthSimplePromptCallback = OnAuthSimplePrompt;
 
325
                static IntPtr OnAuthSimplePrompt (ref IntPtr cred, IntPtr baton, string realm, string user_name, bool may_save, IntPtr pool)
220
326
                {
221
327
                        LibSvnClient.svn_auth_cred_simple_t data = new LibSvnClient.svn_auth_cred_simple_t ();
222
328
                        bool ms;
223
 
                        if (SimpleAuthenticationPrompt (realm, may_save != 0, ref data.username, out data.password, out ms)) {
224
 
                                data.may_save = ms ? 1 : 0;
 
329
                        if (SimpleAuthenticationPrompt (realm, may_save, ref data.username, out data.password, out ms)) {
 
330
                                data.may_save = ms;
225
331
                                cred = apr.pcalloc (pool, data);
226
332
                                return IntPtr.Zero;
227
333
                        } else {
228
334
                                data.password = "";
229
335
                                data.username = "";
230
 
                                data.may_save = 0;
 
336
                                data.may_save = false;
231
337
                                cred = apr.pcalloc (pool, data);
232
338
                                return GetCancelError ();
233
339
                        }
234
340
                }
235
 
                
236
 
                static IntPtr OnAuthUsernamePrompt (ref IntPtr cred, IntPtr baton, [MarshalAs (UnmanagedType.LPStr)] string realm, [MarshalAs (UnmanagedType.SysInt)] int may_save, IntPtr pool)
 
341
 
 
342
                static LibSvnClient.svn_auth_username_prompt_func_t OnAuthUsernamePromptCallback = OnAuthUsernamePrompt;
 
343
                static IntPtr OnAuthUsernamePrompt (ref IntPtr cred, IntPtr baton, string realm, bool may_save, IntPtr pool)
237
344
                {
238
345
                        LibSvnClient.svn_auth_cred_username_t data = new LibSvnClient.svn_auth_cred_username_t ();
239
346
                        data.username = "";
240
347
                        bool ms;
241
 
                        if (UserNameAuthenticationPrompt (realm, may_save != 0, ref data.username, out ms)) {
242
 
                                data.may_save = ms ? 1 : 0;
 
348
                        if (UserNameAuthenticationPrompt (realm, may_save, ref data.username, out ms)) {
 
349
                                data.may_save = ms;
243
350
                                cred = apr.pcalloc (pool, data);
244
351
                                return IntPtr.Zero;
245
352
                        } else {
246
353
                                data.username = "";
247
 
                                data.may_save = 0;
 
354
                                data.may_save = false;
248
355
                                cred = apr.pcalloc (pool, data);
249
356
                                return GetCancelError ();
250
357
                        }
251
358
                }
252
 
                
253
 
                static IntPtr OnAuthSslServerTrustPrompt (ref IntPtr cred, IntPtr baton, [MarshalAs (UnmanagedType.LPStr)] string realm, uint failures, ref LibSvnClient.svn_auth_ssl_server_cert_info_t cert_info, [MarshalAs (UnmanagedType.SysInt)] int may_save, IntPtr pool)
 
359
 
 
360
                static LibSvnClient.svn_auth_ssl_server_trust_prompt_func_t OnAuthSslServerTrustPromptCallback = OnAuthSslServerTrustPrompt;
 
361
                static IntPtr OnAuthSslServerTrustPrompt (ref IntPtr cred, IntPtr baton, string realm, uint failures, ref LibSvnClient.svn_auth_ssl_server_cert_info_t cert_info, bool may_save, IntPtr pool)
254
362
                {
255
363
                        LibSvnClient.svn_auth_cred_ssl_server_trust_t data = new LibSvnClient.svn_auth_cred_ssl_server_trust_t ();
256
364
                        
264
372
 
265
373
                        SslFailure accepted_failures;
266
374
                        bool ms;
267
 
                        if (SslServerTrustAuthenticationPrompt (realm, (SslFailure) failures, may_save != 0, ci, out accepted_failures, out ms) && accepted_failures != SslFailure.None) {
268
 
                                data.may_save = ms ? 1 : 0;
 
375
                        if (SslServerTrustAuthenticationPrompt (realm, (SslFailure) failures, may_save, ci, out accepted_failures, out ms) && accepted_failures != SslFailure.None) {
 
376
                                data.may_save = ms ;
269
377
                                data.accepted_failures = (uint) accepted_failures;
270
378
                                cred = apr.pcalloc (pool, data);
271
379
                                return IntPtr.Zero;
272
380
                        } else {
273
381
                                data.accepted_failures = 0;
274
 
                                data.may_save = 0;
 
382
                                data.may_save = false;
275
383
                                cred = apr.pcalloc (pool, data);
276
384
                                return GetCancelError ();
277
385
                        }
278
386
                }
279
 
                
280
 
                static IntPtr OnAuthSslClientCertPrompt (ref IntPtr cred, IntPtr baton, [MarshalAs (UnmanagedType.LPStr)] string realm, [MarshalAs (UnmanagedType.SysInt)] int may_save, IntPtr pool)
 
387
 
 
388
                static LibSvnClient.svn_auth_ssl_client_cert_prompt_func_t OnAuthSslClientCertPromptCallback = OnAuthSslClientCertPrompt;
 
389
                static IntPtr OnAuthSslClientCertPrompt (ref IntPtr cred, IntPtr baton, string realm, bool may_save, IntPtr pool)
281
390
                {
282
391
                        LibSvnClient.svn_auth_cred_ssl_client_cert_t data = new LibSvnClient.svn_auth_cred_ssl_client_cert_t ();
283
392
                        bool ms;
284
 
                        if (SslClientCertAuthenticationPrompt (realm, may_save != 0, out data.cert_file, out ms)) {
285
 
                                data.may_save = ms ? 1 : 0;
 
393
                        if (SslClientCertAuthenticationPrompt (realm, may_save, out data.cert_file, out ms)) {
 
394
                                data.may_save = ms;
286
395
                                cred = apr.pcalloc (pool, data);
287
396
                                return IntPtr.Zero;
288
397
                        } else {
289
398
                                data.cert_file = "";
290
 
                                data.may_save = 0;
 
399
                                data.may_save = false;
291
400
                                cred = apr.pcalloc (pool, data);
292
401
                                return GetCancelError ();
293
402
                        }
294
403
                }
295
 
                
296
 
                static IntPtr OnAuthSslClientCertPwPrompt (ref IntPtr cred, IntPtr baton, [MarshalAs (UnmanagedType.LPStr)] string realm, [MarshalAs (UnmanagedType.SysInt)] int may_save, IntPtr pool)
 
404
 
 
405
                static LibSvnClient.svn_auth_ssl_client_cert_pw_prompt_func_t OnAuthSslClientCertPwPromptCallback = OnAuthSslClientCertPwPrompt;
 
406
                static IntPtr OnAuthSslClientCertPwPrompt (ref IntPtr cred, IntPtr baton, string realm, bool may_save, IntPtr pool)
297
407
                {
298
408
                        LibSvnClient.svn_auth_cred_ssl_client_cert_pw_t data;
299
409
                        bool ms;
300
 
                        if (SslClientCertPwAuthenticationPrompt (realm, may_save != 0, out data.password, out ms)) {
301
 
                                data.may_save = ms ? 1 : 0;
 
410
                        if (SslClientCertPwAuthenticationPrompt (realm, may_save, out data.password, out ms)) {
 
411
                                data.may_save = ms;
302
412
                                cred = apr.pcalloc (pool, data);
303
413
                                return IntPtr.Zero;
304
414
                        } else {
305
415
                                data.password = "";
306
 
                                data.may_save = 0;
 
416
                                data.may_save = false;
307
417
                                cred = apr.pcalloc (pool, data);
308
418
                                return GetCancelError ();
309
419
                        }
316
426
                        IntPtr ptr = svn.client_version ();
317
427
                        LibSvnClient.svn_version_t ver = (LibSvnClient.svn_version_t) Marshal.PtrToStructure (ptr, typeof (LibSvnClient.svn_version_t));                                
318
428
                        return ver.major + "." + ver.minor + "." + ver.patch;
319
 
                }
320
 
 
 
429
                }
 
430
 
321
431
                public override IEnumerable<DirectoryEntry> List (FilePath path, bool recurse, SvnRevision rev)
322
432
                {
323
433
                        return ListUrl (path, recurse, rev);
324
434
                }
325
435
                
326
 
                string NormalizePath (string pathOrUrl, IntPtr localpool)
 
436
                static string NormalizePath (string pathOrUrl, IntPtr localpool)
327
437
                {
328
 
                        if (pathOrUrl == null)
329
 
                                return null;
330
 
                        IntPtr res = svn.path_internal_style (pathOrUrl, localpool);
331
 
                        return Marshal.PtrToStringAnsi (res);
 
438
                        return SvnClient.NormalizePath (pathOrUrl, localpool);
332
439
                }
333
440
                
334
441
                public override IEnumerable<DirectoryEntry> ListUrl (string pathorurl, bool recurse, SvnRevision rev)
335
442
                {
336
443
                        if (pathorurl == null)
337
444
                                throw new ArgumentNullException ();
338
 
                        
 
445
 
 
446
                        TryStartOperation ();
339
447
                        LibSvnClient.Rev revision = (LibSvnClient.Rev) rev;
340
448
                        IntPtr localpool = newpool (pool);
341
449
                        List<DirectoryEntry> items = new List<DirectoryEntry> ();
359
467
                                        
360
468
                                        DirectoryEntry dent = new DirectoryEntry ();
361
469
                                        dent.Name = name;
362
 
                                        dent.IsDirectory = (ent.kind.ToInt32 () == (int) LibSvnClient.NodeKind.Dir);
 
470
                                        dent.IsDirectory = ent.kind == LibSvnClient.svn_node_kind_t.Dir;
363
471
                                        dent.Size = ent.size;
364
 
                                        dent.HasProps = ent.has_props != 0;
365
 
                                        dent.CreatedRevision = ent.created_rev;
 
472
                                        dent.HasProps = ent.has_props;
 
473
                                        dent.CreatedRevision = (int) ent.created_rev;
366
474
                                        dent.Time = new DateTime (1970, 1, 1).AddTicks(ent.time * 10);
367
475
                                        dent.LastAuthor = ent.last_author;
368
476
                                        items.Add (dent);
369
477
                                }
370
478
                        } finally {
371
479
                                apr.pool_destroy (localpool);
 
480
                                TryEndOperation ();
372
481
                        }
373
482
                        
374
483
                        return items;
383
492
                        ArrayList ret = new ArrayList ();
384
493
                        
385
494
                        StatusCollector collector = new StatusCollector (ret);
386
 
                        
 
495
 
 
496
                        TryStartOperation ();
387
497
                        IntPtr localpool = newpool (pool);
388
498
                        try {
389
499
                                string pathorurl = NormalizePath (path, localpool);
390
 
                                
391
500
                                CheckError (svn.client_status (IntPtr.Zero, pathorurl, ref revision,
392
 
                                                               new LibSvnClient.svn_wc_status_func_t (collector.Func),
393
 
                                                               IntPtr.Zero, descendDirs ? 1 : 0, 
394
 
                                                               changedItemsOnly ? 0 : 1, 
395
 
                                                               remoteStatus ? 1 : 0, 1,
 
501
                                                               collector.Func,
 
502
                                                               IntPtr.Zero, descendDirs, 
 
503
                                                               !changedItemsOnly, 
 
504
                                                               remoteStatus,
 
505
                                                               false,
 
506
                                                               false,
396
507
                                                               ctx, localpool));
397
508
                        } finally {
398
509
                                apr.pool_destroy (localpool);
 
510
                                TryEndOperation ();
399
511
                        }
400
 
                        
 
512
 
 
513
                        List<VersionInfo> nodes = new List<VersionInfo>();
401
514
                        foreach (LibSvnClient.StatusEnt ent in ret)
402
 
                                yield return CreateNode (ent, repo);
 
515
                                nodes.Add (CreateNode (ent, repo));
 
516
                        return nodes;
403
517
                }
404
518
 
405
519
                public override IEnumerable<SvnRevision> Log (Repository repo, FilePath path, SvnRevision revStart, SvnRevision revEnd)
409
523
                        
410
524
                        LibSvnClient.Rev revisionStart = (LibSvnClient.Rev) revStart;
411
525
                        LibSvnClient.Rev revisionEnd = (LibSvnClient.Rev) revEnd;
412
 
                        
 
526
 
 
527
                        TryStartOperation ();
 
528
 
413
529
                        List<SvnRevision> ret = new List<SvnRevision> ();
414
530
                        IntPtr localpool = newpool (pool);
415
531
                        IntPtr strptr = IntPtr.Zero;
423
539
                                LogCollector collector = new LogCollector ((SubversionRepository)repo, ret);
424
540
                                
425
541
                                CheckError (svn.client_log (array, ref revisionStart, ref revisionEnd, 1, 0,
426
 
                                                            new LibSvnClient.svn_log_message_receiver_t (collector.Func),
 
542
                                                            collector.Func,
427
543
                                                            IntPtr.Zero, ctx, localpool));
428
544
                        } finally {
429
545
                                if (strptr != IntPtr.Zero)
430
546
                                        Marshal.FreeHGlobal (strptr);
431
547
                                apr.pool_destroy (localpool);
 
548
                                TryEndOperation ();
432
549
                        }
433
550
                        
434
551
                        return ret;
448
565
                        AnnotationCollector collector = new AnnotationCollector (annotations);
449
566
                        
450
567
                        IntPtr localpool = newpool (pool);
451
 
                        
 
568
 
 
569
                        TryStartOperation ();
452
570
                        try {
453
571
                                string path = NormalizePath (file.FullPath, localpool);
454
 
                                CheckError (svn.client_blame (path, ref revisionStart, ref revisionEnd, new LibSvnClient.svn_client_blame_receiver_t (collector.Func), IntPtr.Zero, ctx, localpool));
 
572
                                CheckError (svn.client_blame (path, ref revisionStart, ref revisionEnd, collector.Func, IntPtr.Zero, ctx, localpool));
455
573
                        } finally {
456
574
                                apr.pool_destroy (localpool);
 
575
                                TryEndOperation ();
457
576
                        }
458
577
                        
459
578
                        return annotations;
460
579
                }
461
 
 
462
 
                public override string GetPathUrl (FilePath path)
463
 
                {
464
 
                        if (path == FilePath.Null)
465
 
                                throw new ArgumentNullException();
466
 
                        
467
 
                        IntPtr ret = IntPtr.Zero;
468
 
                        IntPtr localpool = newpool (pool);
469
 
                        try {
470
 
                                string npath = NormalizePath (path, localpool);
471
 
                                CheckError (svn.client_url_from_path (ref ret, npath, localpool));
472
 
                        } finally {
473
 
                                apr.pool_destroy (localpool);
474
 
                        }
475
 
                        
476
 
                        if (ret == IntPtr.Zero)
477
 
                                return null;
478
 
                        
479
 
                        return Marshal.PtrToStringAnsi (ret);
480
 
                }
481
 
                
 
580
 
482
581
                public override string GetTextAtRevision (string pathorurl, Revision revision)
483
582
                {
484
583
                        MemoryStream memstream = new MemoryStream ();
485
584
                        Cat (pathorurl, (SvnRevision) revision, memstream);
486
 
                        
 
585
 
 
586
                        var buffer = memstream.GetBuffer ();
487
587
                        try {
488
 
                                return System.Text.Encoding.UTF8.GetString (memstream.GetBuffer ());
 
588
                                if (IsBinary (buffer, memstream.Length))
 
589
                                        return null;
 
590
                                return System.Text.Encoding.UTF8.GetString (buffer, 0, (int) memstream.Length);
489
591
                        } catch {
490
592
                        }
491
593
                        
492
 
                        return System.Text.Encoding.ASCII.GetString (memstream.GetBuffer ());
 
594
                        return System.Text.Encoding.ASCII.GetString (buffer, 0, (int) memstream.Length);
493
595
                }
494
596
                
495
597
                public void Cat (string pathorurl, SvnRevision rev, Stream stream)
497
599
                        if (pathorurl == null || stream == null)
498
600
                                throw new ArgumentNullException ();
499
601
                
 
602
                        TryStartOperation ();
500
603
                        LibSvnClient.Rev revision = (LibSvnClient.Rev) rev;
501
604
                        
502
605
                        IntPtr localpool = newpool (pool);
504
607
                                pathorurl = NormalizePath (pathorurl, localpool);
505
608
                                StreamCollector collector = new StreamCollector (stream);
506
609
                                IntPtr svnstream = svn.stream_create (IntPtr.Zero, localpool);
507
 
                                svn.stream_set_write (svnstream, new LibSvnClient.svn_readwrite_fn_t (collector.Func));
 
610
                                svn.stream_set_write (svnstream, collector.Func);
508
611
                                LibSvnClient.Rev peg_revision = LibSvnClient.Rev.Blank;
509
 
                                CheckError (svn.client_cat2 (svnstream, pathorurl, ref peg_revision, ref revision, ctx, localpool));
 
612
                                CheckError (svn.client_cat2 (svnstream, pathorurl, ref peg_revision, ref revision, ctx, localpool), 195007);
510
613
                        } finally {
511
614
                                apr.pool_destroy (localpool);
 
615
                                TryEndOperation ();
512
616
                        }
513
617
                }
514
618
 
517
621
                        if (path == FilePath.Null || monitor == null)
518
622
                                throw new ArgumentNullException();
519
623
                        
520
 
                        lock (sync) {
521
 
                                if (inProgress)
522
 
                                        throw new SubversionException("Another Subversion operation is already in progress.");
523
 
                                inProgress = true;
524
 
                        }
 
624
                        TryStartOperation ();
525
625
                        
526
626
                        updatemonitor = monitor;
527
627
                        updateFileList = new ArrayList ();
530
630
                        IntPtr localpool = newpool (pool);
531
631
                        try {
532
632
                                string pathorurl = NormalizePath (path, localpool);
533
 
                                CheckError (svn.client_update (IntPtr.Zero, pathorurl, ref rev, recurse ? 1 : 0, ctx, localpool));
 
633
                                CheckError (svn.client_update (IntPtr.Zero, pathorurl, ref rev, recurse, ctx, localpool));
534
634
                        } finally {
535
635
                                foreach (string file in updateFileList)
536
636
                                        FileService.NotifyFileChanged (file);
538
638
                                
539
639
                                apr.pool_destroy (localpool);
540
640
                                updatemonitor = null;
541
 
                                inProgress = false;
 
641
                                TryEndOperation ();
542
642
                        }
543
643
                }
544
644
 
547
647
                        if (paths == null || monitor == null)
548
648
                                throw new ArgumentNullException();
549
649
                        
550
 
                        lock (sync) {
551
 
                                if (inProgress)
552
 
                                        throw new SubversionException("Another Subversion operation is already in progress.");
553
 
                                inProgress = true;
554
 
                        }
 
650
                        TryStartOperation ();
555
651
                        
556
652
                        updatemonitor = monitor;
557
653
                        IntPtr localpool = newpool (pool);
569
665
                        } finally {
570
666
                                apr.pool_destroy (localpool);
571
667
                                updatemonitor = null;
572
 
                                inProgress = false;
 
668
                                TryEndOperation ();
573
669
                        }
574
670
                }
575
671
 
578
674
                        if (path == FilePath.Null || monitor == null)
579
675
                                throw new ArgumentNullException();
580
676
                        
581
 
                        lock (sync) {
582
 
                                if (inProgress)
583
 
                                        throw new SubversionException("Another Subversion operation is already in progress.");
584
 
                                inProgress = true;
585
 
                        }
 
677
                        TryStartOperation ();
586
678
                        
587
679
                        updatemonitor = monitor;
588
680
                        IntPtr localpool = newpool (pool);
593
685
                        } finally {
594
686
                                apr.pool_destroy (localpool);
595
687
                                updatemonitor = null;
596
 
                                inProgress = false;
 
688
                                TryEndOperation ();
597
689
                        }
598
690
                }
599
691
 
601
693
                {
602
694
                        if (path == FilePath.Null || monitor == null)
603
695
                                throw new ArgumentNullException ();
604
 
                        
605
 
                        lock (sync) {
606
 
                                if (inProgress)
607
 
                                        throw new SubversionException ("Another Subversion operation is already in progress.");
608
 
                                inProgress = true;
609
 
                        }
 
696
 
 
697
                        TryStartOperation ();
 
698
 
610
699
                        nb = new notify_baton ();
611
700
                        updatemonitor = monitor;
612
701
                        IntPtr localpool = newpool (pool);
616
705
                        } finally {
617
706
                                apr.pool_destroy (localpool);
618
707
                                updatemonitor = null;
619
 
                                inProgress = false;
 
708
                                TryEndOperation ();
620
709
                        }
621
710
                }
622
711
 
629
718
                                revision = SvnRevision.Head;
630
719
                        LibSvnClient.Rev rev = (LibSvnClient.Rev) revision;
631
720
                        
632
 
                        lock (sync) {
633
 
                                if (inProgress)
634
 
                                        throw new SubversionException ("Another Subversion operation is already in progress.");
635
 
                                inProgress = true;
636
 
                        }
 
721
                        TryStartOperation ();
637
722
                        nb = new notify_baton ();
638
723
                        updatemonitor = monitor;
639
 
                        IntPtr result_rev = IntPtr.Zero;
640
724
                        IntPtr localpool = newpool (pool);
641
725
                        try {
642
726
                                // Using Uri here because the normalization method doesn't remove the redundant port number when using https
643
727
                                url = NormalizePath (new Uri(url).ToString(), localpool);
644
728
                                string npath = NormalizePath (path, localpool);
645
 
                                CheckError (svn.client_checkout (result_rev, url, npath, ref rev, (recurse ? 1 :0), ctx, localpool));
 
729
                                CheckError (svn.client_checkout (IntPtr.Zero, url, npath, ref rev, recurse, ctx, localpool));
646
730
                        } finally {
647
731
                                apr.pool_destroy (localpool);
648
732
                                updatemonitor = null;
649
 
                                inProgress = false;
 
733
                                TryEndOperation ();
650
734
                        }
651
735
                }
652
736
 
655
739
                        if (paths == null || message == null || monitor == null)
656
740
                                throw new ArgumentNullException();
657
741
                        
658
 
                        lock (sync) {
659
 
                                if (inProgress)
660
 
                                        throw new SubversionException ("Another Subversion operation is already in progress.");
661
 
                                inProgress = true;
662
 
                        }
 
742
                        TryStartOperation ();
663
743
                        
664
744
                        nb = new notify_baton ();
665
745
                        updatemonitor = monitor;
689
769
                                commitmessage = null;
690
770
                                updatemonitor = null;
691
771
                                apr.pool_destroy (localpool);
692
 
                                inProgress = false;
 
772
                                TryEndOperation ();
693
773
                        }
694
774
                }
695
775
 
698
778
                        if (paths == null || monitor == null)
699
779
                                throw new ArgumentNullException ();
700
780
                
701
 
                        lock (sync) {
702
 
                                if (inProgress)
703
 
                                        throw new SubversionException ("Another Subversion operation is already in progress.");
704
 
                                inProgress = true;
705
 
                        }
 
781
                        TryStartOperation ();
706
782
 
707
783
                        nb = new notify_baton ();
708
784
                        updatemonitor = monitor;
725
801
                                commitmessage = null;
726
802
                                updatemonitor = null;
727
803
                                apr.pool_destroy (localpool);
728
 
                                inProgress = false;
 
804
                                TryEndOperation ();
729
805
                        }
730
806
                }
731
807
 
734
810
                        if (path == FilePath.Null || monitor == null)
735
811
                                throw new ArgumentNullException ();
736
812
                        
737
 
                        lock (sync) {
738
 
                                if (inProgress)
739
 
                                        throw new SubversionException ("Another Subversion operation is already in progress.");
740
 
                                inProgress = true;
741
 
                        }
 
813
                        TryStartOperation ();
742
814
                        
743
815
                        nb = new notify_baton ();
744
816
                        updatemonitor = monitor;
758
830
                                commitmessage = null;
759
831
                                updatemonitor = null;
760
832
                                apr.pool_destroy (localpool);
761
 
                                inProgress = false;
 
833
                                TryEndOperation ();
762
834
                        }
763
835
                }
764
836
 
769
841
                        
770
842
                        LibSvnClient.Rev revision = (LibSvnClient.Rev) rev;
771
843
                        
772
 
                        lock (sync) {
773
 
                                if (inProgress)
774
 
                                        throw new SubversionException ("Another Subversion operation is already in progress.");
775
 
                                inProgress = true;
776
 
                        }
 
844
                        TryStartOperation ();
777
845
                        
778
846
                        nb = new notify_baton ();
779
847
                        updatemonitor = monitor;
787
855
                        } finally {
788
856
                                apr.pool_destroy (localpool);
789
857
                                updatemonitor = null;
790
 
                                inProgress = false;
 
858
                                TryEndOperation ();
791
859
                        }
792
860
                }
793
861
 
794
862
                public override void Lock (IProgressMonitor monitor, string comment, bool stealLock, params FilePath[] paths)
795
863
                {
796
 
                        lock (sync) {
797
 
                                if (inProgress)
798
 
                                        throw new SubversionException ("Another Subversion operation is already in progress.");
799
 
                                inProgress = true;
800
 
                        }
 
864
                        TryStartOperation ();
801
865
                        
802
866
                        IntPtr localpool = newpool (pool);
803
867
                        IntPtr array = apr.array_make (localpool, 0, IntPtr.Size);
820
884
                                apr.pool_destroy (localpool);
821
885
                                lockFileList = null;
822
886
                                updatemonitor = null;
823
 
                                inProgress = false;
 
887
                                TryEndOperation ();
824
888
                        }
825
889
                }
826
890
                
827
891
                public override void Unlock (IProgressMonitor monitor, bool breakLock, params FilePath[] paths)
828
892
                {
829
 
                        lock (sync) {
830
 
                                if (inProgress)
831
 
                                        throw new SubversionException ("Another Subversion operation is already in progress.");
832
 
                                inProgress = true;
833
 
                        }
 
893
                        TryStartOperation ();
834
894
                        
835
895
                        IntPtr localpool = newpool (pool);
836
896
                        IntPtr array = apr.array_make (localpool, 0, IntPtr.Size);
853
913
                                apr.pool_destroy (localpool);
854
914
                                lockFileList = null;
855
915
                                updatemonitor = null;
856
 
                                inProgress = false;
 
916
                                TryEndOperation ();
857
917
                        }
858
918
                }
859
919
 
860
920
                public override string GetUnifiedDiff (FilePath path1, SvnRevision rev1, FilePath path2, SvnRevision rev2, bool recursive)
861
921
                {
 
922
                        TryStartOperation ();
 
923
 
862
924
                        IntPtr localpool = newpool (pool);
863
925
                        IntPtr outfile = IntPtr.Zero;
864
926
                        IntPtr errfile = IntPtr.Zero;
903
965
                                                FileService.DeleteFile (ferr);
904
966
                                        if (fout != null)
905
967
                                                FileService.DeleteFile (fout);
 
968
 
 
969
                                        TryEndOperation ();
906
970
                                } catch {}
907
971
                        }
908
972
                }
920
984
                
921
985
                private void Merge (string path, LibSvnClient.Rev revision1, LibSvnClient.Rev revision2)
922
986
                {
 
987
                        TryStartOperation ();
 
988
 
923
989
                        IntPtr localpool = newpool (pool);
924
990
                        try {
925
991
                                path = NormalizePath (path, localpool);
935
1001
                        }
936
1002
                        finally {
937
1003
                                apr.pool_destroy (localpool);
 
1004
                                TryEndOperation ();
938
1005
                        }
939
 
                        return;
940
1006
                }
941
1007
                
942
1008
                IntPtr svn_client_get_commit_log_impl (ref IntPtr log_msg, ref IntPtr tmp_file,
946
1012
                        tmp_file = IntPtr.Zero;
947
1013
                        return IntPtr.Zero;
948
1014
                }
949
 
                
950
 
                internal static void CheckError (IntPtr error)
951
 
                {
952
 
                        if (error == IntPtr.Zero)
953
 
                                return;
954
 
                        
955
 
                        string msg = null;
956
 
                        while (error != IntPtr.Zero) {
957
 
                                LibSvnClient.svn_error_t error_t = (LibSvnClient.svn_error_t) Marshal.PtrToStructure (error, typeof (LibSvnClient.svn_error_t));
958
 
                                if (msg != null)
959
 
                                        msg += "\n" + GetErrorMessage (error_t);
960
 
                                else
961
 
                                        msg = GetErrorMessage (error_t);
962
 
                                error = error_t.svn_error_t_child;
963
 
                        }
964
 
                        
965
 
                        if (msg == null)
966
 
                                msg = GettextCatalog.GetString ("Unknown error");
967
 
                        
968
 
                        throw new SubversionException (msg);
969
 
                }
970
 
                
971
 
                static string GetErrorMessage (LibSvnClient.svn_error_t error)
972
 
                {
973
 
                        if (error.message != null)
974
 
                                return error.message;
975
 
                        else {
976
 
                                byte[] buf = new byte [300];
977
 
                                svn.strerror (error.apr_err, buf, buf.Length);
978
 
                                return Encoding.UTF8.GetString (buf);
979
 
                        }
980
 
                }
981
 
                
 
1015
 
 
1016
                void TryStartOperation ()
 
1017
                {
 
1018
                        lock (sync) {
 
1019
                                Console.WriteLine ("*************************************");
 
1020
                                Console.WriteLine (Environment.StackTrace);
 
1021
                                Console.WriteLine ("*************************************");
 
1022
                                if (inProgress)
 
1023
                                        throw new SubversionException ("Another Subversion operation is already in progress.");
 
1024
                                inProgress = true;
 
1025
                        }
 
1026
                }
 
1027
 
 
1028
                void TryEndOperation ()
 
1029
                {
 
1030
                        lock (sync) {
 
1031
                                if (!inProgress)
 
1032
                                        throw new SubversionException ("No Subversion operation is in progress.");
 
1033
                                inProgress = false;
 
1034
                        }
 
1035
                }
 
1036
 
982
1037
                private VersionInfo CreateNode (LibSvnClient.StatusEnt ent, Repository repo) 
983
1038
                {
984
1039
                        VersionStatus rs = VersionStatus.Unversioned;
985
1040
                        Revision rr = null;
986
1041
                        
987
 
                        if (ent.RemoteTextStatus != LibSvnClient.VersionStatus.EMPTY) {
 
1042
                        if (ent.RemoteTextStatus != LibSvnClient.svn_wc_status_kind.EMPTY) {
988
1043
                                rs = ConvertStatus (LibSvnClient.NodeSchedule.Normal, ent.RemoteTextStatus);
989
1044
                                rr = new SvnRevision (repo, ent.LastCommitRevision, ent.LastCommitDate,
990
1045
                                                      ent.LastCommitAuthor, "(unavailable)", null);
1009
1064
                        return ret;
1010
1065
                }
1011
1066
                
1012
 
                private VersionStatus ConvertStatus (LibSvnClient.NodeSchedule schedule, LibSvnClient.VersionStatus status) {
 
1067
                private VersionStatus ConvertStatus (LibSvnClient.NodeSchedule schedule, LibSvnClient.svn_wc_status_kind status) {
1013
1068
                        switch (schedule) {
1014
1069
                                case LibSvnClient.NodeSchedule.Add: return VersionStatus.Versioned | VersionStatus.ScheduledAdd;
1015
1070
                                case LibSvnClient.NodeSchedule.Delete: return VersionStatus.Versioned | VersionStatus.ScheduledDelete;
1017
1072
                        }
1018
1073
                        
1019
1074
                        switch (status) {
1020
 
                                case LibSvnClient.VersionStatus.None: return VersionStatus.Versioned;
1021
 
                                case LibSvnClient.VersionStatus.Normal: return VersionStatus.Versioned;
1022
 
                                case LibSvnClient.VersionStatus.Unversioned: return VersionStatus.Unversioned;
1023
 
                                case LibSvnClient.VersionStatus.Modified: return VersionStatus.Versioned | VersionStatus.Modified;
1024
 
                                case LibSvnClient.VersionStatus.Merged: return VersionStatus.Versioned | VersionStatus.Modified;
1025
 
                                case LibSvnClient.VersionStatus.Conflicted: return VersionStatus.Versioned | VersionStatus.Conflicted;
1026
 
                                case LibSvnClient.VersionStatus.Ignored: return VersionStatus.Unversioned | VersionStatus.Ignored;
1027
 
                                case LibSvnClient.VersionStatus.Obstructed: return VersionStatus.Versioned;
1028
 
                                case LibSvnClient.VersionStatus.Added: return VersionStatus.Versioned | VersionStatus.ScheduledAdd;
1029
 
                                case LibSvnClient.VersionStatus.Deleted: return VersionStatus.Versioned | VersionStatus.ScheduledDelete;
1030
 
                                case LibSvnClient.VersionStatus.Replaced: return VersionStatus.Versioned | VersionStatus.ScheduledReplace;
 
1075
                        case LibSvnClient.svn_wc_status_kind.None: return VersionStatus.Versioned;
 
1076
                        case LibSvnClient.svn_wc_status_kind.Normal: return VersionStatus.Versioned;
 
1077
                        case LibSvnClient.svn_wc_status_kind.Unversioned: return VersionStatus.Unversioned;
 
1078
                        case LibSvnClient.svn_wc_status_kind.Modified: return VersionStatus.Versioned | VersionStatus.Modified;
 
1079
                        case LibSvnClient.svn_wc_status_kind.Merged: return VersionStatus.Versioned | VersionStatus.Modified;
 
1080
                        case LibSvnClient.svn_wc_status_kind.Conflicted: return VersionStatus.Versioned | VersionStatus.Conflicted;
 
1081
                        case LibSvnClient.svn_wc_status_kind.Ignored: return VersionStatus.Unversioned | VersionStatus.Ignored;
 
1082
                        case LibSvnClient.svn_wc_status_kind.Obstructed: return VersionStatus.Versioned;
 
1083
                        case LibSvnClient.svn_wc_status_kind.Added: return VersionStatus.Versioned | VersionStatus.ScheduledAdd;
 
1084
                        case LibSvnClient.svn_wc_status_kind.Deleted: return VersionStatus.Versioned | VersionStatus.ScheduledDelete;
 
1085
                        case LibSvnClient.svn_wc_status_kind.Replaced: return VersionStatus.Versioned | VersionStatus.ScheduledReplace;
1031
1086
                        }
1032
1087
                        
1033
1088
                        return VersionStatus.Unversioned;
1226
1281
                
1227
1282
                public class StatusCollector {
1228
1283
                        ArrayList statuses;
1229
 
                        
1230
 
                        public StatusCollector (ArrayList statuses) { this.statuses = statuses; }
1231
 
                        
1232
 
                        public void Func (IntPtr baton, IntPtr path, ref LibSvnClient.svn_wc_status_t status)
 
1284
 
 
1285
                        public LibSvnClient.svn_wc_status_func2_t Func {
 
1286
                                get; private set;
 
1287
                        }
 
1288
 
 
1289
                        public StatusCollector (ArrayList statuses)
 
1290
                        {
 
1291
                                this.statuses = statuses;
 
1292
                                Func = CollectorFunc;
 
1293
                        }
 
1294
                        
 
1295
                        void CollectorFunc (IntPtr baton, IntPtr path, IntPtr statusPtr)
1233
1296
                        {
1234
1297
                                string pathstr = Marshal.PtrToStringAnsi (path);
1235
1298
                                /*if (status.to_svn_wc_entry_t == IntPtr.Zero)
1236
1299
                                        return;
1237
1300
                                 */
 
1301
                                var status = (LibSvnClient.svn_wc_status2_t) Marshal.PtrToStructure (statusPtr, typeof (LibSvnClient.svn_wc_status2_t));
1238
1302
                                statuses.Add (new LibSvnClient.StatusEnt (status, pathstr));
1239
1303
                        }
1240
1304
                }
1245
1309
                        
1246
1310
                        List<SvnRevision> logs;
1247
1311
                        SubversionRepository repo;
1248
 
                        
1249
 
                        public LogCollector (SubversionRepository repo, List<SvnRevision> logs) { this.repo = repo; this.logs = logs; }
1250
 
                        
1251
 
                        public IntPtr Func (IntPtr baton, IntPtr apr_hash_changed_paths, int revision, IntPtr author, IntPtr date, IntPtr message, IntPtr pool)
 
1312
 
 
1313
                        public LibSvnClient.svn_log_message_receiver_t Func {
 
1314
                                get; private set;
 
1315
                        }
 
1316
 
 
1317
                        public LogCollector (SubversionRepository repo, List<SvnRevision> logs) {
 
1318
                                this.repo = repo;
 
1319
                                this.logs = logs;
 
1320
                                Func = CollectorFunc;
 
1321
                        }
 
1322
 
 
1323
                        IntPtr CollectorFunc (IntPtr baton, IntPtr apr_hash_changed_paths, svn_revnum_t revision, IntPtr author, IntPtr date, IntPtr message, IntPtr pool)
1252
1324
                        {
1253
1325
                                long time;
1254
1326
                                svn.time_from_cstring (out time, Marshal.PtrToStringAnsi (date), pool);
1288
1360
                                                items.Add (new RevisionPath (Marshal.PtrToStringAnsi (result) + "/" + name, ac, ""));
1289
1361
                                }
1290
1362
                                
1291
 
                                SvnRevision ent = new SvnRevision (null, revision, Epoch.AddTicks (time * 10), Marshal.PtrToStringAnsi (author), smessage, items.ToArray ());
 
1363
                                SvnRevision ent = new SvnRevision (null, (int) revision, Epoch.AddTicks (time * 10), Marshal.PtrToStringAnsi (author), smessage, items.ToArray ());
1292
1364
                                logs.Add (ent);
1293
1365
                                
1294
1366
                                return IntPtr.Zero;
1297
1369
                
1298
1370
                public class StreamCollector {
1299
1371
                        Stream buf;
1300
 
                        
1301
 
                        public StreamCollector (Stream buf) { this.buf = buf; }
1302
 
                        
1303
 
                        public IntPtr Func (IntPtr baton, IntPtr data, ref IntPtr len)
 
1372
 
 
1373
                        public LibSvnClient.svn_readwrite_fn_t Func {
 
1374
                                get; private set;
 
1375
                        }
 
1376
 
 
1377
                        public StreamCollector (Stream buf) {
 
1378
                                this.buf = buf;
 
1379
                                Func = CollectorFunc;
 
1380
                        }
 
1381
                        
 
1382
                        IntPtr CollectorFunc (IntPtr baton, IntPtr data, ref size_t len)
1304
1383
                        {
1305
1384
                                unsafe {
1306
1385
                                        byte *bp = (byte *) data;
1320
1399
                private class AnnotationCollector
1321
1400
                {
1322
1401
                        Annotation[] annotations;
1323
 
                        
 
1402
                        public LibSvnClient.svn_client_blame_receiver_t Func {
 
1403
                                get; private set;
 
1404
                        }
 
1405
 
1324
1406
                        /// <summary>
1325
1407
                        /// A svn_client_blame_receiver_t implementation.
1326
1408
                        /// </summary>
1327
 
                        public IntPtr Func (IntPtr baton, long line_no, int revision, string author, string date, string line, IntPtr pool)
 
1409
                        IntPtr CollectorFunc (IntPtr baton, long line_no, svn_revnum_t revision, string author, string date, string line, IntPtr pool)
1328
1410
                        {
1329
1411
                                if (line_no < annotations.Length) {
1330
1412
                                        DateTime tdate;
1342
1424
                        public AnnotationCollector (Annotation[] annotations)
1343
1425
                        {
1344
1426
                                this.annotations = annotations;
 
1427
                                Func = CollectorFunc;
1345
1428
                        }
1346
1429
                }
1347
1430