Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I finally came up with a simple solution. I'm not totally happy with it as it actually looks like a brute-force algorithm, but at least it works.</p> <p>What I do is:</p> <p>1) Get the list of <strong>every changeset</strong> that is applied on <strong>the very root of my TFS branches</strong> (i.e. the "parent path" of <code>Main Trunk</code>):</p> <pre><code>var allChangesets = vcs.QueryHistory( "MySourcePath", VersionSpec.Latest, 0, RecursionType.Full, null, firstPossibleChangeset, VersionSpec.Latest, int.MaxValue, true, false).OfType&lt;Changeset&gt;().ToList(); </code></pre> <p>2) For each retrieved changeset, I call <code>TrackMerges</code> to see if the changeset impacts in some way my branches. <code>TrackMerges</code> is able to tell me if a specified changeset is applied on the branches I specify as parameter of the function (it'll return the target changeset ID on these branches). If a changeset is applied on the destination branch (in my case <code>APP_A_1.3</code>) and not in the source branch (<code>APP_A_1.2</code>), then it means it's definitely something new on my <code>APP_A_1.3</code> branch.</p> <pre><code>List&lt;int&gt; newChangesets = new List&lt;int&gt;(); foreach (var z in allChangesets.Where(y =&gt; y.ChangesetId &gt; firstPossibleChangesetId)) { var zz = vcs.TrackMerges( new int[] { z.ChangesetId }, new ItemIdentifier("THE TRUNK PATH"), // The root of all branches new ItemIdentifier[] { new ItemIdentifier(fromBranchPath), new ItemIdentifier(toBranchPath) }, null); var targetInFromBranch = zz.Where(t =&gt; t.TargetItem.Item == fromBranchPath).FirstOrDefault(); var targetInToBranch = zz.Where(t =&gt; t.TargetItem.Item == toBranchPath).FirstOrDefault(); if (targetInToBranch != null &amp;&amp; targetInFromBranch == null) { // Then the changeset is only applied on the ToBranch newChangesets.Add(z.ChangesetId); } } </code></pre> <p>3) Now it's very simple to get my changelog (the list of workitems) from the list of "new changesets":</p> <pre><code>// Now, gets associated work items! Dictionary&lt;int, WorkItem&gt; dico = new Dictionary&lt;int, WorkItem&gt;(); foreach (int changesetId in newChangesets) { foreach (WorkItem zz in vcs.GetChangeset(changesetId).WorkItems) { this.AddWorkItemToDicRecursive(wis, dico, zz); } } private void AddWorkItemToDicRecursive(WorkItemStore wis, Dictionary&lt;int, WorkItem&gt; dico, WorkItem workItem) { if (!dico.ContainsKey(workItem.Id)) { dico.Add(workItem.Id, workItem); foreach (WorkItemLink associatedItem in workItem.WorkItemLinks) { this.AddWorkItemToDicRecursive(wis, dico, wis.GetWorkItem(associatedItem.TargetId)); } } } </code></pre> <p>I don't think it's the best possible approach, but it works fine and remains simple. Also, I didn't have to hardcode anything (branch names/hierarchy) so it's not too bad IMO. Hope it'll help someone.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload