Esempio n. 1
0
        static IntPtr svnclient_log_handler(IntPtr baton, IntPtr logEntryPtr, IntPtr pool)
        {
            var client = AprBaton <SvnClient> .Get(baton);

            if (!(client.CurrentCommandArgs is SvnLogArgs args))
            {
                return(IntPtr.Zero);
            }

            var logEntry = svn_log_entry_t.__CreateInstance(logEntryPtr);

            if (logEntry.revision == -1)
            {
                // This marks the end of logs at this level,
                args._mergeLogLevel--;
                return(IntPtr.Zero);
            }

            using AprPool aprPool = new AprPool(pool, false);

            var e = new SvnLogEventArgs(logEntry, args._mergeLogLevel, args._searchRoot, aprPool);

            if (logEntry.has_children)
            {
                args._mergeLogLevel++;
            }

            try
            {
                args.OnLog(e);

                if (e.Cancel)
                {
                    return(svn_error.svn_error_create((int)SvnErrorCode.SVN_ERR_CEASE_INVOCATION, null, "Log receiver canceled operation").__Instance);
                }
                else
                {
                    return(IntPtr.Zero);
                }
            }
            catch (Exception ex)
            {
                return(SvnException.CreateExceptionSvnError("Log receiver", ex).__Instance);
            }
            finally
            {
                e.Detach(false);
            }
        }
Esempio n. 2
0
        static unsafe IntPtr svnclient_list_handler(
            IntPtr baton,
            sbyte *path,
            IntPtr dirent,
            IntPtr @lock,
            sbyte *absPath,
            sbyte *externalParentUrl,
            sbyte *externalTarget,
            IntPtr pool)
        {
            var client = AprBaton <SvnClient> .Get(baton);

            if (!(client.CurrentCommandArgs is SvnListArgs args))
            {
                return(IntPtr.Zero);
            }

            var e = new SvnListEventArgs(
                path,
                svn_dirent_t.__CreateInstance(dirent),
                svn_lock_t.__CreateInstance(@lock),
                absPath,
                args.CalculateRepositoryRoot(absPath),
                externalParentUrl,
                externalTarget);

            try
            {
                args.OnList(e);

                if (e.Cancel)
                {
                    return(svn_error.svn_error_create((int)SvnErrorCode.SVN_ERR_CEASE_INVOCATION, null, "List receiver canceled operation").__Instance);
                }
                else
                {
                    return(IntPtr.Zero);
                }
            }
            catch (Exception ex)
            {
                return(SvnException.CreateExceptionSvnError("List receiver", ex).__Instance);
            }
            finally
            {
                e.Detach(false);
            }
        }
Esempio n. 3
0
        internal unsafe void Ensure()
        {
            if (_ensured || _status == null)
            {
                return;
            }

            _ensured = true;

            svn_wc_status2_t.__Internal *status2;

            var error = libsvnsharp_wc_private.svn_wc__status2_from_3(
                (void **)&status2,
                svn_wc_status3_t.__CreateInstance(_status.backwards_compatibility_baton),
                _client.CtxHandle.wc_ctx,
                _status.local_abspath,
                _pool.Handle,
                _pool.Handle);

            if (error != null)
            {
                throw SvnException.Create(error);
            }

            var entry = svn_wc_entry_t.__CreateInstance(status2->entry);

            _entry = entry;

            _revision           = entry.revision;
            _nodeKind           = (SvnNodeKind)entry.kind;
            _schedule           = (SvnSchedule)entry.schedule;
            _copied             = entry.copied;
            _deleted            = entry.deleted;
            _absent             = entry.absent;
            _incomplete         = entry.incomplete;
            _copyFromRev        = entry.copyfrom_rev;
            _textTime           = SvnBase.DateTimeFromAprTime(entry.text_time);
            _lastChangeRev      = entry.cmt_rev;
            _lastChangeTime     = SvnBase.DateTimeFromAprTime(entry.cmt_date);
            _lockTime           = SvnBase.DateTimeFromAprTime(entry.lock_creation_date);
            _hasProperties      = entry.has_props;
            _hasPropertyChanges = entry.has_prop_mods;
            _wcSize             = entry.working_size;
            _keepLocal          = entry.keep_local;
            _depth = (SvnDepth)entry.depth;
        }
Esempio n. 4
0
        internal unsafe SvnClientContext(AprPool pool)
        {
            if (pool is null)
            {
                throw new ArgumentNullException(nameof(pool));
            }

            _ctxBaton  = new AprBaton <SvnClientContext>(this);
            _callbacks = new SvnClientCallbacks();

            _pool = pool;
            svn_client_ctx_t.__Internal *ctxInternal = null;

            // We manage the config hash ourselves
            var error = svn_client.svn_client_create_context2((void **)&ctxInternal, null, pool.Handle);

            if (error != null)
            {
                throw SvnException.Create(error);
            }

            var ctx = svn_client_ctx_t.__CreateInstance(new IntPtr(ctxInternal));

            ctx.cancel_func    = _callbacks.libsvnsharp_cancel_func.Get();
            ctx.cancel_baton   = _ctxBaton.Handle;
            ctx.progress_func  = _callbacks.libsvnsharp_progress_func.Get();
            ctx.progress_baton = _ctxBaton.Handle;
            ctx.log_msg_func3  = _callbacks.libsvnsharp_commit_log_func.Get();
            ctx.log_msg_baton3 = _ctxBaton.Handle;

            //TODO:
            //ctx.check_tunnel_func = libsvnsharp_check_tunnel_func;
            //ctx.open_tunnel_func = libsvnsharp_open_tunnel_func;
            //ctx.tunnel_baton = _ctxBaton.Handle;

            ctx.client_name = pool.AllocString(SvnBase._clientName);

            _ctx            = ctx;
            _authentication = new SvnAuthentication(this, pool);
        }
Esempio n. 5
0
        static unsafe IntPtr svnclient_status_handler(IntPtr baton, sbyte *path, IntPtr status_ptr, IntPtr scratch_pool)
        {
            var client = AprBaton <SvnClient> .Get(baton);

            using var aprPool = new AprPool(scratch_pool, false);

            if (!(client.CurrentCommandArgs is SvnStatusArgs args))
            {
                return(IntPtr.Zero);
            }

            var status = svn_client_status_t.__CreateInstance(status_ptr);
            var e      = new SvnStatusEventArgs(path, status, client, aprPool);

            try
            {
                args.OnStatus(e);

                if (e.Cancel)
                {
                    return(svn_error.svn_error_create((int)SvnErrorCode.SVN_ERR_CEASE_INVOCATION, null, "Status receiver canceled operation").__Instance);
                }
                else
                {
                    return(IntPtr.Zero);
                }
            }
            catch (Exception ex)
            {
                return(SvnException.CreateExceptionSvnError("Status receiver", ex).__Instance);
            }
            finally
            {
                e.Detach(false);
            }
        }
Esempio n. 6
0
        static unsafe IntPtr svn_info_receiver(IntPtr baton, sbyte *path, IntPtr info_ptr, IntPtr pool)
        {
            var client = AprBaton <SvnClient> .Get(baton);

            using var thePool = new AprPool(pool, false);

            if (!(client.CurrentCommandArgs is SvnInfoArgs args))
            {
                return(IntPtr.Zero);
            }

            var info = svn_client_info2_t.__CreateInstance(info_ptr);
            var e    = new SvnInfoEventArgs(SvnBase.Utf8_PathPtrToString(path, thePool), info, thePool);

            try
            {
                args.OnInfo(e);

                if (e.Cancel)
                {
                    return(svn_error.svn_error_create((int)SvnErrorCode.SVN_ERR_CEASE_INVOCATION, null, "Info receiver canceled operation").__Instance);
                }
                else
                {
                    return(IntPtr.Zero);
                }
            }
            catch (Exception ex)
            {
                return(SvnException.CreateExceptionSvnError("Info receiver", ex).__Instance);
            }
            finally
            {
                e.Detach(false);
            }
        }
Esempio n. 7
0
 public SvnErrorEventArgs(SvnException exception)
 {
     Exception = exception ?? throw new ArgumentNullException(nameof(exception));
 }