It's all about the answers!

Ask a question

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


Atul Kumar (1872329) | asked Jun 02 '14, 5:54 a.m.
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 ?

Accepted answer


permanent link
Tim Mok (6.6k38) | answered Jun 02 '14, 9:11 a.m.
JAZZ DEVELOPER
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

Comments
Atul Kumar commented Jun 03 '14, 12:00 a.m.

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


Atul Kumar commented Jun 03 '14, 1:15 a.m.

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


Tim Mok commented Jun 03 '14, 9:11 a.m.
JAZZ DEVELOPER

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
Atul Kumar (1872329) | answered Jun 03 '14, 1:13 a.m.
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));

Comments
Tim Mok commented Jun 03 '14, 9:19 a.m.
JAZZ DEVELOPER

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.


Atul Kumar commented Jun 09 '14, 1:23 a.m.

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 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.