diff --git a/changelog/src/main/org/apache/maven/cvslib/CvsConnection.java b/changelog/src/main/org/apache/maven/cvslib/CvsConnection.java index 501be75b..5949fcf4 100644 --- a/changelog/src/main/org/apache/maven/cvslib/CvsConnection.java +++ b/changelog/src/main/org/apache/maven/cvslib/CvsConnection.java @@ -53,37 +53,37 @@ public class CvsConnection /** Log */ 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 { @@ -106,8 +106,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, CommandAbortedException { @@ -132,11 +132,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; @@ -181,12 +181,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) @@ -209,12 +209,12 @@ 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 - */ + * 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 = @@ -228,24 +228,22 @@ public class CvsConnection try { - StringBuffer cvsroot = new StringBuffer(); - reader = new BufferedReader(new FileReader(passFile)); String line; while ((line = reader.readLine()) != null) { - if (line.startsWith("/")) - { - Vector cvspass = StringUtils.split(line, ' '); - if (cvspass.size() >= 3) - { - if (compareCvsRoot(cvsRoot, (String)cvspass.get(1))) { - password = (String)cvspass.get(2); - break; - } - } - } - else if (line.startsWith(cvsRoot)) + if (line.startsWith("/")) + { + Vector cvspass = StringUtils.split(line, ' '); + if (cvspass.size() >= 3) + { + if (compareCvsRoot(cvsRoot, (String)cvspass.get(1))) { + password = (String)cvspass.get(2); + break; + } + } + } + else if (line.startsWith(cvsRoot)) { password = line.substring(cvsRoot.length() + 1); break; @@ -280,43 +278,43 @@ public class CvsConnection static boolean compareCvsRoot(String cvsRoot, String target) { - String s1 = completeCvsRootPort(cvsRoot); - String s2 = completeCvsRootPort(target); - if (s1 != null && s1.equals(s2)) - { - return true; - } - return false; - + String s1 = completeCvsRootPort(cvsRoot); + String s2 = completeCvsRootPort(target); + if (s1 != null && s1.equals(s2)) + { + return true; + } + return false; + } private static String completeCvsRootPort(String cvsRoot) { - String result = cvsRoot; - int idx = cvsRoot.indexOf(':'); - for (int i=0; i < 2 && idx != -1; i++) - { - idx = cvsRoot.indexOf(':', idx+1); - } - if (idx != -1 && cvsRoot.charAt(idx+1) == '/') - { - StringBuffer sb = new StringBuffer(); - sb.append(cvsRoot.substring(0, idx+1)); - sb.append("2401"); - sb.append(cvsRoot.substring(idx+1)); - result = sb.toString(); - } - return result; + String result = cvsRoot; + int idx = cvsRoot.indexOf(':'); + for (int i=0; i < 2 && idx != -1; i++) + { + idx = cvsRoot.indexOf(':', idx+1); + } + if (idx != -1 && cvsRoot.charAt(idx+1) == '/') + { + StringBuffer sb = new StringBuffer(); + sb.append(cvsRoot.substring(0, idx+1)); + sb.append("2401"); + sb.append(cvsRoot.substring(idx+1)); + result = sb.toString(); + } + return result; } /** - * 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 - */ + * 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,