Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > subclipse commit: r1430 - branches/svnClientAdapter/locking-improvements/src/main/org/tigris/subversion/svnclientadapter/commandline

subclipse
Discussion topic

Back to topic list

subclipse commit: r1430 - branches/svnClientAdapter/locking-improvements/src/main/org/tigris/subversion/svnclientadapter/commandline

Author dlr
Full name Daniel Rall
Date 2005-07-06 17:03:13 PDT
Message Author: dlr
Date: Wed Jul 6 19:03:06 2005
New Revision: 1430

Modified:
   branches/svnClientAd​apter/locking-improv​ements/src/main/org/​tigris/subversion/sv​nclientadapter/comma​ndline/CmdLineClient​Adapter.java
   branches/svnClientAd​apter/locking-improv​ements/src/main/org/​tigris/subversion/sv​nclientadapter/comma​ndline/CommandLine.j​ava
   branches/svnClientAd​apter/locking-improv​ements/src/main/org/​tigris/subversion/sv​nclientadapter/comma​ndline/SvnCommandLin​e.java

Log:
Lock-via-URI (rather than via File) implementation for the
command-line client adapter. Passes all svnant regression tests.


[in src/main/org/tigris/​subversion/svnclient​adapter/]

* commandline/CmdLineC​lientAdapter.java
  (lock, unlock): Reworked code to pass SVNUrl parameters through
   basically unadorned. Removed use of notificationHandler, since
   we're operating on the repository rather than on the working copy.


* commandline/SvnCommandLine.java
  (lock, unlock): Added JavaDoc, tweaked formatting.


* commandline/CommandLine.java
  (execProcess): Major refactoring. Rewrote method to do away with
   unnecessary memory allocation and looping by creating the String[]
   array representing the command-line, and used a StringBuffer
   instead of needlessly creating numerous String objects.

  (execString): Improved JavaDoc.


Modified: branches/svnClientAd​apter/locking-improv​ements/src/main/org/​tigris/subversion/sv​nclientadapter/comma​ndline/CmdLineClient​Adapter.java
Url: http://svn.collab.ne​t/viewcvs/subclipse/​branches/svnClientAd​apter/locking-improv​ements/src/main/org/​tigris/subversion/sv​nclientadapter/comma​ndline/CmdLineClient​Adapter.java?rev=143​0&p1=branches/sv​nClientAdapter/locki​ng-improvements/src/​main/org/tigris/subv​ersion/svnclientadap​ter/commandline/CmdL​ineClientAdapter.jav​a&p2=branches/sv​nClientAdapter/locki​ng-improvements/src/​main/org/tigris/subv​ersion/svnclientadap​ter/commandline/CmdL​ineClientAdapter.jav​a&r1=1429&r2​=1430
====================​====================​====================​==================
--- branches/svnClientAd​apter/locking-improv​ements/src/main/org/​tigris/subversion/sv​nclientadapter/comma​ndline/CmdLineClient​Adapter.java (original)
+++ branches/svnClientAd​apter/locking-improv​ements/src/main/org/​tigris/subversion/sv​nclientadapter/comma​ndline/CmdLineClient​Adapter.java Wed Jul 6 19:03:06 2005
@@ -1152,54 +1152,33 @@
         }
     }
     
- /* (non-Javadoc)
+ /* (non-Javadoc)
      * @see org.tigris.subversio​n.svnclientadapter.I​SVNClientAdapter#loc​k(SVNUrl[], java.lang.String, boolean)
      */
- public void lock(SVNUrl[] urls, String comment, boolean force)
- throws SVNClientException {
- String[] files = new String[urls.length];
- for (int i = 0; i < urls.length; i++) {
- files[i] = toString(urls[i]);
- }
- try {
- // ### Unsure how to handle notification system on URLs.
- //notificationHandle​r.setBaseDir(SVNUrlU​tils.getCommonRootUr​l(urls));
- _cmd.lock(files, comment, force);
+ public void lock(SVNUrl[] uris, String comment, boolean force)
+ throws SVNClientException {
+ // notificationHandler isn't used because we're operating on
+ // the repository (rather than the WC).
+ try {
+ _cmd.lock(uris, comment, force);
         } catch (CmdLineException e) {
- throw SVNClientException.w​rapException(e);
- }
- finally {
- /*
- for (int i = 0; i < files.length; i++) {
- notificationHandler.​notifyListenersOfCha​nge(files[i]);
- }
- */
+ throw SVNClientException.w​rapException(e);
         }
     }
 
     /* (non-Javadoc)
      * @see org.tigris.subversio​n.svnclientadapter.I​SVNClientAdapter#unl​ock(SVNUrl[], boolean)
      */
- public void unlock(SVNUrl[] urls, boolean force) throws SVNClientException {
- String[] files = new String[urls.length];
- for (int i = 0; i < urls.length; i++) {
- files[i] = toString(urls[i]);
- }
- try {
- // ### Unsure how to handle notification system on URLs.
- //notificationHandle​r.setBaseDir(SVNBase​Dir.getCommonRootUrl​(urls));
- _cmd.unlock(files, force);
+ public void unlock(SVNUrl[] uris, boolean force)
+ throws SVNClientException {
+ // notificationHandler isn't used because we're operating on
+ // the repository (rather than the WC).
+ try {
+ _cmd.unlock(uris, force);
         } catch (CmdLineException e) {
- throw SVNClientException.w​rapException(e);
+ throw SVNClientException.w​rapException(e);
         }
- finally {
- /*
- for (int i = 0; i < files.length; i++) {
- notificationHandler.​notifyListenersOfCha​nge(files[i]);
- }
- */
- }
- }
+ }
     
     /* (non-Javadoc)
      * @see org.tigris.subversio​n.svnclientadapter.I​SVNClientAdapter#loc​k(java.io.File[], java.lang.String, boolean)

Modified: branches/svnClientAd​apter/locking-improv​ements/src/main/org/​tigris/subversion/sv​nclientadapter/comma​ndline/CommandLine.j​ava
Url: http://svn.collab.ne​t/viewcvs/subclipse/​branches/svnClientAd​apter/locking-improv​ements/src/main/org/​tigris/subversion/sv​nclientadapter/comma​ndline/CommandLine.j​ava?rev=1430&p1=​branches/svnClientAd​apter/locking-improv​ements/src/main/org/​tigris/subversion/sv​nclientadapter/comma​ndline/CommandLine.j​ava&p2=branches/​svnClientAdapter/loc​king-improvements/sr​c/main/org/tigris/su​bversion/svnclientad​apter/commandline/Co​mmandLine.java&r​1=1429&r2=1430
====================​====================​====================​==================
--- branches/svnClientAd​apter/locking-improv​ements/src/main/org/​tigris/subversion/sv​nclientadapter/comma​ndline/CommandLine.j​ava (original)
+++ branches/svnClientAd​apter/locking-improv​ements/src/main/org/​tigris/subversion/sv​nclientadapter/comma​ndline/CommandLine.j​ava Wed Jul 6 19:03:06 2005
@@ -46,61 +46,69 @@
 
 
     /**
- * execute the given svn command and returns the corresponding process
+ * Executes the given svn command and returns the corresponding
+ * <code>Process​</code> object.
+ *
+ * @param svnArguments The command-line arguments to execute.
      */
- protected Process execProcess(ArrayList svnArguments) throws CmdLineException {
- Runtime rt = Runtime.getRuntime();
+ protected Process execProcess(ArrayList svnArguments)
+ throws CmdLineException {
+ // We add "svn" or "svnadmin" to the arguments (as
+ // appropriate), and convert it to an array of strings.
+ int svnArgsLen = svnArguments.size();
+ String[] cmdline = new String[svnArgsLen + 1];
+ cmdline[0] = CMD;
 
- String svnCommand = "";
+ StringBuffer svnCommand = new StringBuffer();
         boolean nextIsPassword = false;
- for (int i = 0; i < svnArguments.size(); i++) {
+
+ for (int i = 0; i < svnArgsLen; i++) {
             if (i != 0)
- svnCommand += " ";
+ svnCommand.append(' ');
             
- String arg = (String)svnArguments.get(i);
+ Object arg = svnArguments.get(i);
+ if (arg != null)
+ arg = arg.toString();
             
- if (arg == "") {
+ if ("".equals(arg)) {
                 arg = "\"\"";
- svnArguments.set(i, arg);
             }
             
             if (nextIsPassword) {
- svnCommand += "*******";
+ // Avoid showing the password on the console.
+ svnCommand.append("*******");
                 nextIsPassword = false;
             } else {
- svnCommand += arg;
+ svnCommand.append(arg);
             }
             
- if (arg.equals("--password")) {
- // we don't want to show the password in the console ...
+ if ("--password".equals(arg)) {
                 nextIsPassword = true;
- }
- }
- notificationHandler.​logCommandLine(svnCo​mmand);
+ }
 
- // we add "svn" or "svnadmin" to the arguments and convert it to an array of strings
- ArrayList argsArrayList = new ArrayList(svnArguments);
- argsArrayList.add(0,CMD);
- String[] argsArray = new String[argsArrayList.size()];
- argsArrayList.toArra​y(argsArray);
+ // Regardless of the data type passed in via svnArguments,
+ // at this point we expect to have a String object.
+ cmdline[i + 1] = (String) arg;
+ }
+ notificationHandler.​logCommandLine(svnCo​mmand.toString());
 
- /* run the process */
- Process proc = null;
+ // Run the command, and return the associated Process object.
         try {
- proc = rt.exec(argsArray);
+ return Runtime.getRuntime()​.exec(cmdline);
         } catch (IOException e) {
             throw new CmdLineException(e);
         }
-
- return proc;
     }
 
     /**
- * runs the process and returns the results.
- * @param cmd
- * @return String
+ * Runs the process and returns the results.
+ *
+ * @param svnArguments The command-line arguments to execute.
+ * @param coalesceLines
+ * @return Any output returned from execution of the command-line.
      */
- protected String execString(ArrayList svnArguments, boolean coalesceLines) throws CmdLineException {
+ protected String execString(ArrayList svnArguments, boolean coalesceLines)
+ throws CmdLineException {
         Process proc = execProcess(svnArguments);
 
         CmdLineStreamPumper outPumper = new CmdLineStreamPumper(​proc.getInputStream(​),coalesceLines);

Modified: branches/svnClientAd​apter/locking-improv​ements/src/main/org/​tigris/subversion/sv​nclientadapter/comma​ndline/SvnCommandLin​e.java
Url: http://svn.collab.ne​t/viewcvs/subclipse/​branches/svnClientAd​apter/locking-improv​ements/src/main/org/​tigris/subversion/sv​nclientadapter/comma​ndline/SvnCommandLin​e.java?rev=1430&​p1=branches/svnClien​tAdapter/locking-imp​rovements/src/main/o​rg/tigris/subversion​/svnclientadapter/co​mmandline/SvnCommand​Line.java&p2=bra​nches/svnClientAdapt​er/locking-improveme​nts/src/main/org/tig​ris/subversion/svncl​ientadapter/commandl​ine/SvnCommandLine.j​ava&r1=1429&​r2=1430
====================​====================​====================​==================
--- branches/svnClientAd​apter/locking-improv​ements/src/main/org/​tigris/subversion/sv​nclientadapter/comma​ndline/SvnCommandLin​e.java (original)
+++ branches/svnClientAd​apter/locking-improv​ements/src/main/org/​tigris/subversion/sv​nclientadapter/comma​ndline/SvnCommandLin​e.java Wed Jul 6 19:03:06 2005
@@ -860,7 +860,14 @@
         execVoid(args);
     }
 
- String lock(String[] path, String comment, boolean force) throws CmdLineException {
+ /**
+ * @param paths Represents either WC paths, or repository URIs.
+ * @param comment The comment to use for the lock operation.
+ * @param force Whether to include <code>--force​</code> in the
+ * command-line.
+ */
+ String lock(Object[] paths, String comment, boolean force)
+ throws CmdLineException {
         setCommand(ISVNNotif​yListener.Command.LO​CK, true);
         ArrayList args = new ArrayList();
         args.add("lock");
@@ -873,14 +880,20 @@
         addAuthInfo(args);
         addConfigInfo(args);
                 
- for (int i = 0; i < path.length;i++) {
- args.add(path[i]);
+ for (int i = 0; i < paths.length; i++) {
+ args.add(paths[i]);
         }
         
- return execString(args,false);
+ return execString(args, false);
     }
 
- String unlock(String[] path, boolean force) throws CmdLineException {
+ /**
+ * @param paths Represents either WC paths, or repository URIs.
+ * @param comment The comment to use for the lock operation.
+ * @param force Whether to include <code>--force​</code> in the
+ * command-line.
+ */
+ String unlock(Object[] paths, boolean force) throws CmdLineException {
         setCommand(ISVNNotif​yListener.Command.UN​LOCK, true);
         ArrayList args = new ArrayList();
         args.add("unlock");
@@ -889,8 +902,8 @@
         addAuthInfo(args);
         addConfigInfo(args);
                 
- for (int i = 0; i < path.length;i++) {
- args.add(path[i]);
+ for (int i = 0; i < paths.length;i++) {
+ args.add(paths[i]);
         }
         
         return execString(args,false);

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

Messages

Show all messages in topic

subclipse commit: r1430 - branches/svnClientAdapter/locking-improvements/src/main/org/tigris/subversion/svnclientadapter/commandline dlr Daniel Rall 2005-07-06 17:03:13 PDT
Messages per page: