Esempio n. 1
0
        internal AprArray(IEnumerable items, AprPool pool)
        {
            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }
            if (pool == null)
            {
                throw new ArgumentNullException(nameof(pool));
            }

            int nItems = 0;

            foreach (TManaged t in items)
            {
                if (ReferenceEquals(t, null))
                {
                    throw new ArgumentException(SharpSvnStrings.ItemInListIsNull, nameof(items));
                }

                nItems++;
            }

            _marshaller = Activator.CreateInstance <TMarshaller>();
            _pool       = pool;
            _handle     = apr_tables.apr_array_make(pool.Handle, nItems, _marshaller.ItemSize);

            foreach (TManaged t in items)
            {
                var ptr = apr_tables.apr_array_push(_handle);

                _marshaller.Write(t, ptr, pool);
            }
        }
        internal SvnCommittingEventArgs(apr_array_header_t commitItems, SvnCommandType commandType, AprPool pool)
        {
            if (commitItems == null)
            {
                throw new ArgumentNullException(nameof(commitItems));
            }
            if (pool == null)
            {
                throw new ArgumentNullException(nameof(pool));
            }

            _commitItems       = commitItems;
            _pool              = pool;
            CurrentCommandType = commandType;
        }
Esempio n. 3
0
        internal AprArray(apr_array_header_t handle, AprPool pool)
        {
            if (handle == null)
            {
                throw new ArgumentNullException(nameof(handle));
            }
            if (pool == null)
            {
                throw new ArgumentNullException(nameof(pool));
            }

            _marshaller = Activator.CreateInstance <TMarshaller>();
            _handle     = handle;
            _pool       = pool;
            IsReadOnly  = true;
        }
 protected internal override void Detach(bool keepProperties)
 {
     try
     {
         if (keepProperties)
         {
             if (Items != null)
             {
                 foreach (SvnCommitItem item in Items)
                 {
                     item.Detach(true);
                 }
             }
         }
     }
     finally
     {
         _commitItems = null;
         _pool        = null;
     }
 }
Esempio n. 5
0
        internal AprArray(ICollection <TManaged> items, AprPool pool)
        {
            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }
            if (pool == null)
            {
                throw new ArgumentNullException(nameof(pool));
            }

            _marshaller = Activator.CreateInstance <TMarshaller>();
            _pool       = pool;
            _handle     = apr_tables.apr_array_make(pool.Handle, items.Count, _marshaller.ItemSize);

            foreach (var t in items)
            {
                var ptr = apr_tables.apr_array_push(_handle);

                _marshaller.Write(t, ptr, pool);
            }
        }
Esempio n. 6
0
        /// <summary>Duplicate something in repository, remembering history (<c>svn copy</c>)</summary>
        /// <remarks>Can be called with either a list of <see cref="SvnTarget" />, <see cref="SvnUriTarget" /> or <see cref="SvnPathTarget" />.
        /// All members must be of the same type.</remarks>
        public unsafe bool RemoteCopy <TSvnTarget>(ICollection <TSvnTarget> sources, Uri toUri, SvnCopyArgs args, out SvnCommitResult result)
            where TSvnTarget : SvnTarget
        {
            if (sources == null)
            {
                throw new ArgumentNullException(nameof(sources));
            }
            if (toUri == null)
            {
                throw new ArgumentNullException(nameof(toUri));
            }
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }
            if (!SvnBase.IsValidReposUri(toUri))
            {
                throw new ArgumentException(SharpSvnStrings.ArgumentMustBeAValidRepositoryUri, nameof(toUri));
            }
            if (sources.Count == 0)
            {
                throw new ArgumentException(SharpSvnStrings.CollectionMustContainAtLeastOneItem, nameof(sources));
            }

            bool isFirst = true;
            bool isLocal = false;

            foreach (SvnTarget target in sources)
            {
                if (target == null)
                {
                    throw new ArgumentException(SharpSvnStrings.ItemInListIsNull, nameof(sources));
                }

                SvnPathTarget pt = target as SvnPathTarget;
                if (isFirst)
                {
                    isLocal = (null != pt);
                    isFirst = false;
                }
                else if (isLocal != (null != pt))
                {
                    throw new ArgumentException(SharpSvnStrings.AllTargetsMustBeUriOrPath, nameof(sources));
                }
            }

            EnsureState(SvnContextState.AuthorizationInitialized);

            using var pool  = new AprPool(_pool);
            using var store = new ArgsStore(this, args, pool);
            using var crr   = new CommitResultReceiver(this);

            apr_array_header_t copies = AllocCopyArray(sources, pool);

            if (copies != null && args.Revision.RevisionType != SvnRevisionType.None)
            {
                svn_opt_revision_t rev = args.Revision.AllocSvnRevision(pool);

                for (int i = 0; i < copies.nelts; i++)
                {
                    var cp = ((svn_client_copy_source_t.__Internal * *)copies.elts)[i];

                    cp->revision = rev.__Instance;
                }
            }

            svn_error_t r = svn_client.svn_client_copy7(
                copies,
                pool.AllocUri(toUri),
                args.AlwaysCopyAsChild || (sources.Count > 1),
                args.CreateParents,
                args.IgnoreExternals,
                args.MetaDataOnly,
                args.PinExternals,
                null /* */,
                CreateRevPropList(args.LogProperties, pool),
                crr.CommitCallback.Get(),
                crr.CommitBaton,
                CtxHandle,
                pool.Handle);

            result = crr.CommitResult;

            return(args.HandleResult(this, r, sources));
        }
Esempio n. 7
0
 private AprArray(apr_array_header_t *ptr)
 {
     mArray = ptr;
     mEltsType = null;
 }
Esempio n. 8
0
 public void Dispose()
 {
     _handle = null;
 }