Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > subclipse commit: rev 236 - trunk/svnClientAdapter/src/main/org/tigris/subversion/svnclientadapter/commandline

subclipse
Discussion topic

Back to topic list

subclipse commit: rev 236 - trunk/svnClientAdapter/src/main/org/tigris/subversion/svnclientadapter/commandline

Author schatz
Full name Philip Schatz
Date 2003-10-18 12:16:18 PDT
Message Author: schatz
Date: Sat Oct 18 14:16:14 2003
New Revision: 236

Added:
   trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/commandli​ne/CmdLineProperty.j​ava
Modified:
   trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/commandli​ne/CmdLineClientAdap​ter.java
   trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/commandli​ne/CmdLineStatus.jav​a
   trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/commandli​ne/CommandLine.java
Log:
Now passes requirements for svnant. Still does not support all methods of the ISVNClientAdapter interface

Modified: trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/commandli​ne/CmdLineClientAdap​ter.java
====================​====================​====================​==================
--- trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/commandli​ne/CmdLineClientAdap​ter.java (original)
+++ trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/commandli​ne/CmdLineClientAdap​ter.java Sat Oct 18 14:16:14 2003
@@ -51,15 +51,15 @@
  * information on the Apache Software Foundation, please see
  * <http://www.apache.org/>.
  *
- */
+ */
 package org.tigris.subversio​n.svnclientadapter.c​ommandline;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
@@ -82,7 +82,7 @@
  */
 public class CmdLineClientAdapter implements ISVNClientAdapter {
 
- //TODO this expects svn to be in the path. should be able to set it in Window, Preferences
+ //PHIL this expects svn to be in the path. should be able to set it in Window, Preferences
     private CommandLine _cmd = new CommandLine("svn");
     private List _listeners = new LinkedList();
 
@@ -103,8 +103,7 @@
     /* (non-Javadoc)
      * @see org.tigris.subversio​n.subclipse.client.I​SVNClientAdapter#get​SingleStatus(java.io​.File)
      */
- public ISVNStatus getSingleStatus(File file)
- throws SVNClientException {
+ public ISVNStatus getSingleStatus(File file) throws SVNClientException {
         String path = null;
         try {
             path = file.getCanonicalPath();
@@ -114,7 +113,9 @@
         } catch (IOException e) {
             throw SVNClientException.w​rapException(e);
         } catch (CmdLineException e) {
- if(e.getMessage().st​artsWith("svn: Path is not a working copy directory")) {
+ if (e
+ .getMessage()
+ .startsWith("svn: Path is not a working copy directory")) {
                 return new CmdLineStatusUnversioned();
             }
             throw SVNClientException.w​rapException(e);
@@ -130,13 +131,13 @@
 
         String listLine;
         try {
- listLine = _cmd.list(svnUrl.toString(), rev.toString());
+ listLine = _cmd.list(toString(svnUrl), toString(rev));
 
             StringTokenizer st = new StringTokenizer(listLine, Helper.NEWLINE);
             while (st.hasMoreTokens()) {
                 String dirLine = st.nextToken();
                 CmdLineRemoteDirEntry entry =
- new CmdLineRemoteDirEntr​y(svnUrl.toString(),​ dirLine);
+ new CmdLineRemoteDirEntr​y(toString(svnUrl), dirLine);
                 entries.add(entry);
             }
             return (ISVNDirEntry[]) entries.toArray(
@@ -186,25 +187,16 @@
     public InputStream getContent(SVNUrl arg0, SVNRevision arg1)
         throws SVNClientException {
 
- InputStream content = _cmd.cat(arg0.toString(), arg1.toString());
+ InputStream content = _cmd.cat(toString(arg0), toString(arg1));
 
         //read byte-by-byte and put it in a vector.
         //then take the vector and fill a byteArray.
- Vector buffer = new Vector(1024);
- int tempByte;
+ byte[] byteArray;
         try {
- while ((tempByte = content.read()) != -1) {
- buffer.add(new Byte((byte) tempByte));
- }
+ byteArray = streamToByteArray(content, false);
         } catch (IOException e) {
             throw SVNClientException.w​rapException(e);
         }
-
- byte[] byteArray = new byte[buffer.size()];
- for (int i = 0; i < byteArray.length; i++) {
- Byte b = (Byte) buffer.get(i);
- byteArray[i] = b.byteValue();
- }
         return new ByteArrayInputStream​(byteArray);
 
     }
@@ -213,7 +205,7 @@
      * @see org.tigris.subversio​n.subclipse.client.I​SVNClientAdapter#mkd​ir(java.net.URL, java.lang.String)
      */
     public void mkdir(SVNUrl arg0, String arg1) throws SVNClientException {
- _cmd.mkdir(arg0.toString(), arg1);
+ _cmd.mkdir(toString(arg0), arg1);
     }
 
     /* (non-Javadoc)
@@ -264,17 +256,21 @@
      */
     public void copy(SVNUrl src, SVNUrl dest, String message, SVNRevision rev)
         throws SVNClientException {
- _cmd.copy(
- src.toString(),
- dest.toString(),
- message,
- rev.toString());
+ _cmd.copy(src.toString(), dest.toString(), message, rev.toString());
     }
 
- public void copy(File srcPath, File destPath)
- throws SVNClientException {
- // TODO : implement this
- }
+ public void copy(File srcPath, File destPath) throws SVNClientException {
+ _cmd.copy(srcPath.toString(), destPath.toString());
+ //sometimes the dir has not yet been created.
+ //wait up to 5 sec for the dir to be created.
+ for (int i = 0; i < 50 && !destPath.exists(); i++) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e2) {
+ //do nothing if interrupted
+ }
+ }
+ }
 
     /* (non-Javadoc)
      * @see org.tigris.subversio​n.subclipse.client.I​SVNClientAdapter#mov​e(java.net.URL, java.net.URL, java.lang.String, org.tigris.subversio​n.subclipse.client.I​SVNRevision)
@@ -322,7 +318,7 @@
      * @see org.tigris.subversio​n.subclipse.client.I​SVNClientAdapter#set​Username(java.lang.S​tring)
      */
     public void setUsername(String string) {
- if(string == null || string.length() == 0)
+ if (string == null || string.length() == 0)
             return;
         _cmd.setUsername(string);
     }
@@ -331,7 +327,7 @@
      * @see org.tigris.subversio​n.subclipse.client.I​SVNClientAdapter#set​Password(java.lang.S​tring)
      */
     public void setPassword(String password) {
- if(password == null)
+ if (password == null)
             return;
 
         _cmd.setPassword(password);
@@ -346,6 +342,11 @@
         } catch (IOException e) {
             throw SVNClientException.w​rapException(e);
         } catch (CmdLineException e) {
+ //if something is already in svn and we
+ //try to add it, we get a warning.
+ //ignore it.\
+ if (e.getMessage().star​tsWith("svn: warning: "))
+ return;
             throw SVNClientException.w​rapException(e);
         }
     }
@@ -360,6 +361,11 @@
         } catch (IOException e) {
             throw SVNClientException.w​rapException(e);
         } catch (CmdLineException e) {
+ //if something is already in svn and we
+ //try to add it, we get a warning.
+ //ignore it.\
+ if (e.getMessage().star​tsWith("svn: warning: "))
+ return;
             throw SVNClientException.w​rapException(e);
         }
     }
@@ -370,18 +376,36 @@
     public long commit(File[] parents, String comment, boolean b)
         throws SVNClientException {
         StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < parents.length; i++) {
+ sb.append(parents[i]​.toString());
+ sb.append(' ');
+ }
         try {
- for (int i = 0; i < parents.length; i++) {
- sb.append(parents[i]​.getCanonicalPath())​;
- sb.append(' ');
- }
             String changedResources = _cmd.checkin(sb.toString(), comment);
- refreshChangedResour​ces(changedResources​);
- // TODO : return the version number !
- return 0;
- } catch (IOException e) {
- throw SVNClientException.w​rapException(e);
+ return refreshChangedResour​ces(changedResources​);
         } catch (CmdLineException e) {
+ if ("".equals(e.getMessage()))
+ return SVNRevision.SVN_INVALID_REVNUM;
+ if (e
+ .getMessage()
+ .startsWith("svn: Attempted to lock an already-locked dir")) {
+ //PHIL is this the best way to handle pending locks? (ie caused by "svn cp")
+ //loop through up to 5 sec, waiting for locks
+ //to be removed.
+ for (int i = 0; i < 50; i++) {
+ try {
+ String changedResources =
+ _cmd.checkin(sb.toString(), comment);
+ return refreshChangedResour​ces(changedResources​);
+ } catch (CmdLineException e1) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e2) {
+ //do nothing if interrupted
+ }
+ }
+ }
+ }
             throw SVNClientException.w​rapException(e);
         }
     }
@@ -402,7 +426,6 @@
         }
     }
 
-
     /* (non-Javadoc)
      * @see org.tigris.subversio​n.subclipse.client.I​SVNClientAdapter#che​ckout(java.net.URL, java.io.File, org.tigris.subversio​n.subclipse.client.I​SVNRevision, boolean)
      */
@@ -415,11 +438,7 @@
         try {
             String dest = destPath.getCanonicalPath();
             String changedResources =
- _cmd.checkout(
- url.toString(),
- dest,
- revision.toString(),
- b);
+ _cmd.checkout(url.toString(), dest, revision.toString(), b);
             refreshChangedResour​ces(changedResources​);
 
         } catch (CmdLineException e) {
@@ -430,11 +449,44 @@
     }
 
     /* (non-Javadoc)
+ * @see org.tigris.subversio​n.subclipse.client.I​SVNClientAdapter#get​StatusRecursively(ja​va.io.File,boolean)
+ */
+ public ISVNStatus[] getStatusRecursively(File file, boolean getAll)
+ throws SVNClientException {
+ String path = null;
+ List statuses = new LinkedList();
+ try {
+ path = file.getCanonicalPath();
+ String statusLines = _cmd.recursiveStatus(path);
+ StringTokenizer st =
+ new StringTokenizer(statusLines, Helper.NEWLINE);
+ while (st.hasMoreTokens()) {
+ String statusLine = st.nextToken();
+ String infoLine = _cmd.info(statusLine​.substring(7));
+ CmdLineStatus status =
+ new CmdLineStatus(statusLine, infoLine);
+ statuses.add(status);
+ }
+
+ return (ISVNStatus[]) statuses.toArray(
+ new ISVNStatus[statuses.size()]);
+ } catch (IOException e) {
+ throw SVNClientException.w​rapException(e);
+ } catch (CmdLineException e) {
+ if (e
+ .getMessage()
+ .startsWith("svn: Path is not a working copy directory")) {
+ return new ISVNStatus[0];
+ }
+ throw SVNClientException.w​rapException(e);
+ }
+ }
+
+ /* (non-Javadoc)
      * @see org.tigris.subversio​n.subclipse.client.I​SVNClientAdapter#get​Revision(java.lang.S​tring)
      */
     public SVNRevision getRevision(String revName) {
- // TODO Auto-generated method stub
- System.out.println("​[CommandLineClientAd​apter] getRevision.");
+ // TODO : implement
         return null;
     }
 
@@ -445,33 +497,31 @@
         return new SVNRevision.Number(revNum);
     }
 
- private void notifyListenersOfChange(
- String path,
- SVNNodeKind type) {
+ private void notifyListenersOfChange(String path, SVNNodeKind type) {
         for (Iterator i = _listeners.iterator(); i.hasNext();) {
- ISVNNotifyListener listener =
- (ISVNNotifyListener) i.next();
+ ISVNNotifyListener listener = (ISVNNotifyListener) i.next();
             listener.onNotify(path, type);
         }
     }
 
- private void refreshChangedResources(String changedResourcesList) {
+ private long refreshChangedResources(String changedResourcesList) {
         StringTokenizer st =
             new StringTokenizer(chan​gedResourcesList, Helper.NEWLINE);
         while (st.hasMoreTokens()) {
             String line = st.nextToken();
-
+
             //check and see if we are at the last line (nothing to do)
             if (line.startsWith("At revision "))
- return;
- if(line.startsWith("Updated to revision "))
- return;
- if(line.startsWith("Committed revision "))
- return;
- if(line.startsWith("Checked out revision "))
- return;
+ return Long.parseLong(line.​substring(12, line.length() - 1));
+ if (line.startsWith("Updated to revision "))
+ return Long.parseLong(line.​substring(18, line.length() - 1));
+ if (line.startsWith("Committed revision "))
+ return Long.parseLong(line.​substring(19, line.length() - 1));
+ if (line.startsWith("Checked out revision "))
+ return Long.parseLong(line.​substring(21, line.length() - 1));
+
             //Jump to the next line if we encounter this: (when checking in)
- if(line.startsWith("​Transmitting file data "))
+ if (line.startsWith("Transmitting file data "))
                 continue;
 
             String fileName = line.substring(line.indexOf(' ')).trim();
@@ -481,168 +531,243 @@
 
             notifyListenersOfChange(
                 fileName,
- f.isDirectory()
- ? SVNNodeKind.DIR
- : SVNNodeKind.FILE);
- }
- }
-
- public void diff(
- File oldPath,
- SVNRevision oldPathRevision,
- File newPath,
- SVNRevision newPathRevision,
- File outFile,
- boolean recurse)
- throws SVNClientException {
- // TODO : implement
- }
-
- public void diff(File path, File outFile, boolean recurse)
- throws SVNClientException {
- // TODO : implement
- }
- /**
- * display the differences between two urls.
- */
- public void diff(
- SVNUrl oldUrl,
- SVNRevision oldUrlRevision,
- SVNUrl newUrl,
- SVNRevision newUrlRevision,
- File outFile,
- boolean recurse)
- throws SVNClientException {
- // TODO : implement
- }
-
- public void diff(
- SVNUrl url,
- SVNRevision oldUrlRevision,
- SVNRevision newUrlRevision,
- File outFile,
- boolean recurse)
- throws SVNClientException {
- // TODO : implement
- }
-
- public ISVNProperty propertyGet(File path, String propertyName)
- throws SVNClientException {
- // TODO : implement
- return null;
- }
-
- public void propertyDel(
- File path,
- String propertyName,
- boolean recurse)
- throws SVNClientException {
- // TODO : implement
- }
-
- public List getIgnoredPatterns(File path)
- throws SVNClientException {
- // TODO : implement
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.tigris.subversio​n.subclipse.client.I​SVNClientAdapter#add​ToIgnoredPatterns(ja​va.io.File, java.lang.String)
- */
- public void addToIgnoredPatterns(File file, String pattern)
- throws SVNClientException {
- // TODO Auto-generated method stub
- System.out.println("​[CommandLineClientAd​apter] addToIgnoredPatterns.");
- }
-
- public void setIgnoredPatterns(File path, List patterns)
- throws SVNClientException {
- // TODO : implement
- }
-
- public void mkdir(File file) throws SVNClientException {
- // TODO : implement
- }
-
- public void doImport(
- File path,
- SVNUrl url,
- String message,
- boolean recurse)
- throws SVNClientException {
- // TODO : implement
- }
-
- public void doExport(
- SVNUrl srcUrl,
- File destPath,
- SVNRevision revision,
- boolean force)
- throws SVNClientException {
- // TODO : implement
- }
-
- public void doExport(File srcPath, File destPath, boolean force)
- throws SVNClientException {
- // TODO : implement
- }
-
- public ISVNStatus[] getStatusRecursively(File file, boolean getAll)
- throws SVNClientException {
- Collection statuses = new ArrayList();
- String path = null;
+ f.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE);
+ }
+ return SVNRevision.SVN_INVALID_REVNUM;
+ }
+
+ private void diff(
+ String oldPath,
+ SVNRevision oldPathRevision,
+ String newPath,
+ SVNRevision newPathRevision,
+ File outFile,
+ boolean recurse) {
+ if (newPath == null)
+ newPath = oldPath;
+ if (oldPathRevision == null)
+ oldPathRevision = SVNRevision.BASE;
+ if (newPathRevision == null)
+ newPathRevision = SVNRevision.WORKING;
+
+ InputStream is =
+ _cmd.diff(
+ oldPath,
+ toString(oldPathRevision),
+ newPath,
+ toString(newPathRevision),
+ recurse);
+ try {
+ streamToFile(is, outFile);
+ } catch (IOException e) {
+ //this should never happen
+ }
+ }
+
+ public void diff(
+ File oldPath,
+ SVNRevision oldPathRevision,
+ File newPath,
+ SVNRevision newPathRevision,
+ File outFile,
+ boolean recurse)
+ throws SVNClientException {
+ if (oldPath == null)
+ oldPath = new File(".");
+ diff(
+ toString(oldPath),
+ oldPathRevision,
+ toString(newPath),
+ newPathRevision,
+ outFile,
+ recurse);
+ }
+
+ public void diff(File path, File outFile, boolean recurse)
+ throws SVNClientException {
+ diff(path, null, null, null, outFile, recurse);
+ }
+ /**
+ * display the differences between two urls.
+ */
+ public void diff(
+ SVNUrl oldUrl,
+ SVNRevision oldUrlRevision,
+ SVNUrl newUrl,
+ SVNRevision newUrlRevision,
+ File outFile,
+ boolean recurse)
+ throws SVNClientException {
+ diff(
+ toString(oldUrl),
+ oldUrlRevision,
+ toString(newUrl),
+ newUrlRevision,
+ outFile,
+ recurse);
+ }
+
+ public void diff(
+ SVNUrl url,
+ SVNRevision oldUrlRevision,
+ SVNRevision newUrlRevision,
+ File outFile,
+ boolean recurse)
+ throws SVNClientException {
+ // TODO : test
+ diff(url, oldUrlRevision, url, newUrlRevision, outFile, recurse);
+ }
+
+ public ISVNProperty propertyGet(File path, String propertyName)
+ throws SVNClientException {
+ try {
+ String pathString = toString(path);
+ InputStream valueAndData =
+ _cmd.propget(toString(path), propertyName);
+
+ byte[] bytes = streamToByteArray(valueAndData, true);
+
+ String value = new String(bytes);
+ value = new StringTokenizer(value, Helper.NEWLINE).nextToken();
+
+ return new CmdLineProperty(propertyName, value, pathString, bytes);
+ } catch (CmdLineException e) {
+ throw SVNClientException.w​rapException(e);
+ } catch (IOException e) {
+ throw SVNClientException.w​rapException(e);
+ }
+ }
+
+ public void propertyDel(File path, String propertyName, boolean recurse)
+ throws SVNClientException {
+ // TODO : implement
+ }
+
+ public List getIgnoredPatterns(File path) throws SVNClientException {
+ // TODO : implement
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tigris.subversio​n.subclipse.client.I​SVNClientAdapter#add​ToIgnoredPatterns(ja​va.io.File, java.lang.String)
+ */
+ public void addToIgnoredPatterns(File file, String pattern)
+ throws SVNClientException {
+ // TODO : implement
+ }
+
+ public void setIgnoredPatterns(File path, List patterns)
+ throws SVNClientException {
+ // TODO : implement
+ }
+
+ public void mkdir(File file) throws SVNClientException {
+ _cmd.mkdir(toString(file));
+ //sometimes the dir has not yet been created.
+ //wait up to 5 sec for the dir to be created.
+ for (int i = 0; i < 50 && !file.exists(); i++) {
             try {
- path = file.getCanonicalPath();
-
- String statusLines = _cmd.recursiveStatus(path);
- StringTokenizer st = new StringTokenizer(statusLines, Helper.NEWLINE);
+ Thread.sleep(100);
+ } catch (InterruptedException e2) {
+ //do nothing if interrupted
+ }
+ }
+ }
+
+ public void doImport(
+ File path,
+ SVNUrl url,
+ String message,
+ boolean recurse)
+ throws SVNClientException {
+ // TODO : implement
+ }
+
+ public void doExport(
+ SVNUrl srcUrl,
+ File destPath,
+ SVNRevision revision,
+ boolean force)
+ throws SVNClientException {
+ try {
+ _cmd.export(
+ toString(srcUrl),
+ toString(destPath),
+ toString(revision),
+ force);
+ } catch (CmdLineException e) {
+ throw SVNClientException.w​rapException(e);
+ }
+ }
+
+ public void doExport(File srcPath, File destPath, boolean force)
+ throws SVNClientException {
+ // TODO : test
+ try {
+ _cmd.export(toString(srcPath), toString(destPath), null, force);
+ } catch (CmdLineException e) {
+ throw SVNClientException.w​rapException(e);
+ }
+ }
+
+ public void propertySet(
+ File path,
+ String propertyName,
+ File propertyFile,
+ boolean recurse)
+ throws SVNClientException, IOException {
+ try {
+ _cmd.propsetFile(
+ propertyName,
+ toString(propertyFile),
+ toString(path),
+ recurse);
+ } catch (CmdLineException e) {
+ throw SVNClientException.w​rapException(e);
+ }
+ }
+
+ public void copy(File srcPath, SVNUrl destUrl, String message)
+ throws SVNClientException {
+ // TODO : implement
+ }
+
+ public ISVNLogMessage[] getLogMessages(
+ File path,
+ SVNRevision revisionStart,
+ SVNRevision revisionEnd)
+ throws SVNClientException {
+ List tempLogs = new java.util.LinkedList();
+ String revRange =
+ revisionStart.toString() + ":" + revisionEnd.toString();
+
+ try {
+ String messages = _cmd.log(path.toString(), revRange);
+
+ StringTokenizer st = new StringTokenizer(messages, Helper.NEWLINE);
+ st.nextToken();
+ while (st.hasMoreTokens()) {
+ tempLogs.add(new CmdLineLogMessage(st));
+ }
+
+ return (ISVNLogMessage[]) tempLogs.toArray(
+ new ISVNLogMessage[tempL​ogs.size()]);
+ } catch (CmdLineException e) {
+ throw SVNClientException.w​rapException(e);
+ }
+ }
 
- while (st.hasMoreTokens()) {
- String line = st.nextToken();
- String fileName = line.substring(CmdLi​neStatus.STATUS_FILE​_WIDTH, line.length());
- String infoLine = _cmd.info(fileName);
-
- statuses.add(new CmdLineStatus(line, infoLine));
- }
-
- } catch (IOException e) {
- throw SVNClientException.w​rapException(e);
- } catch (CmdLineException e) {
- throw SVNClientException.w​rapException(e);
- }
- return (ISVNStatus[])status​es.toArray(new ISVNStatus[statuses.size()]);
- }
-
- public void propertySet(
- File path,
- String propertyName,
- File propertyFile,
- boolean recurse)
- throws SVNClientException, IOException {
- // TODO : implement
- }
-
- public void copy(File srcPath, SVNUrl destUrl, String message)
- throws SVNClientException {
- // TODO : implement
- }
-
- public ISVNLogMessage[] getLogMessages(
- File path,
- SVNRevision revisionStart,
- SVNRevision revisionEnd)
- throws SVNClientException {
- // TODO : implement
- return null;
- }
-
     /* (non-Javadoc)
      * @see org.tigris.subversio​n.svnclientadapter.I​SVNClientAdapter#cop​y(org.tigris.subvers​ion.svnclientadapter​.SVNUrl, java.io.File, org.tigris.subversio​n.svnclientadapter.S​VNRevision)
      */
     public void copy(SVNUrl srcUrl, File destPath, SVNRevision revision)
         throws SVNClientException {
- // TODO Auto-generated method stub
-
+ _cmd.copy(
+ srcUrl.toString(),
+ destPath.toString(),
+ null,
+ revision.toString());
+ // TODO : test
     }
 
     /* (non-Javadoc)
@@ -654,8 +779,60 @@
         String propertyValue,
         boolean recurse)
         throws SVNClientException {
- // TODO Auto-generated method stub
+ try {
+ _cmd.propset(propertyName, propertyValue, toString(path), recurse);
+ } catch (CmdLineException e) {
+ throw SVNClientException.w​rapException(e);
+ }
+ }
 
+ private static String toString(SVNUrl url) {
+ return (url == null) ? null : url.toString();
     }
 
+ private static String toString(File file) {
+ return (file == null) ? null : file.toString();
+ }
+
+ private static String toString(SVNRevision revision) {
+ return (revision == null) ? null : revision.toString();
+ }
+
+ private static void streamToFile(InputStream stream, File outFile)
+ throws IOException {
+ int tempByte;
+ try {
+ FileOutputStream os = new FileOutputStream(outFile);
+ while ((tempByte = stream.read()) != -1) {
+ os.write(tempByte);
+ }
+ os.close();
+ stream.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static byte[] streamToByteArray(
+ InputStream stream,
+ boolean removeTrailing)
+ throws IOException {
+ //read byte-by-byte and put it in a vector.
+ //then take the vector and fill a byteArray.
+ Vector buffer = new Vector(1024);
+ int tempByte;
+ while ((tempByte = stream.read()) != -1) {
+ buffer.add(new Byte((byte) tempByte));
+ }
+
+ if (removeTrailing && !buffer.isEmpty())
+ buffer.remove(buffer.size() - 1);
+
+ byte[] byteArray = new byte[buffer.size()];
+ for (int i = 0; i < byteArray.length; i++) {
+ Byte b = (Byte) buffer.get(i);
+ byteArray[i] = b.byteValue();
+ }
+ return byteArray;
+ }
 }

Added: trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/commandli​ne/CmdLineProperty.j​ava
====================​====================​====================​==================
--- (empty file)
+++ trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/commandli​ne/CmdLineProperty.j​ava Sat Oct 18 14:16:14 2003
@@ -0,0 +1,107 @@
+/* ====================​====================​====================​========
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache at apache dot org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================​====================​====================​========
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.tigris.subversio​n.svnclientadapter.c​ommandline;
+
+import org.tigris.subversio​n.svnclientadapter.I​SVNProperty;
+
+/**
+ * @author Philip Schatz <a href="mailto:schatz@​tigris.org">schat​z@tigris.org</a​>
+ * @since Oct 13, 2003
+ *
+ */
+public class CmdLineProperty implements ISVNProperty {
+ private String _Name;
+ private String _Value;
+ private String _Path;
+ private byte[] _Data;
+
+ /**
+ *
+ */
+ public CmdLineProperty(String name, String value, String path, byte[] data) {
+ _Name = name;
+ _Value = value;
+ _Path = path;
+ _Data = data;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tigris.subversio​n.svnclientadapter.I​SVNProperty#getName(​)
+ */
+ public String getName() {
+ return _Name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tigris.subversio​n.svnclientadapter.I​SVNProperty#getValue​()
+ */
+ public String getValue() {
+ return _Value;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tigris.subversio​n.svnclientadapter.I​SVNProperty#getPath(​)
+ */
+ public String getPath() {
+ return _Path;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tigris.subversio​n.svnclientadapter.I​SVNProperty#getData(​)
+ */
+ public byte[] getData() {
+ return _Data;
+ }
+}

Modified: trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/commandli​ne/CmdLineStatus.jav​a
====================​====================​====================​==================
--- trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/commandli​ne/CmdLineStatus.jav​a (original)
+++ trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/commandli​ne/CmdLineStatus.jav​a Sat Oct 18 14:16:14 2003
@@ -51,7 +51,7 @@
  * information on the Apache Software Foundation, please see
  * <http://www.apache.org/>.
  *
- */
+ */
 package org.tigris.subversio​n.svnclientadapter.c​ommandline;
 
 import java.io.File;
@@ -98,7 +98,7 @@
       '*' a newer revision exists on the server
       ' ' the working copy is up to date
 
- *
+ *
      */
 
     public CmdLineStatus(String statusLine, String infoLine) {

Modified: trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/commandli​ne/CommandLine.java
====================​====================​====================​==================
--- trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/commandli​ne/CommandLine.java (original)
+++ trunk/svnClientAdapt​er/src/main/org/tigr​is/subversion/svncli​entadapter/commandli​ne/CommandLine.java Sat Oct 18 14:16:14 2003
@@ -51,7 +51,7 @@
  * information on the Apache Software Foundation, please see
  * <http://www.apache.org/>.
  *
- */
+ */
 package org.tigris.subversio​n.svnclientadapter.c​ommandline;
 
 import java.io.IOException;
@@ -70,16 +70,25 @@
      */
     private static String CMD_ADD = " add {0} {1}";
     private static String CMD_CAT = " cat -r {0} {1}";
+ private static String CMD_CLEANUP = " cleanup {0}";
     private static String CMD_COMMIT = " ci {0} -m \"{1}\"";
     private static String CMD_COPY = " cp -r {0} -m \"{1}\" {2} {3}";
+ private static String CMD_COPY_LOCAL = " cp {0} {1}";
     private static String CMD_CHECKOUT = " co -r {0} {1} {2}";
     private static String CMD_DELETE = " rm {0} {1} --force";
+ private static String CMD_DIFF = " diff {0} {1}@{2} {3}@{4}";
+ private static String CMD_EXPORT = " export -r {0} {1} {2} {3}";
     private static String CMD_IMPORT = " import {0} {1} {2} -m \"{3}\"";
     private static String CMD_INFO = " info {0}";
     private static String CMD_LIST = " list -v -r {0} {1}";
     private static String CMD_LOG = " log -r {0} {1}";
     private static String CMD_MKDIR = " mkdir -m \"{0}\" {1}";
- private static String CMD_MOVE = " mv -r {0} {1} {2} {3} --force --non-interactive";
+ private static String CMD_MKDIR_LOCAL = " mkdir {0}";
+ private static String CMD_MOVE =
+ " mv -r {0} {1} {2} {3} --force --non-interactive";
+ private static String CMD_PROPGET = " propget {0} {1}";
+ private static String CMD_PROPSET = " propset {0} \"{1}\" {2}";
+ private static String CMD_PROPSET_FILE = " propset {0} -F \"{1}\" {2}";
     private static String CMD_REVERT = " revert {0} {1}";
     private static String CMD_STATUS =
         " status -v -N {0} {1} --non-interactive";
@@ -87,8 +96,7 @@
         " status -v {0} --non-interactive";
 
     private static String CMD_UPDATE = " up -r {0} {1} --non-interactive";
- private static String AUTH_INFO =
- " --username \"{0}\" --password \"{1}\"";
+ private static String AUTH_INFO = " --username \"{0}\" --password \"{1}\"";
 
     private String CMD;
 
@@ -113,8 +121,7 @@
      * @param resource
      * @param recursive
      */
- public String add(String path, boolean recursive)
- throws CmdLineException {
+ public String add(String path, boolean recursive) throws CmdLineException {
         String flags = (recursive) ? "" : "-N";
         return exec(
             CMD + MessageFormat.format(CMD_ADD, new String[] { flags, path }));
@@ -150,6 +157,7 @@
     }
 
     /**
+ * <pre>
      * commit (ci): Send changes from your working copy to the repository.
      * usage: commit [PATH [PATH ... ]]
      *
@@ -167,6 +175,7 @@
      * --no-auth-cache : do not cache authentication tokens
      * --non-interactive : do no interactive prompting
      * --encoding arg : treat value as being in charset encoding ARG
+ * </pre>
      *
      * @param path
      * @param message
@@ -183,6 +192,24 @@
     }
 
     /**
+ * <pre>
+ * cleanup: Recursively clean up the working copy, removing locks, resuming
+ * unfinished operations, etc.
+ * usage: cleanup [PATH...]
+ *
+ * Valid options:
+ * --diff3-cmd arg : use ARG as merge command
+ * --config-dir arg : read user configuration files from directory ARG
+ * </pre>
+ *
+ * @param path
+ */
+ public void cleanup(String path) {
+ execInternal(
+ CMD + MessageFormat.format​(CMD_CLEANUP, new String[] { path }));
+ }
+
+ /**
      * checkout (co): Check out a working copy from a repository.
      * usage: checkout URL [URL [URL ... ]] [PATH]
      * Note: If PATH is omitted, the basename of the URL will be used as
@@ -266,6 +293,14 @@
                     CMD_COPY,
                     new String[] { validRev(revision), message, src, dest })
                 + getAuthInfo());
+
+ }
+ public Process copy(String src, String dest) {
+ return execInternal(
+ CMD
+ + MessageFormat.format​(CMD_COPY_LOCAL, new String[] { src, dest })
+ + getAuthInfo());
+
     }
 
     /**
@@ -306,6 +341,134 @@
     }
 
     /**
+ * <pre>
+ * diff (di): display the differences between two paths.
+ * usage: 1. diff [-r N[:M]] [--old OLD-TGT] [--new NEW-TGT] [PATH...]
+ * 2. diff -r N:M URL
+ * 3. diff [-r N[:M]] URL1[@N] URL2[@M]
+ *
+ * 1. Display the differences between OLD-TGT and NEW-TGT. PATHs, if
+ * given, are relative to OLD-TGT and NEW-TGT and restrict the output
+ * to differences for those paths. OLD-TGT and NEW-TGT may be working
+ * copy paths or URL[@REV].
+ *
+ * OLD-TGT defaults to the path '.' and NEW-TGT defaults to OLD-TGT.
+ * N defaults to "BASE" or, if OLD-TGT is an URL, to "HEAD".
+ * M defaults to the current working version or, if NEW-TGT is an URL,
+ * to "HEAD".
+ *
+ * '-r N' sets the revision of OLD-TGT to N, '-r N:M' also sets the
+ * revision of NEW-TGT to M.
+ *
+ * 2. Shorthand for 'svn diff -r N:M --old=URL --new=URL'.
+ *
+ * 3. Shorthand for 'svn diff [-r N[:M]] --old=URL1 --new=URL2'
+ *
+ * Use just 'svn diff' to display local modifications in a working copy
+ *
+ * Valid options:
+ * -r [--revision] arg : revision X or X:Y range. X or Y can be one of:
+ * {DATE} date instead of revision number
+ * "HEAD" latest in repository
+ * "BASE" base revision of item's working copy
+ * "COMMITTED" revision of item's last commit
+ * "PREV" revision before item's last commit
+ * --old arg : use ARG as the older target
+ * --new arg : use ARG as the newer target
+ * -x [--extensions] arg : pass ARG as bundled options to GNU diff
+ * -N [--non-recursive] : operate on single directory only
+ * --diff-cmd arg : use ARG as diff command
+ * --no-diff-deleted : do not print differences for deleted files
+ * --notice-ancestry : notice ancestry when calculating differences
+ * --username arg : specify a username ARG
+ * --password arg : specify a password ARG
+ * --no-auth-cache : do not cache authentication tokens
+ * --non-interactive : do no interactive prompting
+ * --config-dir arg : read user configuration files from directory ARG
+ */
+ public InputStream diff(
+ String oldPath,
+ String oldRev,
+ String newPath,
+ String newRev,
+ boolean recurse) {
+ /*
+ Process proc =
+ execInternal(
+ CMD
+ + MessageFormat.format(
+ CMD_DIFF,
+ new String[] {
+ recurse ? "" : "-N",
+ oldPath,
+ oldRev,
+ newPath,
+ newRev })
+ + getAuthInfo());
+
+ InputStream content = proc.getInputStream();
+ return content;
+ */
+ String commandLine = " diff ";
+ if (!"BASE".equals(oldRev) || !"WORKING".equals(newPath)) {
+ commandLine += "-r " + oldRev;
+ if (!"WORKING".equals(newRev))
+ commandLine += ":" + newRev + " ";
+ }
+ commandLine += " --old " + oldPath;
+ commandLine += " --new " + newPath;
+
+ Process proc = execInternal(CMD + commandLine);
+ InputStream content = proc.getInputStream();
+ return content;
+ }
+
+ /**
+ * <pre>
+ * export: export stuff.
+ * usage: 1. export [-r REV] URL [PATH]
+ * 2. export PATH1 PATH2
+ *
+ * 1. Exports a clean directory tree from the repository specified by
+ * URL, at revision REV if it is given, otherwise at HEAD, into
+ * PATH. If PATH is omitted, the last component of the URL is used
+ * for the local directory name.
+ *
+ * 2. Exports a clean directory tree from the working copy specified by
+ * PATH1 into PATH2. all local changes will be preserved, but files
+ * not under revision control will not be copied.
+ *
+ * Valid options:
+ * -r [--revision] arg : revision X or X:Y range. X or Y can be one of:
+ * {DATE} date instead of revision number
+ * "HEAD" latest in repository
+ * "BASE" base revision of item's working copy
+ * "COMMITTED" revision of item's last commit
+ * "PREV" revision before item's last commit
+ * -q [--quiet] : print as little as possible
+ * --force : force operation to run
+ * --username arg : specify a username ARG
+ * --password arg : specify a password ARG
+ * --no-auth-cache : do not cache authentication tokens
+ * --non-interactive : do no interactive prompting
+ * --config-dir arg : read user configuration files from directory ARG
+ * </pre>
+ *
+ */
+ public void export(String url, String path, String revision, boolean force)
+ throws CmdLineException {
+ execInternal(
+ CMD
+ + MessageFormat.format(
+ CMD_EXPORT,
+ new String[] {
+ url,
+ path,
+ validRev(revision),
+ (force) ? "--force" : "" }));
+ }
+
+ /**
      * import: Commit an unversioned file or tree into the repository.
      * usage: import URL [PATH [NEW_ENTRY_IN_REPOS]]
      *
@@ -426,8 +589,7 @@
      * --no-auth-cache : do not cache authentication tokens
      * --non-interactive : do no interactive prompting
      */
- public String log(String target, String revision)
- throws CmdLineException {
+ public String log(String target, String revision) throws CmdLineException {
         return exec(
             CMD
                 + MessageFormat.format(
@@ -462,6 +624,13 @@
                 + MessageFormat.format(CMD_MKDIR, new String[] { message, path })
                 + getAuthInfo());
     }
+ public Process mkdir(String localPath) {
+ return execInternal(
+ CMD
+ + MessageFormat.format(
+ CMD_MKDIR_LOCAL,
+ new String[] { localPath }));
+ }
 
     /**
      * move (mv, rename, ren): Move/rename something in working copy or repository.
@@ -502,6 +671,131 @@
     }
 
     /**
+ * <pre>
+ * propget (pget, pg): Print value of PROPNAME on files, dirs, or revisions.
+ * usage: 1. propget PROPNAME [PATH...]
+ * 2. propget PROPNAME --revprop -r REV [URL]
+ *
+ * 1. Prints versioned prop in working copy.
+ * 2. Prints unversioned remote prop on repos revision.
+ *
+ * By default, this subcommand will add an extra newline to the end
+ * of the property values so that the output looks pretty. Also,
+ * whenever there are multiple paths involved, each property value
+ * is prefixed with the path with which it is associated. Use
+ * the --strict option to disable these beautifications (useful,
+ * for example, when redirecting binary property values to a file).
+ *
+ * Valid options:
+ * -R [--recursive] : descend recursively
+ * -r [--revision] arg : revision X or X:Y range. X or Y can be one of:
+ * {DATE} date instead of revision number
+ * "HEAD" latest in repository
+ * "BASE" base revision of item's working copy
+ * "COMMITTED" revision of item's last commit
+ * "PREV" revision before item's last commit
+ * --revprop : operate on a revision property (use with -r)
+ * --strict : use strict semantics
+ * --username arg : specify a username ARG
+ * --password arg : specify a password ARG
+ * --no-auth-cache : do not cache authentication tokens
+ * --non-interactive : do no interactive prompting
+ * --config-dir arg : read user configuration files from directory ARG
+ * </pre>
+ */
+ public InputStream propget(String path, String name)
+ throws CmdLineException {
+ Process proc =
+ execInternal(
+ CMD
+ + MessageFormat.format(
+ CMD_PROPGET,
+ new String[] { name, path }));
+ return proc.getInputStream();
+ }
+
+ /**
+ * <pre>
+ * propset (pset, ps): Set PROPNAME to PROPVAL on files, dirs, or revisions.
+ *
+ * usage: 1. propset PROPNAME [PROPVAL | -F VALFILE] PATH...
+ * 2. propset PROPNAME --revprop -r REV [PROPVAL | -F VALFILE] [URL]
+ *
+ * 1. Creates a versioned, local propchange in working copy.
+ * 2. Creates an unversioned, remote propchange on repos revision.
+ *
+ * Note: svn recognizes the following special versioned properties
+ * but will store any arbitrary properties set:
+ * svn:ignore - A newline separated list of file patterns to ignore.
+ * svn:keywords - Keywords to be expanded. Valid keywords are:
+ * URL, HeadURL - The URL for the head version of the object.
+ * Author, LastChangedBy - The last person to modify the file.
+ * Date, LastChangedDate - The date/time the object was last modified.
+ * Rev, LastChangedRevision - The last revision the object changed.
+ * Id - A compressed summary of the previous
+ * 4 keywords.
+ * svn:executable - If present, make the file executable. This
+ * property cannot be set on a directory. A non-recursive attempt
+ * will fail, and a recursive attempt will set the property only
+ * on the file children of the directory.
+ * svn:eol-style - One of 'native', 'LF', 'CR', 'CRLF'.
+ * svn:mime-type - The mimetype of the file. Used to determine
+ * whether to merge the file, and how to serve it from Apache.
+ * A mimetype beginning with 'text/' (or an absent mimetype) is
+ * treated as text. Anything else is treated as binary.
+ * svn:externals - A newline separated list of module specifiers,
+ * each of which consists of a relative directory path, optional
+ * revision flags, and an URL. For example
+ * foo http://example.com/repos/zig
+ * foo/bar -r 1234 http://example.com/repos/zag
+ *
+ * Valid options:
+ * -F [--file] arg : read data from file ARG
+ * -q [--quiet] : print as little as possible
+ * -r [--revision] arg : revision X or X:Y range. X or Y can be one of:
+ * {DATE} date instead of revision number
+ * "HEAD" latest in repository
+ * "BASE" base revision of item's working copy
+ * "COMMITTED" revision of item's last commit
+ * "PREV" revision before item's last commit
+ * --targets arg : pass contents of file ARG as additional args
+ * -R [--recursive] : descend recursively
+ * --revprop : operate on a revision property (use with -r)
+ * --username arg : specify a username ARG
+ * --password arg : specify a password ARG
+ * --no-auth-cache : do not cache authentication tokens
+ * --non-interactive : do no interactive prompting
+ * --encoding arg : treat value as being in charset encoding ARG
+ * --force : force operation to run
+ * --config-dir arg : read user configuration files from directory ARG
+ * </pre>
+ */
+ public void propset(
+ String propName,
+ String propValue,
+ String target,
+ boolean recurse)
+ throws CmdLineException {
+ exec(
+ CMD
+ + MessageFormat.format(
+ CMD_PROPSET,
+ new String[] { propName, propValue, target }));
+ }
+ public void propsetFile(
+ String propName,
+ String propFile,
+ String target,
+ boolean recurse)
+ throws CmdLineException {
+ exec(
+ CMD
+ + MessageFormat.format(
+ CMD_PROPSET_FILE,
+ new String[] { propName, propFile, target }));
+ }
+
+ /**
      * revert: Restore pristine working copy file (undo all local edits)
      * usage: revert PATH [PATH [PATH ... ]]
      *
@@ -666,7 +960,6 @@
 
     private Process execInternal(String cmd) {
         Runtime rt = Runtime.getRuntime();
-// System.out.println("​CommandLine:starting​ [" + cmd + "]");
 
         /* run the process */
         Process proc = null;

--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@subc​lipse.tigris.org
For additional commands, e-mail: cvs-help at subclipse dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

subclipse commit: rev 236 - trunk/svnClientAdapter/src/main/org/tigris/subversion/svnclientadapter/commandline schatz Philip Schatz 2003-10-18 12:16:18 PDT
Messages per page: