public BranchHistoryTreeItem[][] GetBranchHistory(ItemSpec[] itemSpecs,
                                                          VersionSpec version)
        {
            if (itemSpecs.Length == 0)
            {
                return(null);
            }

            string workspaceName  = String.Empty;
            string workspaceOwner = String.Empty;
            string item           = itemSpecs[0].Item;

            if (!VersionControlPath.IsServerItem(item))
            {
                WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(item);
                if (info != null)
                {
                    workspaceName  = info.Name;
                    workspaceOwner = info.OwnerName;
                }
            }

            return(repository.QueryBranches(workspaceName, workspaceOwner,
                                            itemSpecs, version));
        }
        public ChangesetMerge[] QueryMerges(string sourcePath, VersionSpec sourceVersion,
                                            string targetPath, VersionSpec targetVersion,
                                            VersionSpec versionFrom, VersionSpec versionTo,
                                            RecursionType recursion)
        {
            string workspaceName  = String.Empty;
            string workspaceOwner = String.Empty;

            if (!VersionControlPath.IsServerItem(targetPath))
            {
                WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(targetPath);
                if (info != null)
                {
                    workspaceName  = info.Name;
                    workspaceOwner = info.OwnerName;
                }
            }

            ItemSpec sourceItem = null;

            if (!String.IsNullOrEmpty(sourcePath))
            {
                sourceItem = new ItemSpec(sourcePath, recursion);
            }

            ItemSpec targetItem = new ItemSpec(targetPath, recursion);

            ChangesetMerge[] merges = repository.QueryMerges(workspaceName, workspaceOwner,
                                                             sourceItem, sourceVersion,
                                                             targetItem, targetVersion,
                                                             versionFrom, versionTo,
                                                             Int32.MaxValue);
            return(merges);
        }
        public ItemSet[] GetItems(ItemSpec[] itemSpecs, VersionSpec versionSpec,
                                  DeletedState deletedState, ItemType itemType,
                                  bool includeDownloadInfo)
        {
            if (itemSpecs.Length == 0)
            {
                return(null);
            }

            string workspaceName  = String.Empty;
            string workspaceOwner = String.Empty;

            string item = itemSpecs[0].Item;

            if (!VersionControlPath.IsServerItem(item))
            {
                WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(item);
                if (info != null)
                {
                    workspaceName  = info.Name;
                    workspaceOwner = info.OwnerName;
                }
            }

            return(repository.QueryItems(workspaceName, workspaceOwner,
                                         itemSpecs, versionSpec, deletedState,
                                         itemType, includeDownloadInfo));
        }
 public VersionControlLabel[] QueryLabels(string labelName, string labelScope,
                                          string owner, bool includeItems,
                                          string filterItem, VersionSpec versionFilterItem)
 {
     return(repository.QueryLabels(null, null, labelName, labelScope, owner, filterItem,
                                   versionFilterItem, includeItems, false));
 }
Esempio n. 5
0
 public DiffItemVersionedFile(Item item, VersionSpec versionSpec)
 {
     this.versionControlServer = item.VersionControlServer;
         this.item = item;
         this.versionSpec = versionSpec;
         this.label = item.ServerItem;
 }
Esempio n. 6
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);
        }
Esempio n. 7
0
 public DiffItemVersionedFile(Item item, VersionSpec versionSpec)
 {
     this.versionControlServer = item.VersionControlServer;
     this.item        = item;
     this.versionSpec = versionSpec;
     this.label       = item.ServerItem;
 }
        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());
        }
Esempio n. 9
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());
        }
Esempio n. 10
0
        public ItemSet GetItems(string path, VersionSpec versionSpec,
                                RecursionType recursionType)
        {
            ItemSpec itemSpec = new ItemSpec(path, recursionType);

            return(GetItems(itemSpec, versionSpec, DeletedState.NonDeleted,
                            ItemType.Any, false));
        }
		public FolderDiffWrapper(string assemblyPath, string srcPath, VersionSpec srcSpec, string targetPath, VersionSpec targetSpec, VersionControlServer server, RecursionType recursion)
		{
			_vcControlsAssembly = Assembly.LoadFrom(assemblyPath);
			//internal FolderDiff(string path1, VersionSpec spec1, string path2, VersionSpec spec2, VersionControlServer server, RecursionType recursion);
			FolderDiff = AccessPrivateWrapper.FromType(_vcControlsAssembly, FolderDiffTypeName,
			                                         srcPath, srcSpec, targetPath, targetSpec, server, recursion);
			SetupTypesFromAssembly();
		}
Esempio n. 12
0
        public LabelResult[] UnlabelItem(string labelName, string labelScope,
                                         ItemSpec[] itemSpecs, VersionSpec version)
        {
            Workspace workspace = GetWorkspace(itemSpecs[0].Item);

            return(repository.UnlabelItem(workspace, labelName, labelScope,
                                          itemSpecs, version));
        }
Esempio n. 13
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());
        }
 public ChangeRequest(string path, RequestType requestType, ItemType itemType,
                      RecursionType recursion, LockLevel lockLevel, VersionSpec version)
 {
     this.Item        = new ItemSpec(path, recursion);
     this.RequestType = requestType;
     this.ItemType    = itemType;
     this.LockLevel   = lockLevel;
     this.VersionSpec = version;
 }
Esempio n. 15
0
        private ParsedQuery( string serverPath, VersionSpec startVersion, VersionSpec endVersion )
        {
            HasVersions = true;
            WorkItemIds = new WorkItemIdList();

            ServerPath = serverPath;
            StartVersion = startVersion;
            EndVersion = endVersion;
        }
        public HistoryProvider(VersionControlServer server, string path, VersionSpec version)
        {
            FetchChangesets(server, path, version);

            for (int i = 0; i < PREFETCH_SIZE && i < this.changesets.Count; i++)
            {
                Prefetch(i);
            }
        }
Esempio n. 17
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());
        }
 public List <Item> QueryItems(Workspace workspace, ItemSpec itemSpec, VersionSpec versionSpec,
                               DeletedState deletedState, ItemType itemType,
                               bool includeDownloadInfo)
 {
     if (workspace == null)
     {
         return(QueryItems(itemSpec, versionSpec, deletedState, itemType, includeDownloadInfo));
     }
     return(QueryItems(workspace.Name, workspace.OwnerName, new [] { itemSpec }, versionSpec, deletedState, itemType, includeDownloadInfo));
 }
Esempio n. 19
0
 public IEnumerable QueryHistory(string path, VersionSpec version,
                                 int deletionId, RecursionType recursion,
                                 string user, VersionSpec versionFrom,
                                 VersionSpec versionTo, int maxCount,
                                 bool includeChanges, bool slotMode)
 {
     return(QueryHistory(path, version, deletionId, recursion,
                         user, versionFrom, versionTo, maxCount,
                         includeChanges, slotMode, false));
 }
Esempio n. 20
0
 public TFVersionSpec(string value)
 {
   if (String.IsNullOrWhiteSpace(value))
   {
     this.vs = null;
   }
   else
   {
     this.vs = VersionSpec.ParseSingleSpec(value, null);
   }
 }
Esempio n. 21
0
        public ItemSet GetItems(ItemSpec itemSpec, VersionSpec versionSpec,
                                DeletedState deletedState, ItemType itemType,
                                bool includeDownloadInfo)
        {
            List <ItemSpec> itemSpecs = new List <ItemSpec>();

            itemSpecs.Add(itemSpec);
            ItemSet[] itemSet = GetItems(itemSpecs.ToArray(), versionSpec, deletedState,
                                         itemType, includeDownloadInfo);
            return(itemSet[0]);
        }
Esempio n. 22
0
        public GetStatus Get(string[] items, VersionSpec version,
                             RecursionType recursion, GetOptions options)
        {
            List <GetRequest> requests = new List <GetRequest>();

            foreach (string item in items)
            {
                requests.Add(new GetRequest(item, recursion, version));
            }

            return(Get(requests.ToArray(), options, null, null));
        }
Esempio n. 23
0
        public Item GetItem(string path, VersionSpec versionSpec,
                            int deletionId, bool includeDownloadInfo)
        {
            ItemSpec itemSpec = new ItemSpec(path, RecursionType.None);
            ItemSet  itemSet  = GetItems(itemSpec, versionSpec, DeletedState.NonDeleted,
                                         ItemType.Any, includeDownloadInfo);

            Item[] items = itemSet.Items;
            if (items.Length > 0)
            {
                return(items[0]);
            }
            return(null);
        }
Esempio n. 24
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());
        }
Esempio n. 25
0
        public IEnumerable QueryHistory(string path, VersionSpec version,
                                        int deletionId, RecursionType recursion,
                                        string user, VersionSpec versionFrom,
                                        VersionSpec versionToOrig, int maxCount,
                                        bool includeChanges, bool slotMode,
                                        bool includeDownloadInfo)
        {
            ItemSpec itemSpec = new ItemSpec(path, recursion, deletionId);

            string workspaceName  = String.Empty;
            string workspaceOwner = String.Empty;

            if (!VersionControlPath.IsServerItem(itemSpec.Item))
            {
                WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(itemSpec.Item);
                if (info != null)
                {
                    workspaceName  = info.Name;
                    workspaceOwner = info.OwnerName;
                }
            }

            List <Changeset> changes = new List <Changeset>();
            int         total        = maxCount;
            VersionSpec versionTo    = versionToOrig;

            while (total > 0)
            {
                int batchMax = Math.Min(256, total);
                int batchCnt = repository.QueryHistory(workspaceName, workspaceOwner, itemSpec,
                                                       version, user, versionFrom, versionTo,
                                                       batchMax, includeChanges, slotMode,
                                                       includeDownloadInfo, ref changes);

                if (batchCnt < batchMax)
                {
                    break;
                }

                total -= batchCnt;
                Changeset lastChangeset = changes[changes.Count - 1];
                versionTo = new ChangesetVersionSpec(lastChangeset.ChangesetId - 1);
            }

            return(changes.ToArray());
        }
Esempio n. 26
0
 public LabelItemSpec(ItemSpec itemSpec, VersionSpec version, bool exclude)
 {
     this.itemSpec = itemSpec;
     this.version  = version;
     this.exclude  = exclude;
 }
Esempio n. 27
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();
        }
Esempio n. 28
0
        public GetStatus Get(string[] items, VersionSpec version,
													RecursionType recursion, GetOptions options)
        {
            List<GetRequest> requests = new List<GetRequest>();
            foreach (string item in items)
                {
                    requests.Add(new GetRequest(item, recursion, version));
                }

            return Get(requests.ToArray(), options, null, null);
        }
Esempio n. 29
0
        public GetStatus Get(VersionSpec versionSpec, GetOptions options)
        {
            GetRequest request = new GetRequest(versionSpec);

            return(Get(request, GetOptions.None, null, null));
        }
Esempio n. 30
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();
        }
Esempio n. 31
0
        public void LatestVersionSpec()
        {
            VersionSpec spec = VersionSpec.Latest;

            Assert.AreEqual("T", spec.DisplayString);
        }
Esempio n. 32
0
        public Item GetItem(string path, VersionSpec versionSpec,
												int deletionId, bool includeDownloadInfo)
        {
            ItemSpec itemSpec = new ItemSpec(path, RecursionType.None);
            ItemSet itemSet = GetItems(itemSpec, versionSpec, DeletedState.NonDeleted,
                                                                 ItemType.Any, includeDownloadInfo);

            Item[] items = itemSet.Items;
            if (items.Length > 0) return items[0];
            return null;
        }
 private List<Changeset> GetChangesets( string path, VersionSpec startVersionSpec, VersionSpec endVersionSpec )
 {
     VersionSpec refinedStartVersion = Refine( path, startVersionSpec, true );
     VersionSpec refinedEndVersion = Refine( path, endVersionSpec, false );
     List<Changeset> changesets = new List<Changeset>();
     foreach( Changeset changeset in clientHelper.VersionControl.QueryHistory( path, VersionSpec.Latest, 0, RecursionType.Full, null, refinedStartVersion, refinedEndVersion, Int32.MaxValue, true, false ) )
     {
         changesets.Add( changeset );
     }
     return changesets;
 }
Esempio n. 34
0
        public ItemSet GetItems(string path, VersionSpec versionSpec, 
														RecursionType recursionType)
        {
            ItemSpec itemSpec = new ItemSpec(path, recursionType);
            return GetItems(itemSpec, versionSpec, DeletedState.NonDeleted,
                                            ItemType.Any, false);
        }
 public TFSRevisionVersion(VersionSpec versionSpec)
 {
     VersionSpec = versionSpec;
 }
Esempio n. 36
0
        public ItemSet GetItems(ItemSpec itemSpec, VersionSpec versionSpec,
														DeletedState deletedState, ItemType itemType, 
														bool includeDownloadInfo)
        {
            List<ItemSpec> itemSpecs = new List<ItemSpec>();
            itemSpecs.Add(itemSpec);
            ItemSet[] itemSet = GetItems(itemSpecs.ToArray(), versionSpec, deletedState,
                                                                     itemType, includeDownloadInfo);
            return itemSet[0];
        }
Esempio n. 37
0
 public LabelItemSpec(ItemSpec itemSpec, VersionSpec version, bool exclude)
 {
     this.itemSpec = itemSpec;
     this.version = version;
     this.exclude = exclude;
 }
Esempio n. 38
0
        public IAnnotatedFile Annotate(string path, VersionSpec version)
        {
            var options = new DiffOptions
            {
                Flags = DiffOptionFlags.EnablePreambleHandling | DiffOptionFlags.IgnoreLeadingAndTrailingWhiteSpace | DiffOptionFlags.IgnoreEndOfLineDifference
            };

            PendingChange[] pendingChanges = server.GetWorkspace(path).GetPendingChanges(path);
            if (pendingChanges.Length >= 2)
            {
                throw new InvalidOperationException("Expected at most 1 pending change, but got " + pendingChanges.Length);
            }

            Changeset currentChangeset = null;

            AnnotatedFile annotatedFile;
            string currentPath;
            int currentEncoding;

            if (pendingChanges.Length == 1 && (pendingChanges[0].ChangeType & ChangeType.Edit) != 0)
            {
                annotatedFile = new AnnotatedFile(path, pendingChanges[0].Encoding);
                if (annotatedFile.IsBinary())
                {
                    return annotatedFile;
                }
                currentPath = path;
                currentEncoding = pendingChanges[0].Encoding;
            }
            else
            {
                annotatedFile = null;
                currentPath = null;
                currentEncoding = 0;
            }

            using (var historyProvider = new HistoryProvider(server, path, version))
            {
                bool done = false;

                while (!done && historyProvider.Next())
                {
                    Changeset previousChangeset = historyProvider.Changeset();

                    string previousPath = historyProvider.Filename();
                    int previousEncoding = previousChangeset.Changes[0].Item.Encoding;

                    if (annotatedFile == null)
                    {
                        annotatedFile = new AnnotatedFile(previousPath, previousEncoding);
                        if (annotatedFile.IsBinary())
                        {
                            return annotatedFile;
                        }
                    }
                    else if (previousEncoding == -1)
                    {
                        annotatedFile.Apply(currentChangeset);
                        done = true;
                    }
                    else
                    {
                        var diff = Diff(Difference.DiffFiles(currentPath, currentEncoding, previousPath, previousEncoding, options));
                        done = annotatedFile.ApplyDiff(currentChangeset, diff);
                    }

                    currentChangeset = previousChangeset;
                    currentEncoding = previousEncoding;
                    currentPath = previousPath;
                }

                if (annotatedFile != null)
                {
                    annotatedFile.Apply(currentChangeset);
                }
            }

            return annotatedFile;
        }
Esempio n. 39
0
        public ChangesetMerge[] QueryMerges(string sourcePath, VersionSpec sourceVersion,
																				 string targetPath, VersionSpec targetVersion,
																				 VersionSpec versionFrom, VersionSpec versionTo,
																				 RecursionType recursion)
        {
            string workspaceName = String.Empty;
            string workspaceOwner = String.Empty;

            if (!VersionControlPath.IsServerItem(targetPath))
                {
                    WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(targetPath);
                    if (info != null)
                        {
                            workspaceName = info.Name;
                            workspaceOwner = info.OwnerName;
                        }
                }

            ItemSpec sourceItem = null;
            if (!String.IsNullOrEmpty(sourcePath)) sourceItem = new ItemSpec(sourcePath, recursion);

            ItemSpec targetItem = new ItemSpec(targetPath, recursion);
            ChangesetMerge[] merges = repository.QueryMerges(workspaceName, workspaceOwner,
                                                                                                             sourceItem, sourceVersion,
                                                                                                             targetItem,  targetVersion,
                                                                                                             versionFrom,  versionTo,
                                                                                                             Int32.MaxValue);
            return merges;
        }
Esempio n. 40
0
        public LabelResult[] UnlabelItem(string labelName, string labelScope,
																			ItemSpec[] itemSpecs, VersionSpec version)
        {
            Workspace workspace = GetWorkspace(itemSpecs[0].Item);
            return repository.UnlabelItem(workspace, labelName, labelScope,
                                                                        itemSpecs, version);
        }
Esempio n. 41
0
 public TFVersionSpec(int changeset)
 {
   this.vs = new ChangesetVersionSpec(changeset);
 }
Esempio n. 42
0
 public Item GetItem(string path, VersionSpec versionSpec)
 {
     return GetItem(path, versionSpec, 0, false);
 }
 private VersionSpec Refine( string path, VersionSpec startVersionSpec, bool isStart )
 {
     if( startVersionSpec is LabelVersionSpec )
     {
         int changesetId = GetMostRecentChangesetId( path, (LabelVersionSpec) startVersionSpec );
         return MakeChangesetSpec( changesetId, isStart );
     }
         return startVersionSpec;
 }
Esempio n. 44
0
        public IEnumerable QueryHistory(string path, VersionSpec version,
																		 int deletionId, RecursionType recursion,
																		 string user, VersionSpec versionFrom,
																		 VersionSpec versionToOrig, int maxCount,
																		 bool includeChanges, bool slotMode,
																		 bool includeDownloadInfo)
        {
            ItemSpec itemSpec = new ItemSpec(path, recursion, deletionId);

            string workspaceName = String.Empty;
            string workspaceOwner = String.Empty;

            if (!VersionControlPath.IsServerItem(itemSpec.Item))
                {
                    WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(itemSpec.Item);
                    if (info != null)
                        {
                            workspaceName = info.Name;
                            workspaceOwner = info.OwnerName;
                        }
                }

            List<Changeset> changes = new List<Changeset>();
            int total = maxCount;
            VersionSpec versionTo = versionToOrig;

            while (total > 0)
                {
                    int batchMax = Math.Min(256, total);
                    int batchCnt = repository.QueryHistory(workspaceName, workspaceOwner, itemSpec,
                                                                                                 version, user, versionFrom, versionTo,
                                                                                                 batchMax, includeChanges, slotMode,
                                                                                                 includeDownloadInfo, ref changes);

                    if (batchCnt < batchMax) break;

                    total -= batchCnt;
                    Changeset lastChangeset = changes[changes.Count - 1];
                    versionTo = new ChangesetVersionSpec(lastChangeset.ChangesetId - 1);
                }

            return changes.ToArray();
        }
Esempio n. 45
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();
        }
        //    <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());
        }
Esempio n. 47
0
 public GetStatus Get(VersionSpec versionSpec, GetOptions options)
 {
     GetRequest request = new GetRequest(versionSpec);
     return Get(request, GetOptions.None, null, null);
 }
Esempio n. 48
0
        public VersionControlLabel[] QueryLabels(string labelName, string labelScope, 
																						 string owner, bool includeItems,
																						 string filterItem, VersionSpec versionFilterItem,
																						 bool generateDownloadUrls)
        {
            return repository.QueryLabels(null, null, labelName, labelScope, owner, filterItem,
                                                                        versionFilterItem, includeItems, generateDownloadUrls);
        }
Esempio n. 49
0
        public BranchHistoryTreeItem[][] GetBranchHistory(ItemSpec[] itemSpecs,
																											VersionSpec version)
        {
            if (itemSpecs.Length == 0) return null;

            string workspaceName = String.Empty;
            string workspaceOwner = String.Empty;
            string item = itemSpecs[0].Item;

            if (!VersionControlPath.IsServerItem(item))
                {
                    WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(item);
                    if (info != null)
                        {
                            workspaceName = info.Name;
                            workspaceOwner = info.OwnerName;
                        }
                }

            return repository.QueryBranches(workspaceName, workspaceOwner,
                                                                            itemSpecs, version);
        }
		private IEnumerable<Changeset> GetChangesets(VersionSpec fromChangeset, VersionSpec toChangeset)
		{
			List<Changeset> changesets = new List<Changeset>();

			foreach (var teamProject in _teamProjects)
			{
				changesets.AddRange(
						_versionControl.QueryHistory(
								teamProject.ServerItem,
								VersionSpec.Latest,
								0,
								RecursionType.Full,
								null,
								fromChangeset,
								toChangeset,
								int.MaxValue,
								true,
								true,
								false,
								true).Cast<Changeset>());
			}

			return changesets;
		}
 public List <Item> QueryItems(ItemSpec itemSpec, VersionSpec versionSpec,
                               DeletedState deletedState, ItemType itemType,
                               bool includeDownloadInfo)
 {
     return(QueryItems(string.Empty, string.Empty, new [] { itemSpec }, versionSpec, deletedState, itemType, includeDownloadInfo));
 }
Esempio n. 52
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();
        }
Esempio n. 53
0
        public IEnumerable QueryHistory(string path, VersionSpec version,
																		 int deletionId, RecursionType recursion,
																		 string user, VersionSpec versionFrom,
																		 VersionSpec versionTo, int maxCount,
																		 bool includeChanges, bool slotMode)
        {
            return QueryHistory(path, version, deletionId, recursion,
                                                    user, versionFrom, versionTo, maxCount,
                                                    includeChanges, slotMode, false);
        }
Esempio n. 54
0
        public ItemSet[] GetItems(ItemSpec[] itemSpecs, VersionSpec versionSpec,
															DeletedState deletedState, ItemType itemType, 
															bool includeDownloadInfo)
        {
            if (itemSpecs.Length == 0) return null;

            string workspaceName = String.Empty;
            string workspaceOwner = String.Empty;

            string item = itemSpecs[0].Item;
            if (!VersionControlPath.IsServerItem(item))
                {
                    WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(item);
                    if (info != null)
                        {
                            workspaceName = info.Name;
                            workspaceOwner = info.OwnerName;
                        }
                }

            return repository.QueryItems(workspaceName, workspaceOwner,
                                                                     itemSpecs, versionSpec, deletedState,
                                                                     itemType, includeDownloadInfo);
        }
Esempio n. 55
0
 internal GetRequest(VersionSpec versionSpec)
 {
     this.versionSpec = versionSpec;
 }
Esempio n. 56
0
 public Item GetItem(string path, VersionSpec versionSpec)
 {
     return(GetItem(path, versionSpec, 0, false));
 }
Esempio n. 57
0
 public GetRequest(ItemSpec itemSpec, int changesetId)
 {
     this.itemSpec    = itemSpec;
     this.versionSpec = new ChangesetVersionSpec(changesetId);
 }
Esempio n. 58
0
 public GetRequest(string item, RecursionType recursionType, VersionSpec versionSpec)
 {
     this.itemSpec    = new ItemSpec(item, recursionType);
     this.versionSpec = versionSpec;
 }
Esempio n. 59
0
 public GetRequest(ItemSpec itemSpec, VersionSpec versionSpec)
 {
     this.itemSpec    = itemSpec;
     this.versionSpec = versionSpec;
 }
Esempio n. 60
-1
        private MergeResult MergeByFile(Change[] changes, string targetBranch, List<MergeRelation> mergeRelationships,
            VersionSpec version, MergeOption mergeOption, Workspace workspace)
        {
            if (!GetLatest(targetBranch, mergeRelationships, workspace))
            {
                return MergeResult.CanNotGetLatest;
            }

            var mergeOptions = ToTfsMergeOptions(mergeOption);
            var hasConflicts = false;
            foreach (var change in changes)
            {
                var mergeRelation =
                    mergeRelationships.FirstOrDefault(
                        r => r.Item == change.Item.ServerItem && r.Target.StartsWith(targetBranch));
                if (mergeRelation != null)
                {
                    var recursionType = CalculateRecursionType(mergeRelation);
                    var status = workspace.Merge(mergeRelation.Source, mergeRelation.Target, version, version,
                        LockLevel.None, recursionType, mergeOptions);
                    if (!hasConflicts && HasConflicts(status))
                    {
                        hasConflicts = true;
                    }
                }
                else
                {
                    Logger.Info("File {0} not merged to branch {1}", change.Item.ServerItem, targetBranch);
                }
            }

            if (hasConflicts)
            {
                var conflicts = AutoResolveConflicts(workspace, targetBranch, mergeOption);
                if (!conflicts.IsNullOrEmpty())
                {
                    return IsTryRestoreUnexpectedFile(conflicts)
                        ? MergeResult.UnexpectedFileRestored
                        : MergeResult.HasConflicts;
                }
            }

            return MergeResult.Merged;
        }