Reputation: 655
In an answer to another question, Edward Thomson recommends using QueryItems
to find a moved file by its old file name.
However, I can't seem to figure this out. It looks like it's part of Microsoft.teamfoundation.versioncontrol.server.dll
, but I can't seem to locate this anywhere. I wonder if this is a DLL on the TFS server itself (which I don't have access to at the moment). If so, it won't help me for what I need.
How can I programmatically find the moved file name by the old file name in TFS 2010?
Upvotes: 3
Views: 864
Reputation: 3104
If the server you are talking to is at least TFS 2010 then you can do this using Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer.GetChangesForChangeset(). Once you determine the changeset that the rename occurred in using QueryHistory, call GetChangesForChangeset and pass "true" for the "includeMergeSourceInfo" parameter. This will populate the "MergeSources" property on each Change object.
With the switch to "slotmode" in 2010 a rename in TFS Version Control is very similar to a "Branch and Delete" operation under the covers. Because of this, renames are actually tracked as part of "merge history".
So, if you iterate over the changes and find the change that has a MergeSource that is both a rename (see IsRename property) and has your source item then you will have found the target item of the rename operation.
Upvotes: 3
Reputation: 115037
I think he actually means the GetItem(s) or QueryHistory methods of the
Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer
Namespace: Microsoft.TeamFoundation.VersionControl.Client
Assembly: Microsoft.TeamFoundation.VersionControl.Client (in Microsoft.TeamFoundation.VersionControl.Client.dll)
See this msdn page for more information on these items. You can specify a VersionSpec which can include a Deletion Identifier. If I remember correctly though, you'll need to be careful if you want to use this code against older versions of TFS. In TFS2010 slotmode was introduced, which is more efficient and can track filename changes across versions. Before that a rename basically came down to a Delete of the old version and an Add of the new version, no relationship stored.
Upvotes: 1