git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114246 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
dion 2003-10-28 18:18:26 +00:00
parent 00c5f1cd63
commit 72fb4e18d1

View File

@ -80,7 +80,7 @@ import org.netbeans.lib.cvsclient.event.CVSListener;
/**
* A Cvs connection that simulates a command line interface.
*
*
* @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
*/
public class CvsConnection
@ -90,37 +90,37 @@ public class CvsConnection
private static final Log LOG =
LogFactory.getLog(CvsConnection.class);
/**
* The path to the repository on the server
*/
* The path to the repository on the server
*/
private String repository;
/**
* The local path to use to perform operations (the top level)
*/
* The local path to use to perform operations (the top level)
*/
private String localPath;
/**
* The connection to the server
*/
* The connection to the server
*/
private Connection connection;
/**
* The client that manages interactions with the server
*/
* The client that manages interactions with the server
*/
private Client client;
/**
* The global options being used. GlobalOptions are only global for a
* particular command.
*/
* The global options being used. GlobalOptions are only global for a
* particular command.
*/
private GlobalOptions globalOptions;
/**
* Execute a configured CVS command
*
* @param command the command to execute
* @throws CommandException if there is an error running the command
*/
* Execute a configured CVS command
*
* @param command the command to execute
* @throws CommandException if there is an error running the command
*/
public void executeCommand(Command command)
throws CommandException, AuthenticationException
{
@ -143,8 +143,8 @@ public class CvsConnection
}
/**
* Creates the connection and the client and connects.
*/
* Creates the connection and the client and connects.
*/
private void connect(CVSRoot root, String password)
throws IllegalArgumentException, AuthenticationException
{
@ -170,11 +170,11 @@ public class CvsConnection
/**
* Obtain the CVS root, either from the -D option cvs.root or from the CVS
* directory
*
* @return the CVSRoot string
*/
* Obtain the CVS root, either from the -D option cvs.root or from the CVS
* directory
*
* @return the CVSRoot string
*/
private static String getCVSRoot(String workingDir)
{
String root = null;
@ -202,7 +202,9 @@ public class CvsConnection
try
{
if (r != null)
{
r.close();
}
}
catch (IOException e)
{
@ -217,12 +219,12 @@ public class CvsConnection
}
/**
* Process global options passed into the application
*
* @param args the argument list, complete
* @param globalOptions the global options structure that will be passed to
* the command
*/
* Process global options passed into the application
*
* @param args the argument list, complete
* @param globalOptions the global options structure that will be passed to
* the command
*/
private static int processGlobalOptions(
String[] args,
GlobalOptions globalOptions)
@ -234,7 +236,7 @@ public class CvsConnection
while ((ch = go.getopt()) != GetOpt.optEOF)
{
//System.out.println("Global option '"+((char) ch)+"',
// '"+go.optArgGet()+"'");
// '"+go.optArgGet()+"'");
boolean success =
globalOptions.setCVSCommand((char) ch, go.optArgGet());
if (!success)
@ -245,13 +247,13 @@ public class CvsConnection
}
/**
* Lookup the password in the .cvspass file. This file is looked for in the
* user.home directory if the option cvs.passfile is not set
*
* @param CVSRoot the CVS root for which the password is being searched
* @return the password, scrambled
*/
private static String lookupPassword(String CVSRoot)
* Lookup the password in the .cvspass file. This file is looked for in the
* user.home directory if the option cvs.passfile is not set
*
* @param CVSRoot the CVS root for which the password is being searched
* @return the password, scrambled
*/
private static String lookupPassword(String cvsRoot)
{
File passFile =
new File(
@ -268,9 +270,9 @@ public class CvsConnection
String line;
while ((line = reader.readLine()) != null)
{
if (line.startsWith(CVSRoot))
if (line.startsWith(cvsRoot))
{
password = line.substring(CVSRoot.length() + 1);
password = line.substring(cvsRoot.length() + 1);
break;
}
}
@ -297,20 +299,18 @@ public class CvsConnection
if (password == null)
{
LOG.error(
"Didn't find password for CVSROOT '" + CVSRoot + "'.");
"Didn't find password for CVSROOT '" + cvsRoot + "'.");
}
return password;
}
/**
* Process the CVS command passed in args[] array with all necessary
* options. The only difference from main() method is, that this method
* does not exit the JVM and provides command output.
*
* @param args The command with options
* @param files The files to execute the command on.
* @param stdout The standard output of the command
*/
* Process the CVS command passed in args[] array with all necessary
* options. The only difference from main() method is, that this method
* does not exit the JVM and provides command output.
*
* @param args The command with options
*/
public static boolean processCommand(
String[] args,
String localPath,
@ -326,10 +326,10 @@ public class CvsConnection
// Set up any global options specified. These occur before the
// name of the command to run
int commandIndex = -1;
try
{
commandIndex = processGlobalOptions(args, globalOptions);
}
catch (IllegalArgumentException e)
{
@ -418,21 +418,13 @@ public class CvsConnection
try
{
cvsCommand.connect(root, password);
cvsCommand.addListener(listener);
cvsCommand.executeCommand(c);
}
catch (Exception t)
{
LOG.error("Error: " + t,t);
return false;
}
finally
{
}
return true;
}