This follows my previous question about TFS 2010 and the possibility to create a changelog.
I was previously using labels to identify a version of the program, but as labels are not fixed points in time, now I'm using branches.
Here's how the branch hierarchy looks like:
As you can see, there are two different applications that are branches of the trunk: APP_A
(application A) and APP_B
(application B). Both are almost identical, but there are some functional differences.
Here is the process to create a new version of the application (say version 1.3):
- The
Main trunk
is modified (new functionalities are added, bug fixes...) - From the modified
Main trunk
, a new branch is created:Main trunk 1.3
APP_A
branch might be modified, so unique functionalities ofAPP_A
will work with modification of v1.3APP_B
branch might be modified, so unique functionalities ofAPP_B
will work with modification of v1.3Main trunk 1.3
is merged toAPP_A
andAPP_B
, so bothAPP_A
andAPP_B
applications receive the modifications of theMain trunk
- From the modified
APP_A
branch, a new branch is created:APP_A_1.3
- From the modified
APP_B
branch, a new branch is created:APP_B_1.3
My goal is to be able to produce a changelog between APP_A_1.3
and APP_A_1.2
.
By changelog I mean a list of WorkItems. Each changeset that is checked-in is associated with one or more WorkItem (for instance a Bug item). I would like to be able to get the list of all workitems that were linked to a changeset that has impacted APP_A_1.3
: those changesets might come from the Main trunk
(step 1 above), the APP_A branch
(step 3 above) or even the APP_A_1.3
branch itself (if hotfixes are checked-in after the branch has been created).
To get this list of workitems, I tried to get the list of all changesets that are "linked" to APP_A_1.2
("linked" = the code that was checked-in in the changeset is now on the branch APP_A_1.2
) and the list of all changesets that are "linked" to APP_A_1.3
.
Then, I'll be able to know which changesets are "linked" to APP_A_1.3
and not "linked" to APP_A_1.2
. From this subset of changesets, I'll get all associated WorkItems and thus my changelog.
Here's my problem: how could I get the list of ALL changesets that are "linked" with a specified branch? I'm using the TFS 2010 API for C# code.
The input of my program (that would retrieve all changesets for a specified branch) would be the name of the branch (say APP_A_1.2
), and the output would be the list of following changesets:
- changesets applied on
APP_A_1.2
branch itself - changesets applied on
APP_A
branch beforeAPP_A_1.2
was created - changesets applied on
Main trunk 1.2
branch before it has been merged toAPP_A
- changesets applied on
Main trunk
branch beforeMain trunk 1.2
was created
I've wrote the following pieces of code to get all those changesets:
// Gets the list of all changesets ID from APP_A_1.2 branch
var branch1ChangeSets = myVersionControlServer.QueryHistory(
"$/PATH/APP_A_1.2/",
VersionSpec.Latest,
0,
RecursionType.Full,
null,
null,
null,
int.MaxValue,
false,
false).OfType<Changeset>().Select(z => z.ChangesetId).ToList();
Even if RecursionType.Full
is specified, the above code only returns changesets that were checked-in on the APP_A_1.2
branch itself. This is identical to the "History" command on Source Code Explorer view in Visual Studio.
Then I tried the following piece of code:
// Gets the list of all changesets ID from APP_A_1.2 branch
var branch1MergedChangeSets = myVersionControlServer.QueryMerges(
null,
null,
"$/PATH/APP_A_1.2/",
VersionSpec.Latest,
null,
null,
RecursionType.Full).Select(z => z.SourceVersion).ToList();
This returns changesets that were checked-in on APP_A_1.2
branch + those that were cheked-in on APP_A
branch before APP_A_1.2
was created. Much better, but not sufficient. I can't find a way to make the recursion work with branches that are "above" APP_A
(Main trunk
in my case)...
Anyone has an idea?
Also, any better ideas to get the changelog between two branches are welcome... Thx.