Saw
Saw

Reputation: 6436

Does canceling "get latest version" work in TFS?

I have chosen to get latest version from a TFS connected solution, and pressed cancel, is this operation transactional, I mean is canceling get latest version command cancels the whole operation or get some of the code and cancel the remaining files?

My Machine:

TFS 2010

VS 2010 SP1

Upvotes: 2

Views: 711

Answers (3)

Edward Thomson
Edward Thomson

Reputation: 78893

TL;DR: Yes, it's possible to get into a state where some of the files in your working folder are at the requested changeset and some of the files are at their previous changeset. You may wish to do a get specific of the previous version you were at in order to "roll back" to that version.

To see what's happening, we can break this down into the actual steps that are being performed when you do a get:

First, the client asks the server to get a particular version. The server will compute what files are needed to be transferred to bring you from the current changeset you're at to the changeset you requested. It will return these to the client as a series of "get operations".

At this point, the client should spawn multiple threads to service the get operations. Most of these threads will be threads that download the data and place it on disk. There will be an additional thread devoted to sending "local version updates" to the server.

The download threads take the get operation off the list returned by the server and download it to disk to a temporary location. Once the download has finished, they will move it into its permanent location and notify the thread that sends local version updates that the file has been fully downloaded.

The local version update thread will batch local version updates coming from the downloader threads until some fixed number is reached, since a local version update message is very small and sending them one-at-a-time would incur unnecessary network overhead. Once the local version update thread has accumulated enough updates, they will be sent to the server. This is the point at which the server knows the client has the versions of the files they requested.

The download threads will continue to service get operations until there are no more to process, and the local version update thread will continue until all download threads have finished downloading and all local version updates have been sent to the server. Once these occur, the get has finished.

If a client supports cancellation, its logic should be as follows: if the user requests cancellation (eg, by pressing the "cancel" button in a UI-based client) then all download worker threads should be notified to cancel. If they are in the middle of downloading a file, they should stop immediately (just discard the HTTP response they're reading.) However, once they have moved the file from its temporary location to its permanent location, they must notify the local version update thread before they exit. The local version update thread must wait for all download threads to finish, then flush any outstanding local version updates before it may exit.

Thus, if you were to cancel in the middle of a get, you may have some of the files on-disk that you were trying to download, but the client and server should have a consistent view of the versions of each file.

If you were to kill the client such that it was not able to cleanly stop the worker threads (by simply turning off power to your computer, for example) then you may be able to get into a state where the items had been committed to disk but the client had not yet flushed the local version updates to the server. In this case, you may have a version on-disk while the server believed you to have a different version. In the unlikely event that this would happen, you would need to use the "force" option when getting this file to reconcile this issue.

Upvotes: 2

maxim1000
maxim1000

Reputation: 6375

In my experience pressing "Cancel" creates difference between versions you have on your disk and versions TFS thinks you have on your disk. So if you try to update again, nothing will be downloaded, because server thinks you already have the latest version.

Upvotes: 1

user1793714
user1793714

Reputation: 329

It is not transactional. Some files may already be downloaded. In this case you should get a specific version after canceling your request.

Upvotes: 1

Related Questions