Tf Command Line utility - Determine previous file path after a rename

250 views Asked by At

Is there any way to do this? I know that I can do tf changeset xxx and it will tell me which files were "delete, source rename" for the old file paths but if there are multiple renames, there is no way to be sure which file goes with which.

Also if the change is local and has not yet been committed, I do not see a way to make this work.

1

There are 1 answers

2
jessehouwing On BEST ANSWER

For local changes:

C:\Users\JesseHouwing\Source\Workspaces\vsts-tfvc-tasks-test>tf rename "changes.122204,old" "changes.122204.new"
changes.122204.new

C:\Users\JesseHouwing\Source\Workspaces\vsts-tfvc-tasks-test>tf status /format:detailed
$/vsts-tfvc-tasks-test/changes.122204.new;C29
  User       : Jesse Houwing
  Date       : Friday, 15 September 2017 11:10:29
  Lock       : none
  Change     : rename
  Workspace  : SNAPPIE
  Source item: $/vsts-tfvc-tasks-test/changes.122204,old
  Local item : [SNAPPIE] C:\Users\JesseHouwing\Source\Workspaces\vsts-tfvc-tasks-test\changes.122204.new
  File type  : Windows-1252

1 change(s)

For remote changes, when you know the changeset number, use the changeset option to see:

C:\Users\JesseHouwing\Source\Workspaces\vsts-tfvc-tasks-test>tf changeset 29 /noprompt
Changeset: 29
User: Jesse Houwing
Date: Thursday, 14 September 2017 20:02:54

Comment:

Items:
  delete, source rename $/vsts-tfvc-tasks-test/changes.122204;X2
  rename                $/vsts-tfvc-tasks-test/changes.122204,old

use /itemmode and history to track a specific file, here you can see the previous name of that specific file:

C:\Users\JesseHouwing\Source\Workspaces\vsts-tfvc-tasks-test>tf vc history "changes.122204,old" /noprompt /format:detailed /itemmode
-----------------------------------------------------------------------------------------------------------------------
Changeset: 29
User: Jesse Houwing
Date: Thursday, 14 September 2017 20:02:54

Comment:

Items:
  rename $/vsts-tfvc-tasks-test/changes.122204,old

-----------------------------------------------------------------------------------------------------------------------
Changeset: 11
User: Jesse Houwing
Checked in by: Project Collection Build Service (jessehouwing-dev)
Date: Saturday, 2 April 2016 20:46:32

Comment:

  ***NO_CI***

Items:
  add $/vsts-tfvc-tasks-test/changes.122204

If the rename wasn't done through Visual Studio or through the tf rename command it may show up as a delete and an add and the relationship between those changes would have been lost. Visual Studio provides a UI to fix those kinds of changes before check-in, but once checked in, that information won't come back