Comparison keyboard shortcuts for Pending Changes in TFS

by Alex Meyer-Gleaves 5 September 2009 - 6:01 PM

Logitech MX5500

One of the first things I configured in my Visual Studio environment when I starting using TFS was keyboard shortcuts to make comparing my pending changes easier. I find having to right-click on each item in the Pending Changes window and navigate through the context menu to perform a comparison quickly tests my patience. The drop down menu on the tool bar button is slightly faster but still not quick enough for my liking. I am always fastest when my hands don’t need to leave the keyboard.

I have configured keyboard shortcuts to compare my pending changes with the Latest, Workspace and Previous versions. Obviously the shortcuts only work when the option would normally appear enabled on the context menu. To configure these shortcuts select Options from the Tools menu in Visual Studio. In the Options dialog use the tree to drill into Environment and then to the Keyboard settings. Enter the command names below into the Show commands containing text box one at a time:

  • TeamFoundationContextMenus.SourceControlPendingChangesSourceFiles.Compare.TfsContextPendingCheckinsCompareWithLatestVersion
  • TeamFoundationContextMenus.SourceControlPendingChangesSourceFiles.Compare.TfsContextPendingCheckinsCompareWithWorkspaceVersion
  • TeamFoundationContextMenus.SourceControlPendingChangesSourceFiles.Compare.TfsContextPendingCheckinsCompareWithPreviousVersion

For each command enter your desired keyboard shortcut into the Press shortcut keys text box and click the Assign button. I have used the shortcut keys below, assigned to the commands in the same ordinal position above:

  • Ctrl+`
  • Ctrl+Shift+`
  • Ctrl+Alt+`

With this in place I can quickly fire up and navigate through my diffs in WinMerge using only my keyboard. No mucking about and no reaching for the mouse. Even a simple set of steps can become frustrating when you have to repeat them a large number of times. Save yourself all that clunky mouse based GUI interaction and embrace the power of the keyboard!

Update: With the new Pending Changes page in Visual Studio 2012 the command have changed.

For Visual Studio 2012 use the command names below instead:

  • TeamFoundationContextMenus.PendingChangesPageChangestoInclude.TfsContextPendingChangesPageCompareWithLatestVersion
  • TeamFoundationContextMenus.PendingChangesPageChangestoInclude.TfsContextPendingChangesPageCompareWithPreviousVersion
  • TeamFoundationContextMenus.PendingChangesPageChangestoInclude.TfsContextPendingChangesPageCompareWithWorkspaceVersion

Tags: ,

Development Tools

Moving files between projects in TFS

by Alex Meyer-Gleaves 28 January 2009 - 6:25 PM

Team Foundation Server I came across a knowledge base article by Microsoft Support that describes how to move files between projects in TFS in a way that keeps their history. In short, to keep your history you need to perform the move in the Source Control Explorer and then fix up your project files. Performing the move in the Solution Explorer causes the project files to be updated immediately, but the history will not be kept because it results in a delete and add operation.

Strangely, the article recommends that you perform the move and check in your changes before fixing up the affected projects. That would put your version control database into an invalid state, and anyone who performed a Get Latest Version would find themselves with a solution that does not compile.

You can easily perform all the actions required to complete the move in one Change Set. These are the steps I find work well for me:

  1. In the Solution Explorer, right-click the files (or folders) you want to move and select Exclude From Project. This will check out the project file and remove any references to the items you are about to move.
  2. Use the Source Control Explorer to move the items to the new location. The moved items will be checked out and have a pending rename operation.
  3. Back in the Solution Explorer, go the the project you moved the items into and click the Show All Files button.
  4. You will now see the items you moved marked with a plain white document icon. Right-click the items and select Include In Project. This will check out the project file and add a reference to the items you moved.
  5. In your Pending Changes window you will see the two project files have edit operations pending, and the moved items have a rename operation pending.
  6. Make sure the solution builds, your unit tests pass and that the changes look correct in your favourite diff tool.
  7. Check in your Pending Changes. These changes will all go into one Change Set and your version control database will never be in an invalid state. You will of course also have kept your history.

This simple process allows you to keep your source control operations atomic while ensuring you keep your valuable history.

Tags: ,

Development Tools

About the author

Alex Meyer-Gleaves I'm a Technical Architect living in Australia (that island like continent in the southern hemisphere). I love Microsoft .NET and C#. I hate early mornings, slow drivers and Lotus Notes.

Twitter

Google Shared

 

Month List

Recent Comments

Comment RSS

Links

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010