Update of /cvsroot/clearcase-java/net.sourceforge.clearcase/src/java/net/sourceforge/clearcase/simple
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26693/src/java/net/sourceforge/clearcase/simple
Modified Files:
ClearcaseUtil.java ClearcaseDummy.java IClearcase.java
ClearcaseCLI.java ClearcaseJNI.java
Log Message:
API change in IClearcase to support "-master" (TODO: need to implement UI support for Eclipse)
Index: IClearcase.java
===================================================================
RCS file: /cvsroot/clearcase-java/net.sourceforge.clearcase/src/java/net/sourceforge/clearcase/simple/IClearcase.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** IClearcase.java 28 Apr 2004 09:04:09 -0000 1.5
--- IClearcase.java 28 Apr 2004 11:45:15 -0000 1.6
***************
*** 13,138 ****
package net.sourceforge.clearcase.simple;
! public interface IClearcase
! {
! public static class Status
! {
! public boolean status;
! public String message;
! public Status(boolean status, String message)
! {
! this.status = status;
! this.message = message;
! }
! }
! /** Destroys this instance */
! public void destroy();
! /**
! Does a clearcase checkout of the given file. Comment can be
! empty string. If reserved is true, does a reserved checkout.
! ptime preserves file timestamp
! */
! public Status checkout(
! String file,
! String comment,
! boolean reserved,
! boolean ptime);
! /**
! Does a clearcase checkin of the given file. Comment can be
! empty string. ptime preserves file timestamp
! */
! public Status checkin(String file, String comment, boolean ptime);
! /**
! Does a clearcase uncheckout of the given file. If keep is true,
! the file is copied to a ".keep" file
! */
! public Status uncheckout(String file, boolean keep);
! /**
! Adds the given file to clearcase source control. This requires
! the parent directory to be under version control and checked
! out. The isdirectory flag causes creation of a directory element
! when true. Comment can be empty string.
! */
! public Status add(String file, String comment, boolean isdirectory);
! /**
! Removes the given file from clearcase source control (rmname NOT
! rmelem). This requires the parent directory to be under version
! control and checked out. Comment can be empty string.
! */
! public Status delete(String file, String comment);
! /** Moves file to newfile. The parent directories of both file and newfile must be checked out. Comment can be empty string. */
! public Status move(String file, String newfile, String comment);
! /** Gets the view tag name for the view associated with file. */
! public Status getViewName(String file);
/** Gets the view root path for the view associated with file. */
public Status getViewRoot(String file);
! /**
! Executes the command "cmd" just like a command line "cleartool cmd".
! */
! public Status cleartool(String cmd);
! /**
! Returns true if the file is under version control and checked
! out
! */
! public boolean isCheckedOut(String file);
! /**
! Returns true if the file is under clearcase version control
! */
! public boolean isElement(String file);
! /**
! Returns true if the file is a link
! */
! public boolean isSymbolicLink(String file);
!
! /**
! Returns true if the link has a valid target
! */
! public boolean isSymbolicLinkTargetValid(String file);
!
! /**
! * Returns the target for a link.
! */
! public Status getSymbolicLinkTarget(String file);
! /**
! Returns true if the file is checked out and different from its
! predecessor
! */
! public boolean isDifferent(String file);
! /**
! * Indicates if the file is not checked out in this view but in another view.
! * @param file
! * @return <code>true</code> if the file is checked out in another view
! */
! public boolean isCheckedOutInAnotherView(String file);
!
! /**
! Returns true if the file is under version control and part of a snapshot view
! */
! public boolean isSnapShot(String file);
- /**
- Returns true if the file is under version control and hijacked from a snapshot view
- */
- public boolean isHijacked(String file);
-
/**
* Sets the debugger.
! * @param debugger the debugger to set
*/
void setDebugger(IClearcaseDebugger debugger);
--- 13,181 ----
package net.sourceforge.clearcase.simple;
! /**
! * The interface to ClearCase.
! * <p>
! * This interface defines the API for operating with ClearCase.
! * </p>
! *
! * <p>
! * Clients must not implement this interface.
! * </p>
! *
! * <p>
! * Note that his API is suspect to change until a final 1.0 version is
! * officially announced.
! * </p>
! */
! public interface IClearcase {
! /**
! * The status
! */
! public static class Status {
! public boolean status;
! public String message;
! public Status(boolean status, String message) {
! this.status = status;
! this.message = message;
! }
! }
! /** Destroys this instance */
! public void destroy();
! /**
! * Does a clearcase checkout of the given file.
! * <p>
! * Comment can be empty string. If reserved is <code>true</code>, does a
! * reserved checkout. <code>ptime</code> preserves file timestamp.
! * </p>
! *
! * @param file
! * the file
! * @param comment
! * the comment
! * @param reserved
! * @param ptime
! */
! public Status checkout(String file, String comment, boolean reserved,
! boolean ptime);
! /**
! * Does a clearcase checkin of the given file. Comment can be empty string.
! * ptime preserves file timestamp
! */
! public Status checkin(String file, String comment, boolean ptime);
! /**
! * Does a clearcase uncheckout of the given file. If keep is true, the file
! * is copied to a ".keep" file
! */
! public Status uncheckout(String file, boolean keep);
! /**
! * Adds the given file to clearcase source control.
! * <p>
! * This requires the parent directory to be under version control and
! * checked out. The isdirectory flag causes creation of a directory element
! * when true. Comment can be empty string.
! * </p>
! *
! * @param file
! * (may not be <code>null</code>)
! * @param comment
! * the comment (may not be <code>null</code>)
! * @param isDirectory
! * indicates if the element is a directory
! * @param makeMaster
! * indicates if the element should be the master for replicas
! */
! public Status add(String file, String comment, boolean isDirectory,
! boolean makeMaster);
!
! /**
! * Removes the given file from clearcase source control (rmname NOT rmelem).
! * This requires the parent directory to be under version control and
! * checked out. Comment can be empty string.
! */
! public Status delete(String file, String comment);
!
! /**
! * Moves file to newfile. The parent directories of both file and newfile
! * must be checked out. Comment can be empty string.
! */
! public Status move(String file, String newfile, String comment);
!
! /** Gets the view tag name for the view associated with file. */
! public Status getViewName(String file);
/** Gets the view root path for the view associated with file. */
public Status getViewRoot(String file);
! /**
! * Executes the command "cmd" just like a command line "cleartool cmd".
! */
! public Status cleartool(String cmd);
! /**
! * Returns true if the file is under version control and checked out
! */
! public boolean isCheckedOut(String file);
! /**
! * Returns true if the file is under clearcase version control
! */
! public boolean isElement(String file);
! /**
! * Returns true if the file is a link
! */
! public boolean isSymbolicLink(String file);
! /**
! * Returns true if the link has a valid target
! */
! public boolean isSymbolicLinkTargetValid(String file);
! /**
! * Returns the target for a link.
! */
! public Status getSymbolicLinkTarget(String file);
! /**
! * Returns true if the file is checked out and different from its
! * predecessor
! */
! public boolean isDifferent(String file);
!
! /**
! * Indicates if the file is not checked out in this view but in another
! * view.
! *
! * @param file
! * @return <code>true</code> if the file is checked out in another view
! */
! public boolean isCheckedOutInAnotherView(String file);
!
! /**
! * Returns true if the file is under version control and part of a snapshot
! * view
! */
! public boolean isSnapShot(String file);
!
! /**
! * Returns true if the file is under version control and hijacked from a
! * snapshot view
! */
! public boolean isHijacked(String file);
/**
* Sets the debugger.
! *
! * @param debugger
! * the debugger to set
*/
void setDebugger(IClearcaseDebugger debugger);
Index: ClearcaseDummy.java
===================================================================
RCS file: /cvsroot/clearcase-java/net.sourceforge.clearcase/src/java/net/sourceforge/clearcase/simple/ClearcaseDummy.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** ClearcaseDummy.java 28 Apr 2004 09:04:09 -0000 1.7
--- ClearcaseDummy.java 28 Apr 2004 11:45:15 -0000 1.8
***************
*** 69,99 ****
}
! public Status checkout(
! String file,
! String comment,
! boolean reserved,
! boolean ptime)
! {
! String msg =
! "Checkout: '"
! + file
! + "', '"
! + comment
! + "', reserved: "
! + reserved
! + ", ptime: "
! + ptime;
! log(info, msg, null);
! try
! {
! getElt(file).checkedOut = true;
! }
! catch (Throwable ex)
! {
! return new Status(false, msg + ", ex: " + ex);
! }
! return new Status(true, msg);
! }
!
public Status checkin(String file, String comment, boolean ptime)
{
--- 69,99 ----
}
!
! /* (non-Javadoc)
! * @see net.sourceforge.clearcase.simple.IClearcase#checkout(java.lang.String, java.lang.String, boolean, boolean, boolean, boolean)
! */
! public Status checkout(String file, String comment, boolean reserved,
! boolean ptime) {
! String msg =
! "Checkout: '"
! + file
! + "', '"
! + comment
! + "', reserved: "
! + reserved
! + ", ptime: "
! + ptime;
! log(info, msg, null);
! try
! {
! getElt(file).checkedOut = true;
! }
! catch (Throwable ex)
! {
! return new Status(false, msg + ", ex: " + ex);
! }
! return new Status(true, msg);
! }
!
public Status checkin(String file, String comment, boolean ptime)
{
***************
*** 127,153 ****
}
! public Status add(String file, String comment, boolean isdirectory)
! {
! String msg =
! "Add: '"
! + file
! + "', '"
! + comment
! + "', isdirectory: "
! + isdirectory;
! log(info, msg, null);
! try
! {
! makeElt(file);
! if (isdirectory)
! new File(file).mkdir();
! }
! catch (Throwable ex)
! {
! return new Status(false, msg + ", ex: " + ex);
! }
! return new Status(true, msg);
! }
!
public Status delete(String file, String comment)
{
--- 127,157 ----
}
!
! /* (non-Javadoc)
! * @see net.sourceforge.clearcase.simple.IClearcase#add(java.lang.String, java.lang.String, boolean, boolean)
! */
! public Status add(String file, String comment, boolean isDirectory,
! boolean makeMaster) {
! String msg =
! "Add: '"
! + file
! + "', '"
! + comment
! + "', isdirectory: "
! + isDirectory;
! log(info, msg, null);
! try
! {
! makeElt(file);
! if (isDirectory)
! new File(file).mkdir();
! }
! catch (Throwable ex)
! {
! return new Status(false, msg + ", ex: " + ex);
! }
! return new Status(true, msg);
! }
!
public Status delete(String file, String comment)
{
Index: ClearcaseJNI.java
===================================================================
RCS file: /cvsroot/clearcase-java/net.sourceforge.clearcase/src/java/net/sourceforge/clearcase/simple/ClearcaseJNI.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** ClearcaseJNI.java 28 Apr 2004 10:25:59 -0000 1.16
--- ClearcaseJNI.java 28 Apr 2004 11:45:15 -0000 1.17
***************
*** 1,3 ****
-
package net.sourceforge.clearcase.simple;
--- 1,2 ----
***************
*** 18,53 ****
import com.jacob.com.Variant;
! public class ClearcaseJNI implements IClearcase
! {
! ClearcaseJNI()
! {}
// synchronize all access in the hopes it fixes JVM crashes
! public synchronized void destroy()
! {}
! /**
! * @see net.sourceforge.eclipseccase.IClearcase#add(String, String, boolean)
*/
public synchronized Status add(String file, String comment,
! boolean isdirectory)
! {
Status result;
! try
! {
IClearCase ccase = new Application();
ICCCheckedOutFile cofile = null;
! if (isdirectory) cofile = ccase.createElement(file, comment, false,
! new Variant("directory"));
else
! cofile = ccase.createElement(file, comment, false);
! if (null != cofile) result = new Status(true, "Add Successful");
else
result = new Status(false, "Add Error");
! }
! catch (Exception ex)
! {
result = new Status(false, ex.getMessage());
}
--- 17,54 ----
import com.jacob.com.Variant;
! public class ClearcaseJNI implements IClearcase {
! ClearcaseJNI() {
! // super();
! }
// synchronize all access in the hopes it fixes JVM crashes
! public synchronized void destroy() {
! // nothing
! }
! /*
! * (non-Javadoc)
! *
! * @see net.sourceforge.clearcase.simple.IClearcase#add(java.lang.String,
! * java.lang.String, boolean, boolean)
*/
public synchronized Status add(String file, String comment,
! boolean isDirectory, boolean makeMaster) {
Status result;
! try {
IClearCase ccase = new Application();
ICCCheckedOutFile cofile = null;
! if (isDirectory)
! cofile = ccase.createElement(file, comment, makeMaster,
! new Variant("directory"));
else
! cofile = ccase.createElement(file, comment, makeMaster);
! if (null != cofile)
! result = new Status(true, "Add Successful");
else
result = new Status(false, "Add Error");
! } catch (Exception ex) {
result = new Status(false, ex.getMessage());
}
***************
*** 60,100 ****
*/
public synchronized Status checkin(String file, String comment,
! boolean ptime)
! {
Status result;
! try
! {
! if (isSymbolicLink(file))
! {
String oldFile = file;
file = getResolvedLinkTarget(file);
! if (null == file) throw new RuntimeException("Invalid link target: " + oldFile);
}
! if (ptime)
! {
result = cleartool("checkin -identical -ptime "
+ getArgumentWithComment(comment, ClearcaseUtil
.quote(file)));
if (result.status) result.message = "Checkin Successful";
! }
! else
! {
IClearCase ccase = new Application();
ICCVersion version = ccase.getVersion(new Variant(file));
! if (null != version)
! {
ICCCheckedOutFile cofile = ccase.getCheckedOutFile(file);
cofile.checkIn(comment, true, "", CCKeepState.ccRemove);
result = new Status(true, "Checkin Successful");
! }
! else
! {
result = new Status(false, "No Element");
}
}
! }
! catch (Exception ex)
! {
result = new Status(false, ex.getMessage());
}
--- 61,92 ----
*/
public synchronized Status checkin(String file, String comment,
! boolean ptime) {
Status result;
! try {
! if (isSymbolicLink(file)) {
String oldFile = file;
file = getResolvedLinkTarget(file);
! if (null == file)
! throw new RuntimeException("Invalid link target: "
! + oldFile);
}
! if (ptime) {
result = cleartool("checkin -identical -ptime "
+ getArgumentWithComment(comment, ClearcaseUtil
.quote(file)));
if (result.status) result.message = "Checkin Successful";
! } else {
IClearCase ccase = new Application();
ICCVersion version = ccase.getVersion(new Variant(file));
! if (null != version) {
ICCCheckedOutFile cofile = ccase.getCheckedOutFile(file);
cofile.checkIn(comment, true, "", CCKeepState.ccRemove);
result = new Status(true, "Checkin Successful");
! } else {
result = new Status(false, "No Element");
}
}
! } catch (Exception ex) {
result = new Status(false, ex.getMessage());
}
***************
*** 102,137 ****
}
! /**
! * @see net.sourceforge.eclipseccase.IClearcase#checkout(String, String,
! * boolean, boolean)
*/
public synchronized Status checkout(String file, String comment,
! boolean reserved, boolean ptime)
! {
Status result;
! try
! {
! if (isSymbolicLink(file))
! {
String oldFile = file;
file = getResolvedLinkTarget(file);
! if (null == file) throw new RuntimeException("Invalid link target: " + oldFile);
}
IClearCase ccase = new Application();
ICCVersion version = ccase.getVersion(new Variant(file));
- boolean useHijacked = false;
- boolean mustBeLatest = false;
ICCCheckedOutFile cofile = version.checkOut(
reserved ? CCReservedState.ccReserved
: CCReservedState.ccUnreserved, comment,
! useHijacked, CCVersionToCheckOut.ccVersion_Default,
! mustBeLatest, ptime);
! if (null != cofile) result = new Status(true, "Checkout Successful");
else
result = new Status(false, "Checkout Error");
! }
! catch (Exception ex)
! {
result = new Status(false, ex.getMessage());
}
--- 94,127 ----
}
! /*
! * (non-Javadoc)
! *
! * @see net.sourceforge.clearcase.simple.IClearcase#checkout(java.lang.String,
! * java.lang.String, boolean, boolean, boolean, boolean)
*/
public synchronized Status checkout(String file, String comment,
! boolean reserved, boolean ptime) {
Status result;
! try {
! if (isSymbolicLink(file)) {
String oldFile = file;
file = getResolvedLinkTarget(file);
! if (null == file)
! throw new RuntimeException("Invalid link target: "
! + oldFile);
}
IClearCase ccase = new Application();
ICCVersion version = ccase.getVersion(new Variant(file));
ICCCheckedOutFile cofile = version.checkOut(
reserved ? CCReservedState.ccReserved
: CCReservedState.ccUnreserved, comment,
! false, CCVersionToCheckOut.ccVersion_Default,
! false, ptime);
! if (null != cofile)
! result = new Status(true, "Checkout Successful");
else
result = new Status(false, "Checkout Error");
! } catch (Exception ex) {
result = new Status(false, ex.getMessage());
}
***************
*** 142,160 ****
* @see net.sourceforge.eclipseccase.IClearcase#cleartool(String)
*/
! public synchronized Status cleartool(String cmd)
! {
if (null != debugger)
debugger.debugClearcase("ClearCaseJNI", "[execute]: " + cmd);
Status result;
! try
! {
IClearTool cleartool = new ClearTool();
String output = cleartool.cmdExec(cmd);
if (output == null) output = "";
result = new Status(true, output);
! }
! catch (Exception ex)
! {
if (null != debugger)
debugger.debugClearcase("ClearCaseJNI", "[error]: "
--- 132,146 ----
* @see net.sourceforge.eclipseccase.IClearcase#cleartool(String)
*/
! public synchronized Status cleartool(String cmd) {
if (null != debugger)
debugger.debugClearcase("ClearCaseJNI", "[execute]: " + cmd);
Status result;
! try {
IClearTool cleartool = new ClearTool();
String output = cleartool.cmdExec(cmd);
if (output == null) output = "";
result = new Status(true, output);
! } catch (Exception ex) {
if (null != debugger)
debugger.debugClearcase("ClearCaseJNI", "[error]: "
***************
*** 169,182 ****
* @see net.sourceforge.eclipseccase.IClearcase#delete(String, String)
*/
! public synchronized Status delete(String file, String comment)
! {
Status result;
! try
! {
! if (isSymbolicLink(file))
! {
! throw new RuntimeException("Cannot delete link: " + file);
! }
!
IClearCase ccase = new Application();
ICCVersion version = ccase.getVersion(new Variant(file));
--- 155,164 ----
* @see net.sourceforge.eclipseccase.IClearcase#delete(String, String)
*/
! public synchronized Status delete(String file, String comment) {
Status result;
! try {
! if (isSymbolicLink(file)) { throw new RuntimeException(
! "Cannot delete link: " + file); }
!
IClearCase ccase = new Application();
ICCVersion version = ccase.getVersion(new Variant(file));
***************
*** 184,190 ****
element.removeName(comment, true);
result = new Status(true, "Delete Successful");
! }
! catch (Exception ex)
! {
result = new Status(false, ex.getMessage());
}
--- 166,170 ----
element.removeName(comment, true);
result = new Status(true, "Delete Successful");
! } catch (Exception ex) {
result = new Status(false, ex.getMessage());
}
***************
*** 195,210 ****
* @see net.sourceforge.eclipseccase.IClearcase#getViewName(String)
*/
! public synchronized Status getViewName(String file)
! {
Status result;
! try
! {
IClearCase ccase = new Application();
ICCView view = ccase.getView(file);
result = new Status(true, view.getTagName());
! }
! catch (Exception ex)
! {
result = new Status(false, ex.getMessage());
}
--- 175,186 ----
* @see net.sourceforge.eclipseccase.IClearcase#getViewName(String)
*/
! public synchronized Status getViewName(String file) {
Status result;
! try {
IClearCase ccase = new Application();
ICCView view = ccase.getView(file);
result = new Status(true, view.getTagName());
! } catch (Exception ex) {
result = new Status(false, ex.getMessage());
}
***************
*** 217,235 ****
* @see net.sourceforge.clearcase.simple.IClearcase#getViewRoot(java.lang.String)
*/
! public Status getViewRoot(String file)
! {
Status result;
! try
! {
File dir = new File(file);
if (!dir.isDirectory()) dir = dir.getParentFile();
! synchronized (this)
! {
result = cleartool("cd " + ClearcaseUtil.quote(dir.getPath()));
if (result.status) result = cleartool("pwv -root");
}
! }
! catch (Exception ex)
! {
result = new Status(false, ex.getMessage());
}
--- 193,206 ----
* @see net.sourceforge.clearcase.simple.IClearcase#getViewRoot(java.lang.String)
*/
! public Status getViewRoot(String file) {
Status result;
! try {
File dir = new File(file);
if (!dir.isDirectory()) dir = dir.getParentFile();
! synchronized (this) {
result = cleartool("cd " + ClearcaseUtil.quote(dir.getPath()));
if (result.status) result = cleartool("pwv -root");
}
! } catch (Exception ex) {
result = new Status(false, ex.getMessage());
}
***************
*** 240,250 ****
* @see net.sourceforge.eclipseccase.IClearcase#isCheckedOut(String)
*/
! public synchronized boolean isCheckedOut(String file)
! {
boolean result;
! try
! {
! if (isSymbolicLink(file))
! {
file = getResolvedLinkTarget(file);
if (null == file) return false;
--- 211,218 ----
* @see net.sourceforge.eclipseccase.IClearcase#isCheckedOut(String)
*/
! public synchronized boolean isCheckedOut(String file) {
boolean result;
! try {
! if (isSymbolicLink(file)) {
file = getResolvedLinkTarget(file);
if (null == file) return false;
***************
*** 254,274 ****
ICCVersion version = ccase.getVersion(new Variant(file));
result = version.getIsCheckedOut();
! }
! catch (Exception ex)
! {
throw new RuntimeException(ex.getMessage());
}
return result;
}
!
!
! /* (non-Javadoc)
* @see net.sourceforge.clearcase.simple.IClearcase#isCheckedOutInAnotherView(java.lang.String)
*/
public synchronized boolean isCheckedOutInAnotherView(String file) {
! try
! {
! if (isSymbolicLink(file))
! {
file = getResolvedLinkTarget(file);
if (null == file) return false;
--- 222,239 ----
ICCVersion version = ccase.getVersion(new Variant(file));
result = version.getIsCheckedOut();
! } catch (Exception ex) {
throw new RuntimeException(ex.getMessage());
}
return result;
}
!
! /*
! * (non-Javadoc)
! *
* @see net.sourceforge.clearcase.simple.IClearcase#isCheckedOutInAnotherView(java.lang.String)
*/
public synchronized boolean isCheckedOutInAnotherView(String file) {
! try {
! if (isSymbolicLink(file)) {
file = getResolvedLinkTarget(file);
if (null == file) return false;
***************
*** 276,289 ****
Status status = getViewName(file);
! if(status.status && status.message.trim().length() > 0)
! {
String currentView = status.message.trim();
! status = cleartool("lsco -fmt " + ClearcaseUtil.quote("%Tf") + " "
! + ClearcaseUtil.quote(file));
! if (status.status && status.message.trim().length() > 0 && !currentView.equals(status.message.trim())) return true;
}
! }
! catch (Exception ex)
! {
throw new RuntimeException(ex.getMessage());
}
--- 241,253 ----
Status status = getViewName(file);
! if (status.status && status.message.trim().length() > 0) {
String currentView = status.message.trim();
! status = cleartool("lsco -fmt " + ClearcaseUtil.quote("%Tf")
! + " " + ClearcaseUtil.quote(file));
! if (status.status && status.message.trim().length() > 0
! && !currentView.equals(status.message.trim()))
! return true;
}
! } catch (Exception ex) {
throw new RuntimeException(ex.getMessage());
}
***************
*** 296,306 ****
* @return
*/
! private synchronized String getResolvedLinkTarget(String file)
! {
Status status = getSymbolicLinkTarget(file);
! if (status.status)
! {
File target = new File(status.message);
! if (target.isAbsolute()) return target.exists() ? target.getAbsolutePath() :null;
// target is relative to source
--- 260,269 ----
* @return
*/
! private synchronized String getResolvedLinkTarget(String file) {
Status status = getSymbolicLinkTarget(file);
! if (status.status) {
File target = new File(status.message);
! if (target.isAbsolute())
! return target.exists() ? target.getAbsolutePath() : null;
// target is relative to source
***************
*** 308,321 ****
if (null == parent) return null;
target = new File(parent, status.message);
! return target.exists() ? target.getAbsolutePath():null;
}
return null;
}
!
! /* (non-Javadoc)
* @see net.sourceforge.clearcase.simple.IClearcase#isSymbolicLinkTargetValid(java.lang.String)
*/
! public boolean isSymbolicLinkTargetValid(String file)
! {
return null != getResolvedLinkTarget(file);
}
--- 271,285 ----
if (null == parent) return null;
target = new File(parent, status.message);
! return target.exists() ? target.getAbsolutePath() : null;
}
return null;
}
!
! /*
! * (non-Javadoc)
! *
* @see net.sourceforge.clearcase.simple.IClearcase#isSymbolicLinkTargetValid(java.lang.String)
*/
! public boolean isSymbolicLinkTargetValid(String file) {
return null != getResolvedLinkTarget(file);
}
***************
*** 324,334 ****
* @see net.sourceforge.eclipseccase.IClearcase#isDifferent(String)
*/
! public synchronized boolean isDifferent(String file)
! {
boolean result = false;
! try
! {
! if (isSymbolicLink(file))
! {
file = getResolvedLinkTarget(file);
if (null == file) return false;
--- 288,295 ----
* @see net.sourceforge.eclipseccase.IClearcase#isDifferent(String)
*/
! public synchronized boolean isDifferent(String file) {
boolean result = false;
! try {
! if (isSymbolicLink(file)) {
file = getResolvedLinkTarget(file);
if (null == file) return false;
***************
*** 338,344 ****
ICCVersion version = ccase.getVersion(new Variant(file));
result = version.getIsCheckedOut() && version.getIsDifferent();
! }
! catch (Exception ex)
! {
// could not determine version, ignore;
}
--- 299,303 ----
ICCVersion version = ccase.getVersion(new Variant(file));
result = version.getIsCheckedOut() && version.getIsDifferent();
! } catch (Exception ex) {
// could not determine version, ignore;
}
***************
*** 349,362 ****
* @see net.sourceforge.eclipseccase.IClearcase#isElement(String)
*/
! public synchronized boolean isElement(String file)
! {
! try
! {
IClearCase ccase = new Application();
ICCVersion version = ccase.getVersion(new Variant(file));
if (null != version) return true;
! }
! catch (Exception ex)
! {
// ignore
}
--- 308,317 ----
* @see net.sourceforge.eclipseccase.IClearcase#isElement(String)
*/
! public synchronized boolean isElement(String file) {
! try {
IClearCase ccase = new Application();
ICCVersion version = ccase.getVersion(new Variant(file));
if (null != version) return true;
! } catch (Exception ex) {
// ignore
}
***************
*** 371,385 ****
* @see net.sourceforge.clearcase.simple.IClearcase#isSymbolicLink(java.lang.String)
*/
! public synchronized boolean isSymbolicLink(String file)
! {
! try
! {
Status status = cleartool("describe -fmt \"%m\" "
+ ClearcaseUtil.quote(file));
if (status.status && status.message.indexOf("symbolic link") >= 0)
return true;
! }
! catch (Exception ex)
! {
// ignore
}
--- 326,336 ----
* @see net.sourceforge.clearcase.simple.IClearcase#isSymbolicLink(java.lang.String)
*/
! public synchronized boolean isSymbolicLink(String file) {
! try {
Status status = cleartool("describe -fmt \"%m\" "
+ ClearcaseUtil.quote(file));
if (status.status && status.message.indexOf("symbolic link") >= 0)
return true;
! } catch (Exception ex) {
// ignore
}
***************
*** 392,408 ****
* @see net.sourceforge.clearcase.simple.IClearcase#getSymbolicLinkTarget(java.lang.String)
*/
! public Status getSymbolicLinkTarget(String file)
! {
! try
! {
! if (isSymbolicLink(file))
! {
Status status = cleartool("describe -fmt \"%[slink_text]p\" "
+ ClearcaseUtil.quote(file));
if (status.status) return status;
}
! }
! catch (Exception ex)
! {
// ignore
}
--- 343,354 ----
* @see net.sourceforge.clearcase.simple.IClearcase#getSymbolicLinkTarget(java.lang.String)
*/
! public Status getSymbolicLinkTarget(String file) {
! try {
! if (isSymbolicLink(file)) {
Status status = cleartool("describe -fmt \"%[slink_text]p\" "
+ ClearcaseUtil.quote(file));
if (status.status) return status;
}
! } catch (Exception ex) {
// ignore
}
***************
*** 413,423 ****
* @see net.sourceforge.eclipseccase.IClearcase#isHijacked(String)
*/
! public synchronized boolean isHijacked(String file)
! {
boolean result = false;
! try
! {
! if (isSymbolicLink(file))
! {
file = getResolvedLinkTarget(file);
if (null == file) return false;
--- 359,366 ----
* @see net.sourceforge.eclipseccase.IClearcase#isHijacked(String)
*/
! public synchronized boolean isHijacked(String file) {
boolean result = false;
! try {
! if (isSymbolicLink(file)) {
file = getResolvedLinkTarget(file);
if (null == file) return false;
***************
*** 427,433 ****
ICCVersion version = ccase.getVersion(new Variant(file));
result = version.getIsHijacked();
}
- catch (Exception ex)
- {}
return result;
}
--- 370,376 ----
ICCVersion version = ccase.getVersion(new Variant(file));
result = version.getIsHijacked();
+ } catch (Exception ex) {
+ // nothing
}
return result;
}
***************
*** 436,446 ****
* @see net.sourceforge.eclipseccase.IClearcase#isSnapShot(String)
*/
! public synchronized boolean isSnapShot(String file)
! {
boolean result = false;
! try
! {
! if (isSymbolicLink(file))
! {
file = getResolvedLinkTarget(file);
if (null == file) return false;
--- 379,386 ----
* @see net.sourceforge.eclipseccase.IClearcase#isSnapShot(String)
*/
! public synchronized boolean isSnapShot(String file) {
boolean result = false;
! try {
! if (isSymbolicLink(file)) {
file = getResolvedLinkTarget(file);
if (null == file) return false;
***************
*** 450,456 ****
ICCView view = ccase.getView(file);
result = view.getIsSnapShot();
}
- catch (Exception ex)
- {}
return result;
}
--- 390,396 ----
ICCView view = ccase.getView(file);
result = view.getIsSnapShot();
+ } catch (Exception ex) {
+ // nothing
}
return result;
}
***************
*** 459,479 ****
* @see net.sourceforge.eclipseccase.IClearcase#move(String, String, String)
*/
! public synchronized Status move(String file, String newfile, String comment)
! {
Status result;
! try
! {
! if (isSymbolicLink(file))
! {
! throw new RuntimeException("Cannot move link: " + file);
! }
!
IClearCase ccase = new Application();
ICCElement element = ccase.getElement(file);
element.rename(newfile, comment);
result = new Status(true, "Move Successful");
! }
! catch (Exception ex)
! {
result = new Status(false, ex.getMessage());
}
--- 399,413 ----
* @see net.sourceforge.eclipseccase.IClearcase#move(String, String, String)
*/
! public synchronized Status move(String file, String newfile, String comment) {
Status result;
! try {
! if (isSymbolicLink(file)) { throw new RuntimeException(
! "Cannot move link: " + file); }
!
IClearCase ccase = new Application();
ICCElement element = ccase.getElement(file);
element.rename(newfile, comment);
result = new Status(true, "Move Successful");
! } catch (Exception ex) {
result = new Status(false, ex.getMessage());
}
***************
*** 484,497 ****
* @see net.sourceforge.eclipseccase.IClearcase#uncheckout(String, boolean)
*/
! public synchronized Status uncheckout(String file, boolean keep)
! {
Status result;
! try
! {
! if (isSymbolicLink(file))
! {
String oldFile = file;
file = getResolvedLinkTarget(file);
! if (null == file) throw new RuntimeException("Invalid link target: " + oldFile);
}
--- 418,430 ----
* @see net.sourceforge.eclipseccase.IClearcase#uncheckout(String, boolean)
*/
! public synchronized Status uncheckout(String file, boolean keep) {
Status result;
! try {
! if (isSymbolicLink(file)) {
String oldFile = file;
file = getResolvedLinkTarget(file);
! if (null == file)
! throw new RuntimeException("Invalid link target: "
! + oldFile);
}
***************
*** 500,506 ****
cofile.unCheckOut(keep ? CCKeepState.ccKeep : CCKeepState.ccRemove);
result = new Status(true, "Uncheckout Successful");
! }
! catch (Exception ex)
! {
result = new Status(false, ex.getMessage());
}
--- 433,437 ----
cofile.unCheckOut(keep ? CCKeepState.ccKeep : CCKeepState.ccRemove);
result = new Status(true, "Uncheckout Successful");
! } catch (Exception ex) {
result = new Status(false, ex.getMessage());
}
***************
*** 517,543 ****
* @return the argument with comment
*/
! private final String getArgumentWithComment(String comment, String argument)
! {
! if (comment.indexOf('\n') != -1 || comment.indexOf('\r') != -1)
! {
StringBuffer buffer = new StringBuffer(comment.length());
! for (int i = 0; i < comment.length(); i++)
! {
char c = comment.charAt(i);
! switch (c)
! {
! case '\r':
! //buffer.append("\\r");
! // drop
! break;
! case '\n':
! //buffer.append("\\n");
! buffer.append(" ");
! break;
! default:
! buffer.append(c);
! break;
}
}
--- 448,470 ----
* @return the argument with comment
*/
! private final String getArgumentWithComment(String comment, String argument) {
! if (comment.indexOf('\n') != -1 || comment.indexOf('\r') != -1) {
StringBuffer buffer = new StringBuffer(comment.length());
! for (int i = 0; i < comment.length(); i++) {
char c = comment.charAt(i);
! switch (c) {
! case '\r':
! //buffer.append("\\r");
! // drop
! break;
! case '\n':
! //buffer.append("\\n");
! buffer.append(" ");
! break;
! default:
! buffer.append(c);
! break;
}
}
***************
*** 554,559 ****
* @see net.sourceforge.clearcase.simple.IClearcase#setDebugger(net.sourceforge.clearcase.simple.IClearcaseDebugger)
*/
! public void setDebugger(IClearcaseDebugger debugger)
! {
this.debugger = debugger;
}
--- 481,485 ----
* @see net.sourceforge.clearcase.simple.IClearcase#setDebugger(net.sourceforge.clearcase.simple.IClearcaseDebugger)
*/
! public void setDebugger(IClearcaseDebugger debugger) {
this.debugger = debugger;
}
Index: ClearcaseCLI.java
===================================================================
RCS file: /cvsroot/clearcase-java/net.sourceforge.clearcase/src/java/net/sourceforge/clearcase/simple/ClearcaseCLI.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** ClearcaseCLI.java 28 Apr 2004 10:25:59 -0000 1.11
--- ClearcaseCLI.java 28 Apr 2004 11:45:15 -0000 1.12
***************
*** 216,230 ****
}
! /**
! * @see net.sourceforge.eclipseccase.IClearcase#add(String, String, boolean)
*/
! public Status add(String file, String comment, boolean isdirectory)
! {
! if (isdirectory) return execute("mkdir "
! + getArgumentWithComment(comment, ClearcaseUtil.quote(file)));
else
return execute("mkelem "
! + getArgumentWithComment(comment, ClearcaseUtil.quote(file)));
}
--- 216,232 ----
}
!
! /* (non-Javadoc)
! * @see net.sourceforge.clearcase.simple.IClearcase#add(java.lang.String, java.lang.String, boolean, boolean)
*/
! public Status add(String file, String comment, boolean isDirectory,
! boolean makeMaster) {
! String masterFlag = makeMaster ? "-master " : "";
! if (isDirectory) return execute("mkdir "
! + getArgumentWithComment(comment, masterFlag + ClearcaseUtil.quote(file)));
else
return execute("mkelem "
! + getArgumentWithComment(comment, masterFlag + ClearcaseUtil.quote(file)));
}
***************
*** 290,300 ****
}
! /**
! * @see net.sourceforge.eclipseccase.IClearcase#checkout(String, String,
! * boolean, boolean)
*/
public Status checkout(String file, String comment, boolean reserved,
! boolean ptime)
! {
if (isSymbolicLink(file))
{
--- 292,301 ----
}
!
! /* (non-Javadoc)
! * @see net.sourceforge.clearcase.simple.IClearcase#checkout(java.lang.String, java.lang.String, boolean, boolean, boolean, boolean)
*/
public Status checkout(String file, String comment, boolean reserved,
! boolean ptime) {
if (isSymbolicLink(file))
{
***************
*** 304,308 ****
}
! String ptimeFlag = ptime ? "-ptime " : "";
String resFlag = reserved ? "-reserved " : "-unreserved ";
return execute("checkout "
--- 305,309 ----
}
! String ptimeFlag = ptime ? "-ptime " : "";
String resFlag = reserved ? "-reserved " : "-unreserved ";
return execute("checkout "
Index: ClearcaseUtil.java
===================================================================
RCS file: /cvsroot/clearcase-java/net.sourceforge.clearcase/src/java/net/sourceforge/clearcase/simple/ClearcaseUtil.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ClearcaseUtil.java 26 Jan 2004 08:26:10 -0000 1.6
--- ClearcaseUtil.java 28 Apr 2004 11:45:15 -0000 1.7
***************
*** 315,319 ****
}
! public static void add(IClearcase ccase, File file, String comment) throws ClearcaseException
{
// Sanity check - can't add something that already is under VC
--- 315,319 ----
}
! public static void add(IClearcase ccase, File file, String comment, boolean makeMaster) throws ClearcaseException
{
// Sanity check - can't add something that already is under VC
***************
*** 348,352 ****
else
{
! add(ccase, parent, comment);
}
--- 348,352 ----
else
{
! add(ccase, parent, comment, makeMaster);
}
***************
*** 357,361 ****
File mkelemfolder = new File(path + ".mkelem");
origfolder.renameTo(mkelemfolder);
! Status status = ccase.add(path, comment, true);
if (status.status)
{
--- 357,361 ----
File mkelemfolder = new File(path + ".mkelem");
origfolder.renameTo(mkelemfolder);
! Status status = ccase.add(path, comment, true, makeMaster);
if (status.status)
{
***************
*** 376,380 ****
else
{
! Status status = ccase.add(file.toString(), comment, false);
if (!status.status)
{
--- 376,380 ----
else
{
! Status status = ccase.add(file.toString(), comment, false, makeMaster);
if (!status.status)
{
|