Keep SVN timestamp

May 6, 2011 at 7:12 AM
Edited May 6, 2011 at 7:13 AM

"SVN original check-in date and revision number are not imported in TFS, they are just written in check-in notes (This is a limitation of TFS and can not be overridden)."

Wouldn't it be possible to set the TFS server's system time to the original commit time when replaying the SVN actions? (assuming the tool runs on the server and there are not other checkins running a the same time)

I did this when converting from CVS to SVN. I'm just not sure if TFS (and SQL Server) would allow this.

May 6, 2011 at 8:05 AM

Yes, this would be a workaround. However I did not plan to use it because changing continuously the time on a server is not a "best practice" and I had other priorities to finish before introducing minor, "unstable", features. If you would like, feel free to send a *patch* for this so that I can include it in the next version: I then would add a checkbox for this option and a msgbox that warns the user about the consequences. Thanks ichris.

Jun 7, 2011 at 6:22 PM

I don't know if something like this is supported and it is definitely not tested, but it may yield a useful post-processing script (when you have direct access to the server) with far less effort than modifying the migration tool to handle this case.  It also sounds a lot less risky than constantly updating the server time.

I am also not sure what the impact of this could potentially be on the server and how the server behaves, so use it cautiously in a test environment first.  Be sure to adjust the ParentPath to handle your specific project.  The first query to determine the impacted changesets should be optimized better since it doesn't perform very well.  Be sure to run it in the appropriate Tfs_<collection> database.

declare @changeSetDates table (ChangeSetId int, SvnDate datetime)

insert into @changeSetDates
SELECT [ChangeSetId]
      ,[SvnDate] = (
            select top 1 BaseValue
            from [dbo].[tbl_ReleaseNoteDetails] det
            where det.ReleaseNoteId = cs.CheckInNoteId
                  and det.FieldName = 'SvnDate'
FROM [dbo].[tbl_ChangeSet] cs
where cs.CheckInNoteId is not null
 and cs.changesetid in (
  select cs.ChangeSetId from [dbo].[tbl_File] f
  inner join [dbo].[tbl_Version] v on v.itemid = f.itemid and v.ParentPath like '$\MyProjectInsideCollection%'
  where f.versionfrom = cs.changesetid or v.VersionTo = cs.ChangeSetId

delete from @changeSetDates
where SvnDate is null

update f
set CreationDate = csd.SvnDate
from [dbo].[tbl_File] f
inner join @changeSetDates csd on f.versionfrom = csd.changesetid
--select * from [dbo].[tbl_File] f

update content
set CreationDate = csd.SvnDate
from [dbo].[tbl_File] f
inner join @changeSetDates csd on f.versionfrom = csd.changesetid
inner join [dbo].[tbl_Content] content on content.FileId = f.FileId

update cs
set CreationDate = csd.SvnDate
from [dbo].[tbl_ChangeSet] cs
inner join @changeSetDates csd on csd.ChangeSetId = cs.ChangeSetId
--select * from [dbo].[tbl_ChangeSet]

update rn
set DateCreated = csd.SvnDate
from [dbo].[tbl_ReleaseNote] rn
inner join [dbo].[tbl_ChangeSet] cs on cs.CheckInNoteId = rn.ReleaseNoteId
inner join @changeSetDates csd on csd.ChangeSetId = cs.ChangeSetId
--select * from [dbo].[tbl_ReleaseNote] rn


Jun 8, 2011 at 7:20 AM

Cool! Thank you jim!