public List <Changeset> QueryHistory(ItemSpec item, VersionSpec versionItem,
                                             VersionSpec versionFrom, VersionSpec versionTo, int maxCount = short.MaxValue)
        {
            var invoker = new SoapInvoker(this);
            var msg     = invoker.CreateEnvelope("QueryHistory");

            msg.Add(item.ToXml(MessageNs + "itemSpec"));
            msg.Add(versionItem.ToXml(MessageNs + "versionItem"));
            if (versionFrom != null)
            {
                msg.Add(versionFrom.ToXml(MessageNs + "versionFrom"));
            }
            if (versionTo != null)
            {
                msg.Add(versionTo.ToXml(MessageNs + "versionTo"));
            }
            msg.Add(new XElement(MessageNs + "maxCount", maxCount));
            msg.Add(new XElement(MessageNs + "includeFiles", false));
            msg.Add(new XElement(MessageNs + "generateDownloadUrls", false));
            msg.Add(new XElement(MessageNs + "slotMode", false));
            msg.Add(new XElement(MessageNs + "sortAscending", false));

            var result = invoker.InvokeResult();

            return(result.Elements(MessageNs + "Changeset").Select(Changeset.FromXml).ToList());
        }
Exemplo n.º 2
0
        public int QueryHistory(string workspaceName, string workspaceOwner,
                                ItemSpec itemSpec, VersionSpec version,
                                string user, VersionSpec versionFrom,
                                VersionSpec versionTo, int maxCount,
                                bool includeFiles, bool slotMode,
                                bool generateDownloadUrls, ref List <Changeset> changes)
        {
            Message msg = new Message(GetWebRequest(new Uri(Url)), "QueryHistory");

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

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

            if (!String.IsNullOrEmpty(user))
            {
                msg.Body.WriteElementString("user", user);
            }
            msg.Body.WriteElementString("maxCount", Convert.ToString(maxCount));
            msg.Body.WriteElementString("includeFiles", Convert.ToString(includeFiles).ToLower());
            msg.Body.WriteElementString("generateDownloadUrls", Convert.ToString(generateDownloadUrls).ToLower());
            msg.Body.WriteElementString("slotMode", Convert.ToString(slotMode).ToLower());

            int cnt = 0;

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

                while (results.Read())
                {
                    if (results.NodeType == XmlNodeType.Element &&
                        results.Name == "Changeset")
                    {
                        changes.Add(Changeset.FromXml(this, results));
                        cnt++;
                    }
                }
            }

            return(cnt);
        }
        //    <QueryItems xmlns="http://schemas.microsoft.com/TeamFoundation/2005/06/VersionControl/ClientServices/03">
        //      <workspaceName>string</workspaceName>
        //      <workspaceOwner>string</workspaceOwner>
        //      <items>
        //        <ItemSpec item="string" recurse="None or OneLevel or Full" did="int" />
        //        <ItemSpec item="string" recurse="None or OneLevel or Full" did="int" />
        //      </items>
        //      <version />
        //      <deletedState>NonDeleted or Deleted or Any</deletedState>
        //      <itemType>Any or Folder or File</itemType>
        //      <generateDownloadUrls>boolean</generateDownloadUrls>
        //      <options>int</options>
        //    </QueryItems>
        public List <Item> QueryItems(string workspaceName, string workspaceOwner, ItemSpec[] itemSpecs, VersionSpec versionSpec,
                                      DeletedState deletedState, ItemType itemType,
                                      bool includeDownloadInfo)
        {
            var invoker = new SoapInvoker(this);
            var msg     = invoker.CreateEnvelope("QueryItems");

            if (!string.IsNullOrEmpty(workspaceName))
            {
                msg.Add(new XElement(MessageNs + "workspaceName", workspaceName));
            }
            if (!string.IsNullOrEmpty(workspaceOwner))
            {
                msg.Add(new XElement(MessageNs + "workspaceOwner", workspaceOwner));
            }
            msg.Add(new XElement(MessageNs + "items", itemSpecs.Select(itemSpec => itemSpec.ToXml(MessageNs + "ItemSpec"))));
            msg.Add(versionSpec.ToXml(MessageNs + "version"));
            msg.Add(new XElement(MessageNs + "deletedState", deletedState));
            msg.Add(new XElement(MessageNs + "itemType", itemType));
            msg.Add(new XElement(MessageNs + "generateDownloadUrls", includeDownloadInfo.ToLowString()));

            var result = invoker.InvokeResult();

            return(result.Descendants(MessageNs + "Item").Select(Item.FromXml).ToList());
        }
Exemplo n.º 4
0
        public BranchHistoryTreeItem[][] QueryBranches(string workspaceName, string workspaceOwner,
                                                       ItemSpec[] itemSpecs, VersionSpec versionSpec)
        {
            Message msg = new Message(GetWebRequest(new Uri(Url)), "QueryBranches");

            if (!String.IsNullOrEmpty(workspaceName))
            {
                msg.Body.WriteElementString("workspaceName", workspaceName);
            }
            if (!String.IsNullOrEmpty(workspaceOwner))
            {
                msg.Body.WriteElementString("workspaceOwner", workspaceOwner);
            }
            msg.Body.WriteStartElement("items");
            foreach (ItemSpec itemSpec in itemSpecs)
            {
                itemSpec.ToXml(msg.Body, "ItemSpec");
            }
            msg.Body.WriteEndElement();

            versionSpec.ToXml(msg.Body, "version");

            List <BranchHistoryTreeItem[]> tree = new List <BranchHistoryTreeItem[]>();

            using (HttpWebResponse response = Invoke(msg))
            {
                XmlReader results = msg.ResponseReader(response);
                while (results.Read())
                {
                    if (results.NodeType == XmlNodeType.Element &&
                        results.Name == "ArrayOfBranchRelative")
                    {
                        List <BranchRelative> branches = new List <BranchRelative>();
                        while (results.Read())
                        {
                            if (results.NodeType == XmlNodeType.EndElement &&
                                results.Name == "ArrayOfBranchRelative")
                            {
                                break;
                            }
                            if (results.NodeType == XmlNodeType.Element &&
                                results.Name == "BranchRelative")
                            {
                                branches.Add(BranchRelative.FromXml(this, results));
                            }
                        }

                        if (branches.Count > 0)
                        {
                            List <BranchHistoryTreeItem> items = new List <BranchHistoryTreeItem>();
                            items.Add(new BranchHistoryTreeItem(branches.ToArray()));
                            tree.Add(items.ToArray());
                        }
                    }
                }
            }

            return(tree.ToArray());
        }
Exemplo n.º 5
0
        public VersionControlLabel[] QueryLabels(string workspaceName, string workspaceOwner,
                                                 string labelName, string labelScope,
                                                 string owner, string filterItem,
                                                 VersionSpec versionFilterItem,
                                                 bool includeItems, bool generateDownloadUrls)
        {
            Message msg = new Message(GetWebRequest(new Uri(Url)), "QueryLabels");

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

            if (null != versionFilterItem)
            {
                versionFilterItem.ToXml(msg.Body, "versionFilterItem");
            }
            msg.Body.WriteElementString("includeItems", includeItems.ToString().ToLower());
            msg.Body.WriteElementString("generateDownloadUrls", generateDownloadUrls.ToString().ToLower());

            List <VersionControlLabel> labels = new List <VersionControlLabel>();

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

                while (results.Read())
                {
                    if (results.NodeType == XmlNodeType.Element &&
                        results.Name == "VersionControlLabel")
                    {
                        labels.Add(VersionControlLabel.FromXml(this, results));
                    }
                }
            }

            return(labels.ToArray());
        }
Exemplo n.º 6
0
        public LabelResult[] UnlabelItem(Workspace workspace, string labelName,
                                         string labelScope, ItemSpec[] itemSpecs,
                                         VersionSpec version)
        {
            Message msg = new Message(GetWebRequest(new Uri(Url)), "UnlabelItem");

            msg.Body.WriteElementString("workspaceName", workspace.Name);
            msg.Body.WriteElementString("workspaceOwner", workspace.OwnerName);
            msg.Body.WriteElementString("labelName", labelName);

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

            msg.Body.WriteStartElement("items");
            foreach (ItemSpec itemSpec in itemSpecs)
            {
                itemSpec.ToXml(msg.Body, "ItemSpec");
            }
            msg.Body.WriteEndElement();

            version.ToXml(msg.Body, "version");

            List <LabelResult> labelResults = new List <LabelResult>();
            List <Failure>     faillist     = new List <Failure>();

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

                while (results.Read())
                {
                    if (results.NodeType == XmlNodeType.Element)
                    {
                        switch (results.Name)
                        {
                        case "LabelResult":
                            labelResults.Add(LabelResult.FromXml(this, results));
                            break;

                        case "Failure":
                            faillist.Add(Failure.FromXml(this, results));
                            break;
                        }
                    }
                }
            }

            foreach (Failure failure in faillist)
            {
                versionControlServer.OnNonFatalError(workspace, failure);
            }

            return(labelResults.ToArray());
        }
Exemplo n.º 7
0
 internal void ToXml(XmlWriter writer, string element)
 {
     writer.WriteStartElement("GetRequest");
     if (itemSpec != null)
     {
         itemSpec.ToXml(writer, "ItemSpec");
     }
     versionSpec.ToXml(writer, "VersionSpec");
     writer.WriteEndElement();
 }
Exemplo n.º 8
0
        public ItemSet[] QueryItems(string workspaceName, string workspaceOwner,
                                    ItemSpec[] itemSpecs, VersionSpec versionSpec,
                                    DeletedState deletedState, ItemType itemType,
                                    bool generateDownloadUrls)
        {
            Message msg = new Message(GetWebRequest(new Uri(Url)), "QueryItems");

            if (!String.IsNullOrEmpty(workspaceName))
            {
                msg.Body.WriteElementString("workspaceName", workspaceName);
            }
            if (!String.IsNullOrEmpty(workspaceOwner))
            {
                msg.Body.WriteElementString("workspaceOwner", workspaceOwner);
            }
            msg.Body.WriteStartElement("items");
            foreach (ItemSpec itemSpec in itemSpecs)
            {
                itemSpec.ToXml(msg.Body, "ItemSpec");
            }
            msg.Body.WriteEndElement();

            versionSpec.ToXml(msg.Body, "version");

            msg.Body.WriteElementString("deletedState",
                                        deletedState.ToString());
            msg.Body.WriteElementString("itemType",
                                        itemType.ToString());
            msg.Body.WriteElementString("generateDownloadUrls",
                                        generateDownloadUrls.ToString().ToLower());

            List <ItemSet> itemSet = new List <ItemSet>();

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

                while (results.Read())
                {
                    if (results.NodeType == XmlNodeType.Element &&
                        results.Name == "ItemSet")
                    {
                        itemSet.Add(ItemSet.FromXml(this, results));
                    }
                }
            }

            return(itemSet.ToArray());
        }
Exemplo n.º 9
0
        public LabelResult[] UnlabelItem(Workspace workspace, string labelName,
																		 string labelScope, ItemSpec[] itemSpecs, 
																		 VersionSpec version)
        {
            Message msg = new Message(GetWebRequest (new Uri(Url)), "UnlabelItem");

            msg.Body.WriteElementString("workspaceName", workspace.Name);
            msg.Body.WriteElementString("workspaceOwner", workspace.OwnerName);
            msg.Body.WriteElementString("labelName", labelName);

            if (!String.IsNullOrEmpty(labelScope))
                msg.Body.WriteElementString("labelScope", labelScope);

            msg.Body.WriteStartElement("items");
            foreach (ItemSpec itemSpec in itemSpecs)
                {
                    itemSpec.ToXml(msg.Body, "ItemSpec");
                }
            msg.Body.WriteEndElement();

            version.ToXml(msg.Body, "version");

            List<LabelResult> labelResults = new List<LabelResult>();
            List<Failure> faillist = new List<Failure>();

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

                    while (results.Read())
                        {
                            if (results.NodeType == XmlNodeType.Element)
                                {
                                    switch (results.Name)
                                        {
                                        case "LabelResult":
                                            labelResults.Add(LabelResult.FromXml(this, results));
                                            break;
                                        case "Failure":
                                            faillist.Add(Failure.FromXml(this, results));
                                            break;
                                        }
                                }
                        }
                }

            foreach (Failure failure in faillist)
                {
                    versionControlServer.OnNonFatalError(workspace, failure);
                }

            return labelResults.ToArray();
        }
Exemplo n.º 10
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();
        }
Exemplo n.º 11
0
        public VersionControlLabel[] QueryLabels(string workspaceName, string workspaceOwner, 
																						 string labelName, string labelScope, 
																						 string owner, string filterItem, 
																						 VersionSpec versionFilterItem, 
																						 bool includeItems, bool generateDownloadUrls)
        {
            Message msg = new Message(GetWebRequest (new Uri(Url)), "QueryLabels");

            if (!String.IsNullOrEmpty(workspaceName)) msg.Body.WriteElementString("workspaceName", workspaceName);
            if (!String.IsNullOrEmpty(workspaceOwner)) msg.Body.WriteElementString("workspaceOwner", workspaceOwner);
            if (!String.IsNullOrEmpty(labelName)) msg.Body.WriteElementString("labelName", labelName);
            if (!String.IsNullOrEmpty(labelScope)) msg.Body.WriteElementString("labelScope", labelScope);
            if (!String.IsNullOrEmpty(owner)) msg.Body.WriteElementString("owner", owner);
            if (!String.IsNullOrEmpty(filterItem)) msg.Body.WriteElementString("filterItem", filterItem);

            if (null != versionFilterItem) versionFilterItem.ToXml(msg.Body, "versionFilterItem");
            msg.Body.WriteElementString("includeItems", includeItems.ToString().ToLower());
            msg.Body.WriteElementString("generateDownloadUrls", generateDownloadUrls.ToString().ToLower());

            List<VersionControlLabel> labels = new List<VersionControlLabel>();
            using (HttpWebResponse response = Invoke(msg))
                {
                    XmlReader results = msg.ResponseReader(response);

                    while (results.Read())
                        {
                            if (results.NodeType == XmlNodeType.Element &&
                                    results.Name == "VersionControlLabel")
                                labels.Add(VersionControlLabel.FromXml(this, results));
                        }
                }

            return labels.ToArray();
        }
Exemplo n.º 12
0
        public ItemSet[] QueryItems(string workspaceName, string workspaceOwner, 
																ItemSpec[] itemSpecs, VersionSpec versionSpec, 
																DeletedState deletedState, ItemType itemType, 
																bool generateDownloadUrls)
        {
            Message msg = new Message(GetWebRequest (new Uri(Url)), "QueryItems");

            if (!String.IsNullOrEmpty(workspaceName)) msg.Body.WriteElementString("workspaceName", workspaceName);
            if (!String.IsNullOrEmpty(workspaceOwner)) msg.Body.WriteElementString("workspaceOwner", workspaceOwner);
            msg.Body.WriteStartElement("items");
            foreach (ItemSpec itemSpec in itemSpecs)
                itemSpec.ToXml(msg.Body, "ItemSpec");
            msg.Body.WriteEndElement();

            versionSpec.ToXml(msg.Body, "version");

            msg.Body.WriteElementString("deletedState",
                                                                    deletedState.ToString());
            msg.Body.WriteElementString("itemType",
                                                                    itemType.ToString());
            msg.Body.WriteElementString("generateDownloadUrls",
                                                                    generateDownloadUrls.ToString().ToLower());

            List<ItemSet> itemSet = new List<ItemSet>();
            using (HttpWebResponse response = Invoke(msg))
                {
                    XmlReader results = msg.ResponseReader(response);

                    while (results.Read())
                        {
                            if (results.NodeType == XmlNodeType.Element &&
                                    results.Name == "ItemSet")
                                itemSet.Add(ItemSet.FromXml(this, results));
                        }
                }

            return itemSet.ToArray();
        }
Exemplo n.º 13
0
        public int QueryHistory(string workspaceName, string workspaceOwner,
														 ItemSpec itemSpec, VersionSpec version,
														 string user, VersionSpec versionFrom,
														 VersionSpec versionTo, int maxCount,
														 bool includeFiles, bool slotMode,
														 bool generateDownloadUrls, ref List<Changeset> changes)
        {
            Message msg = new Message(GetWebRequest (new Uri(Url)), "QueryHistory");

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

            itemSpec.ToXml(msg.Body, "itemSpec");
            if (version != null) version.ToXml(msg.Body, "versionItem");
            if (versionFrom != null) versionFrom.ToXml(msg.Body, "versionFrom");
            if (versionTo != null) versionTo.ToXml(msg.Body, "versionTo");

            if (!String.IsNullOrEmpty(user)) msg.Body.WriteElementString("user", user);
            msg.Body.WriteElementString("maxCount", Convert.ToString(maxCount));
            msg.Body.WriteElementString("includeFiles", Convert.ToString(includeFiles).ToLower());
            msg.Body.WriteElementString("generateDownloadUrls", Convert.ToString(generateDownloadUrls).ToLower());
            msg.Body.WriteElementString("slotMode", Convert.ToString(slotMode).ToLower());

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

                    while (results.Read())
                        {
                            if (results.NodeType == XmlNodeType.Element &&
                                    results.Name == "Changeset")
                                {
                                    changes.Add(Changeset.FromXml(this, results));
                                    cnt++;
                                }
                        }
                }

            return cnt;
        }
Exemplo n.º 14
0
        public BranchHistoryTreeItem[][] QueryBranches(string workspaceName, string workspaceOwner, 
																									 ItemSpec[] itemSpecs, VersionSpec versionSpec)
        {
            Message msg = new Message(GetWebRequest (new Uri(Url)), "QueryBranches");

            if (!String.IsNullOrEmpty(workspaceName)) msg.Body.WriteElementString("workspaceName", workspaceName);
            if (!String.IsNullOrEmpty(workspaceOwner)) msg.Body.WriteElementString("workspaceOwner", workspaceOwner);
            msg.Body.WriteStartElement("items");
            foreach (ItemSpec itemSpec in itemSpecs)
                itemSpec.ToXml(msg.Body, "ItemSpec");
            msg.Body.WriteEndElement();

            versionSpec.ToXml(msg.Body, "version");

            List<BranchHistoryTreeItem[]> tree = new List<BranchHistoryTreeItem[]>();
            using (HttpWebResponse response = Invoke(msg))
                {
                    XmlReader results = msg.ResponseReader(response);
                    while (results.Read())
                        {
                            if (results.NodeType == XmlNodeType.Element &&
                                    results.Name == "ArrayOfBranchRelative")
                                {
                                    List<BranchRelative> branches = new List<BranchRelative>();
                                    while (results.Read())
                                        {
                                            if (results.NodeType == XmlNodeType.EndElement &&
                                                    results.Name == "ArrayOfBranchRelative") break;
                                            if (results.NodeType == XmlNodeType.Element &&
                                                    results.Name == "BranchRelative")
                                                branches.Add(BranchRelative.FromXml(this, results));
                                        }

                                    if (branches.Count > 0)
                                        {
                                            List<BranchHistoryTreeItem> items = new List<BranchHistoryTreeItem>();
                                            items.Add(new BranchHistoryTreeItem(branches.ToArray()));
                                            tree.Add(items.ToArray());
                                        }
                                }
                        }
                }

            return tree.ToArray();
        }
Exemplo n.º 15
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());
        }