It's all about the answers!

Ask a question

Finding whether a file is deleted in a change-set programmatically.


Atul Kumar (1872329) | asked Jan 07 '15, 12:50 a.m.
edited Jan 07 '15, 12:54 a.m.
Hi,

I need to find out whether a file was deleted as a change in a change-set. Can I do so using IChange/IChangeSet references ?

I tried using following, but it threw IllegalStateException:

int mergeKind = change.getMergeKind(versionableHandle);
if(mergeKind == IChange.DELETE) {
    System.out.println("Deleted");
}

Thanks,
Atul

Accepted answer


permanent link
Atul Kumar (1872329) | answered Mar 09 '15, 2:34 a.m.
had found a way to do this...posting it for the sake of this question -

for (IChange change : (List<IChange>) changeset.changes()) {
                if(((ChangeImpl) change).getItem() instanceof FileItemHandleImpl) {                   
                    if (((FileItemHandleImpl) ((ChangeImpl) change).getItem()).getItemId().getUuidValue().equals(rtcFile.getRtcFileUuid())) {
                        if (change.kind() == IChange.DELETE) {
                            //File Deleted.
                        }
                    }
                }
            }
Ralph Schoon selected this answer as the correct answer

Comments
Evan Hughes commented Mar 09 '15, 2:14 p.m.
JAZZ DEVELOPER

You should also verify that the change set is in the same component (e.g. changeSet.getComponent().sameItemId(myComponent)). 


I'm not sure where you're getting your change sets from, but you might be able to compose a query that would give you the exact change sets rather than iterating over a set of changes. You can do that with the com.ibm.team.scm.common.internal.IScmQueryService.findChangeSets() . The IChangeSetSearchCriteria object has some useful fields, such as setChangeType() which you can set to DELETE, setItem() which you can use to limit the search to a specific versionable, and setContext() which can be set to a stream or workspace.

That may not be appropriate to your application, however. 

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.