9
9
using MonoDevelop.VersionControl.Subversion.Gui;
12
using svn_revnum_t = System.Int32;
13
using size_t = System.Int32;
12
15
namespace MonoDevelop.VersionControl.Subversion.Unix
14
17
class SvnClient : SubversionVersionControl
16
static LibSvnClient svn;
18
static bool isInstallChecked;
20
bool disposed = false;
25
object sync = new object();
26
bool inProgress = false;
28
IProgressMonitor updatemonitor;
29
ArrayList updateFileList;
30
string commitmessage = null;
32
ArrayList lockFileList;
33
LibSvnClient.NotifyLockState requiredLockState;
35
// retain this so the delegates aren't GC'ed
36
LibSvnClient.svn_client_ctx_t ctxstruct;
38
static void CheckInstalled ()
40
isInstallChecked = true;
19
internal static LibApr apr;
20
static Lazy<bool> isInstalled;
21
internal static LibSvnClient svn;
23
internal static void CheckError (IntPtr error)
25
CheckError (error, null);
28
public static void CheckError (IntPtr error, int? allowedError)
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)
37
msg += "\n" + GetErrorMessage (error_t);
39
msg = GetErrorMessage (error_t);
40
error = error_t.svn_error_t_child;
43
msg = GettextCatalog.GetString ("Unknown error");
45
throw new SubversionException (msg);
49
static string GetErrorMessage (LibSvnClient.svn_error_t error)
51
if (error.message != null)
54
byte[] buf = new byte [300];
55
svn.strerror (error.apr_err, buf, buf.Length);
56
return Encoding.UTF8.GetString (buf);
60
internal static IntPtr newpool (IntPtr parent)
63
apr.pool_create_ex (out p, parent, IntPtr.Zero, IntPtr.Zero);
65
throw new InvalidOperationException ("Could not create an APR pool.");
69
public static string NormalizePath (string pathOrUrl, IntPtr localpool)
71
if (pathOrUrl == null)
73
IntPtr res = svn.path_internal_style (pathOrUrl, localpool);
74
return Marshal.PtrToStringAnsi (res);
77
static bool CheckInstalled ()
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 ();
47
84
LoggingService.LogWarning ("Subversion addin could not load libsvn_client, so it will be disabled.");
50
87
aprver = GetLoadAprLib (aprver);
84
115
return oldVersion;
88
private static IntPtr newpool (IntPtr parent)
91
apr.pool_create_ex (out p, parent, IntPtr.Zero, IntPtr.Zero);
93
throw new InvalidOperationException ("Could not create an APR pool.");
97
119
public override string Id {
99
121
return "MonoDevelop.VersionControl.Subversion.SubversionVersionControl";
125
public override bool IsInstalled {
126
get { return isInstalled.Value; }
131
isInstalled = new Lazy<bool> (CheckInstalled);
134
public override SubversionBackend CreateBackend ()
136
return new UnixSvnBackend ();
139
public override string GetPathUrl (FilePath path)
141
if (path == FilePath.Null)
142
throw new ArgumentNullException();
144
IntPtr ret = IntPtr.Zero;
145
IntPtr localpool = newpool (IntPtr.Zero);
147
string npath = NormalizePath (path, localpool);
148
CheckError (svn.client_url_from_path (ref ret, npath, localpool));
150
apr.pool_destroy (localpool);
153
if (ret == IntPtr.Zero)
156
return Marshal.PtrToStringAnsi (ret);
160
class UnixSvnBackend : SubversionBackend
162
protected static LibApr apr {
163
get { return SvnClient.apr; }
166
protected static LibSvnClient svn {
167
get { return SvnClient.svn; }
170
static void CheckError (IntPtr error)
172
SvnClient.CheckError (error);
175
static void CheckError (IntPtr error, int? allowedError)
177
SvnClient.CheckError (error, allowedError);
180
static IntPtr newpool (IntPtr parent)
182
return SvnClient.newpool (parent);
185
bool disposed = false;
190
object sync = new object();
191
bool inProgress = false;
193
IProgressMonitor updatemonitor;
194
ArrayList updateFileList;
195
string commitmessage = null;
197
ArrayList lockFileList;
198
LibSvnClient.NotifyLockState requiredLockState;
200
// retain this so the delegates aren't GC'ed
201
LibSvnClient.svn_client_ctx_t ctxstruct;
203
static bool IsBinary (byte[] buffer, long length)
205
length = (int)Math.Min (50 * 1024, length);
206
for (int i = 0; i < length; i ++)
212
public UnixSvnBackend ()
109
214
// Allocate the APR pool and the SVN client context.
110
215
pool = newpool (IntPtr.Zero);
138
243
// Load user and system configuration
139
244
svn.config_get_config (ref ctxstruct.config, null, pool);
141
IntPtr providers = apr.array_make (pool, 1, IntPtr.Size);
246
IntPtr providers = apr.array_make (pool, 16, IntPtr.Size);
144
249
// The main disk-caching auth providers, for both
164
269
// Two basic prompt providers: username/password, and just username.
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);
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);
172
277
// Three ssl prompt providers, for server-certs, client-certs,
173
278
// and client-cert-passphrases.
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);
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);
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);
283
item = apr.array_push (providers);
284
svn.client_get_ssl_client_cert_prompt_provider (item, OnAuthSslClientCertPromptCallback, IntPtr.Zero, 2, pool);
286
item = apr.array_push (providers);
287
svn.client_get_ssl_client_cert_pw_prompt_provider (item, OnAuthSslClientCertPwPromptCallback, IntPtr.Zero, 2, pool);
184
289
// Create the authentication baton
215
320
error.pool = localpool;
216
321
return apr.pcalloc (localpool, error);
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)
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)
221
327
LibSvnClient.svn_auth_cred_simple_t data = new LibSvnClient.svn_auth_cred_simple_t ();
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)) {
225
331
cred = apr.pcalloc (pool, data);
226
332
return IntPtr.Zero;
228
334
data.password = "";
229
335
data.username = "";
336
data.may_save = false;
231
337
cred = apr.pcalloc (pool, data);
232
338
return GetCancelError ();
236
static IntPtr OnAuthUsernamePrompt (ref IntPtr cred, IntPtr baton, [MarshalAs (UnmanagedType.LPStr)] string realm, [MarshalAs (UnmanagedType.SysInt)] int may_save, IntPtr pool)
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)
238
345
LibSvnClient.svn_auth_cred_username_t data = new LibSvnClient.svn_auth_cred_username_t ();
239
346
data.username = "";
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)) {
243
350
cred = apr.pcalloc (pool, data);
244
351
return IntPtr.Zero;
246
353
data.username = "";
354
data.may_save = false;
248
355
cred = apr.pcalloc (pool, data);
249
356
return GetCancelError ();
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)
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)
255
363
LibSvnClient.svn_auth_cred_ssl_server_trust_t data = new LibSvnClient.svn_auth_cred_ssl_server_trust_t ();
265
373
SslFailure accepted_failures;
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) {
269
377
data.accepted_failures = (uint) accepted_failures;
270
378
cred = apr.pcalloc (pool, data);
271
379
return IntPtr.Zero;
273
381
data.accepted_failures = 0;
382
data.may_save = false;
275
383
cred = apr.pcalloc (pool, data);
276
384
return GetCancelError ();
280
static IntPtr OnAuthSslClientCertPrompt (ref IntPtr cred, IntPtr baton, [MarshalAs (UnmanagedType.LPStr)] string realm, [MarshalAs (UnmanagedType.SysInt)] int may_save, IntPtr pool)
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)
282
391
LibSvnClient.svn_auth_cred_ssl_client_cert_t data = new LibSvnClient.svn_auth_cred_ssl_client_cert_t ();
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)) {
286
395
cred = apr.pcalloc (pool, data);
287
396
return IntPtr.Zero;
289
398
data.cert_file = "";
399
data.may_save = false;
291
400
cred = apr.pcalloc (pool, data);
292
401
return GetCancelError ();
296
static IntPtr OnAuthSslClientCertPwPrompt (ref IntPtr cred, IntPtr baton, [MarshalAs (UnmanagedType.LPStr)] string realm, [MarshalAs (UnmanagedType.SysInt)] int may_save, IntPtr pool)
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)
298
408
LibSvnClient.svn_auth_cred_ssl_client_cert_pw_t data;
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)) {
302
412
cred = apr.pcalloc (pool, data);
303
413
return IntPtr.Zero;
305
415
data.password = "";
416
data.may_save = false;
307
417
cred = apr.pcalloc (pool, data);
308
418
return GetCancelError ();
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;
321
431
public override IEnumerable<DirectoryEntry> List (FilePath path, bool recurse, SvnRevision rev)
323
433
return ListUrl (path, recurse, rev);
326
string NormalizePath (string pathOrUrl, IntPtr localpool)
436
static string NormalizePath (string pathOrUrl, IntPtr localpool)
328
if (pathOrUrl == null)
330
IntPtr res = svn.path_internal_style (pathOrUrl, localpool);
331
return Marshal.PtrToStringAnsi (res);
438
return SvnClient.NormalizePath (pathOrUrl, localpool);
334
441
public override IEnumerable<DirectoryEntry> ListUrl (string pathorurl, bool recurse, SvnRevision rev)
336
443
if (pathorurl == null)
337
444
throw new ArgumentNullException ();
446
TryStartOperation ();
339
447
LibSvnClient.Rev revision = (LibSvnClient.Rev) rev;
340
448
IntPtr localpool = newpool (pool);
341
449
List<DirectoryEntry> items = new List<DirectoryEntry> ();
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);
371
479
apr.pool_destroy (localpool);
383
492
ArrayList ret = new ArrayList ();
385
494
StatusCollector collector = new StatusCollector (ret);
496
TryStartOperation ();
387
497
IntPtr localpool = newpool (pool);
389
499
string pathorurl = NormalizePath (path, localpool);
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,
502
IntPtr.Zero, descendDirs,
396
507
ctx, localpool));
398
509
apr.pool_destroy (localpool);
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));
405
519
public override IEnumerable<SvnRevision> Log (Repository repo, FilePath path, SvnRevision revStart, SvnRevision revEnd)
423
539
LogCollector collector = new LogCollector ((SubversionRepository)repo, ret);
425
541
CheckError (svn.client_log (array, ref revisionStart, ref revisionEnd, 1, 0,
426
new LibSvnClient.svn_log_message_receiver_t (collector.Func),
427
543
IntPtr.Zero, ctx, localpool));
429
545
if (strptr != IntPtr.Zero)
430
546
Marshal.FreeHGlobal (strptr);
431
547
apr.pool_destroy (localpool);
448
565
AnnotationCollector collector = new AnnotationCollector (annotations);
450
567
IntPtr localpool = newpool (pool);
569
TryStartOperation ();
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));
456
574
apr.pool_destroy (localpool);
459
578
return annotations;
462
public override string GetPathUrl (FilePath path)
464
if (path == FilePath.Null)
465
throw new ArgumentNullException();
467
IntPtr ret = IntPtr.Zero;
468
IntPtr localpool = newpool (pool);
470
string npath = NormalizePath (path, localpool);
471
CheckError (svn.client_url_from_path (ref ret, npath, localpool));
473
apr.pool_destroy (localpool);
476
if (ret == IntPtr.Zero)
479
return Marshal.PtrToStringAnsi (ret);
482
581
public override string GetTextAtRevision (string pathorurl, Revision revision)
484
583
MemoryStream memstream = new MemoryStream ();
485
584
Cat (pathorurl, (SvnRevision) revision, memstream);
586
var buffer = memstream.GetBuffer ();
488
return System.Text.Encoding.UTF8.GetString (memstream.GetBuffer ());
588
if (IsBinary (buffer, memstream.Length))
590
return System.Text.Encoding.UTF8.GetString (buffer, 0, (int) memstream.Length);
492
return System.Text.Encoding.ASCII.GetString (memstream.GetBuffer ());
594
return System.Text.Encoding.ASCII.GetString (buffer, 0, (int) memstream.Length);
495
597
public void Cat (string pathorurl, SvnRevision rev, Stream stream)
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);
511
614
apr.pool_destroy (localpool);
530
630
IntPtr localpool = newpool (pool);
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));
535
635
foreach (string file in updateFileList)
536
636
FileService.NotifyFileChanged (file);
629
718
revision = SvnRevision.Head;
630
719
LibSvnClient.Rev rev = (LibSvnClient.Rev) revision;
634
throw new SubversionException ("Another Subversion operation is already in progress.");
721
TryStartOperation ();
637
722
nb = new notify_baton ();
638
723
updatemonitor = monitor;
639
IntPtr result_rev = IntPtr.Zero;
640
724
IntPtr localpool = newpool (pool);
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));
647
731
apr.pool_destroy (localpool);
648
732
updatemonitor = null;
788
856
apr.pool_destroy (localpool);
789
857
updatemonitor = null;
794
862
public override void Lock (IProgressMonitor monitor, string comment, bool stealLock, params FilePath[] paths)
798
throw new SubversionException ("Another Subversion operation is already in progress.");
864
TryStartOperation ();
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;
827
891
public override void Unlock (IProgressMonitor monitor, bool breakLock, params FilePath[] paths)
831
throw new SubversionException ("Another Subversion operation is already in progress.");
893
TryStartOperation ();
835
895
IntPtr localpool = newpool (pool);
836
896
IntPtr array = apr.array_make (localpool, 0, IntPtr.Size);
946
1012
tmp_file = IntPtr.Zero;
947
1013
return IntPtr.Zero;
950
internal static void CheckError (IntPtr error)
952
if (error == IntPtr.Zero)
956
while (error != IntPtr.Zero) {
957
LibSvnClient.svn_error_t error_t = (LibSvnClient.svn_error_t) Marshal.PtrToStructure (error, typeof (LibSvnClient.svn_error_t));
959
msg += "\n" + GetErrorMessage (error_t);
961
msg = GetErrorMessage (error_t);
962
error = error_t.svn_error_t_child;
966
msg = GettextCatalog.GetString ("Unknown error");
968
throw new SubversionException (msg);
971
static string GetErrorMessage (LibSvnClient.svn_error_t error)
973
if (error.message != null)
974
return error.message;
976
byte[] buf = new byte [300];
977
svn.strerror (error.apr_err, buf, buf.Length);
978
return Encoding.UTF8.GetString (buf);
1016
void TryStartOperation ()
1019
Console.WriteLine ("*************************************");
1020
Console.WriteLine (Environment.StackTrace);
1021
Console.WriteLine ("*************************************");
1023
throw new SubversionException ("Another Subversion operation is already in progress.");
1028
void TryEndOperation ()
1032
throw new SubversionException ("No Subversion operation is in progress.");
982
1037
private VersionInfo CreateNode (LibSvnClient.StatusEnt ent, Repository repo)
984
1039
VersionStatus rs = VersionStatus.Unversioned;
985
1040
Revision rr = null;
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);
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;
1033
1088
return VersionStatus.Unversioned;
1227
1282
public class StatusCollector {
1228
1283
ArrayList statuses;
1230
public StatusCollector (ArrayList statuses) { this.statuses = statuses; }
1232
public void Func (IntPtr baton, IntPtr path, ref LibSvnClient.svn_wc_status_t status)
1285
public LibSvnClient.svn_wc_status_func2_t Func {
1289
public StatusCollector (ArrayList statuses)
1291
this.statuses = statuses;
1292
Func = CollectorFunc;
1295
void CollectorFunc (IntPtr baton, IntPtr path, IntPtr statusPtr)
1234
1297
string pathstr = Marshal.PtrToStringAnsi (path);
1235
1298
/*if (status.to_svn_wc_entry_t == IntPtr.Zero)
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));
1246
1310
List<SvnRevision> logs;
1247
1311
SubversionRepository repo;
1249
public LogCollector (SubversionRepository repo, List<SvnRevision> logs) { this.repo = repo; this.logs = logs; }
1251
public IntPtr Func (IntPtr baton, IntPtr apr_hash_changed_paths, int revision, IntPtr author, IntPtr date, IntPtr message, IntPtr pool)
1313
public LibSvnClient.svn_log_message_receiver_t Func {
1317
public LogCollector (SubversionRepository repo, List<SvnRevision> logs) {
1320
Func = CollectorFunc;
1323
IntPtr CollectorFunc (IntPtr baton, IntPtr apr_hash_changed_paths, svn_revnum_t revision, IntPtr author, IntPtr date, IntPtr message, IntPtr pool)
1254
1326
svn.time_from_cstring (out time, Marshal.PtrToStringAnsi (date), pool);
1288
1360
items.Add (new RevisionPath (Marshal.PtrToStringAnsi (result) + "/" + name, ac, ""));
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);
1294
1366
return IntPtr.Zero;
1298
1370
public class StreamCollector {
1301
public StreamCollector (Stream buf) { this.buf = buf; }
1303
public IntPtr Func (IntPtr baton, IntPtr data, ref IntPtr len)
1373
public LibSvnClient.svn_readwrite_fn_t Func {
1377
public StreamCollector (Stream buf) {
1379
Func = CollectorFunc;
1382
IntPtr CollectorFunc (IntPtr baton, IntPtr data, ref size_t len)
1306
1385
byte *bp = (byte *) data;
1320
1399
private class AnnotationCollector
1322
1401
Annotation[] annotations;
1402
public LibSvnClient.svn_client_blame_receiver_t Func {
1325
1407
/// A svn_client_blame_receiver_t implementation.
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)
1329
1411
if (line_no < annotations.Length) {
1330
1412
DateTime tdate;