Helix Core — version control from Perforce — offers plugins and integrations for everyone on your team. Developers, designers, and third-party contributors can use the tools they love. And you can still maintain a single source of truth across teams.
Full Video Transcript
In this video we’ll look at how to configure and use P4VS, the Perforce plug-in for Visual Studio. Installing P4VS is easy; simply download the free plug-in from the Perforce website and double-click to install it in Visual Studio. Or you can install it directly from the Visual Studio Gallery, from within Visual Studio.
You’ll need to use version 2008 of Visual Studio or later, and your Perforce Server should be version 2009.2 or later. If you’d like to take advantage of all the latest features in P4VS, like P4Sandbox and Streams, your Perforce Server should be version 2012.1 or later.
Once you have P4VS installed, you’ll see it listed in the Extension Manager. Next, go to the Options Menu and make sure P4VS is selected as your source control provider. The rest of the source control options let you configure P4VS. For example you can select which Diff and Merge tools to use, if you don’t want to use Perforce’s own P4Merge Utility.
Another important option defines how P4VS will determine Perforce connection information, such as your Perforce Server, user name, and workspace. The Default option lets you select your Perforce connection information whenever you open a project under source control. You can instead choose to connect using your latest connection, connect using settings specific to a project solution, or have P4VS detect your connection from your Perforce Environment Settings. For most users, the rest of the default options will be acceptable.
If you’d like to connect a new, unversioned project to Perforce. You’ll have the option to add it when you create it. Just make sure you’re working in a Perforce Workspace Directory. If you forget this step, you can add your files to Perforce later. You’ll need to connect to a Perforce Server and add your files manually.
For this tutorial, I’m going to open up an existing Visual Studio project that someone else created and checked in. I already have the project files synced to my workspace. Since I left the default connection configuration option selected, I’m now prompted for my Perforce connection information. Once I’m connected, I’ll drill down to the solution in the depot browser, and open it.
Notice that the project is now connected to Perforce, and I see some basic Perforce information, like revision numbers, in the solution explorer. The files icons show the current state of each file under version control. I can also open up some Perforce-specific views via the View Menu, to display Workspaces, File History, Jobs, and more. These views are also accessible via the Toolbar, and are resizable and dockable like other Visual Studio views.
Now let’s look at how you might use P4VS to help you work in Visual Studio. I use Perforce Jobs as a way to integrate with Defect Tracking. So I’m going to take a quick look at the jobs assigned to me. I can see that there’s one related to the function GetChangeList. So I’ll start working on Changelist.cs.
Notice that I was prompted to check out the file when I started making changes. Here, I can also select the pending changelist I’d like this file added to. If I select the option “don’t show this dialog again” I won’t be prompted next time with this dialog box. If you do select this option, the file will be added to the active changelist specified in the Connection Toolbar. Once the file is checked out, you can see that the icon for this file changed in the Solution Explorer, letting us know that this file is indeed checked out.
Now I’ll add some code, to fix the out-of-range issue with GetChangeList. Now I’ll save my changes, and bring up the Diff Tool to compare my changes to the Have Revision. I can easily see the differences between the file I have from the depot, and my local file where I’ve just made edits.
I can shelve this change to let someone else review it, before check-in. Shelving stores a copy of the file on the server, without officially submitting it. I’ll change ownership of that changelist, to my team lead Duncan, so he can review my edits before they get submitted.
Now that I’ve shelved this change, I’ll login as Duncan and review it. The Connection Toolbar is a handy way to quickly change connections, as well as create new connections to frequently used workspaces. You can also use the Connection Toolbar to set the default changelist, and even the current stream.
Now that I’m logged in as Duncan, I can Diff the shelved file against its source revision to see what’s changed. That way, I don’t have to unshelve or even sync the file locally in order to review. Here, Duncan sees the same Diffs I did, when diffing against Have. Duncan has some comments to send back to me for review, so I’ll edit this pending changelist. And now Duncan can assign that pending changelist back to me.
I’m going to use the Connection Toolbar again to log back in as myself. And then I’ll unshelve this file so I can make the changes that Duncan suggested. Note that I’m prompted when the file currently displayed in the Visual Studio Editor has been modified. This is normal since I’ve just unshelved this file. So I’m going to go ahead and click “Yes” to reload the file. And now I’ll make the changes Duncan asked for.
Now it’s time to submit this change. I’ll open the jobs browser, so I can link to the job that this change was originally assigned to. And there’s my original job, so I’ll go ahead and select that one. And I’ll edit the changelist description as well. Notice that the file icon changed again, since this file is no longer checked out. Since I’m working in a Streams Depot, it’s easy to determine if there’s any merges or copies that I need to take care of.
I’ll open the Streams Tool Window and see if there’s any pending work as a result of that last submit. I can see that there’s a copy that needs to go to the mainline. So I’ll go ahead and do that. First I’d like to preview the copy. I think the only file that needs to be copied is ChangeList.cs, and I can confirm that with a preview. That looks correct, so I’ll proceed with the copy. And when prompted to select a changelist for the copy, I’ll also proceed directly to submit the file. I’ll write a description, and reference/link to? the same job that I fixed in the development stream, and submit.
And now that the mainline is up to date, that same change is ready for the release line. Though in this case, my team has continuous integration builds running in main. I’m going to wait until our QA gets a build to confirm the job I just closed as fix verified.
Now let’s take a look at a file’s history, using the P4VS File History Tab. For each revision of the file, I can see all of the associated information. such as the date, who submition author, and much more.
The time-lapse view gives me an easier way to look at the evolution of this file. Note that P4VS launches a time-lapse view tool. In order to use this feature, you’ll need to make sure that P4V – our cross-platform GUI client for Perforce is installed on your computer. I can also invoke the Revision Graph. Since I’m working in a Perforce Stream, I also see a menu option for the Stream Graph here. Again, most of the Perforce operations are available from within the conext menus inside of the Solution Explorer, or under the Perforce Menu.
And that wraps up our quick overview of using Perforce inside Visual Studio with P4VS.
Thanks for watching!