Modify CreationDate for TFS Changeset

自作多情 提交于 2020-01-07 05:05:10

问题


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?


回答1:


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.




回答2:


Updating the Changeset date is TOTALLY UNSUPPORTED. The TFVC server object ensures that changesets are always created in chronological order and makes a few assumptions based on this assurance.

History, sparse storage and reporting also make use of this cardinal rule. It's also one of the reasons why it's still not possible to merge two team projects from different collections.

I checked with the product team to be sure, their response:

Yes, we certainly make that assumption in the TFVC code.

So when changing a date, there are a number of not publicly documented rules that must be taken into account. Otherwise your database could fail to upgrade in the future or won't be able to be imported into VSTS when you way to make the jump.

If you need to make these changes, the best solution is to contact Microsoft Support so that they provide you with a script that performs the correct consistency checks.



来源:https://stackoverflow.com/questions/33223958/modify-creationdate-for-tfs-changeset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!