Handle Project out of synch using Plain Java API after discarding changeset
After discarding changes i can not do any further changes using plain java, as project is out of synch, I must open EWM client press reload out of synch project, close it and go further. I tried to reload the project using code below but it gives this error
"Loading the directories in the file system would overwrite/remove existing directories."
which is clear as it want to over write the content of local workspace(sandbox) but it cant, notice that both requestreload and requestload giving the same error. which is logical, but how can I do force reload or reload which resynch the project. just like scm command
which is clear as it want to over write the content of local workspace(sandbox) but it cant, notice that both requestreload and requestload giving the same error. which is logical, but how can I do force reload or reload which resynch the project. just like scm command
./scm.exe, load, --resync, -r repository uri .../ccm, -d sandboxPath
I used this code to reload my sandbox also load my workspace too
IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(repo); List<IWorkspaceHandle> workspaceHandleList = getWorkspaceByName("BRM Stream Workspace"); ISharingManager sharingManager = FileSystemCore.getSharingManager();
IWorkspaceConnection workspaceConnection = wm.getWorkspaceConnection(
workspaceHandleList.get(0), monitor);
IPath sandboxPath = new Path(
"Path to my local workspace(sandbox root)");
ILocation sandboxLocation = new PathLocation(sandboxPath);
FileSystemCore.startUp();
ISandbox sandbox = sharingManager.getSandbox(sandboxLocation, false);
List<IComponentHandle> componentHandles = workspaceConnection
.getComponents();
ILoadOperation loadOperation = null;
for (IComponentHandle componentHandle : componentHandles) {
IComponent component = (IComponent) repo.itemManager()
.fetchCompleteItem(componentHandle, IItemManager.REFRESH,
monitor);
IConfiguration configuration = workspaceConnection
.configuration(componentHandle);
Map<String, IVersionableHandle> versionableMap = configuration
.childEntriesForRoot(monitor);
Collection<IVersionableHandle> versionableHandles = versionableMap
.values();
LoadDilemmaHandler loadDilemmaHandler = LoadDilemmaHandler
.getDefault();
// LoadDilemmaHandler loadDilemmaHandler = CBLoadDilemmaHandler.getDefault();
loadOperation = IOperationFactory.instance
.getLoadOperation(loadDilemmaHandler);
// Evaluate the load requests that have been created
// loadOperation.evaluateLoadRequests(monitor);
IRepositoryResolver resolver = new IRepositoryResolver() {
@Override
public ITeamRepository getRepoFor(String uri, UUID id)
throws TeamRepositoryException {
// TODO Auto-generated method stub
return repo;
}
};
IShare[] iShare = sandbox.allShares(monitor);
Collection<IShare> ishareCol = new ArrayList();
for (int j = 0; j < iShare.length; j++) {
ishareCol.add(iShare[j]);
}
loadOperation.setEclipseSpecificLoadOptions(com.ibm.team.filesystem.client.operations.ILoadOperation.IMPORT_PROJECTS);
loadOperation.setPreserveLocalChanges(false);
loadOperation.setPreserveFileTimestamps(false);
// loadOperation.
loadOperation.requestReLoad(ishareCol, resolver, false, monitor);
// loadOperation.requestLoad(sandbox,/* IRelativeLocation */null,
// workspaceConnection, componentHandle, versionableHandles);
loadOperation.run(monitor);
sharingManager.deregister(sandbox, monitor);
workspaceConnection.refresh(monitor);
Accepted answer
The SCM system gets out of sync, if someone modifies a Repository Workspace and that repository workspace is loaded.
Do not do that. You are not supposed to modify repository workspaces that are loaded in parallel. Repository workspaces do not handle this situation. The repository workspace assumes it is only loaded once and the SCM system monitors the loaded sandbox. If local files change, this is synced with the repository workspace in the server. If there are changes accepted into the repository workspace, these changes are synched into the sandbox.
You use streams, if you want to do parallel development to be able to deliver these changes.
You use streams, if you want to do parallel development to be able to deliver these changes.
Comments
Yes I have read your post that said out of sync error is because of double loading workspace. but i Have it only once in EWM loaded.
Actually Rhapsody use the workspace to run and do tests on latest code in the workspace. The test create many artifacts, which should be undo or discarded in some case. I need the workspace be clean after the test as it was at the beginning.
The local workspace (sandbox) access by Rhapsody, once loaded in EWM client and My plain java API code have access to the local workspace(sandbox) too. Java Api should do loading latest repository workspace changes into sandbox and at the end clean unresolved or checked in changes.
It means I need a way to undo and discard changes that does not bring the state of version control into out of synch or repair state. Do you have any suggestion!
Currently we don't need to deliver these changes to repository workspace through corresponding streams. Parallel development come later on.