Ejemplo n.º 1
0
        internal static unsafe apr_hash_t CreateRevPropList(SvnRevisionPropertyCollection revProps, AprPool pool)
        {
            if (pool == null)
            {
                throw new ArgumentNullException(nameof(pool));
            }

            if (revProps != null && revProps.Count != 0)
            {
                apr_hash_t items = apr_hash.apr_hash_make(pool.Handle);

                foreach (SvnPropertyValue value in revProps)
                {
                    sbyte *key = pool.AllocString(value.Key);

                    var val = pool.AllocSvnString((byte[])value.RawValue);

                    apr_hash.apr_hash_set(items, new IntPtr(key), Constants.APR_HASH_KEY_STRING, val.__Instance);
                }

                return(items);
            }

            return(null);
        }
Ejemplo n.º 2
0
        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();
            }
        }