コード例 #1
0
        internal XElement ToXml(XNamespace ns)
        {
            var result = new XElement(ns + "ChangeRequest",
                                      new XAttribute("req", RequestType),
                                      new XAttribute("type", ItemType));

            if (RequestType == RequestType.Lock || LockLevel != LockLevel.None)
            {
                result.Add(new XAttribute("lock", LockLevel));
            }

            if (RequestType == RequestType.Add)
            {
                result.Add(new XAttribute("enc", Encoding));
            }

            if (!string.IsNullOrEmpty(Target))
            {
                // convert local path specs from platform paths to tfs paths as needed
                string fxdTarget = VersionControlPath.IsServerItem(Target) ? Target : TfsPath.FromPlatformPath(Target);
                result.Add(new XAttribute("target", fxdTarget));
            }

            result.Add(this.Item.ToXml(ns + "item"));
            result.Add(this.VersionSpec.ToXml(ns + "vspec"));

            return(result);
        }
コード例 #2
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);
        }
コード例 #3
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));
        }
コード例 #4
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));
        }
コード例 #5
0
        internal void ToXml(XmlWriter writer, string element)
        {
            if (String.IsNullOrEmpty(item))
            {
                return;
            }

            writer.WriteStartElement(element);

            if (this.RecursionType != RecursionType.None)
            {
                writer.WriteAttributeString("recurse", RecursionType.ToString());
            }
            if (this.DeletionId != 0)
            {
                writer.WriteAttributeString("did", DeletionId.ToString());
            }

            // only convert local path specs from platform paths to tfs paths
            if (VersionControlPath.IsServerItem(Item))
            {
                writer.WriteAttributeString("item", Item);
            }
            else
            {
                writer.WriteAttributeString("item", TfsPath.FromPlatformPath(Item));
            }

            writer.WriteEndElement();
        }
コード例 #6
0
        internal void CheckServerPathStartsWithDollarSlash(string serverItem)
        {
            if (VersionControlPath.IsServerItem(serverItem))
            {
                return;
            }
            string msg = String.Format("TF10125: The path '{0}' must start with {1}", serverItem, VersionControlPath.RootFolder);

            throw new InvalidPathException(msg);
        }
コード例 #7
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());
        }
コード例 #8
0
        public int PendRename(string oldPath, string newPath)
        {
            string newServerPath;

            if (VersionControlPath.IsServerItem(newPath))
            {
                newServerPath = GetServerItemForLocalItem(newPath);
            }
            else
            {
                newServerPath = newPath;
            }

            ItemType itemType = ItemType.File;

            if (Directory.Exists(oldPath))
            {
                itemType = ItemType.Folder;
            }

            List <ChangeRequest> changes = new List <ChangeRequest>();

            changes.Add(new ChangeRequest(oldPath, newServerPath, RequestType.Rename, itemType));

            GetOperation[] getOperations = Repository.PendChanges(this, changes.ToArray());

            if (itemType == ItemType.File)
            {
                File.Move(oldPath, newPath);
            }
            else
            {
                Directory.Move(oldPath, newPath);
            }

            UpdateLocalVersionQueue updates = new UpdateLocalVersionQueue(this);

            foreach (GetOperation getOperation in getOperations)
            {
                updates.QueueUpdate(getOperation.ItemId, getOperation.TargetLocalItem, getOperation.VersionServer);
            }

            updates.Flush();
            return(1);
        }
コード例 #9
0
        public string GetLocalPathForServerPath(VersionControlPath serverItem)
        {
            var mappedFolder = Folders.FirstOrDefault(f => serverItem.IsChildOrEqualTo(f.ServerItem));

            if (mappedFolder == null)
            {
                return(null);
            }
            if (serverItem == mappedFolder.ServerItem)
            {
                return(mappedFolder.LocalItem);
            }
            else
            {
                //string rest = TfsPath.ServerToLocalPath(serverItem.ToString().Substring(mappedFolder.ServerItem.ToString().Length + 1));
                string rest = TfsPath.ServerToLocalPath(serverItem.ChildPart(mappedFolder.ServerItem));
                return(Path.Combine(mappedFolder.LocalItem, rest));
            }
        }
コード例 #10
0
ファイル: ChangeRequest.cs プロジェクト: arleyschrock/opentf
        internal void ToXml(XmlWriter writer, string element)
        {
            writer.WriteStartElement("ChangeRequest");
            writer.WriteAttributeString("req", RequestType.ToString());

            if (RequestType == RequestType.Lock || LockLevel != LockLevel.None)
            {
                writer.WriteAttributeString("lock", LockLevel.ToString());
            }

            if (RequestType == RequestType.Add)
            {
                writer.WriteAttributeString("enc", Encoding.ToString());
            }

            writer.WriteAttributeString("type", ItemType.ToString());
            //writer.WriteAttributeString("did", DeletionId.ToString());
            //writer.WriteAttributeString("targettype", TargetType.ToString());

            if (!String.IsNullOrEmpty(Target))
            {
                // convert local path specs from platform paths to tfs paths as needed
                string fxdTarget;
                if (VersionControlPath.IsServerItem(Target))
                {
                    fxdTarget = Target;
                }
                else
                {
                    fxdTarget = TfsPath.FromPlatformPath(Target);
                }
                writer.WriteAttributeString("target", fxdTarget);
            }

            this.Item.ToXml(writer, "item");
            //this.VersionSpec.ToXml(writer, "vspec");

            writer.WriteEndElement();
        }
コード例 #11
0
 public bool IsServerPathMapped(VersionControlPath serverPath)
 {
     return(Folders.Any(f => serverPath.IsChildOrEqualTo(f.ServerItem)));
 }