Answered Change list of files to exclude in pending changes

  • Friday, August 24, 2012 3:20 PM
     
     

    With the new pending changes in TFS2012, is there a way to modify the files that are automatically excluded. My team is using a tool that creates some private files that are coming up under include changes, but we want them under exclude.


All Replies

  • Friday, August 24, 2012 3:57 PM
     
     Proposed Answer

    Hi Anthony,

    Yes, I believe you can use the UpdateCheckinItems on the SavedCheckin object to do this. Something like

    SavedCheckin mySavedCheckin = myWorkspace.LastSavedCheckin;

    mySavedCheckin.UpdateCheckinItems(includedItems, excludedItems);

    myWorkspace.LastSavedCheckin = mySavedCheckin;

    http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.savedcheckin.updatecheckinitems.aspx

    I don't think that the change will be immediately reflected in the Pending Changes page of the Team Explorer. You may have to restart Visual Studio for the changes to be reflected.

    Thanks,
    P. Kelley

  • Friday, August 24, 2012 4:53 PM
     
     

    So this would need to be done through code then? No option in the IDE to make this change?

    Also, is there a way to find out what is currently in the exclude list?

    Thanks,

    Anthony


  • Monday, August 27, 2012 6:11 AM
     
     

    Anthony,

    I agree with kelly. You need to use code, i do not find any IDE way to exclude.

    Thanks,

  • Monday, August 27, 2012 12:28 PM
     
     Answered

    Anthony,

    It looks like the way you would build the set of excluded items is to take all pending changes in the workspace (from Workspace.GetPendingChanges()). Iterate over each pending change in that list and present the server item of the change (pendingChange.ServerItem) to the IsExcluded method on SavedCheckin. Something like:

    IEnumerable<PendingChange> pendingChanges = workspace.GetPendingChangesEnumerable();
    SavedCheckin savedCheckin = workspace.LastSavedCheckin;
    List<PendingChange> excludedChanges = new List<PendingChange>();

    foreach (PendingChange change in pendingChanges)
    {
        if (savedCheckin.IsExcluded(change.ServerItem))
        {
            excludedChanges.Add(change);
       }
    }

    Thanks,
    P. Kelley

    • Marked As Answer by Anthony Hunter Monday, August 27, 2012 7:43 PM
    •  
  • Monday, August 27, 2012 7:43 PM
     
     

    Thanks for the help. I'll play around with this and see if I get what I'm looking for.

    Anthony