Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-01-16 16:49:28 +0000
committerMichael Valenta2002-01-16 16:49:28 +0000
commit4ee63c5dad720f46aa2ee57547d5165698f6bbae (patch)
treeabb2cc96ece7684ce8dfc813c39e215bfd967969
parentf8d039f6bc4f5e5aaac6e016165733e9e8670f67 (diff)
downloadeclipse.platform.team-4ee63c5dad720f46aa2ee57547d5165698f6bbae.tar.gz
eclipse.platform.team-4ee63c5dad720f46aa2ee57547d5165698f6bbae.tar.xz
eclipse.platform.team-4ee63c5dad720f46aa2ee57547d5165698f6bbae.zip
7262: Missing nature causes Check Out to fail
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties1
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ProjectDescriptionManager.java22
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java634
3 files changed, 333 insertions, 324 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties
index 244dd23e0..2ea65547a 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties
@@ -43,6 +43,7 @@ CVSTeamProvider.visitError=An error occurred while visiting resource {0}
CVSTeamProvider.invalidResource=Resource {0} is not a child of project {1}
CVSTeamProvider.checkinProblems
+ProjectDescriptionManager.unableToSetDescription=An error occured setting the project description
ProjectDescriptionManager.unableToReadDescription=An error occured reading the project description
ProjectDescriptionManager.ioDescription=An IO error occured while writing the project description
ProjectDescriptionManager.coreDescription=A Core error occured while writing the project description
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 6ce9fed1d..b333f4305 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
@@ -47,7 +47,7 @@ public class ProjectDescriptionManager {
public final static boolean UPDATE_PROJECT_DESCRIPTION_ON_LOAD = true;
/*
- * Read the projetc meta file into the provider description
+ * Read the project meta file into the provider description
*/
public static void readProjectDescription(IProjectDescription desc, InputStream stream) throws IOException, CVSException {
SAXParser parser = new SAXParser();
@@ -139,10 +139,22 @@ public class ProjectDescriptionManager {
} finally {
is.close();
}
- project.setDescription(desc, progress);
+ try {
+ project.setDescription(desc, progress);
+ } catch (CoreException ex) {
+ // Failing to set the description is probably due to a missing nature
+ // Other natures are still set
+ Util.logError(Policy.bind("ProjectDescriptionManager.unableToSetDescription"), ex);
+ }
// Make sure we have the cvs nature (the above read may have removed it)
if (!project.getDescription().hasNature(CVSProviderPlugin.NATURE_ID)) {
- TeamPlugin.getManager().setProvider(project, CVSProviderPlugin.NATURE_ID, null, progress);
+ try {
+ TeamPlugin.getManager().setProvider(project, CVSProviderPlugin.NATURE_ID, null, progress);
+ } catch (TeamException 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);
+ }
writeProjectDescription(project, progress);
}
} catch(TeamException ex) {
@@ -153,10 +165,6 @@ public class ProjectDescriptionManager {
Util.logError(Policy.bind("ProjectDescriptionManager.unableToReadDescription"), ex);
// something went wrong, delete the project description file
descResource.delete(true, progress);
- } catch (CoreException ex) {
- Util.logError(Policy.bind("ProjectDescriptionManager.unableToReadDescription"), ex);
- // something went wrong, delete the project description file
- descResource.delete(true, progress);
}
}
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
index 6797f8c9f..808e0d741 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
@@ -1,318 +1,318 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-
-/**
- * Unsorted static helper-methods
- */
-public class Util {
-
- private static final String AT = "@";
- private static final String COLON = ":";
-
-
- // private static final String newLine = System.getProperty("line.separator");
-
- /**
- * Looks for search in original. If it findes search it puts excange
- * in the result. Otherwise it copies original in the result.
- */
- public static byte[] replace(final byte[] original,final byte[] search,final byte[] excange) {
-
- final int tmpMulti;
- final byte[] tmpResult;
- final byte[] result;
-
- int size=0;
- boolean replaced;
-
- // create an array, that can hold the result for sure
- tmpMulti = (int) Math.ceil((double)excange.length/(double)search.length);
-
- Assert.isTrue((long)tmpMulti * (long)original.length < Integer.MAX_VALUE);
- tmpResult = new byte[tmpMulti * original.length];
-
- int i=0;
- while (i < original.length) {
- replaced = false;
- for (int j = 0; j < search.length; j++) {
-
- if ((i+j >= original.length) || (original[i+j] != search[j])) {
- // Send another letter to the result
- // array
- break;
- }
-
- if (j == search.length-1) {
- // We have found the search and going to
- // put excange intead of it
- System.arraycopy(excange,0,tmpResult,size,excange.length);
- size += excange.length;
- i += search.length;
- replaced = true;
- }
- }
-
- if (!replaced) {
- tmpResult[size] = original[i];
- i++;
- size++;
- }
- }
-
- result = new byte[size];
- System.arraycopy(tmpResult,0,result,0,size);
- return result;
- }
-
- /**
- * @see Util#getOptions(String[],String,boolean)
- */
- public static String getOption(String[] options, String key, boolean deleteOption) {
-
- String[] result;
-
- result = getOptions(options,key,deleteOption);
-
- if (result.length == 0) {
- return null;
- } else {
- return result[0];
- }
- }
-
- /**
- * Get an option out of an array of options. It assumes, that
- * the next field to the key contains the parameter to the
- * option.
- *
- * @param options not null
- * @param key not null
- * @param deleteOption nulls both the option-tag and the information
- * @return String[0] if the option could not be found
- */
- public static String[] getOptions(String[] options, String key, boolean deleteOption) {
-
- String[] tmpResult;
- String[] result;
- int size = 0;
-
- Assert.isNotNull(options);
- Assert.isNotNull(key);
-
- tmpResult = new String[options.length];
-
- for (int i=0; i<options.length; i++) {
- if (key.equals(options[i]) && i<options.length-1) {
- tmpResult[size++] = options[i+1];
-
- // This should be done in another way maybe we should
- // have an options Object or give the array modified
- // back.
- // Maybe we are going to change that.
- if (deleteOption) {
- options[i] = null;
- options[i+1] = null;
- }
- }
- }
-
- result = new String[size];
- System.arraycopy(tmpResult,0,result,0,size);
- return result;
- }
-
- /**
- * Checks wether the Array options contains the String
- * key.
- * @param options not null
- * @param key not null
- */
- public static boolean isOption(String[] options, String key) {
-
- Assert.isNotNull(options);
- Assert.isNotNull(key);
-
- for (int i=0; i<options.length; i++) {
- if (key.equals(options[i])) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Remove or get the password out of a repoString.
- */
- // FIXME: This is only used for tests ... move it
- private static String passwordHandle(String repoName, boolean remove) {
-
- int atPlace = -1;
- int colonPlace = -1;
- int colonCount = 0;
- String currentChar;
-
- Assert.isTrue(repoName.indexOf(AT) != -1);
- Assert.isTrue(repoName.indexOf(COLON) != -1);
-
- for (int i=0; i<repoName.length(); i++) {
-
- currentChar = repoName.substring(i,i+1);
-
- if (currentChar.equals(COLON)) {
- colonCount++;
-
- if (colonCount == 3) {
- colonPlace = i;
- }
- }
-
- if (currentChar.equals(AT)) {
- if (colonPlace == -1) {
-
- // If the @ comes before the third colon, then
- // we do not have a password and return with the
- // same string
- return repoName;
- } else {
- atPlace = i;
- }
-
- }
- }
-
- if (atPlace == -1) {
- return repoName;
- }
-
- if (remove) {
- return repoName.substring(0,colonPlace) + repoName.substring(atPlace);
- } else {
- return repoName.substring(colonPlace + 1, atPlace);
- }
- }
-
- /**
- * returns ":pserver:nkrambro@fiji:/home/nkrambro/repo"
- * when you insert ":pserver:nkrambro:password@fiji:/home/nkrambro/repo"
- */
- // FIXME: This is only used for tests ... move it
- public static String removePassword(String root) {
- return passwordHandle(root,true);
- }
-
- /**
- *
- * returns "password"
- * when you insert ":pserver:nkrambro:password@fiji:/home/nkrambro/repo"
- */
- // FIXME: This is only used for tests ... move it
- public static String getPassword(String root) {
- return passwordHandle(root,false);
- }
-
- // FIXME: This is only used for tests ... move it
- public static String mergeRoot(String rootWithoutPwd, String password) {
-
- StringBuffer result = new StringBuffer();
-
- Assert.isTrue(rootWithoutPwd.indexOf(AT) != -1);
- Assert.isTrue(rootWithoutPwd.indexOf(COLON) != -1);
-
- if (password == null) {
- return rootWithoutPwd;
- }
-
- result.append(rootWithoutPwd.substring(0,rootWithoutPwd.indexOf(AT)));
- result.append(COLON);
- result.append(password);
- result.append(rootWithoutPwd.substring(rootWithoutPwd.indexOf(AT)));
-
- return result.toString();
- }
-
- /**
- * Get the extention of the path of resource
- * relative to the path of root
- *
- * @throws CVSException if root is not a root-folder of resource
- */
- public static String getRelativePath(String rootName, String resourceName)
- throws CVSException {
-
- if (!resourceName.startsWith(rootName)) {
- throw new CVSException("Internal error, resource does not start with root.");
- }
-
- // Otherwise we would get an ArrayOutOfBoundException
- // in case of two equal Resources
- if (rootName.length() == resourceName.length()) {
- return "";
- }
-
- // Get rid of the seperator, that would be in the
- // beginning, if we did not go from +1
- return resourceName.substring(rootName.length() + 1);
- }
-
- /*
- /**
- * Transfer an InputStream to an OutputStream
- * and update the monitor in between.
- *
- * Used for saving files from server
- * on disc, etc.
- *
- public static void transferWithProgress(
- InputStream in,
- OutputStream out,
- long size,
- IProgressMonitor monitor,
- String title)
- throws IOException {
- // This special transfer utility will show progress to
- // the monitor for files that are bigger than 25K
- boolean progress = size > 25000;
- int read = 0;
- long totalRead = 0;
- long ksize = size / 1024;
- // buffer size is smaller than MAXINT...
- int toRead = (int) Math.min(BUFFER.length, size);
- synchronized (BUFFER) {
- while ((totalRead < size) && (read = in.read(BUFFER, 0, toRead)) != -1) {
- if (progress && totalRead > 0) {
- monitor.subTask(
- CVSPlugin.getResourceString(
- "StreamUtil.monitor",
- new Object[] { title, new Long(totalRead / 1024), new Long(ksize)}));
- monitor.worked(read);
- }
- totalRead += read;
- out.write(BUFFER, 0, read);
- toRead = (int) Math.min(BUFFER.length, size - totalRead);
- }
- }
- }
- */
- /*
- public static void convertNewlines(IManagedFile mFile) throws CVSException {
- mFile.setContent(mFile.getContent());
- }
- */
-
- public static void logError(String message, Throwable throwable) {
- CVSProviderPlugin.log(new Status(IStatus.ERROR, null, IStatus.ERROR, message, throwable));
- }
+package org.eclipse.team.internal.ccvs.core.util;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.team.internal.ccvs.core.util.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.ccvs.core.CVSProviderPlugin;
+
+/**
+ * Unsorted static helper-methods
+ */
+public class Util {
+
+ private static final String AT = "@";
+ private static final String COLON = ":";
+
+
+ // private static final String newLine = System.getProperty("line.separator");
+
+ /**
+ * Looks for search in original. If it findes search it puts excange
+ * in the result. Otherwise it copies original in the result.
+ */
+ public static byte[] replace(final byte[] original,final byte[] search,final byte[] excange) {
+
+ final int tmpMulti;
+ final byte[] tmpResult;
+ final byte[] result;
+
+ int size=0;
+ boolean replaced;
+
+ // create an array, that can hold the result for sure
+ tmpMulti = (int) Math.ceil((double)excange.length/(double)search.length);
+
+ Assert.isTrue((long)tmpMulti * (long)original.length < Integer.MAX_VALUE);
+ tmpResult = new byte[tmpMulti * original.length];
+
+ int i=0;
+ while (i < original.length) {
+ replaced = false;
+ for (int j = 0; j < search.length; j++) {
+
+ if ((i+j >= original.length) || (original[i+j] != search[j])) {
+ // Send another letter to the result
+ // array
+ break;
+ }
+
+ if (j == search.length-1) {
+ // We have found the search and going to
+ // put excange intead of it
+ System.arraycopy(excange,0,tmpResult,size,excange.length);
+ size += excange.length;
+ i += search.length;
+ replaced = true;
+ }
+ }
+
+ if (!replaced) {
+ tmpResult[size] = original[i];
+ i++;
+ size++;
+ }
+ }
+
+ result = new byte[size];
+ System.arraycopy(tmpResult,0,result,0,size);
+ return result;
+ }
+
+ /**
+ * @see Util#getOptions(String[],String,boolean)
+ */
+ public static String getOption(String[] options, String key, boolean deleteOption) {
+
+ String[] result;
+
+ result = getOptions(options,key,deleteOption);
+
+ if (result.length == 0) {
+ return null;
+ } else {
+ return result[0];
+ }
+ }
+
+ /**
+ * Get an option out of an array of options. It assumes, that
+ * the next field to the key contains the parameter to the
+ * option.
+ *
+ * @param options not null
+ * @param key not null
+ * @param deleteOption nulls both the option-tag and the information
+ * @return String[0] if the option could not be found
+ */
+ public static String[] getOptions(String[] options, String key, boolean deleteOption) {
+
+ String[] tmpResult;
+ String[] result;
+ int size = 0;
+
+ Assert.isNotNull(options);
+ Assert.isNotNull(key);
+
+ tmpResult = new String[options.length];
+
+ for (int i=0; i<options.length; i++) {
+ if (key.equals(options[i]) && i<options.length-1) {
+ tmpResult[size++] = options[i+1];
+
+ // This should be done in another way maybe we should
+ // have an options Object or give the array modified
+ // back.
+ // Maybe we are going to change that.
+ if (deleteOption) {
+ options[i] = null;
+ options[i+1] = null;
+ }
+ }
+ }
+
+ result = new String[size];
+ System.arraycopy(tmpResult,0,result,0,size);
+ return result;
+ }
+
+ /**
+ * Checks wether the Array options contains the String
+ * key.
+ * @param options not null
+ * @param key not null
+ */
+ public static boolean isOption(String[] options, String key) {
+
+ Assert.isNotNull(options);
+ Assert.isNotNull(key);
+
+ for (int i=0; i<options.length; i++) {
+ if (key.equals(options[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Remove or get the password out of a repoString.
+ */
+ // FIXME: This is only used for tests ... move it
+ private static String passwordHandle(String repoName, boolean remove) {
+
+ int atPlace = -1;
+ int colonPlace = -1;
+ int colonCount = 0;
+ String currentChar;
+
+ Assert.isTrue(repoName.indexOf(AT) != -1);
+ Assert.isTrue(repoName.indexOf(COLON) != -1);
+
+ for (int i=0; i<repoName.length(); i++) {
+
+ currentChar = repoName.substring(i,i+1);
+
+ if (currentChar.equals(COLON)) {
+ colonCount++;
+
+ if (colonCount == 3) {
+ colonPlace = i;
+ }
+ }
+
+ if (currentChar.equals(AT)) {
+ if (colonPlace == -1) {
+
+ // If the @ comes before the third colon, then
+ // we do not have a password and return with the
+ // same string
+ return repoName;
+ } else {
+ atPlace = i;
+ }
+
+ }
+ }
+
+ if (atPlace == -1) {
+ return repoName;
+ }
+
+ if (remove) {
+ return repoName.substring(0,colonPlace) + repoName.substring(atPlace);
+ } else {
+ return repoName.substring(colonPlace + 1, atPlace);
+ }
+ }
+
+ /**
+ * returns ":pserver:nkrambro@fiji:/home/nkrambro/repo"
+ * when you insert ":pserver:nkrambro:password@fiji:/home/nkrambro/repo"
+ */
+ // FIXME: This is only used for tests ... move it
+ public static String removePassword(String root) {
+ return passwordHandle(root,true);
+ }
+
+ /**
+ *
+ * returns "password"
+ * when you insert ":pserver:nkrambro:password@fiji:/home/nkrambro/repo"
+ */
+ // FIXME: This is only used for tests ... move it
+ public static String getPassword(String root) {
+ return passwordHandle(root,false);
+ }
+
+ // FIXME: This is only used for tests ... move it
+ public static String mergeRoot(String rootWithoutPwd, String password) {
+
+ StringBuffer result = new StringBuffer();
+
+ Assert.isTrue(rootWithoutPwd.indexOf(AT) != -1);
+ Assert.isTrue(rootWithoutPwd.indexOf(COLON) != -1);
+
+ if (password == null) {
+ return rootWithoutPwd;
+ }
+
+ result.append(rootWithoutPwd.substring(0,rootWithoutPwd.indexOf(AT)));
+ result.append(COLON);
+ result.append(password);
+ result.append(rootWithoutPwd.substring(rootWithoutPwd.indexOf(AT)));
+
+ return result.toString();
+ }
+
+ /**
+ * Get the extention of the path of resource
+ * relative to the path of root
+ *
+ * @throws CVSException if root is not a root-folder of resource
+ */
+ public static String getRelativePath(String rootName, String resourceName)
+ throws CVSException {
+
+ if (!resourceName.startsWith(rootName)) {
+ throw new CVSException("Internal error, resource does not start with root.");
+ }
+
+ // Otherwise we would get an ArrayOutOfBoundException
+ // in case of two equal Resources
+ if (rootName.length() == resourceName.length()) {
+ return "";
+ }
+
+ // Get rid of the seperator, that would be in the
+ // beginning, if we did not go from +1
+ return resourceName.substring(rootName.length() + 1);
+ }
+
+ /*
+ /**
+ * Transfer an InputStream to an OutputStream
+ * and update the monitor in between.
+ *
+ * Used for saving files from server
+ * on disc, etc.
+ *
+ public static void transferWithProgress(
+ InputStream in,
+ OutputStream out,
+ long size,
+ IProgressMonitor monitor,
+ String title)
+ throws IOException {
+ // This special transfer utility will show progress to
+ // the monitor for files that are bigger than 25K
+ boolean progress = size > 25000;
+ int read = 0;
+ long totalRead = 0;
+ long ksize = size / 1024;
+ // buffer size is smaller than MAXINT...
+ int toRead = (int) Math.min(BUFFER.length, size);
+ synchronized (BUFFER) {
+ while ((totalRead < size) && (read = in.read(BUFFER, 0, toRead)) != -1) {
+ if (progress && totalRead > 0) {
+ monitor.subTask(
+ CVSPlugin.getResourceString(
+ "StreamUtil.monitor",
+ new Object[] { title, new Long(totalRead / 1024), new Long(ksize)}));
+ monitor.worked(read);
+ }
+ totalRead += read;
+ out.write(BUFFER, 0, read);
+ toRead = (int) Math.min(BUFFER.length, size - totalRead);
+ }
+ }
+ }
+ */
+ /*
+ public static void convertNewlines(IManagedFile mFile) throws CVSException {
+ mFile.setContent(mFile.getContent());
+ }
+ */
+
+ public static void logError(String message, Throwable throwable) {
+ CVSProviderPlugin.log(new Status(IStatus.ERROR, CVSProviderPlugin.ID, IStatus.ERROR, message, throwable));
+ }
} \ No newline at end of file

Back to the top