How to get unresolved changes of a repository workspace using java API
We are able to get the OutgoingChangeSets using the below code. But is there a way to find the unresolved changes of the workspace?
IChangeHistorySyncReport changeHistorySyncReport =
repositoryWorkspcaeConnection.compareTo(streamConnection,
WorkspaceComparisonFlags.CHANGE_SET_COMPARISON_ONLY, Collections.EMPTY_LIST, monitor);
List<IChangeSetHandle> outgoingChangeSets = changeHistorySyncReport.outgoingChangeSets();
Thanks.
One answer
Note:
None of the Filesystem client layer is official API.
You can use it, but per non-API, it is subject to change at any time.
For example, here is a snippet of code that might help.
protected boolean hasUncheckedInChangesInWorkspace(IProgressMonitor monitor) {
boolean uncheckedInChangesExist = false;
IWorkspace workspace = getWorkspace();
if (workspace != null) {
ILocalChangeManager lcm = FileSystemCore.getSharingManager().getLocalChangeManager();
ISharingManager sm = FileSystemCore.getSharingManager();
Collection<ISandbox> sandboxes = sm.getRegisteredSandboxes();
SubMonitor subMonitor = SubMonitor.convert(monitor, sandboxes.size());
outter: for (ISandbox sandbox : sandboxes) {
Collection<? extends IConfigurationDescriptor> loadedComponents = null;
try {
loadedComponents = sandbox.allLoadedConfigurations(subMonitor.newChild(1));
} catch (FileSystemException exception) {
// TODO log exception
}
for (IConfigurationDescriptor loaded : loadedComponents) {
if (loaded.getConnectionHandle() instanceof IWorkspaceHandle) {
IComponentHandle component = loaded.getComponentHandle();
ILocalChange[] localChanges = lcm.getPendingChanges(workspace, component, sandbox);
if (localChanges.length > 0) {
uncheckedInChangesExist = true;
break outter;
}
}
}
}
}
return uncheckedInChangesExist;
}
boolean uncheckedInChangesExist = false;
IWorkspace workspace = getWorkspace();
if (workspace != null) {
ILocalChangeManager lcm = FileSystemCore.getSharingManager().getLocalChangeManager();
ISharingManager sm = FileSystemCore.getSharingManager();
Collection<ISandbox> sandboxes = sm.getRegisteredSandboxes();
SubMonitor subMonitor = SubMonitor.convert(monitor, sandboxes.size());
outter: for (ISandbox sandbox : sandboxes) {
Collection<? extends IConfigurationDescriptor> loadedComponents = null;
try {
loadedComponents = sandbox.allLoadedConfigurations(subMonitor.newChild(1));
} catch (FileSystemException exception) {
// TODO log exception
}
for (IConfigurationDescriptor loaded : loadedComponents) {
if (loaded.getConnectionHandle() instanceof IWorkspaceHandle) {
IComponentHandle component = loaded.getComponentHandle();
ILocalChange[] localChanges = lcm.getPendingChanges(workspace, component, sandbox);
if (localChanges.length > 0) {
uncheckedInChangesExist = true;
break outter;
}
}
}
}
}
return uncheckedInChangesExist;
}
Comments
Many Thanks for your reply!
Since our code is running with the help of plain java server API’s and not the eclipse plugin setup, the pending changes are not been retrieved and it always end with the error message: “org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred while retrieving component type of array”
Also, we have figured out that the error message is coming from : com.ibm.team.filesystem.client.internal.localchanges.LocalChangeManager
@Override
public ILocalChange[] getPendingChanges(IContextHandle connection,IComponentHandle component, ISandbox sandbox) {
LocalChangeTracker tracker = findTracker(connection, component, sandbox.getRoot());
if (tracker == null)
{
return NO_CHANGES; // control returns from here.
}
return tracker.getPendingChanges();
}
Let us know if we are missing anything here. Thanks.
Nope, you're not missing anything. Take a look at the Java package that ILocalChangeManager is in, which is: "com.ibm.team.filesystem.client". I.e. all this code is client-side code. The server does not know about these 'unresolved' changes (which is a client-side concept).
I would like to put my question in other way. Do we have any API which gives us the files which are modified and are not yet checked-in.
"Pending local changes" or "Unresolved changes" or "files which are modified and are not yet check-in" are all the same thing. There is the API I mentioned above, but this API is client-side API. The server has no concept of this and thus there is no API on the server.