Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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
There are APIs today which allow you to retrieve the old comments on a change set, so nothing is lost. Once you have a IChangeSet in hand, simply get the IItemManager.fetchAllStateHandles(), then for each handle get the states. Each state has the comment.


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&lt;IChangeSet&gt; stateList = (List&lt;IChangeSet&gt;) repo.itemManager().fetchAllStateHandles(changeSet,monitor);
for (IChangeSetHandle csHandle : stateList) {
final IChangeSet cs =
(IChangeSet) repo.itemManager().fetchCompleteItem(csHandle, IItemManager.REFRESH, monitor);
System.out.println(&quot;state comment=&quot;+cs.getComment());
</B> };

System.out.println(&quot;comment=&quot;+changeSet.getComment());
}
return;
}
}

If there's a Junit or API documentation I should look at, please point me to it.

Thank you

0 votes



2 answers

Permanent link
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&lt;IChangeSetHandle&gt; handles = mgr.fetchAllStateHandles(cs, progress.newChild(40));
List&lt;IChangeSet&gt; csStates = mgr.fetchCompleteStates(handles, progress.newChild(50));

StringBuffer buf = new StringBuffer();
for (IChangeSet c : csStates) {
buf.append(c.getComment() + &quot;\n&quot;);
}
buf.toString();

}

0 votes


Permanent link
It works for me, too. Thank you!

0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Mar 06 '09, 1:26 p.m.

Question was seen: 8,104 times

Last updated: Mar 06 '09, 1:26 p.m.

Confirmation Cancel Confirm