示例#1
0
        protected override void OnCheckout(FilePath targetLocalPath, Revision rev, bool recurse, IProgressMonitor monitor)
        {
            var ws = WorkspaceHelper.GetLocalWorkspaces(this.VersionControlService.Collection);

            if (ws.Count == 0)
            {
                Workspace newWorkspace = new Workspace(this.VersionControlService,
                                                       Environment.MachineName + ".WS", this.VersionControlService.Collection.Server.UserName, "Auto created",
                                                       new List <WorkingFolder> {
                    new WorkingFolder(VersionControlPath.RootFolder, targetLocalPath)
                }, Environment.MachineName);
                var workspace = this.VersionControlService.CreateWorkspace(newWorkspace);
                workspace.Get(new GetRequest(VersionControlPath.RootFolder, RecursionType.Full, VersionSpec.Latest), GetOptions.None, monitor);
            }
            else
            {
                this.workspaces.AddRange(ws);
                var workspace = GetWorkspaceByLocalPath(targetLocalPath);
                if (workspace == null)
                {
                    return;
                }
                workspace.Get(new GetRequest(workspace.GetServerPathForLocalPath(targetLocalPath), RecursionType.Full, VersionSpec.Latest), GetOptions.None, monitor);
            }
        }
        private void FillWorkspaces()
        {
            string activeWorkspace = TFSVersionControlService.Instance.GetActiveWorkspace(projectCollection);

            _workspaceComboBox.Changed -= OnChangeActiveWorkspaces;
            _workspaceStore.Clear();
            _workspaces.Clear();
            _workspaces.AddRange(WorkspaceHelper.GetLocalWorkspaces(projectCollection));
            TreeIter activeWorkspaceRow = TreeIter.Zero;

            foreach (var workspace in _workspaces)
            {
                var iter = _workspaceStore.AppendValues(workspace, workspace.Name);
                if (string.Equals(workspace.Name, activeWorkspace, StringComparison.Ordinal))
                {
                    activeWorkspaceRow = iter;
                }
            }
            _workspaceComboBox.Changed += OnChangeActiveWorkspaces;
            if (_workspaces.Count > 0)
            {
                if (!activeWorkspaceRow.Equals(TreeIter.Zero))
                {
                    _workspaceComboBox.SetActiveIter(activeWorkspaceRow);
                }
                else
                {
                    _workspaceComboBox.Active = 0;
                }
            }
        }
        private void FillWorkspaces()
        {
            _listStore.Clear();
            var workspaces = _showRemoteCheck.State == CheckBoxState.On ? WorkspaceHelper.GetRemoteWorkspaces(this.projectCollection) :
                             WorkspaceHelper.GetLocalWorkspaces(this.projectCollection);

            foreach (var workspace in workspaces)
            {
                var row = _listStore.AddRow();
                _listStore.SetValue(row, _name, workspace.Name);
                _listStore.SetValue(row, _computer, workspace.Computer);
                _listStore.SetValue(row, _owner, workspace.OwnerName);
                _listStore.SetValue(row, _comment, workspace.Comment.Replace(Environment.NewLine, " "));
            }
        }
        private TFSRepository GetRepoFromServer(BaseTeamFoundationServer server, FilePath path)
        {
            foreach (var collection in server.ProjectCollections)
            {
                var workspaces = WorkspaceHelper.GetLocalWorkspaces(collection);
                var workspace  = workspaces.SingleOrDefault(w => w.IsLocalPathMapped(path));
                if (workspace != null)
                {
                    var result = new TFSRepository(workspace.VersionControlService, path);
                    result.AttachWorkspace(workspace);

                    return(result);
                }
            }
            return(null);
        }