|
From: Mikael P. <er...@us...> - 2012-01-13 13:43:25
|
Update of /cvsroot/eclipse-ccase/net.sourceforge.eclipseccase/src/net/sourceforge/eclipseccase
In directory vz-cvs-4.sog:/tmp/cvs-serv15423/src/net/sourceforge/eclipseccase
Modified Files:
ClearCaseProvider.java MoveHandler.java
Log Message:
3473425 error checkout directory that is soft link
Index: ClearCaseProvider.java
===================================================================
RCS file: /cvsroot/eclipse-ccase/net.sourceforge.eclipseccase/src/net/sourceforge/eclipseccase/ClearCaseProvider.java,v
retrieving revision 1.76
retrieving revision 1.77
diff -C2 -d -r1.76 -r1.77
*** ClearCaseProvider.java 21 Dec 2011 12:02:51 -0000 1.76
--- ClearCaseProvider.java 13 Jan 2012 13:43:23 -0000 1.77
***************
*** 16,19 ****
--- 16,22 ----
import java.text.MessageFormat;
import java.util.*;
+ import java.util.regex.Matcher;
+ import java.util.regex.Pattern;
+
import net.sourceforge.clearcase.ClearCase;
import net.sourceforge.clearcase.ClearCaseCLIImpl;
***************
*** 85,92 ****
public static final String NO_ACTIVITY = "No activity in view";
boolean refreshResources = true;
private OperationListener opListener = null;
!
private boolean isTest = false;
--- 88,103 ----
public static final String NO_ACTIVITY = "No activity in view";
+ public static final String UNRESERVED = "unreserved";
+
+ public static final String RESERVED = "reserved";
+
+ // is used to keep track of which views that has a file checked out when
+ // doing a move.
+ public static final ArrayList<String> checkedOutInOtherView = new ArrayList<String>();
+
boolean refreshResources = true;
private OperationListener opListener = null;
!
private boolean isTest = false;
***************
*** 402,405 ****
--- 413,456 ----
}
+ /**
+ * Parsers single/multiple line/-s of output. Type.java Predecessor:
+ * /main/dev/0 View:eraonel_w12b2 Status: unreserved
+ *
+ * @param element
+ * @return
+ */
+ public boolean isCheckedOutInAnyView(String element) {
+ boolean isCheckedoutInOtherView = false;
+ checkedOutInOtherView.clear();
+ HashMap<Integer, String> args = new HashMap<Integer, String>();
+ args
+ .put(Integer.valueOf(ClearCase.FORMAT),
+ "%En\tPredecessor: %[version_predecessor]p\tView: %Tf\tStatus: %Rf\n");
+ String[] output = ClearCasePlugin.getEngine().findCheckouts(
+ ClearCase.FORMAT, args, new String[] { element });
+ // Check if line ends with these keywords.
+ Pattern pattern = Pattern.compile(".*View:\\s(.*)\\sStatus:.*");
+
+ if (output.length > 0) {
+ // we have file checked-out in other view.
+ isCheckedoutInOtherView = true;
+ for (int i = 0; i < output.length; i++) {
+ String line = output[i];
+ Matcher matcher = pattern.matcher(line);
+ if (matcher.find()) {
+ // Adding information to user.Filter out current view.
+ String view = matcher.group(1);
+ if (!view.equals(getViewName(element))) {
+ checkedOutInOtherView.add(view);
+ }
+ }
+
+ }
+
+ }
+
+ return isCheckedoutInOtherView;
+ }
+
public static String getViewName(IResource resource) {
if (resource == null || resource.getProject() == null)
***************
*** 581,586 ****
}
! return new ArrayList<String>(
! Arrays.asList(new String[] { NO_ACTIVITY }));
}
--- 632,637 ----
}
! return new ArrayList<String>(Arrays
! .asList(new String[] { NO_ACTIVITY }));
}
***************
*** 637,644 ****
public ClearCaseElementState createActivity(String headline,
String activitySelector, String path) throws ClearCaseException {
! ClearCaseElementState[] cces = ClearCasePlugin.getEngine()
! .mkActivity(
! ClearCase.HEADLINE | ClearCase.FORCE | ClearCase.NSET,
! headline, activitySelector, path);
if (cces != null) {
return cces[0];
--- 688,694 ----
public ClearCaseElementState createActivity(String headline,
String activitySelector, String path) throws ClearCaseException {
! ClearCaseElementState[] cces = ClearCasePlugin.getEngine().mkActivity(
! ClearCase.HEADLINE | ClearCase.FORCE | ClearCase.NSET,
! headline, activitySelector, path);
if (cces != null) {
return cces[0];
***************
*** 657,664 ****
public String getCurrentStream() {
String result = "";
! String [] output = ClearCasePlugin.getEngine().getStream(ClearCase.SHORT, null);
if (output != null && output.length > 0) {
! result = output[0];
!
}
return result;
--- 707,715 ----
public String getCurrentStream() {
String result = "";
! String[] output = ClearCasePlugin.getEngine().getStream(
! ClearCase.SHORT, null);
if (output != null && output.length > 0) {
! result = output[0];
!
}
return result;
***************
*** 681,701 ****
* getStream() returns an array but contains one or no element.If we have
* actvities in stream we have one element.
! * activity:<activityId>@/vobs/$pvob,activity:<activityId>@/vobs/$pvob, activity: ...
! * All activities are on one line.
* @return array of activities or an empty array.
*/
public String[] getActivitySelectors(String view) {
! String[] result = new String[]{};
HashMap<Integer, String> args = new HashMap<Integer, String>();
args.put(Integer.valueOf(ClearCase.FORMAT), "%[activities]CXp");
args.put(Integer.valueOf(ClearCase.VIEW), view);
!
! String [] output = ClearCasePlugin.getEngine().getStream(
ClearCase.FORMAT | ClearCase.VIEW, args);
!
if (output != null && output.length == 1) {
result = output[0].split(", ");
}
!
return result;
--- 732,753 ----
* getStream() returns an array but contains one or no element.If we have
* actvities in stream we have one element.
! * activity:<activityId>@/vobs/$pvob,activity:<activityId>@/vobs/$pvob,
! * activity: ... All activities are on one line.
! *
* @return array of activities or an empty array.
*/
public String[] getActivitySelectors(String view) {
! String[] result = new String[] {};
HashMap<Integer, String> args = new HashMap<Integer, String>();
args.put(Integer.valueOf(ClearCase.FORMAT), "%[activities]CXp");
args.put(Integer.valueOf(ClearCase.VIEW), view);
!
! String[] output = ClearCasePlugin.getEngine().getStream(
ClearCase.FORMAT | ClearCase.VIEW, args);
!
if (output != null && output.length == 1) {
result = output[0].split(", ");
}
!
return result;
***************
*** 719,722 ****
--- 771,775 ----
public IStatus move(IResource source, IResource destination,
IProgressMonitor monitor) {
+ int returnCode = 1;// Used in messge dialog.
try {
monitor.beginTask("Moving " + source.getFullPath() + " to "
***************
*** 729,733 ****
TeamException.NO_REMOTE_RESOURCE,
MessageFormat
! .format("Resource \"{0}\" is not under source control!",
new Object[] { source.getFullPath()
.toString() }), null);
--- 782,787 ----
TeamException.NO_REMOTE_RESOURCE,
MessageFormat
! .format(
! "Resource \"{0}\" is not under source control!",
new Object[] { source.getFullPath()
.toString() }), null);
***************
*** 736,742 ****
ClearCaseElementState[] state = null;
if (ClearCasePreferences.isAutoCheckinParentAfterMoveAllowed()) {
state = ClearCasePlugin.getEngine()
! .move(source.getLocation().toOSString(),
destination.getLocation().toOSString(),
getComment(),
--- 790,825 ----
ClearCaseElementState[] state = null;
+ if (isCheckedOutInAnyView(source.getLocation().toOSString())) {
+
+ StringBuffer sb = new StringBuffer();
+ for (String view : checkedOutInOtherView) {
+ sb.append(view + "\t");
+ }
+ // Open message dialog and ask if we want to continue.
+ returnCode = showMessageDialog(
+ "File Checkedout in Other View ",
+ "File checkedout in the following views: "
+ + sb.toString()+"\n"
+ + " Do you still want to move, "
+ + source.getName() + "?");
+
+ }
+ // If not 1 ( ok) then we cancel operation.
+ if (returnCode != 0) {
+ return new Status(
+ IStatus.ERROR,
+ ID,
+ TeamException.CONFLICT,
+ MessageFormat
+ .format(
+ "Cancelled move operation for \"{0}\"!",
+ new Object[] { source.getFullPath()
+ .toString() }), null);
+ }
+
if (ClearCasePreferences.isAutoCheckinParentAfterMoveAllowed()) {
state = ClearCasePlugin.getEngine()
! .move(
! source.getLocation().toOSString(),
destination.getLocation().toOSString(),
getComment(),
***************
*** 925,947 ****
File target = new File(cache.getSymbolicLinkTarget());
if (!target.isAbsolute()) {
! target = null != cache.getPath() ? new File(
! cache.getPath()).getParentFile() : null;
if (null != target) {
! target = new File(target,
! cache.getSymbolicLinkTarget());
}
}
if (null != target && target.exists()) {
! IPath targetLocation = new Path(
! target.getAbsolutePath());
IResource[] resources = null;
if (target.isDirectory()) {
resources = ResourcesPlugin.getWorkspace()
! .getRoot()
! .findContainersForLocation(targetLocation);
} else {
resources = ResourcesPlugin.getWorkspace()
! .getRoot()
! .findFilesForLocation(targetLocation);
}
if (null != resources) {
--- 1008,1030 ----
File target = new File(cache.getSymbolicLinkTarget());
if (!target.isAbsolute()) {
! target = null != cache.getPath() ? new File(cache
! .getPath()).getParentFile() : null;
if (null != target) {
! target = new File(target, cache
! .getSymbolicLinkTarget());
}
}
if (null != target && target.exists()) {
! IPath targetLocation = new Path(target
! .getAbsolutePath());
IResource[] resources = null;
if (target.isDirectory()) {
resources = ResourcesPlugin.getWorkspace()
! .getRoot().findContainersForLocation(
! targetLocation);
} else {
resources = ResourcesPlugin.getWorkspace()
! .getRoot().findFilesForLocation(
! targetLocation);
}
if (null != resources) {
***************
*** 951,957 ****
.getClearCaseProvider(foundResource);
if (null != provider) {
! StateCacheFactory.getInstance()
! .get(foundResource)
! .updateAsync(false);
// after the target is updated, we must
// update the
--- 1034,1039 ----
.getClearCaseProvider(foundResource);
if (null != provider) {
! StateCacheFactory.getInstance().get(
! foundResource).updateAsync(false);
// after the target is updated, we must
// update the
***************
*** 988,992 ****
TeamException.UNABLE,
MessageFormat
! .format("Resource \"{0}\" is already under source control!",
new Object[] { resource
.getFullPath().toString() }),
--- 1070,1075 ----
TeamException.UNABLE,
MessageFormat
! .format(
! "Resource \"{0}\" is already under source control!",
new Object[] { resource
.getFullPath().toString() }),
***************
*** 1125,1129 ****
ClearCaseElementState state = ClearCasePlugin
.getEngine()
! .add(resource.getLocation().toOSString(),
false,
getComment(),
--- 1208,1213 ----
ClearCaseElementState state = ClearCasePlugin
.getEngine()
! .add(
! resource.getLocation().toOSString(),
false,
getComment(),
***************
*** 1254,1258 ****
TeamException.NO_REMOTE_RESOURCE,
MessageFormat
! .format("Resource \"{0}\" is not a ClearCase element!",
new Object[] { resource
.getFullPath().toString() }),
--- 1338,1343 ----
TeamException.NO_REMOTE_RESOURCE,
MessageFormat
! .format(
! "Resource \"{0}\" is not a ClearCase element!",
new Object[] { resource
.getFullPath().toString() }),
***************
*** 1309,1313 ****
TeamException.NO_REMOTE_RESOURCE,
MessageFormat
! .format("Resource \"{0}\" is not a ClearCase element!",
new Object[] { resource
.getFullPath().toString() }),
--- 1394,1399 ----
TeamException.NO_REMOTE_RESOURCE,
MessageFormat
! .format(
! "Resource \"{0}\" is not a ClearCase element!",
new Object[] { resource
.getFullPath().toString() }),
***************
*** 1317,1322 ****
if (result.isOK()) {
ClearCasePlugin.getEngine()
! .delete(new String[] { resource.getLocation()
! .toOSString() }, getComment(),
ClearCase.RECURSIVE | ClearCase.KEEP,
opListener);
--- 1403,1409 ----
if (result.isOK()) {
ClearCasePlugin.getEngine()
! .delete(
! new String[] { resource.getLocation()
! .toOSString() }, getComment(),
ClearCase.RECURSIVE | ClearCase.KEEP,
opListener);
***************
*** 1356,1360 ****
TeamException.NO_REMOTE_RESOURCE,
MessageFormat
! .format("Resource \"{0}\" is not a ClearCase element!",
new Object[] { resource
.getFullPath().toString() }),
--- 1443,1448 ----
TeamException.NO_REMOTE_RESOURCE,
MessageFormat
! .format(
! "Resource \"{0}\" is not a ClearCase element!",
new Object[] { resource
.getFullPath().toString() }),
***************
*** 1390,1396 ****
ID,
TeamException.NOT_CHECKED_IN,
! MessageFormat.format(
! Messages.getString("ClearCasePlugin.error.checkin.identicalPredecessor"),
! new Object[] { cce.getElements() }),
null);
break;
--- 1478,1487 ----
ID,
TeamException.NOT_CHECKED_IN,
! MessageFormat
! .format(
! Messages
! .getString("ClearCasePlugin.error.checkin.identicalPredecessor"),
! new Object[] { cce
! .getElements() }),
null);
break;
***************
*** 1400,1406 ****
ID,
TeamException.NOT_CHECKED_IN,
! MessageFormat.format(
! Messages.getString("ClearCasePlugin.error.checkin.elementHasCheckouts"),
! new Object[] { cce.getElements() }),
null);
break;
--- 1491,1500 ----
ID,
TeamException.NOT_CHECKED_IN,
! MessageFormat
! .format(
! Messages
! .getString("ClearCasePlugin.error.checkin.elementHasCheckouts"),
! new Object[] { cce
! .getElements() }),
null);
break;
***************
*** 1412,1418 ****
String latestVersion = resource.getLocation()
.toOSString()
! + "@@"
! + branchName
! + "LATEST";
ClearCaseElementState myState = ClearCasePlugin
--- 1506,1510 ----
String latestVersion = resource.getLocation()
.toOSString()
! + "@@" + branchName + "LATEST";
ClearCaseElementState myState = ClearCasePlugin
***************
*** 1428,1438 ****
if (returnCode == 0) {
// Yes continue checkin
! ClearCasePlugin
! .getEngine()
! .checkin(
! new String[] { targetElement
! .getPath() },
! getComment(),
! ClearCase.PTIME, opListener);
}
--- 1520,1527 ----
if (returnCode == 0) {
// Yes continue checkin
! ClearCasePlugin.getEngine().checkin(
! new String[] { targetElement
! .getPath() }, getComment(),
! ClearCase.PTIME, opListener);
}
***************
*** 1443,1450 ****
ID,
TeamException.CONFLICT,
! MessageFormat.format(
! Messages.getString("ClearCasePlugin.error.checkin.mergeLatestProblem"),
! new Object[] { cce
! .getElements() }), null);
}
--- 1532,1542 ----
ID,
TeamException.CONFLICT,
! MessageFormat
! .format(
! Messages
! .getString("ClearCasePlugin.error.checkin.mergeLatestProblem"),
! new Object[] { cce
! .getElements() }),
! null);
}
***************
*** 1456,1462 ****
ID,
TeamException.NOT_CHECKED_IN,
! MessageFormat.format(
! Messages.getString("ClearCasePlugin.error.checkin.unknown"),
! new Object[] { cce.getElements() }),
null);
--- 1548,1557 ----
ID,
TeamException.NOT_CHECKED_IN,
! MessageFormat
! .format(
! Messages
! .getString("ClearCasePlugin.error.checkin.unknown"),
! new Object[] { cce
! .getElements() }),
null);
***************
*** 1484,1488 ****
try {
int returnCode = 1;// Used for message dialogs.
! monitor.beginTask("Checking out " + resource.getFullPath(), 100);
StateCache cache = getCache(resource);
final StateCache targetElement = getFinalTargetElement(cache);
--- 1579,1585 ----
try {
int returnCode = 1;// Used for message dialogs.
! monitor
! .beginTask("Checking out " + resource.getFullPath(),
! 100);
StateCache cache = getCache(resource);
final StateCache targetElement = getFinalTargetElement(cache);
***************
*** 1496,1500 ****
TeamException.NO_REMOTE_RESOURCE,
MessageFormat
! .format("Resource \"{0}\" is not a ClearCase element!",
new Object[] { resource
.getFullPath().toString() }),
--- 1593,1598 ----
TeamException.NO_REMOTE_RESOURCE,
MessageFormat
! .format(
! "Resource \"{0}\" is not a ClearCase element!",
new Object[] { resource
.getFullPath().toString() }),
***************
*** 1546,1551 ****
// Yes continue checking out but
// unreserved.
! ClearCasePlugin
! .getEngine()
.checkout(
new String[] { targetElement
--- 1644,1648 ----
// Yes continue checking out but
// unreserved.
! ClearCasePlugin.getEngine()
.checkout(
new String[] { targetElement
***************
*** 1577,1583 ****
ID,
TeamException.UNABLE,
! MessageFormat.format(
! Messages.getString("ClearCasePlugin.error.checkin.unknown"),
! new Object[] { cce.getElements() }),
null);
--- 1674,1683 ----
ID,
TeamException.UNABLE,
! MessageFormat
! .format(
! Messages
! .getString("ClearCasePlugin.error.checkin.unknown"),
! new Object[] { cce
! .getElements() }),
null);
***************
*** 1618,1622 ****
TeamException.NOT_AUTHORIZED,
MessageFormat
! .format("Resource \"{0}\" is not a Hijacked ClearCase element!",
new Object[] { resource
.getFullPath().toString() }),
--- 1718,1723 ----
TeamException.NOT_AUTHORIZED,
MessageFormat
! .format(
! "Resource \"{0}\" is not a Hijacked ClearCase element!",
new Object[] { resource
.getFullPath().toString() }),
***************
*** 1637,1641 ****
if (keep.exists()) {
keep.renameTo(new File(resource.getLocation()
! .toOSString() + ".keep"));
}
} catch (Exception e) {
--- 1738,1743 ----
if (keep.exists()) {
keep.renameTo(new File(resource.getLocation()
! .toOSString()
! + ".keep"));
}
} catch (Exception e) {
***************
*** 1682,1686 ****
TeamException.NO_REMOTE_RESOURCE,
MessageFormat
! .format("Resource \"{0}\" is not a ClearCase element!",
new Object[] { resource
.getFullPath().toString() }),
--- 1784,1789 ----
TeamException.NO_REMOTE_RESOURCE,
MessageFormat
! .format(
! "Resource \"{0}\" is not a ClearCase element!",
new Object[] { resource
.getFullPath().toString() }),
***************
*** 1705,1711 ****
IProgressMonitor monitor) {
try {
! monitor.beginTask(
! "Changing checkout to unreserved "
! + resource.getFullPath(), 100);
// Sanity check - can't update something that is not part of
--- 1808,1813 ----
IProgressMonitor monitor) {
try {
! monitor.beginTask("Changing checkout to unreserved "
! + resource.getFullPath(), 100);
// Sanity check - can't update something that is not part of
***************
*** 1717,1721 ****
TeamException.NO_REMOTE_RESOURCE,
MessageFormat
! .format("Resource \"{0}\" is not a ClearCase element!",
new Object[] { resource
.getFullPath().toString() }),
--- 1819,1824 ----
TeamException.NO_REMOTE_RESOURCE,
MessageFormat
! .format(
! "Resource \"{0}\" is not a ClearCase element!",
new Object[] { resource
.getFullPath().toString() }),
***************
*** 1741,1747 ****
IProgressMonitor monitor) {
try {
! monitor.beginTask(
! "Changing checkout to reserved "
! + resource.getFullPath(), 100);
// Sanity check - can't update something that is not part of
--- 1844,1849 ----
IProgressMonitor monitor) {
try {
! monitor.beginTask("Changing checkout to reserved "
! + resource.getFullPath(), 100);
// Sanity check - can't update something that is not part of
***************
*** 1753,1757 ****
TeamException.NO_REMOTE_RESOURCE,
MessageFormat
! .format("Resource \"{0}\" is not a ClearCase element!",
new Object[] { resource
.getFullPath().toString() }),
--- 1855,1860 ----
TeamException.NO_REMOTE_RESOURCE,
MessageFormat
! .format(
! "Resource \"{0}\" is not a ClearCase element!",
new Object[] { resource
.getFullPath().toString() }),
***************
*** 1835,1840 ****
throw new TeamException(new MultiStatus(
multiStatus.getPlugin(), multiStatus.getCode(),
! multiStatus.getChildren(), message,
! multiStatus.getException()));
}
// Cause all the resource changes to be broadcast to listeners.
--- 1938,1943 ----
throw new TeamException(new MultiStatus(
multiStatus.getPlugin(), multiStatus.getCode(),
! multiStatus.getChildren(), message, multiStatus
! .getException()));
}
// Cause all the resource changes to be broadcast to listeners.
***************
*** 1880,1885 ****
// multi-status.
MultiStatus multiStatus = new MultiStatus(status.getPlugin(),
! status.getCode(), status.getMessage(),
! status.getException());
// The next level will be one less than the current level...
int childDepth = (depth == IResource.DEPTH_ONE) ? IResource.DEPTH_ZERO
--- 1983,1988 ----
// multi-status.
MultiStatus multiStatus = new MultiStatus(status.getPlugin(),
! status.getCode(), status.getMessage(), status
! .getException());
// The next level will be one less than the current level...
int childDepth = (depth == IResource.DEPTH_ONE) ? IResource.DEPTH_ZERO
Index: MoveHandler.java
===================================================================
RCS file: /cvsroot/eclipse-ccase/net.sourceforge.eclipseccase/src/net/sourceforge/eclipseccase/MoveHandler.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** MoveHandler.java 22 Dec 2010 14:53:39 -0000 1.25
--- MoveHandler.java 13 Jan 2012 13:43:23 -0000 1.26
***************
*** 1,6 ****
--- 1,9 ----
package net.sourceforge.eclipseccase;
+ import java.text.MessageFormat;
import java.util.LinkedList;
+ import net.sourceforge.clearcase.ClearCaseError;
+
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
***************
*** 18,21 ****
--- 21,26 ----
public class MoveHandler implements IMoveDeleteHook {
+
+ public static final String ID = "net.sourceforge.eclipseccase.MoveHandler"; //$NON-NLS-1$
ClearCaseProvider provider;
***************
*** 266,275 ****
}
! return true;
!
} finally {
provider.refreshResources = true;
monitor.done();
}
}
}
--- 271,288 ----
}
! //return true;
! }catch(ClearCaseError e){
! tree.failed(new Status(
! IStatus.ERROR,
! ID,
! TeamException.UNABLE
! ,"An Error occurred! "+e.getMessage(), e));
!
} finally {
provider.refreshResources = true;
monitor.done();
}
+
+ return true;
}
}
|