3

I want to get the current changeset id in my workspace. This problem is solved in "Get current changeset id on workspace for TFS".

tf history . /r /noprompt /stopafter:1 /version:W

This works in almost all cases. However, this fails if the current changeset contains ONLY deletes from TFS. This is not necessarily changesetId - 1, but depends on the history of the file / folder I query. If the current changeset only deleted a few files, the changeset prio to the current changeset in the history of the file / folder that I query.

The same thing happens when I use the TFS API calls that are mentioned on http://blogs.msdn.com/b/buckh/archive/2009/01/26/how-to-determine-the-latest-changeset-in-your-workspace.aspx

Is this a bug in TFS? Does anyone have a solution?

Thanks in advance.

Community
  • 1
  • 1
Quido
  • 629
  • 1
  • 7
  • 17

1 Answers1

0

The key here is that the version you've specified is W, meaning workspace. The history query is looking for changes that you have in your workspace. The problem is that the you can never "have" a changeset where all the files are deleted - they won't be in your workspace. The way get works is that it computes what you need and compares it to what you have (all in SQL) and sends the list of differences to the client. As a result, there is nothing on the server that records the fact that your client has already processed these deletions. In order to fix this, we'd have to run the get logic to check for this corner case. So, you are right that it's wrong in this case. I will ask the team, but unless there is a better way to fix it that I'm not thinking of, I don't anticipate changing it.

Buck Hodges
  • 3,342
  • 1
  • 19
  • 20
  • I have implemented a work-around with the API. When I get a result from QueryHistory(), I check for any changesets that are newer than that changeset. If a newer changeset contains only deletes, I check whether the deleted files are present on the local disk. I keep repeating this while the changesets only contains deletes and the files are not present on the local disk. The last changeset I find with only deletes and no files present, must be the correct one. – Quido Feb 25 '15 at 22:00