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

Get snapshot information; I've got change-set information

I've got a change-set's details (IChangeSet/UUID). Now, I want to emulate the "Open in Change-Explorer" action in my eclipse application.

Tried searching for samples...could locate ShowChangeSetsAction class in the plugin - com.ibm.team.filesystem.ide.ui

This is the API that the plugin uses to open the change-explorer:
 @Override
    protected void open(IWorkbenchPage page, SnapshotId snapshot, List<IChangeSetHandle> changeSets) {
        ChangesViewConverter.openChangeExplorer(page, new ChangeSetInput(snapshot, changeSets));
    }

I've got changeSets, but how do I find the snapshot ?

Any alternate way to open the change-set, without providing snapshot ?

0 votes


Accepted answer

Permanent link
You can create an empty SnapshotId: snapshot = SnapshotId.createEmptyId(repo);

That will allow you to open just the change sets with no reference to a snapshot, workspace, or stream. That means no paths will be resolved for any items in the change set. Also, you are referencing internals and they may change without warning. Use at your own risk.
Atul Kumar selected this answer as the correct answer

1 vote

Comments

Tried this API, but on the change-set's getOrigin() (i.e., repository), I'm getting NPE. Debugging it, will update with my findings.

I skipped snapshot creation, as there was another constructor of ChangeSetInput, that doesn't require it.

The use of getOrigin() can return null if the repository is unknown. It's not a guarantee that the origin will always be able to provide you with a repository.


One other answer

Permanent link
Could fix this.

Following is the code that opens change-set explorer, given its changeset UUID:

IChangeSetHandle changeSetHandle = (IChangeSetHandle) IChangeSet.ITEM_TYPE.createItemHandle(UUID.valueOf("_Zpj9EOo3EeOlUpxIHF-S3w"), null);
IChangeSet cs = (IChangeSet) repository.itemManager().fetchCompleteItem(changeSetHandle, IItemManager.DEFAULT, monitor);                   
List<IChangeSet> changeSets = new ArrayList<IChangeSet>();
changeSets.add(cs);
ChangesViewConverter.openChangeExplorer(getSite().getPage(), new ChangeSetInput(changeSets));

0 votes

Comments

When creating the item handle from the item id, it won't have the repository and that is why the getOrigin() call in your response above returned null.

That code is acceptable but, for future reference for others, it is using internal API and is subject to change without notice. Also, it follows the same method in my response and Change Explorer will have no reference to a snapshot, workspace, or stream. No paths will be resolved.

Yeah, I didn't require any references to snapshots/workspace/stream for that change-set when viewing in Change-explorer. So, it works for me.

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
× 10,938

Question asked: Jun 02 '14, 5:54 a.m.

Question was seen: 3,149 times

Last updated: Jun 09 '14, 1:23 a.m.

Confirmation Cancel Confirm