Esempio n. 1
0
        static bool MakePeg(SvnClient client, ref SvnExternalItem ei, string hostUrl)
        {
            Exter.EPinType oldType;
            if (!Exter.GetExternalType(ei, out oldType))
            {
                return(false);
            }

            switch (oldType)
            {
            case Exter.EPinType.Head:
            case Exter.EPinType.Branch:
            {
                // resolve relative url references
                string fullRefUrl;
                if (!Exter.GetFullReferenceUrl(client, ei, hostUrl, out fullRefUrl))
                {
                    return(false);
                }

                // find the revision of the external
                SvnInfoEventArgs info;
                if (!client.GetInfo(new SvnUriTarget(fullRefUrl, SvnRevision.Head), out info))
                {
                    return(false);
                }

                // change to peg revision
                ei = new SvnExternalItem(ei.Target, ei.Reference, info.Revision);

                return(true);
            }

            case Exter.EPinType.Peg:
            {
                // no change needed, already a peg external
                return(true);
            }

            case Exter.EPinType.Tag:
            {
                // no change needed, tag is considered unchangeable, keep it as it is
                return(true);
            }

            default:
            {
                // unknown Pin type
                return(false);
            }
            }

            //return true;
        }
Esempio n. 2
0
        static bool MakeTagBranch(SvnClient client, ref SvnExternalItem ei, string hostUrl, string releaseName, string branchTagType)
        {
            Exter.EPinType oldType;
            if (!Exter.GetExternalType(ei, out oldType))
            {
                return(false);
            }

            string fullRefUrl;

            if (!Exter.GetFullReferenceUrl(client, ei, hostUrl, out fullRefUrl))
            {
                return(false);
            }

            var origBaseUrl     = Exter.StripStdSvnLayoutFromUrl(ei.Reference);
            var origTaggizedUrl = $"{origBaseUrl}/{branchTagType}/{releaseName}";

            var fullBaseUrl     = Exter.StripStdSvnLayoutFromUrl(fullRefUrl);
            var fullTaggizedUrl = $"{fullBaseUrl}/{branchTagType}/{releaseName}";

            switch (oldType)
            {
            case Exter.EPinType.Head:
            case Exter.EPinType.Branch:
            {
                // create tag by svncopying from the head

                try
                {
                    SvnCommitResult copyResult;
                    var             args = new SvnCopyArgs();
                    args.LogMessage    = "";
                    args.CreateParents = true;
                    if (!client.RemoteCopy(new SvnUriTarget(fullRefUrl, SvnRevision.Head), new Uri(fullTaggizedUrl), args, out copyResult))
                    {
                        return(false);
                    }
                }
                catch (SvnException ex)
                {
                    Logger.Warn(ex, $"Failed creating tag/branch '{fullTaggizedUrl}'");
                }

                ei = new SvnExternalItem(ei.Target, origTaggizedUrl);

                return(true);
            }

            case Exter.EPinType.Peg:
            {
                // create tag by svncopying from given peg revision
                try
                {
                    SvnCommitResult copyResult;
                    var             args = new SvnCopyArgs();
                    args.LogMessage    = "";
                    args.CreateParents = true;
                    if (!client.RemoteCopy(new SvnUriTarget(fullRefUrl, ei.Revision), new Uri(fullTaggizedUrl), args, out copyResult))
                    {
                        return(false);
                    }
                }
                catch (SvnException ex)
                {
                    Logger.Warn(ex, $"Failed creating tag/branch '{fullTaggizedUrl}'");
                }

                ei = new SvnExternalItem(ei.Target, origTaggizedUrl);

                return(true);
            }

            case Exter.EPinType.Tag:
            {
                // leave the tag as is
                return(false);
            }

            default:
            {
                // unknown Pin type
                return(false);
            }
            }

            //return false;
        }