Professional Visual Studio 2005 Team System (Programmer to Programmer)
The Source Control Explorer is similar to other explorers in Visual Studio. It enables you to browse and manage entire projects and individual folders in the repository. You can add and delete files; check in, check out, and view any of your pending changes; and view the status your local code compared to the code in Team Foundation version control. Think of it as your master control area for all tasks related to source code management. Some of the important tasks it will allow you to do include:
-
Creating Shelvesets. A shelveset is a collection of changes stored in a "shelf," or area, to temporarily store your source code without committing it to the repository.
-
Locking and unlocking files and folders.
-
Resolving conflicts.
-
Branching and Merging.
-
Viewing Historical Data.
-
Labeling your files and folders.
We will cover many of these topics later in the chapter. To access the Source Code Explorer, simply click View
Another way you can open your source code is by clicking File
The Source Control Explorer interface is pictured in Figure 20-5. It is divided into three main areas: the source tree view on the left (which enables you to navigate and select source files from your project), the details view on the right, and the Source Location bar. The Workspace drop-down list enables you to easily jump from one workspace to another. You will examine workspaces in more detail in the next section.
Workspaces
When you create a project or solution, you can automatically add it to Source Control (as shown in Figure 20-6). Please note that a workspace is created only if you don't already have one. Think of the workspace as your local copy of the source files and folders contained on the server. It enables you to work on an application without affecting any changes the rest of your team might be making.
Each of the changes you make to these files will be pending until you check them in or undo them. Once they are checked into the repository, they will be committed into the main repository.
You can manipulate your workspace using the Team Foundation command-line tool. You can also manipulate it from the GUI by selecting File
> tf.exe workspace /new MobileExplorerProject
In the preceding example, a new workspace is created called MobileExplorerProject. Anyone can create his own workspaces, but you must be logged in as an administrator to create and assign workspaces for other people. Table 20-3 describes common workspace options.
Workspace Options | Description |
---|---|
/comment | Tag a workspace with a comment. |
/computer | Specify the target computer for the workspace. |
/delete | Delete a workspace. |
/new | Create a new workspace. |
/newname | Rename an existing workspace. |
/noprompt | Execute workspace commands without prompts. |
/template | Specify a workspace to be used as a template to create brand-new workspaces. |
The workspaces (plural) command provides you with a holistic view of the workspaces on your Team Foundation Server. Note that the workspaces command will update the local cache file. It will cause the server to update its user cache when /updateUserName is used. The /updateComputerName option will change the computer name that is associated with the workspace on the server.
Workspaces Options | Description |
---|---|
/computer | Indicate what workspaces you want to view or manipulate from the repository, filtered by computer name. |
/format | Specify the format in which you would like to see the reports. You have two possible values at your disposal: Brief or Detailed. The default value is Brief. |
/owner | Specify the creator of the workspace. |
/s | Specify the name of the Team Foundation Server. |
/updateComputerName | Instruct Team Foundation Server to refresh because the client computer has changed name. It is typically written out as /updateComputerName:oldComputerName. The oldComputer-Name is the name that the computer had previously. |
/updateUserName | Instruct Team Foundation Server to refresh because one (or more) network users have changed names. |
In addition to the command line, you can also use Visual Studio to manage your workspaces. Figure 20-7 shows the Manage Workspaces window. You can access this window by clicking File
Adding Projects to the Source Repository
Once you have created workspaces, you can import the associated source files into the repository. The process of putting code in Team Foundation Server is called checking in. (You'll learn more about the check-in/check-out process in the next section.) To open the Add to Source Control window, simply right-click your solution in the Solution Explorer and select Add Solution to Source Control.
First, select which Team Foundation Server project, workspace, and folders will end up in the repository. The combination of these elements makes up the solution. Click the Advanced button to invoke a window in which you can specify the project locations, as shown in Figure 20-8.
In the next section, you will learn how to effectively check in and check out code from the source repository. You also find out about changesets and how to configure team check-in policies.