Пример #1
0
    public void BriefOutput(ChangesetMerge[] merges)
    {
        if (merges.Length == 0) return;
        int maxAuthor = 29;

        string line = String.Format("{0} {1} {2} {3}", SourceHdr, TargetHdr,
                                                                AuthorHdr.PadRight(maxAuthor), DateHdr);
        Console.WriteLine(line);

        line = String.Format("{0} {1} {2} {3}", "-".PadRight(SourceHdr.Length, '-'),
                                                 "-".PadRight(TargetHdr.Length, '-'),
                                                 "-".PadRight(maxAuthor, '-'),
                                                 "-".PadRight(10, '-'));
        Console.WriteLine(line);

        foreach (ChangesetMerge merge in merges)
            {
                string srcver = merge.SourceVersion.ToString();
                string trgver = merge.TargetVersion.ToString();
                char partialCh = (merge.Partial)? '*' : ' ';

                line = String.Format("{0}{1} {2} {3} {4}",
                                                         srcver.PadLeft(SourceHdr.Length-1),
                                                         partialCh,
                                                         trgver.PadLeft(TargetHdr.Length),
                                                         merge.TargetChangeset.Owner.PadRight(maxAuthor),
                                                         merge.TargetChangeset.CreationDate.ToString("d"));
                Console.WriteLine(line);
            }
    }
Пример #2
0
        internal static ChangesetMerge FromXml(Repository repository, XmlReader reader)
        {
            ChangesetMerge merge = new ChangesetMerge();

            merge.sourceVersion = Convert.ToInt32(reader.GetAttribute("srcver"));
            merge.targetVersion = Convert.ToInt32(reader.GetAttribute("tgtver"));
            merge.partialFlag   = Convert.ToBoolean(reader.GetAttribute("part"));

            return(merge);
        }
Пример #3
0
        internal static ChangesetMerge FromXml(Repository repository, XmlReader reader)
        {
            ChangesetMerge merge = new ChangesetMerge();
            merge.sourceVersion = Convert.ToInt32(reader.GetAttribute("srcver"));
            merge.targetVersion = Convert.ToInt32(reader.GetAttribute("tgtver"));
            merge.partialFlag = Convert.ToBoolean(reader.GetAttribute("part"));

            return merge;
        }
Пример #4
0
        public ChangesetMerge[] QueryMerges(string workspaceName, string workspaceOwner,
                                            ItemSpec source, VersionSpec versionSource,
                                            ItemSpec target, VersionSpec versionTarget,
                                            VersionSpec versionFrom, VersionSpec versionTo,
                                            int maxChangesets)
        {
            Message msg = new Message(GetWebRequest(new Uri(Url)), "QueryMerges");

            if (!String.IsNullOrEmpty(workspaceName))
            {
                msg.Body.WriteElementString("workspaceName", workspaceName);
            }
            if (!String.IsNullOrEmpty(workspaceOwner))
            {
                msg.Body.WriteElementString("workspaceOwner", workspaceOwner);
            }

            if (source != null)
            {
                source.ToXml(msg.Body, "source");
            }
            if (versionSource != null)
            {
                versionSource.ToXml(msg.Body, "versionSource");
            }

            target.ToXml(msg.Body, "target");
            versionTarget.ToXml(msg.Body, "versionTarget");

            if (versionFrom != null)
            {
                versionFrom.ToXml(msg.Body, "versionFrom");
            }
            if (versionTo != null)
            {
                versionTo.ToXml(msg.Body, "versionTo");
            }

            msg.Body.WriteElementString("maxChangesets", Convert.ToString(maxChangesets));

            List <ChangesetMerge>       merges     = new List <ChangesetMerge>();
            Dictionary <int, Changeset> changesets = new Dictionary <int, Changeset>();

            using (HttpWebResponse response = Invoke(msg))
            {
                XmlReader results = msg.ResponseReader(response);

                while (results.Read())
                {
                    if (results.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }

                    if (results.Name == "ChangesetMerge")
                    {
                        merges.Add(ChangesetMerge.FromXml(this, results));
                    }
                    else if (results.Name == "Changeset")
                    {
                        Changeset changeset = Changeset.FromXml(this, results);
                        changesets.Add(changeset.ChangesetId, changeset);
                    }
                }
            }

            foreach (ChangesetMerge merge in merges)
            {
                Changeset changeset;
                if (changesets.TryGetValue(merge.TargetVersion, out changeset))
                {
                    merge.TargetChangeset = changeset;
                }
            }

            return(merges.ToArray());
        }