Find moved file programmatically by old name

In answer to another question , Edward Thomson recommends using the QueryItems

old file name to search for a relocated file.

However, I cannot figure it out. It looks like a part Microsoft.teamfoundation.versioncontrol.server.dll

, but I can't find it anywhere. I wonder if this is a DLL on the TFS server itself (which I don't have access to right now). If so, it will not help me with what I need.

How can I programmatically find the moved filename by old filename in TFS 2010?


source to share

2 answers

If the server you are talking to is at least TFS 2010, then you can do so using Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer.GetChangesForChangeset (). After you define the changeset that you renamed using QueryHistory, call GetChangesForChangeset and pass "true" for the "includeMergeSourceInfo" parameter. This will add a MergeSources property to each Change object.

With the move to "slotmode" in 2010, the rename to TFS Version Control is very similar to the Branch and Delete operation under the covers. Because of this, renames are actually tracked as part of the "merge history".

So, if you redo the changes and find a change that has a MergeSource that is both the rename (see the IsRename property) and your original item, you will find the target of the rename operation.



I think it actually means the GetItem (s) or QueryHistory methods for

Namespace:  Microsoft.TeamFoundation.VersionControl.Client
Assembly:  Microsoft.TeamFoundation.VersionControl.Client (in Microsoft.TeamFoundation.VersionControl.Client.dll)


For more information on these elements see this msdn page . You can specify a VersionSpec, which can include the delete ID. If I remember correctly, you need to be careful if you want to use this code for older versions of TFS. TFS2010 introduced a slot modem which is more efficient and can track file name changes in different versions. Prior to that, renaming was mostly limited to removing the old version and adding a new version, no links were preserved.



All Articles