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