コード例 #1
0
ファイル: MyTFSConnection.cs プロジェクト: vcsb/tfs-merge
        public void SetLocalPath(BranchType branch, string localPath)
        {
            if (branch == BranchType.All)
            {
                throw new MyTfsConnectionException("Cannot set a local directory for BranchType.All");
            }
            if (!Directory.Exists(localPath))
            {
                throw new MyTfsConnectionException("Local directory does not exist: " + localPath);
            }
            if (!WorkSpace.IsLocalPathMapped(localPath))
            {
                throw new MyTfsConnectionException("Local directory " + localPath + " is not mapped in the TFS workspace");
            }

            string serverPath = WorkSpace.GetServerItemForLocalItem(localPath);

            // double check
            string localPathFromWorkspace = WorkSpace.GetLocalItemForServerItem(serverPath);

            if (!Utility.PathHelper.PathsEqual(localPathFromWorkspace, localPath))
            {
                string message = $"When trying to set {branch.ToString()}:\n";
                message += string.Format("Inconsistent local and server items: local {0}, server {1}, local matching server {2}.",
                                         localPath, serverPath, localPathFromWorkspace);
                throw new MyTfsConnectionException(message);
            }

            _branchMap[branch] = new BranchPaths(localPath, serverPath);
        }
コード例 #2
0
ファイル: MyTFSConnection.cs プロジェクト: vcsb/tfs-merge
        /// <summary>
        /// Returns the server item matching the given local item. Returns an empty string if such was not found.
        /// </summary>
        /// <param name="localPath"></param>
        /// <returns></returns>
        public string GetServerPathForLocalPath(string localPath)
        {
            if (IsConnected == false)
            {
                throw new InvalidOperationException("Cannot get folders before connecting to server");
            }
            if (WorkSpace == null)
            {
                throw new InvalidOperationException("Cannot get folders before setting a workspace");
            }

            if (!WorkSpace.IsLocalPathMapped(localPath))
            {
                return(string.Empty);
            }
            try
            {
                string serverPath = WorkSpace.GetServerItemForLocalItem(localPath);
                return(serverPath);
            }
            catch (ItemNotMappedException)
            {
                return(string.Empty);
            }
        }
コード例 #3
0
ファイル: MyTFSConnection.cs プロジェクト: vcsb/tfs-merge
        public IEnumerable <Changeset> GetHistory(string localPath)
        {
            if (!Directory.Exists(localPath))
            {
                throw new ArgumentException("Local path does not exist: " + localPath);
            }

            try
            {
                var serverPath = WorkSpace.GetServerItemForLocalItem(localPath);
                var itemSpec   = new ItemSpec(serverPath, RecursionType.Full);
                var changesets = _versionControlServer.QueryHistory(itemSpec);
                return(changesets);
            }
            catch (Exception ex)
            {
                throw new MyTfsConnectionException("Exception when getting history :\n" + ex.ToString());
            }
        }