Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7577109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:06:04+00:00 2026-05-30T17:06:04+00:00

Given a changeset c and given that c contains merge operations, I would like

  • 0

Given a changeset c and given that c contains merge operations, I would like to get a list of all changesets that have been merged and resulted in c.

For example:

  • Changeset 1 contains some edits for some files.
  • Changeset 2 contains some edits for some other files.
  • Changeset 3 is a merge of changesets 1+2 to a parent branch.

Now I would like to get changesets 1+2 from asking changeset 3 which changeset merges it contained.

I want to do this using the TFS API. I came across the versionControlServer.TrackMerges method, however I do not understand what the ItemIdentifiers that the method expects should be. Unfortunately, I cannot find an example of how to use this method. Also I’m not sure if that is really the correct one.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:06:05+00:00Added an answer on May 30, 2026 at 5:06 pm

    Okay, it took me really long, but I think I found out how to do this. This is the Code that will find all the “parent” changesets:

    /// <summary>
    /// Gets the changesets which have resulted in the given changeset due
    /// to a merge operation.
    /// </summary>
    /// <param name="changeset">The changeset.</param>
    /// <param name="versionControlServer">The version control server.</param>
    /// <returns>
    /// A list of all changesets that have resulted into the given changeset.
    /// </returns>
    public static List<Changeset> GetMergedChangesets(Changeset changeset, VersionControlServer versionControlServer)
    {
        // remember the already covered changeset id's
        Dictionary<int, bool> alreadyCoveredChangesets = new Dictionary<int, bool>();
    
        // initialize list of parent changesets
        List<Changeset> parentChangesets = new List<Changeset>();
    
        // go through each change inside the changeset
        foreach(Change change in changeset.Changes)
        {
            // query for the items' history
            var queryResults = versionControlServer.QueryMergesExtended(
                                    new ItemSpec(change.Item.ServerItem, RecursionType.Full),
                                    new ChangesetVersionSpec(changeset.ChangesetId),
                                    null,
                                    null);
    
            // go through each changeset in the history
            foreach (var result in queryResults)
            {
                // only if the target-change is the given changeset, we have a hit
                if (result.TargetChangeset.ChangesetId == changeset.ChangesetId)
                {
                    // if that hit has already been processed elsewhere, then just skip it
                    if (!alreadyCoveredChangesets.ContainsKey(result.SourceChangeset.ChangesetId))
                    {
                        // otherwise add it
                        alreadyCoveredChangesets.Add(result.SourceChangeset.ChangesetId, true);
                        parentChangesets.Add(versionControlServer.GetChangeset(result.SourceChangeset.ChangesetId));
                    }
                }
            }
        }
    
        return parentChangesets;
    }
    

    Edit:

    I just realized that there is a small “bug” in the above code, I used to write “VersionSpec.Latest” in the query, however: “new ChangesetVersionSpec(changeset.ChangesetId)” would be better, because then the changesets would also be tracked once the source branch has been deleted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a two-dimensional list, I would like to find everything that contains a sublist.
I have a revision hash key. I would like to get the closest revision
Given an absolute or relative path (in a Unix-like system), I would like to
I am very new to Spring and I have been given some basic instructions
I have a table that contains URL strings, i.e. /A/B/C /C/E /C/B/A/R Each string
I have a ListBox that contains a number of User items that are DataTemplate
I have a JPanel that uses a FlowLayout and contains many JButtons. The buttons
I have to read in a file that contains a number of coordinates. The
Given the Following Code how Would i Change/Set my Silverlight WCF Service URI in
Given a specific DateTime value, how do I display relative time, like: 2 hours

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.