Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-03-18 16:17:58 +0000
committerMichael Valenta2002-03-18 16:17:58 +0000
commit8637c554a66476439ab80b9570373bccef899800 (patch)
treeccb3fe48360a54031b442a23edb1a6184a725d35
parentf016933fbd4505a01806411f40007b958f31e212 (diff)
downloadeclipse.platform.team-8637c554a66476439ab80b9570373bccef899800.tar.gz
eclipse.platform.team-8637c554a66476439ab80b9570373bccef899800.tar.xz
eclipse.platform.team-8637c554a66476439ab80b9570373bccef899800.zip
.vcm_meta to .project switch over
-rw-r--r--bundles/org.eclipse.team.cvs.core/plugin.properties3
-rw-r--r--bundles/org.eclipse.team.cvs.core/plugin.xml7
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java18
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java10
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/OrphanedFolderListener.java118
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionManager.java59
6 files changed, 86 insertions, 129 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/plugin.properties b/bundles/org.eclipse.team.cvs.core/plugin.properties
index aaa56cf85..dec360e84 100644
--- a/bundles/org.eclipse.team.cvs.core/plugin.properties
+++ b/bundles/org.eclipse.team.cvs.core/plugin.properties
@@ -1,2 +1,3 @@
pluginName = CVS Team Provider
-cvsNature=CVS Team Nature \ No newline at end of file
+cvsNature=CVS Team Nature
+vcmMetaMarker=VCM meta file \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/plugin.xml b/bundles/org.eclipse.team.cvs.core/plugin.xml
index 3d1a367d1..89aad520f 100644
--- a/bundles/org.eclipse.team.cvs.core/plugin.xml
+++ b/bundles/org.eclipse.team.cvs.core/plugin.xml
@@ -60,4 +60,11 @@
<ignore pattern = "*.class" selected = "true"/>
</extension>
+ <!-- *************** Markers **************** -->
+ <extension id="cvsmarker" point="org.eclipse.core.resources.markers"/>
+ <extension id="vcmmeta" point="org.eclipse.core.resources.markers" name="%vcmMetaMarker">
+ <super type="org.eclipse.core.resources.problemmarker"/>
+ <super type="org.eclipse.team.cvs.core.cvsmarker"/>
+ <persistent value="true"/>
+ </extension>
</plugin> \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java
index c72db56e1..9c2abdf55 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java
@@ -22,6 +22,7 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable;
@@ -35,6 +36,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSStatus;
import org.eclipse.team.ccvs.core.CVSTag;
+import org.eclipse.team.ccvs.core.ICVSFile;
import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSListener;
import org.eclipse.team.ccvs.core.ICVSProvider;
@@ -163,9 +165,23 @@ public class CVSProvider implements ICVSProvider {
IProject project = projects[i];
// Register the project with Team
// (unless the project already has the proper nature from the project meta-information)
- if (!project.getDescription().hasNature(CVSProviderPlugin.getTypeId())) {
+
+ // XXX The following workaround is required to ensure that the provider nature is set.
+ // The reasoning is as followings
+ // - if there is a vcm_meta, then the nature is set by the ProjectDescriptionManager
+ // - if there is a managed .project file, it shoudl contain the provider nature which
+ // will be read after the operation ends
+ // - if neither of the above is true, we can set the nature
+ // The workaround should be removed when the .project file updates result in immediate
+ // update of the project description
+ IFile vcm_meta = project.getFile(".vcm_meta");
+ ICVSFile project_meta = CVSWorkspaceRoot.getCVSFileFor(project.getFile(".project"));
+ if ( ! vcm_meta.exists() && ! project_meta.isManaged()) {
TeamPlugin.addNatureToProject(project, CVSProviderPlugin.getTypeId(), Policy.subMonitorFor(monitor, 100));
}
+// if (!project.getDescription().hasNature(CVSProviderPlugin.getTypeId())) {
+// TeamPlugin.addNatureToProject(project, CVSProviderPlugin.getTypeId(), Policy.subMonitorFor(monitor, 100));
+// }
}
} finally {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
index 6a506ade7..c541f3538 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
@@ -36,7 +36,7 @@ import org.eclipse.team.internal.ccvs.core.util.EntryFileDateFormat;
*/
class EclipseFile extends EclipseResource implements ICVSFile {
- private static final String TEMP_FILE_EXTENSION = ".tmp"; //$NON-NLS-1$
+ private static final String TEMP_FILE_EXTENSION = ".tmp";//$NON-NLS-1$
/**
* Create a handle based on the given local resource.
@@ -74,7 +74,13 @@ class EclipseFile extends EclipseResource implements ICVSFile {
try {
IFile file = getIFile();
if (responseType == CREATED || (responseType == UPDATED && ! resource.exists())) {
- file.create(new ByteArrayInputStream(toByteArray()), false /*force*/, null);
+ if (resource.exists()) {
+ // Special handling for the .project meta-file
+ // XXX This behavior should be restricted to the meta file!
+ file.setContents(new ByteArrayInputStream(toByteArray()), true /*force*/, true /*keep history*/, null);
+ } else {
+ file.create(new ByteArrayInputStream(toByteArray()), false /*force*/, null);
+ }
} else if(responseType == UPDATE_EXISTING) {
file.setContents(new ByteArrayInputStream(toByteArray()), false /*force*/, keepLocalHistory /*keep history*/, null);
} else {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/OrphanedFolderListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/OrphanedFolderListener.java
deleted file mode 100644
index 93407ed21..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/OrphanedFolderListener.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.ccvs.core.ICVSFile;
-import org.eclipse.team.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.client.Session;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-
-/**
- * Listen for the addition of orphaned subtrees as a result of a copy or move.
- *
- * Listen in IResourceChangeEvent.PRE_AUTO_BUILD so that other interested parties
- * (most notably, the file synchronizer) will receive up to date notifications
- */
-public class OrphanedFolderListener extends ResourceDeltaVisitor {
-
- private void handleOrphanedSubtree(IResource resource) {
- if (resource.getType() == IResource.FOLDER) {
- try {
- ICVSFolder mFolder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)resource);
- if (mFolder.isCVSFolder() && ! mFolder.isManaged() && mFolder.getParent().isCVSFolder()) {
- mFolder.unmanage();
- }
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- }
- }
-
- private void handleDeletedResource(IResource resource) {
- if (resource.getType() == IResource.FILE) {
- try {
- ICVSFile mFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource);
- if (mFile.isManaged()) {
- ResourceSyncInfo info = mFile.getSyncInfo();
- if (info.isAdded()) {
- mFile.unmanage();
- } else {
- mFile.setSyncInfo(new ResourceSyncInfo(info.getName(), info.DELETED_PREFIX + info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions()));
- }
- }
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- }
- }
-
- /*
- * Handle the case where an added file has the same name as a "cvs removed" file
- * by restoring the sync info to what it was before the delete
- */
- private void handleReplacedDeletion(IResource resource) {
- if (resource.getType() == IResource.FILE) {
- try {
- ICVSFile mFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource);
- if (mFile.isManaged()) {
- ResourceSyncInfo info = mFile.getSyncInfo();
- if (info.isDeleted()) {
- mFile.setSyncInfo(new ResourceSyncInfo(info.getName(), info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions()));
- }
- }
- } catch (CVSException e) {
- CVSProviderPlugin.log(e);
- }
- }
- }
-
- /*
- * @see ResourceDeltaVisitor#handleAdded(IResource[])
- */
- protected void handleAdded(IResource[] resources) {
- for (int i = 0; i < resources.length; i++) {
- if (resources[i].getType() == IResource.FOLDER) {
- handleOrphanedSubtree(resources[i]);
- } else if (resources[i].getType() == IResource.FILE) {
- handleReplacedDeletion(resources[i]);
- }
- }
- }
-
- /*
- * @see ResourceDeltaVisitor#handleRemoved(IResource[])
- */
- protected void handleRemoved(IResource[] resources) {
- for (int i = 0; i < resources.length; i++) {
- handleDeletedResource(resources[i]);
- }
- }
-
- /*
- * @see ResourceDeltaVisitor#handleChanged(IResource[])
- */
- protected void handleChanged(IResource[] resources) {
- }
-
- /*
- * @see ResourceDeltaVisitor#finished()
- */
- protected void finished() {
- }
-
- protected int getEventMask() {
- return IResourceChangeEvent.PRE_AUTO_BUILD;
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionManager.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionManager.java
index 7352733c7..b68077006 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionManager.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionManager.java
@@ -13,6 +13,7 @@ import java.io.InputStream;
import org.apache.xerces.parsers.SAXParser;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
@@ -27,12 +28,13 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.ccvs.core.ICVSFile;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.RepositoryProviderType;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.TeamPlugin;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.Policy;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -45,8 +47,11 @@ import org.xml.sax.SAXException;
public class ProjectDescriptionManager {
public final static IPath PROJECT_DESCRIPTION_PATH = new Path(".vcm_meta"); //$NON-NLS-1$
+ public final static IPath CORE_PROJECT_DESCRIPTION_PATH = new Path(".project"); //$NON-NLS-1$
public final static boolean UPDATE_PROJECT_DESCRIPTION_ON_LOAD = true;
+ public static final String VCMMETA_MARKER = "org.eclipse.team.cvs.core.vcmmeta";
+
/*
* Read the project meta file into the provider description
*/
@@ -127,9 +132,19 @@ public class ProjectDescriptionManager {
* To be called whenever the project description file is believed to have changed by
* a load/loadIfIncoming operation.
*/
- public static void updateProjectIfNecessary(IProject project, IProgressMonitor progress) throws CoreException {
- IFile descResource = project.getFile(PROJECT_DESCRIPTION_PATH);
+ public static void updateProjectIfNecessary(IProject project, IProgressMonitor progress) throws CoreException, CVSException {
+
+ IFile descResource = project.getFile(PROJECT_DESCRIPTION_PATH);
if (descResource.exists() && UPDATE_PROJECT_DESCRIPTION_ON_LOAD) {
+
+ // If a managed .project files exists, don't read the .vcm_meta
+ ICVSFile coreDescResource = CVSWorkspaceRoot.getCVSFileFor(project.getFile(CORE_PROJECT_DESCRIPTION_PATH));
+ if (coreDescResource.exists() && coreDescResource.isManaged()) {
+ createVCMMetaMarker(descResource);
+ Util.logError(".vcm_meta file ignored for project " + project.getName(), null);
+ return;
+ }
+
// update project description file (assuming it has changed)
IProjectDescription desc = project.getDescription();
DataInputStream is = null;
@@ -141,7 +156,7 @@ public class ProjectDescriptionManager {
is.close();
}
try {
- project.setDescription(desc, progress);
+ project.setDescription(desc, IResource.FORCE | IResource.KEEP_HISTORY, progress);
} catch (CoreException ex) {
// Failing to set the description is probably due to a missing nature
// Other natures are still set
@@ -150,13 +165,26 @@ public class ProjectDescriptionManager {
// Make sure we have the cvs nature (the above read may have removed it)
if (!project.getDescription().hasNature(CVSProviderPlugin.getTypeId())) {
try {
- TeamPlugin.addNatureToProject(project, CVSProviderPlugin.getTypeId(), progress);
- } catch (TeamException ex) {
+ // TeamPlugin.addNatureToProject(project, CVSProviderPlugin.getTypeId(), progress);
+
+ // Set the nature manually in order to override any .project file
+ IProjectDescription description = project.getDescription();
+ String[] prevNatures= description.getNatureIds();
+ String[] newNatures= new String[prevNatures.length + 1];
+ System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
+ newNatures[prevNatures.length]= CVSProviderPlugin.getTypeId();
+ description.setNatureIds(newNatures);
+ project.setDescription(description, IResource.FORCE | IResource.KEEP_HISTORY, progress);
+ } catch (CoreException ex) {
// Failing to set the provider is probably due to a missing nature.
// Other natures are still set
Util.logError(Policy.bind("ProjectDescriptionManager.unableToSetDescription"), ex); //$NON-NLS-1$
}
}
+ // Mark the .vcm_meta file with a problem marker
+ if (project.getFile(CORE_PROJECT_DESCRIPTION_PATH).exists()) {
+ createVCMMetaMarker(descResource);
+ }
} catch(TeamException ex) {
Util.logError(Policy.bind("ProjectDescriptionManager.unableToReadDescription"), ex); //$NON-NLS-1$
// something went wrong, delete the project description file
@@ -178,7 +206,9 @@ public class ProjectDescriptionManager {
public static void writeProjectDescriptionIfNecessary(CVSTeamProvider provider, IResource resource, IProgressMonitor monitor) throws CVSException {
if (resource.getType() == IResource.PROJECT || isProjectDescription(resource)) {
IProject project = resource.getProject();
- writeProjectDescription(project, monitor);
+ if (project.getFile(PROJECT_DESCRIPTION_PATH).exists() /* || ! project.getFile(CORE_PROJECT_DESCRIPTION_PATH).exists() */) {
+ writeProjectDescription(project, monitor);
+ }
}
}
@@ -233,4 +263,19 @@ public class ProjectDescriptionManager {
};
ResourcesPlugin.getWorkspace().addResourceChangeListener(changeListener, IResourceChangeEvent.PRE_AUTO_BUILD);
}
+
+ protected static IMarker createVCMMetaMarker(IResource resource) {
+ try {
+ IMarker[] markers = resource.findMarkers(VCMMETA_MARKER, false, IResource.DEPTH_ZERO);
+ if (markers.length == 1) {
+ return markers[0];
+ }
+ IMarker marker = resource.createMarker(VCMMETA_MARKER);
+ marker.setAttribute(IMarker.MESSAGE, resource.getName() + " file exists in " + resource.getProject().getName() + " but is no longer required and can be deleted");
+ return marker;
+ } catch (CoreException e) {
+ Util.logError("Error creating deletion marker", e);
+ }
+ return null;
+ }
} \ No newline at end of file

Back to the top