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

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

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

0 votes


Accepted answer

Permanent link
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

0 votes

Comments

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 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,941

Question asked: Jan 07 '15, 12:50 a.m.

Question was seen: 2,634 times

Last updated: Mar 09 '15, 2:14 p.m.

Confirmation Cancel Confirm