3

Using tf.exe, the command line utility for TFS, I've automated the process of merging two branches using tf.exe in a batch file in simple steps:

  1. TF Get... /Recursive
  2. TF Merge... /Recursive

However, while checking in the changes, "TF Checkin" Dialog shows all the pending changes selected in the dialog whether using /Recursive or not.

What I want: To select only modified files in my selected folder instead of all the pending changes. Please note that this is a random thing, as I have 100's of files in my folders, so only files changed during Merge should be selected (definitely these would be modified ones).

Solution I expect: To create a separate Workspace for my automated merge process. This would isolate the checkin process and would select only the changes made through this Workspace.

Another Possibility: Is it possible to Checkin files in a specific folder and ignore rest of the pending changes?

Thankx

Farrukh Waheed
  • 2,163
  • 2
  • 29
  • 59

2 Answers2

6

I'm not sure I understand your problem right, but it is indeed possible to checkin only files in a specific folder. To avoid checkin problems you should probably do a "resolve" first. For instance

tf.exe get /r c:\src\branch1\project1 c:\src\branch2\project1

tf.exe merge c:\src\branch1\project1 c:\src\branch2\project1 /r /noprompt

tf.exe resolve c:\src\branch2\project1 /r /auto:acceptTheirs /noprompt
tf.exe checkin c:\src\branch2\project1 /r /noprompt /override:"done by script"

You should always do a /noprompt when running tf.exe from a script/automation process. This is to avoid popups. In the resolve I put /auto:acceptTheirs which will take the changes from the source branch when a conflicting change occurs. There are several different options here, you will have to concider which suits your purpose. /override on the checkin will override any checkin policies, which is probably (but not necessarily) a good idea from a script.

The approach with creating new workspaces every time is something I would try to avoid if possible. Creating and deleting a workspace is a heavy process, and in my experience it is difficult to keep track of all the workspaces so I usually end up with lots and lots of unused workspaces that needs to be removed.

SteveC
  • 15,808
  • 23
  • 102
  • 173
Snorre
  • 955
  • 1
  • 5
  • 18
  • Seems like a working solution @Snorre. I actually tried like: "CD c:\src\branch2\", and do "tf Checkin Project1 /r", it might not work. So it takes "Mapped Folder Values" i.e. full paths. Thanks – Farrukh Waheed Dec 02 '13 at 07:56
  • btw, although I'm aware of /NoPrompt, but for the time being, avoiding it, just to take a review of what we are going to checkin. That only step we have to analyze. – Farrukh Waheed Dec 02 '13 at 07:58
  • great. you can also do tfs path values like tf.exe checkin $/projectname/branch1/ etc – Snorre Dec 02 '13 at 08:00
  • In addition, we never planned to create separate workspaces for each session, instead just create one Workspace just to accomplish this merge task and no need to delete that workspace. But thanks for this good solution with folders. – Farrukh Waheed Dec 02 '13 at 08:00
  • Yes, I also discovered same. – Farrukh Waheed Dec 02 '13 at 11:53
2

Just discovered that we can also use Repository Address instead of hard-coding paths:

tf checkin $/MainRep/Playground/MyFolder/HTMLLogViewer /r

Would give same facility and would prevent us from using hard coded paths.

SteveC
  • 15,808
  • 23
  • 102
  • 173
Farrukh Waheed
  • 2,163
  • 2
  • 29
  • 59