예제 #1
0
        internal static unsafe bool TryParse(string targetString, bool allowOperationalRevision, out SvnUriTarget target, AprPool pool)
        {
            if (string.IsNullOrEmpty(targetString))
            {
                throw new ArgumentNullException(nameof(targetString));
            }
            if (pool == null)
            {
                throw new ArgumentNullException(nameof(pool));
            }

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

                var path = pool.AllocString(targetString);

                if ((r = svn_opt.svn_opt_parse_path(out svn_opt_revision_t rev, &truePath, path, pool.Handle)) == null)
                {
                    if (Uri.TryCreate(Utf8_PtrToString(truePath), UriKind.Absolute, out var uri))
                    {
                        var pegRev = SvnRevision.Load(rev);

                        target = new SvnUriTarget(uri, pegRev);
                        return(true);
                    }
                }
                else
                {
                    svn_error.svn_error_clear(r);
                }
            }
예제 #2
0
        public static bool TryParse(string path, bool allowOperationalRevision, out SvnUriTarget pegUri)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            using (var pool = new AprPool())
            {
                return(TryParse(path, allowOperationalRevision, out pegUri, pool));
            }
        }
예제 #3
0
        /// <summary>Performs a recursive checkout of <paramref name="url" /> to <paramref name="path" /></summary>
        /// <exception type="SvnException">Operation failed</exception>
        /// <exception type="ArgumentException">Parameters invalid</exception>
        public bool CheckOut(SvnUriTarget url, string path, out SvnUpdateResult result)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            return(CheckOut(url, path, new SvnCheckOutArgs(), out result));
        }
예제 #4
0
        public new static SvnUriTarget FromString(string value, bool allowOperationalRevision)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (SvnUriTarget.TryParse(value, allowOperationalRevision, out var result))
            {
                return(result);
            }

            throw new ArgumentException(SharpSvnStrings.TheTargetIsNotAValidUriTarget, nameof(value));
        }
예제 #5
0
        /// <summary>Performs a checkout of <paramref name="url" /> to <paramref name="path" /> to the specified param</summary>
        /// <exception type="SvnException">Operation failed and args.ThrowOnError = true</exception>
        /// <exception type="ArgumentException">Parameters invalid</exception>
        /// <returns>true if the operation succeeded; false if it did not</returns>
        public unsafe bool CheckOut(SvnUriTarget url, string path, SvnCheckOutArgs args, out SvnUpdateResult result)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }

            if (args.Revision.RequiresWorkingCopy)
            {
                throw new ArgumentException(SharpSvnStrings.RevisionTypeMustBeHeadDateOrSpecific, nameof(args));
            }
            if (url.Revision.RequiresWorkingCopy)
            {
                throw new ArgumentException(SharpSvnStrings.RevisionTypeMustBeHeadDateOrSpecific, nameof(url));
            }

            EnsureState(SvnContextState.AuthorizationInitialized);
            using var pool  = new AprPool(_pool);
            using var store = new ArgsStore(this, args, pool);

            int version = 0;

            svn_opt_revision_t pegRev = url.Revision.AllocSvnRevision(pool);
            svn_opt_revision_t coRev  = args.Revision.Or(url.Revision).Or(SvnRevision.Head).AllocSvnRevision(pool);

            svn_error_t r = svn_client.svn_client_checkout3(
                ref version,
                pool.AllocUri(url.Uri),
                pool.AllocDirent(path),
                pegRev,
                coRev,
                (svn_depth_t)args.Depth,
                args.IgnoreExternals,
                args.AllowObstructions,
                CtxHandle,
                pool.Handle);

            result = SvnUpdateResult.Create(this, args, version);

            return(args.HandleResult(this, r, url));
        }
예제 #6
0
        /// <summary>Performs a checkout of <paramref name="url" /> to <paramref name="path" /> to the specified param</summary>
        /// <exception type="SvnException">Operation failed and args.ThrowOnError = true</exception>
        /// <exception type="ArgumentException">Parameters invalid</exception>
        /// <returns>true if the operation succeeded; false if it did not</returns>
        public bool CheckOut(SvnUriTarget url, string path, SvnCheckOutArgs args)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }

            return(CheckOut(url, path, args, out _));
        }
예제 #7
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);
        }
예제 #8
0
 public static bool TryParse(string path, out SvnUriTarget pegUri)
 {
     return(TryParse(path, false, out pegUri));
 }