diff options
author | Michael Valenta | 2002-10-02 14:42:11 +0000 |
---|---|---|
committer | Michael Valenta | 2002-10-02 14:42:11 +0000 |
commit | 1973a1614eb4cb21e26064f8bedb8f9abefc8f3a (patch) | |
tree | 24062479aa9e2b71ddba9266d8c03f4fa2f56ac3 /bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java | |
parent | 297788dab64477747e170afa0821e505981dbbf7 (diff) | |
download | eclipse.platform.team-1973a1614eb4cb21e26064f8bedb8f9abefc8f3a.tar.gz eclipse.platform.team-1973a1614eb4cb21e26064f8bedb8f9abefc8f3a.tar.xz eclipse.platform.team-1973a1614eb4cb21e26064f8bedb8f9abefc8f3a.zip |
22338: [CVS Repo View Modules] Need a way to checkout a file/folder/module (CVS) into existing project
Diffstat (limited to 'bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java')
-rw-r--r-- | bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java | 90 |
1 files changed, 89 insertions, 1 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java index 641d820ba..b14c18e9d 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java @@ -144,7 +144,6 @@ public class CVSWorkspaceRoot { // Fetch the module expansions IStatus status = Request.EXPAND_MODULES.execute(session, new String[] {moduleName}, Policy.subMonitorFor(pm, 50)); if (status.getCode() == CVSStatus.SERVER_ERROR) { - // XXX Should we cleanup any partially checked out projects? throw new CVSServerException(status); } @@ -224,6 +223,95 @@ public class CVSWorkspaceRoot { } /** + * Checkout the remote resources into the provided local folder. + */ + public static void checkout(final ICVSRemoteFolder resource, final IContainer target, final boolean configure, final boolean recurse, final IProgressMonitor monitor) throws TeamException { + final TeamException[] eHolder = new TeamException[1]; + try { + IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() { + public void run(IProgressMonitor pm) throws CoreException { + try { + pm.beginTask(null, 1000); + + final ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(target); + + // Delete the target folder if it exists. + String folderName = cvsFolder.getName(); + if (cvsFolder.exists()) { + // Unmanage first so we don't get outgoing deletions + cvsFolder.unmanage(Policy.subMonitorFor(pm, 50)); + cvsFolder.delete(); + } + + // Prepare the target to receive the contents of the directory + cvsFolder.mkdir(); + cvsFolder.setFolderSyncInfo(resource.getFolderSyncInfo()); + + // Open a connection session to the repository + ICVSRepositoryLocation repository = resource.getRepository(); + Session.run(repository, cvsFolder, true, new ICVSRunnable() { + public void run(IProgressMonitor monitor) throws CVSException { + List localOptions = new ArrayList(); + // Add recurse option + if (!recurse) + localOptions.add(Update.DO_NOT_RECURSE); + // Perform the checkout using the update command + // We use update to avoid communicating info about the parent + // directory which may or may not be shared with CVS + IStatus status = Command.UPDATE.execute( + Command.NO_GLOBAL_OPTIONS, + (LocalOption[])localOptions.toArray(new LocalOption[localOptions.size()]), + new ICVSResource[]{ cvsFolder }, + null, + monitor); + if (status.getCode() == CVSStatus.SERVER_ERROR) { + throw new CVSServerException(status); + } + } + }, Policy.subMonitorFor(pm, 800)); + if (configure) { + manageFolder(cvsFolder, repository.getLocation()); + refreshProjects(new IProject[] { target.getProject() }, Policy.subMonitorFor(pm, 50)); + } else { + cvsFolder.unmanage(Policy.subMonitorFor(pm, 50)); + } + } + catch (TeamException e) { + // Pass it outside the workspace runnable + eHolder[0] = e; + } finally { + pm.done(); + } + // CoreException and OperationCanceledException are propagated + } + }; + ResourcesPlugin.getWorkspace().run(workspaceRunnable, monitor); + } catch (CoreException e) { + throw CVSException.wrapException(e); + } finally { + monitor.done(); + } + // Re-throw the TeamException, if one occurred + if (eHolder[0] != null) { + throw eHolder[0]; + } + } + + private static void manageFolder(ICVSFolder folder, String root) throws CVSException { + // Ensure that the parent is a CVS folder + ICVSFolder parent = folder.getParent(); + if (!parent.isCVSFolder()) { + parent.setFolderSyncInfo(new FolderSyncInfo(FolderSyncInfo.VIRTUAL_DIRECTORY, root, CVSTag.DEFAULT, true)); + IResource resource = parent.getIResource(); + if (resource.getType() != IResource.PROJECT) { + manageFolder(parent, root); + } + } + // Set the sync info for the folder so it is managed by it's parent + folder.setSyncInfo(new ResourceSyncInfo(folder.getName())); + } + + /** * Create a remote module in the CVS repository and link the project directory to this remote module. * The contents of the project are not imported. */ |