コード例 #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);
        }