How to check if there are new changsets on TFS server? - tfs

I was a user of Mercurial for very long time and got very used to a hg incoming command. It shows what is the difference between my local Mercurial repository and remote server.
I was using it daily to check what others committed and together with tortoisehg I was able to quickly review commits of others.
Is there a similar command available in TFS?

One way of accomplishing this would be to find the latest changeset number in your local workspace first and then right click the branch to find it's history and associated changesets. If the local changeset and the last changeset in view history is same then you dont have anything to review or else you have changes to review.
To get the changeset number from your local workspace you can use the following command, as per this MSDN Buck Hodges: This should be run from the root of your workspace in the commandline.
tf history . /r /noprompt /stopafter:1 /version:W
You are also trying to follow the same process that you have been doing all along, have you tried exploring some of the code review functionality which TFS2012 gives? Check that out as well HERE.
Hope it helps!

Closest behavior to
hg incoming
is
tf history . /recursive /format:detailed /version:W~T
It shows a windowed (/format:detailed) list of changes from workspace version (W) until tip (T) on the server.

From a command line in your source folder use
tf get /preview
It will show what would occur if you did a get latest, effectively telling you what changes are incoming.
If you want the change set details as well, have a look at the answer to: Is there a way to find out which changesets I haven't synced to?

Related

Checkin multiple files with tf.exe in one changeset

On one of our builds we are kicking off some automated process which is checking out and checking in some files automatically.
This all works rather well, but at this time we are running the checkin command which looks like the following
tf.exe checkin /force /comment:"foo" /noprompt /bypass /override:"bar"
All of the files with a Pending status will get checked in.
I'd like to make this script a bit more specific and only checkin the files (2 in total) which we actually change during the build, so we know for sure no files will get checked in 'by accident'.
I've already seen we can specify a single filename with the checkin command, but doing so we will get 2 different changesets in TFS, instead of 1. We would really like to have 1 changeset, containing both changed files as the changes belong to eachother.
Any ideas on how to approach this?
Minor addition / Short term solution
For the moment I've solved our 'problem' by specifying the folder where our modified files are located, which kind of looks like this
tf.exe checkin "/my/folder/location/" /recurse /force /comment:"foo" /noprompt /bypass /override:"bar"
Note the folder location and the /recurse parameter added.
You simply separate the files by spaces:
tf.exe checkin file1.ext file2.ext /force /Comment:"foo" /noprompt /bypass /override:"bar"
The documentation is not clear about this point but it might be a general specification of an itemspec that it can be multiple items.
See similar question about checkout: Is there a way to check-out multiple files from various folders in TFS in a single operation
As mentioned by others you might run into problems with the command line being longer than the system supports, in which case you might need to look at other solutions.
cmd.exe has a limit on how long a command can be. Using the version control API, or simply 'tf checkin /i' (no arguments) is likely to be a better choice than passing lots of long filenames.
It's normal if a file becomes automatically checked out due to a change, and if ultimately the contents of the file are changed back to it's original state. At that point you would see the message about identical contents upon comparison. You could also use tfpt uu /noget /r * command to ignore Files which are identical to the originals. You'll need to have TFS Power Tools installed for this to work. Note: there is no TFS Power tool 2017.
For more details please refer below two links:
Visual Studio TFS shows unchanged files in the list of pending changes
Can TFS Pending Changes show files that are truly changed like SourceGear Vault?

tf.exe undo pending changes from other users

I am looking to migrate our TFS projects to another server. Before doing this I want to inspect all pending changes, undo them (or tell the person that has it checked out what it's all about) and lock the project on the old server.
For this I need to undo checkouts in very old workspaces that no longer exist. I'm now looking for ways to make this work. I realise there are a bunch of other questions like this, most with answers that point towards using tf.exe, which I am also using, but there's one thing that I just can't seem to get my head around.
Here's the deal. I'm using the following command to check to see if there's still files checked out by anyone.
tf status "$/MyProject" /s:MyServer /u:* /recursive
This presents me with a list of all files that are checked out and by whom. To undo the checkout I can now use this command:
tf undo /workspace:"TheWorkspace";TheUser
$/MyProject" /server:MyServer /recursive
This is all very nice, but notice how I need the workspace name to make this work. This name is however not returned by the tf status command. So now I'm forced to mess around with the workspaces command to figure out which workspaces a user has like this:
tf workspaces /server:MyServer /owner:TheUser /format:detailed
There has to be another way right? This way I'm just looking through a massive report on workspaces for each user (some have had as many as 6 computers/laptops over the years, all with dozens of workspaces), it's no fun :(
Is there any way to make tf status report the workspace name as well? Or make the undo command work across workspaces?
Any help would be appreciated.
tf status supports a /format parameter. The brief output (which is the default) doesn't include the workspace. the detailed one does.
tf status "$/MyProject" /s:MyServer /u:* /recursive /format:detailed

Show all changesets between two labels

In TFS2010 each build is associated with a label by the build server.
Our SCM management wants to see all the changesets and related workitems between two labels. Mostly those labels are builds that have a build quality "Released". This way all changes between two delivered builds can be reported.
How is this done in TFS 2010 ?
I don't think you want to use the label, I think you want to use the date/time of the build(s). Labels are easily mutable and don't necessarily represent a point in time. Assuming you have the datetimes of the builds, you can use the TF.EXE command line to generate this.
For example:
tf.exe history /server:http://tfs:8080 "$/ProjectName/src" /version:D2010-09-12T11:30~D2010-09-29T11:30 /recursive /noprompt /brief
The /version: parameter is one of the keys here. This should be after the time of your first build and up to and including the time of the second build.
if you use /format:detailed, you'll get a listing of all files that changed in each of the changesets as well. This can be a lot of data. You'll probably want to redirect the output > output.txt if you do this.
UPDATE
As mentioned, you can, in fact, determine the changes between two labels. However, if these labels have moved, your results may be compromised.
tf.exe history /server:http://tfs:8080 "$/ProjectName/src" /version:LMain-CI_20100831.6~LMain-CI_20100927.1 /recursive /noprompt /brief
I would still recommend using the dates instead of the labels. I believe the results you receive from that approach probably more closely match your requirements.
UPDATE 2
I just noticed you're using TFS 2010. You will probably have to change the /server: parameter to point to the appropriate collection. Use TF.EXE history /? to get the list of parameters, but the change would be to use /collection:TeamProjectCollectionUrl
tf history /server:"http://tfsserver:8080/tfs/DefaultCollection" "$/project root/Dir/SubDir" /recursive /noprompt /format:detailed /version:"L1.1.66.0~L1.1.67.0"
Notice L prefix in version option.

TFS List File modified after 'Label'

I'm working with TFS 2008 with Continuous Build integration.
It's possible to have a list of files modified after Label applied?
Thanks a lot!
This is not as easy as you might thing. First off, don't consider the label to be a specific point in time. You can move a label from one version of a file to another, so the date of one given file might not be the same as the dates of the rest of the files in the build.
Instead, you probably want to go by a given date.
Get the start time of the build, then
Use the commandline TF.EXE to get the list (where the build start time is the datetime shown in version below).
tf history /server:http://tfs:8080 "$/Project/Dev/Src" /version:D2010-06-04T00:00~T /format:detailed /noprompt /recursive
This will get a detailed list of all changes that happened since 06/04/2010 at midnight, and the current time ("T").
If you're looking to do this programmatically, let me know and I can give some guidance there.
I've found that the history command will only tell you files that have changed between two labels, but won't tell you files that have been added or removed.
If you want to know that then you need to use the diff command, e.g.
tf.exe diff "$/<tfs folder>" /recursive /noprompt /format:basic /version:"Llabel1~Llabel2"
This is equivalent to doing the following from Visual Studio 2010
EDIT: I've recently re-tried this using TFS2013, and it now only shows changes to files that exist in both labels, i.e. is now the same as using history. So either I was wrong when I first posted this, or TF.exe has been changed.

Comparing differences in an entrie workspace in TFS

As TFS maintains an idea of the version that is downloaded on the client, such that "Get Latest" might not get the latest version; I was wondering if there was an easy way to report differences across an entire workspace?
I only ask as a member of my team is leaving immanently, and our IT department need to recycle his laptop very quickly, and I'm a little concerned that there is potential for some changes not to have been changed in.
Sorry misread the question.
If you have proper checkouts you can just do the following:
Go to the command line, and at the top if the workspace type
tf checkin . /recursive
This will present the what's outstanding in the workspace.
Or just shelve the lot to the serve and then you can peruse at leisure.
tf shelve
Oherwise the other thing I would do is
Just get the latest version of the software to another Directory and then use the excellent beyond compare tool from scootersoft to compare the directories recursively.
Once you have the files just copy the list to a bat file calling tf checkout on each one.
Then do tf shelve.

Resources