How are previous change set comments retrieved using the API
How can I see the history of change set comments?
Comment from Jean-Michel in Enhancement https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWorkItem&id=72237 I can see the current comment with changeset.getComment(), but I haven't been able get the previous states. What code should I use? public static void getChangeSetComments(ITeamRepository repo, IProgressMonitor monitor) throws TeamRepositoryException, ItemNotFoundException, ComponentNotInWorkspaceException { IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(repo); IChangeSetSearchCriteria criteria = IChangeSetSearchCriteria.FACTORY.newInstance(); //Get any 10 changesets. List<IChangeSetHandle> changeSets = wm.findChangeSets(criteria, 10, monitor); for (IChangeSetHandle changeSetHandle : changeSets) { //For each changeset final IChangeSet changeSet = (IChangeSet) repo.itemManager().fetchCompleteItem(changeSetHandle, IItemManager.REFRESH, monitor); //For the given change set, get all the states. Each state will have a comment. <B> //These next lines are where I don't know what to do. I put some code here just to experiment. //I'm going in a circle. fetchAllStateHandles returns a few rows per change set, but it's not //the number of revisions. cs.GetComment() returns the most recent change set comment. final List<IChangeSet> stateList = (List<IChangeSet>) repo.itemManager().fetchAllStateHandles(changeSet,monitor); for (IChangeSetHandle csHandle : stateList) { final IChangeSet cs = (IChangeSet) repo.itemManager().fetchCompleteItem(csHandle, IItemManager.REFRESH, monitor); System.out.println("state comment="+cs.getComment()); </B> }; System.out.println("comment="+changeSet.getComment()); } return; } } If there's a Junit or API documentation I should look at, please point me to it. Thank you |
2 answers
This should work. Here is a snippet that I just tested locally and it prints all the comments given to a particular change set.
void showChangesetHistory(IChangeSet cs, IWorkspaceConnection wc, IProgressMonitor monitor) throws TeamRepositoryException { SubMonitor progress = SubMonitor.convert(monitor, 100); IItemManager mgr = wc.teamRepository().itemManager(); List<IChangeSetHandle> handles = mgr.fetchAllStateHandles(cs, progress.newChild(40)); List<IChangeSet> csStates = mgr.fetchCompleteStates(handles, progress.newChild(50)); StringBuffer buf = new StringBuffer(); for (IChangeSet c : csStates) { buf.append(c.getComment() + "\n"); } buf.toString(); } |
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.