static IntPtr _libsvnsharp_cancel_func(IntPtr cancelBaton) { var client = AprBaton <SvnClientContext> .Get(cancelBaton); SvnCancelEventArgs ea = new SvnCancelEventArgs(); try { client.HandleClientCancel(ea); if (ea.Cancel) { return(svn_error.svn_error_create( (int)SvnErrorCode.SVN_ERR_CANCELLED, null, "Operation canceled from OnCancel").__Instance); } return(IntPtr.Zero); } catch (Exception e) { return(SvnException.CreateExceptionSvnError("Cancel function", e).__Instance); } finally { ea.Detach(false); } }
static unsafe IntPtr _svn_wc_conflict_resolver_func( void **resultPtr, IntPtr descriptionPtr, IntPtr baton, IntPtr resultPoolPtr, IntPtr scratchPoolPtr) { var client = AprBaton <SvnClient> .Get(baton); var conflictResult = svn_wc.svn_wc_create_conflict_result( svn_wc_conflict_choice_t.svn_wc_conflict_choose_postpone, null, apr_pool_t.__CreateInstance(resultPoolPtr)); *resultPtr = conflictResult.__Instance.ToPointer(); var resultPool = new AprPool(resultPoolPtr, false); // Connect to parent pool var scratchPool = new AprPool(scratchPoolPtr, false); // Connect to parent pool var description = svn_wc_conflict_description2_t.__CreateInstance(descriptionPtr); var ea = new SvnConflictEventArgs(description, scratchPool); try { client.HandleClientConflict(ea); if (ea.Cancel) { return(svn_error.svn_error_create((int)SvnErrorCode.SVN_ERR_CANCELLED, null, "Operation canceled from OnConflict").__Instance); } conflictResult.choice = (svn_wc_conflict_choice_t)ea.Choice; if (ea.Choice == SvnAccept.Merged) { if (ea.MergedValue != null) { conflictResult.merged_value = resultPool.AllocSvnString(ea.MergedValue); } if (ea.MergedFile != null) { conflictResult.merged_file = resultPool.AllocAbsoluteDirent(ea.MergedFile); } } return(IntPtr.Zero); } catch (Exception e) { return(SvnException.CreateExceptionSvnError("Conflict resolver", e).__Instance); } finally { ea.Detach(false); scratchPool.Dispose(); resultPool.Dispose(); } }
static IntPtr svnStreamClose(IntPtr baton) { SvnStreamWrapper sw = AprBaton <SvnStreamWrapper> .Get(baton); if (sw._written) { sw._written = false; sw.Stream.Flush(); } return(IntPtr.Zero); }
static unsafe IntPtr svnStreamMark(IntPtr baton, void **mark, IntPtr pool_ptr) { SvnStreamWrapper sw = AprBaton <SvnStreamWrapper> .Get(baton); using (var pool = new AprPool(pool_ptr, false)) { long *pos = (long *)pool.Alloc(sizeof(long)); *pos = sw.Stream.Position; *mark = (void *)pos; } return(IntPtr.Zero); }
static void _libsvnsharp_progress_func(long progress, long total, IntPtr baton, IntPtr pool) { var client = AprBaton <SvnClientContext> .Get(baton); SvnProgressEventArgs ea = new SvnProgressEventArgs(progress, total); try { client.HandleClientProgress(ea); } finally { ea.Detach(false); } }
static unsafe IntPtr _libsvnsharp_commit_log_func( sbyte **logMsg, sbyte **tmpFile, IntPtr commitItemsPtr, IntPtr baton, IntPtr pool) { var client = AprBaton <SvnClientContext> .Get(baton); var tmpPool = new AprPool(pool, false); var commit_items = apr_array_header_t.__CreateInstance(commitItemsPtr); var ea = new SvnCommittingEventArgs(commit_items, client.CurrentCommandArgs.CommandType, tmpPool); *logMsg = null; *tmpFile = null; try { client.HandleClientCommitting(ea); if (ea.Cancel) { return(svn_error.svn_error_create((int)SvnErrorCode.SVN_ERR_CANCELLED, null, "Operation canceled from OnCommitting").__Instance); } else if (ea.LogMessage != null) { *logMsg = tmpPool.AllocUnixString(ea.LogMessage); } else if (!client._noLogMessageRequired) { return(svn_error.svn_error_create((int)SvnErrorCode.SVN_ERR_CANCELLED, null, "Commit canceled: A logmessage is required").__Instance); } else { *logMsg = tmpPool.AllocString(""); } return(IntPtr.Zero); } catch (Exception e) { return(SvnException.CreateExceptionSvnError("Commit log", e).__Instance); } finally { ea.Detach(false); tmpPool.Dispose(); } }
static unsafe IntPtr svnStreamRead(IntPtr baton, sbyte *buffer, ulong *len) { // Subversion: // Handlers are obliged to complete a read or write // to the maximum extent possible; thus, a short read with no // associated error implies the end of the input stream, and a short // write should never occur without an associated error. SvnStreamWrapper sw = AprBaton <SvnStreamWrapper> .Get(baton); byte[] bytes = new byte[(int)*len]; int count = sw.Stream.Read(bytes, 0, (int)*len); Marshal.Copy(bytes, 0, new IntPtr(buffer), count); *len = (ulong)count; return(IntPtr.Zero); }
static void _svn_wc_notify_func2(IntPtr baton, IntPtr notifyPtr, IntPtr pool) { var client = AprBaton <SvnClient> .Get(baton); var aprPool = new AprPool(pool, false); var notify = svn_wc_notify_t.__CreateInstance(notifyPtr); var ea = new SvnNotifyEventArgs(notify, client.CurrentCommandArgs.CommandType, aprPool); try { client.HandleClientNotify(ea); } finally { ea.Detach(false); aprPool.Dispose(); } }
static unsafe IntPtr svnStreamSeek(IntPtr baton, IntPtr mark) { SvnStreamWrapper sw = AprBaton <SvnStreamWrapper> .Get(baton); long newPos = 0; if (mark != IntPtr.Zero) { newPos = *(long *)mark.ToPointer(); } try { sw.Stream.Position = newPos; } catch (Exception ex) { return(SvnException.CreateExceptionSvnError("Seek stream", ex).__Instance); } return(IntPtr.Zero); }
static IntPtr the_commit_callback2(IntPtr commit_info_ptr, IntPtr baton, IntPtr pool) { var tmpPool = new AprPool(pool, false); var receiver = AprBaton <CommitResultReceiver> .Get(baton); try { var commit_info = svn_commit_info_t.__CreateInstance(commit_info_ptr); receiver.ProvideCommitResult(commit_info, tmpPool); return(IntPtr.Zero); } catch (Exception e) { return(SvnException.CreateExceptionSvnError("CommitResult function", e).__Instance); } finally { tmpPool.Dispose(); } }
static unsafe IntPtr svnStreamWrite(IntPtr baton, sbyte *data, ulong *len) { if (*len == 0) { return(IntPtr.Zero); } // Subversion: // Handlers are obliged to complete a read or write // to the maximum extent possible; thus, a short read with no // associated error implies the end of the input stream, and a short // write should never occur without an associated error. SvnStreamWrapper sw = AprBaton <SvnStreamWrapper> .Get(baton); byte[] bytes = new byte[(int)*len]; Marshal.Copy(new IntPtr(data), bytes, 0, bytes.Length); sw.Stream.Write(bytes, 0, bytes.Length); sw._written = true; return(IntPtr.Zero); }