Show all changesets between two labels - tfs

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.

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?

View history with Visual Studio shelvesets

Is it possible to view history and compare with shelvesets? We are investigating the possibility of using shelvesets instead of check-ins. From our initial investigation it seems we cannot view history like we do for check-ins.
We are using Visual Studio 2010/TFS 2010.
From http://msdn.microsoft.com/en-us/library/ms181403(v=vs.90).aspx
Section: The Difference Between Changesets and Shelvesets:
Unlike a changeset, a shelveset is a non-versioned entity. If you or another user unshelve the items of which a shelveset consists, edit several files, and reshelve the shelveset, Team Foundation does not create a new version of the items for future comparison and maintains no record of who revised the items, when, or in what manner. The original shelveset is completely replaced.
So, no, you can't review history. I am unsure on methods of comparing shelvesets. You should also read that entire section (The Difference Between Changesets and Shelvesets) as each item in it is a strong argument to not use shelvesets in the place of changesets.
I also cannot think of any reason why using shelvesets instead of changesets would be desirable, maybe you can list the reasons why you all were exploring this path. Just think about not being able to track changes, that alone should be a deal breaker (of course, shelvesets not even being versioned should just about do it)..
Like it says on the link posted by dugas, shelvesets are built more for...well, shelving things. For example, on the project I am working on right now, I did a shelveset for some refactoring changes I was in the middle of because something unrelated broke and I needed the code back to the original non error-filled version. I also use it for when I'm in the middle of attempting something and want to have a backup but I don't want to check in code just yet.
There's no versioning on shelvesets, but it is possible to compare code in a workspace, to the code in a shelveset, without pulling the shelveset files.
Pull the versions of files you want to compare the shelveset contents to, into a workspace
open the solution in that workspace
File >> Source Control >> Unshelve Pending Changes...
find the desired shelveset and bring up its details
On each file in the Shelveset Details window, you can right-click and select Compare >> With Workspace Version...
TFS will pull the shelveset file to a temporary location, show the diff, and then (?) clean up the temp file after you're done.
You'll be comparing the shelveset file contents, to the contents of the files on the local disk in this workspace. If changes were made to both files, the compare won't be able to tell and will indicate all those changes. However, you can compare the selveset version to its original (Compare >> With Unmodified Version..), to see all the changes that were made just to the shelveset file. You can also find out the changeset that was the base for the shelveset file (Properties..), and see what changes were added to the workspace version since that common base changeset.
There's no tree compare though, and this may require the TFS power tools to work.
P.S> I don't recomment trying to use shelvesets in place of checkins like this. If there's one thing I've learned over the years, it's not to fight Microsoft's designed-in workflows -- you do things their way, or you find a different tool. Microsoft doesn't intend you to use shelvesets this way (they want you to use changesets and a branch), and if you try, you'll constantly be fighting Microsoft's designed-in workflow.
You can use shelvesets for peer code-review before committing them to the repository ... and also for parking commits before going through a gated build process.
They are not suitable for anything other than "quick shelving" of work - use branching if you want to have multiple parallel work streams.

TFS Changeset "Roll-up" / Cumulative Report

I need to have several changesets rolled-up into a single list of changed files, so that I can code-review the collective differences (from an initial changeset, up through an arbitrary ending changeset), rather than reviewing all changes through the individual intervening changesets.
I'm using VS 2k8. What is the easiest way to accomplish this?
The answer is to open a Visual Studio explorer window, and type this:
tf folderdiff "$/MyStuffInSource;C88986~C91716" /recursive
That causes a window to open that shows the added, removed, changed files - and allows diffs to be launched on the individual files. Superb!!

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.

How do I find the text changes in TFS 2005 history?

I'm wondering how I search history in TFS 2005 for any changeset that contains a change (diff) between the file and it's previous version with the word "foobar" in it.
In other words, and more specifically, I want to find the changeset that removed a subscription to an event. Clearly the change won't be in the class raising the event, and because the event subscription is now gone, I don't know where it used to be.
I can probably narrow this down to a few hundred files, but viewing their individual history and then performing a difference on each seems excessive. The TF history command, even in detailed view, only shows me file names.
tf history /format:detailed *.* /noprompt /stopafter:1
Is there an undocumented uber-detailed output that shows a diff of each file with it's previous version?
You can't do this in TFS 2005. You would have to write a program that retrieved the history for the chosen file and for each changeset in the history of the file, it would have to retrieve the version in the changeset and the previous version, and diff the two to determine the changes made and compare them with the text change sought.

Resources