Exemple #1
0
        internal static unsafe bool TryParse(string targetName, bool allowOperationalRevisions, out SvnPathTarget target, AprPool pool)
        {
            if (string.IsNullOrEmpty(targetName))
            {
                throw new ArgumentNullException(nameof(targetName));
            }
            if (pool == null)
            {
                throw new ArgumentNullException(nameof(pool));
            }

            target = null;

            if (!IsNotUri(targetName))
            {
                return(false);
            }

            if (allowOperationalRevisions)
            {
                svn_error_t r;
                sbyte *     truePath;

                var path = pool.AllocDirent(targetName);

                if ((r = svn_opt.svn_opt_parse_path(out svn_opt_revision_t rev, &truePath, path, pool.Handle)) == null)
                {
                    var realPath = Utf8_PtrToString(truePath);

                    if (!realPath.Contains("://"))
                    {
                        var pegRev = SvnRevision.Load(rev);

                        target = new SvnPathTarget(realPath, pegRev);
                        return(true);
                    }
                }
                else
                {
                    svn_error.svn_error_clear(r);
                }
            }
Exemple #2
0
        public static bool TryParse(string targetName, bool allowOperationalRevision, out SvnTarget target)
        {
            if (string.IsNullOrEmpty(targetName))
            {
                throw new ArgumentNullException(nameof(targetName));
            }

            if (targetName.Contains("://") && SvnUriTarget.TryParse(targetName, allowOperationalRevision, out var uriTarget))
            {
                target = uriTarget;
                return(true);
            }

            if (SvnPathTarget.TryParse(targetName, allowOperationalRevision, out var pathTarget))
            {
                target = pathTarget;
                return(true);
            }

            target = null;
            return(false);
        }
Exemple #3
0
        public static bool TryParse(string targetName, bool allowPegRevision, out SvnPathTarget target)
        {
            if (string.IsNullOrEmpty(targetName))
            {
                throw new ArgumentNullException(nameof(targetName));
            }

            target = null;

            if (!IsNotUri(targetName))
            {
                return(false);
            }

            if (allowPegRevision)
            {
                using (var pool = new AprPool(SmallThreadPool))
                    return(TryParse(targetName, allowPegRevision, out target, pool));
            }

            target = new SvnPathTarget(targetName);
            return(true);
        }
Exemple #4
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));
        }
Exemple #5
0
 public static bool TryParse(string targetName, out SvnPathTarget target)
 {
     return(TryParse(targetName, false, out target));
 }