MohamedG's Log

TW9oYW1lZCBFbC1HZWlzaA==

How to: Query All Labels on a Folder Recursively?

To do this, you can’t call query labels with a wildcard character, you need to do the following:   – Get all items blow $/Dir1 using GetItems – Loop through them calling QueryLabels on each one.   Here’s a code snippet: VersionControlServer sc = tfs.GetService<VersionControlServer>();List<VersionControlLabel> labels = new List<VersionControlLabel>();  foreach (Item i in sc.GetItems(“$/Proj”, RecursionType.Full).Items){   labels.AddRange(sc.QueryLabels(null, null, null, false, i.ServerItem, null));}… Read more

How to: Move a Shelveset to Another Branch?

A very handy power tool is tfpt unshelve. It’s capable of migrating a shelveset from a branch to another, it does that by performing a baseless merge, so you will need to resolve the conflicts produced. The syntax of the command looks like the following: tfpt unshelve shelvsetName /migrate /source:$/SourceBranch /target:$/TargetBranch… Read more

How to: Diff Shelved Files?

You can run: tf diff /shelveset:shelvesetName;DOMAIN\ownerUserName Please note that this will diff the shelved changes against the unmodified version, not necessarily the latest version, just like what the you get from clicking compare in the shelveset details dialog. If you want to diff the shelved files programmatically against the latest version, you will need to… Read more

How to: List Changesets Between Two Labeled Versions?

You can achieve that behavior by running: tf hist rootItemSpec /r /version:LstartLabel~LendLabel Here’s my scenario: tf hist /i File.cs Changeset Change                     User          Date       Comment ——— ————————– ————- ———- ——– 65        edit                       mohamedg      4/2/2009 63        edit                       mohamedg      4/2/2009 60        edit                       mohamedg      4/2/2009 59        edit                       mohamedg      4/2/2009 50        edit                       mohamedg      4/1/2009 49        edit                       mohamedg      4/1/2009 48        edit                       mohamedg     … Read more

How to: View History of an Item Across Branches?

You can use tfpt history /followbranches to follow the history of an item across branches. We are looking into supporting this in the history dialog in the next version. You can see which versions are ported over during the merge operation if you use tf.exe: tf merge BranchA BranchB /r merge: $/mohamedg/blog/BranchA/File.cs;C663~C664 -> $/mohamedg/blog/BranchB/File.cs;C665 After… Read more

How to: Copy Workspace Mappings?

A common scenario that you may see is the need to share/sync workspace mappings amongst team members. A developer adds a new dependency in a certain project and changes his/her mappings to get this library, and everyone else in the team now needs to do the same thing. Since workspace mappings are stored on the… Read more

How to: Switch Branches in a Workspace Without Getting All the Files of the New Branch?

One of the new features added in VSTF 2008 SP1 is that you can switch to another branch in your workspace and you don’t need to download all the files of the new branch. TFS will only download the files that differ in the new branch, if you use tf get /remap. It will also… Read more

How to: Move Your Workspace to Another Drive?

A common problem occurs when the drive that contains your workspaces runs out of disk space, or when you find yourself in a situation that you have to move your workspace to another drive. This might get tricky because your workspace mappings are stored on the server side. TFS knows about the local path and… Read more

How to Get List of Changes in a Shelveset Programmatically?

In a previous post, we used the command-line to list the changes in a shelveset. This time we are going to use an API to get the changes by calling: VersionControlServer.QueryShelvedChanges You have to be a valid user that can connect to Version Control, and you don’t need a workspace to call this method. The… Read more