Search code examples
tfsmigrationchangeset

Modify CreationDate for TFS Changeset


I'm currently creating a migration tool from one version control system to TFS and am using the Microsoft.TeamFoundation.Client assembly and have run into a problem. I am able to mimic the changes for each Changeset, but the CreationDate property is automatically generated by the CheckIn method as shown below:

var changeSetId = workspace.CheckIn(pendingChanges, userName, comment, note, null, null);

I am then able to load the Changeset object by ID that was returned by the CheckIn method:

var changeSet = workspace.VersionControlServer.GetChangeset(changeSetId);

I am attempting to set the CreationDate (not readonly) in the Changeset and I am able to do that via the following code:

changeSet.CreationDate = legacyLog.Date;
changeSet.Update();

But, after calling the Update method, the changes are not saved on the server as I have attempted to verify the date in the browser and it still shows today's date as the CreationDate (unless I'm misunderstanding where that date is displayed/rendered). Has anyone attempted to change the CreationDate for a Changeset before or am I going about this all wrong?


Solution

  • I agree with DaveShaw, you need to directly modify changeset's check-in time in TFS database. SQL statement: UPDATE tbl_Changeset SET CreationDate='?' WHERE ChangeSetId='?'

    Please check the ModifyCheckinDate2012 source code on this link for the details: https://tfsprod.codeplex.com/SourceControl/latest

    However, be note that it is not recommended to modify directly in TFS database, as this may bring some potential risks.