netbeans-cvsclient_6.5/0000755000175300001440000000000011175434272014130 5ustar ludousersnetbeans-cvsclient_6.5/build.xml0000644000175300001440000000417011175406776015763 0ustar ludousers netbeans-cvsclient_6.5/manifest.mf0000644000175300001440000000042711175416503016262 0ustar ludousersManifest-Version: 1.0 OpenIDE-Module: org.netbeans.lib.cvsclient/1 OpenIDE-Module-Localizing-Bundle: org/netbeans/lib/cvsclient/Bundle.properties OpenIDE-Module-Specification-Version: 1.17 Specification-Version: 1.9 Main-Class: org.netbeans.lib.cvsclient.commandLine.CVSCommand netbeans-cvsclient_6.5/nbproject/0000755000175300001440000000000011175434236016116 5ustar ludousersnetbeans-cvsclient_6.5/nbproject/project.xml0000644000175300001440000001105111175406776020314 0ustar ludousers org.netbeans.modules.apisupport.project org.netbeans.lib.cvsclient org.netbeans.lib.cvsclient org.netbeans.lib.cvsclient.admin org.netbeans.lib.cvsclient.command org.netbeans.lib.cvsclient.command.add org.netbeans.lib.cvsclient.command.annotate org.netbeans.lib.cvsclient.command.checkout org.netbeans.lib.cvsclient.command.commit org.netbeans.lib.cvsclient.command.diff org.netbeans.lib.cvsclient.command.edit org.netbeans.lib.cvsclient.command.editors org.netbeans.lib.cvsclient.command.export org.netbeans.lib.cvsclient.command.history org.netbeans.lib.cvsclient.command.importcmd org.netbeans.lib.cvsclient.command.log org.netbeans.lib.cvsclient.command.remove org.netbeans.lib.cvsclient.command.status org.netbeans.lib.cvsclient.command.tag org.netbeans.lib.cvsclient.command.unedit org.netbeans.lib.cvsclient.command.update org.netbeans.lib.cvsclient.command.watch org.netbeans.lib.cvsclient.command.watchers org.netbeans.lib.cvsclient.commandLine org.netbeans.lib.cvsclient.commandLine.command org.netbeans.lib.cvsclient.connection org.netbeans.lib.cvsclient.event org.netbeans.lib.cvsclient.file org.netbeans.lib.cvsclient.request org.netbeans.lib.cvsclient.response org.netbeans.lib.cvsclient.util netbeans-cvsclient_6.5/nbproject/project.properties0000644000175300001440000000436611175416503021710 0ustar ludousers# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # # Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. # # The contents of this file are subject to the terms of either the GNU # General Public License Version 2 only ("GPL") or the Common # Development and Distribution License("CDDL") (collectively, the # "License"). You may not use this file except in compliance with the # License. You can obtain a copy of the License at # http://www.netbeans.org/cddl-gplv2.html # or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the # specific language governing permissions and limitations under the # License. When distributing the software, include this License Header # Notice in each file and include the License file at # nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this # particular file as subject to the "Classpath" exception as provided # by Sun in the GPL Version 2 section of the License file that # accompanied this code. If applicable, add the following below the # License Header, with the fields enclosed by brackets [] replaced by # your own identifying information: # "Portions Copyrighted [year] [name of copyright owner]" # # Contributor(s): # # The Original Software is NetBeans. The Initial Developer of the Original # Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun # Microsystems, Inc. All Rights Reserved. # # If you wish your version of this file to be governed by only the CDDL # or only the GPL Version 2, indicate your decision by adding # "[Contributor] elects to include this software in this distribution # under the [CDDL or GPL Version 2] license." If you do not indicate a # single choice of license, a recipient has the option to distribute # your version of this file under either the CDDL, the GPL Version 2 or # to extend the choice of license to its licensees as provided above. # However, if you add GPL Version 2 code and therefore, elected the GPL # Version 2 license, then the option applies only if the new code is # made subject to such option by the copyright holder. is.autoload=true #javadoc.apichanges=${basedir}/api/doc/changes/apichanges.xml #javadoc.arch=${basedir}/arch/arch-javacvs.xml test-unit-sys-prop.test.junit.jar=${junit.dir}/modules/ext/junit-3.8.1.jar disable.qa-functional.tests=true netbeans-cvsclient_6.5/src/0000755000175300001440000000000011175434236014717 5ustar ludousersnetbeans-cvsclient_6.5/src/org/0000755000175300001440000000000011175434236015506 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/0000755000175300001440000000000011175434236017305 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/0000755000175300001440000000000011175434236020053 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/0000755000175300001440000000000011175434236022045 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/Bundle.properties0000644000175300001440000000473011175406776025410 0ustar ludousers# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # # Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. # # The contents of this file are subject to the terms of either the GNU # General Public License Version 2 only ("GPL") or the Common # Development and Distribution License("CDDL") (collectively, the # "License"). You may not use this file except in compliance with the # License. You can obtain a copy of the License at # http://www.netbeans.org/cddl-gplv2.html # or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the # specific language governing permissions and limitations under the # License. When distributing the software, include this License Header # Notice in each file and include the License file at # nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this # particular file as subject to the "Classpath" exception as provided # by Sun in the GPL Version 2 section of the License file that # accompanied this code. If applicable, add the following below the # License Header, with the fields enclosed by brackets [] replaced by # your own identifying information: # "Portions Copyrighted [year] [name of copyright owner]" # # Contributor(s): # # The Original Software is NetBeans. The Initial Developer of the Original # Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun # Microsystems, Inc. All Rights Reserved. # # If you wish your version of this file to be governed by only the CDDL # or only the GPL Version 2, indicate your decision by adding # "[Contributor] elects to include this software in this distribution # under the [CDDL or GPL Version 2] license." If you do not indicate a # single choice of license, a recipient has the option to distribute # your version of this file under either the CDDL, the GPL Version 2 or # to extend the choice of license to its licensees as provided above. # However, if you add GPL Version 2 code and therefore, elected the GPL # Version 2 license, then the option applies only if the new code is # made subject to such option by the copyright holder. #-------------------------------------------------------------------- # ResourceBundle properties file OpenIDE-Module-Name=CVS Client Library OpenIDE-Module-Short-Description=A CVS client library, that substitutes the client side of the native CVS executable. OpenIDE-Module-Long-Description=The CVS Client Library module implements the client side of CVS server connection. Local connections are not supported. OpenIDE-Module-Display-Category=Version Control netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/CVSRoot.java0000644000175300001440000006354211175406776024231 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Rami Ojares. Portions created by Rami Ojares are Copyright (C) 2003. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Rami Ojares */ package org.netbeans.lib.cvsclient; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.connection.Connection; import org.netbeans.lib.cvsclient.connection.ConnectionFactory; /**

CVSRoot represents the cvsroot that identifies the cvs repository's location and the means to get to it. We use following definition of cvsroot:

[:method:][[user][:password]@][hostname[:[port]]]/path/to/repository

When the method is not defined, we treat it as local or ext method depending on whether the hostname is present or not. This gives us two different formats:

1. Local format

[:method:]/path/to/repository or (:local:|:fork:)anything

2. Server format

[:method:][[user][:password]@]hostname[:[port]]/path/to/repository

There are currently 6 different methods that are implemented by 3 different connection classes.

* Note that in the case where the Entries file does not exist, it * is simply created and the entry appended immediately. * This all ensures that if a failure occurs at any stage, the original * Entries file can be retrieved * @param originalFile the original Entries file, which need not exist yet * @param entry the specific entry to update * @throws IOException if an error occurs writing the files */ private void updateEntriesFile(File originalFile, Entry entry) throws IOException { synchronized (ksEntries) { final File directory = originalFile.getParentFile(); final File tempFile = new File(directory, "Entries.Backup"); //NOI18N tempFile.createNewFile(); BufferedReader reader = null; BufferedWriter writer = null; try { reader = new BufferedReader(new FileReader(originalFile)); writer = new BufferedWriter(new FileWriter(tempFile)); String line; // indicates whether we have written the entry that was passed in // if we finish copying the file without writing it, then it is // a new entry and must simply be append at the end boolean written = false; while ((line = reader.readLine()) != null) { final Entry currentEntry = new Entry(line); if ((currentEntry.getName() != null) && currentEntry.getName().equals(entry.getName())) { writer.write(entry.toString()); written = true; } else { writer.write(line); } writer.newLine(); } if (!written) { writer.write(entry.toString()); writer.newLine(); } } finally { try { if (writer != null) { writer.close(); } } finally { if (reader != null) { reader.close(); } } } if (t9yBeforeRename != null) t9yBeforeRename.run(); FileUtils.renameFile(tempFile, originalFile); } } /** * Get the Entry for the specified file, if one exists * @param f the file * @throws IOException if the Entries file cannot be read */ public Entry getEntry(File file) throws IOException { final File entriesFile = seekEntries(file.getParentFile()); //NOI18N // if there is no Entries file we cannot very well get any Entry // from it if (entriesFile == null) { return null; } processEntriesDotLog(new File(file.getParent(), "CVS")); //NOI18N BufferedReader reader = null; Entry entry = null; boolean found = false; try { reader = new BufferedReader(new FileReader(entriesFile)); String line; while (!found && ((line = reader.readLine()) != null)) { entry = new Entry(line); // can have a name of null in the case of the single // D entry line spec, indicating no subdirectories if (entry.getName() != null) { // file equality and string equality are not the same thing File entryFile = new File(file.getParentFile(), entry.getName()); found = entryFile.equals(file); } } } finally { if (reader != null) { reader.close(); } } if (!found) { return null; } return entry; } /** * Get the entries for a specified directory. * @param directory the directory for which to get the entries * @return an array of Entry objects */ public Entry[] getEntriesAsArray(File directory) throws IOException { List entries = new LinkedList(); final File entriesFile = seekEntries(directory); // if there is no Entries file we just return the empty iterator if (entriesFile == null) { return new Entry[0]; } processEntriesDotLog(new File(directory, "CVS")); //NOI18N BufferedReader reader = null; Entry entry = null; try { reader = new BufferedReader(new FileReader(entriesFile)); String line; while ((line = reader.readLine()) != null) { entry = new Entry(line); // can have a name of null in the case of the single // D entry line spec, indicating no subdirectories if (entry.getName() != null) { entries.add(entry); } } } finally { if (reader != null) { reader.close(); } } Entry[] toReturnArray = new Entry[entries.size()]; toReturnArray = (Entry[])entries.toArray(toReturnArray); return toReturnArray; } /** * Get the entries for a specified directory. * @param directory the directory for which to get the entries (CVS/Entries is appended) * @return an iterator of Entry objects */ public Iterator getEntries(File directory) throws IOException { List entries = new LinkedList(); final File entriesFile = seekEntries(directory); // if there is no Entries file we just return the empty iterator if (entriesFile == null) { return entries.iterator(); } processEntriesDotLog(new File(directory, "CVS")); //NOI18N BufferedReader reader = null; Entry entry = null; try { reader = new BufferedReader(new FileReader(entriesFile)); String line; while ((line = reader.readLine()) != null) { entry = new Entry(line); // can have a name of null in the case of the single // D entry line spec, indicating no subdirectories if (entry.getName() != null) { entries.add(entry); } } } finally { if (reader != null) { reader.close(); } } return entries.iterator(); } /** * Set the Entry for the specified file * @param f the file whose entry is being updated * @throws IOException if an error occurs writing the details */ public void setEntry(File file, Entry entry) throws IOException { String parent = file.getParent(); File entriesFile = seekEntries(parent); if (entriesFile == null) { entriesFile = new File(parent, "CVS/Entries"); //NOI18N } processEntriesDotLog(new File(parent, "CVS")); //NOI18N updateEntriesFile(entriesFile, entry); } /** * Remove the Entry for the specified file * @param f the file whose entry is to be removed * @throws IOException if an error occurs writing the Entries file */ public void removeEntry(File file) throws IOException { synchronized (ksEntries) { final File entriesFile = seekEntries(file.getParent()); // if there is no Entries file we cannot very well remove an Entry // from it if (entriesFile == null) { return; } processEntriesDotLog(new File(file.getParent(), "CVS")); //NOI18N final File directory = file.getParentFile(); final File tempFile = new File(directory, "Entries.Backup"); //NOI18N tempFile.createNewFile(); BufferedReader reader = null; BufferedWriter writer = null; try { reader = new BufferedReader(new FileReader(entriesFile)); writer = new BufferedWriter(new FileWriter(tempFile)); String line; // allows us to determine whether we need to put in a "D" line. We do // that if we remove the last directory from the Entries file boolean directoriesExist = false; while ((line = reader.readLine()) != null) { final Entry currentEntry = new Entry(line); if ((currentEntry.getName() != null) && !currentEntry.getName().equals(file.getName())) { writer.write(currentEntry.toString()); writer.newLine(); directoriesExist = directoriesExist || currentEntry.isDirectory(); } } if (!directoriesExist) { writer.write("D"); //NOI18N writer.newLine(); } } finally { try { if (writer != null) { writer.close(); } } finally { if (reader != null) { reader.close(); } } } if (t9yBeforeRename != null) t9yBeforeRename.run(); FileUtils.renameFile(tempFile, entriesFile); } } /** * Get the repository path for a given directory, for example in * the directory /home/project/foo/bar, the repository directory * might be /usr/cvs/foo/bar. The repository directory is commonly * stored in the file
Repository
in the CVS directory on * the client. (This is the case in the standard CVS command-line tool). * However, the path stored in that file is relative to the repository * path * @param directory the directory * @param the repository path on the server, e.g. /home/bob/cvs. Must not * end with a slash. */ public String getRepositoryForDirectory(String directory, String repository) throws IOException { // if there is no "CVS/Repository" file, try to search up the file- // hierarchy File repositoryFile = null; String repositoryDirs = ""; //NOI18N File dirFile = new File(directory); while (true) { // if there is no Repository file we cannot very well get any // repository from it if (dirFile == null || dirFile.getName().length() == 0 || !dirFile.exists()) { throw new FileNotFoundException("Repository file not found " + //NOI18N "for directory " + directory); //NOI18N } repositoryFile = new File(dirFile, "CVS/Repository"); //NOI18N if (repositoryFile.exists()) { break; } repositoryDirs = '/' + dirFile.getName() + repositoryDirs; dirFile = dirFile.getParentFile(); } BufferedReader reader = null; // fileRepository is the value of the repository read from the // Repository file String fileRepository = null; try { reader = new BufferedReader(new FileReader(repositoryFile)); fileRepository = reader.readLine(); } finally { if (reader != null) { reader.close(); } } if (fileRepository == null) { fileRepository = ""; //NOI18N } fileRepository += repositoryDirs; // absolute repository path ? if (fileRepository.startsWith("/")) { //NOI18N return fileRepository; } // #69795 'normalize' repository path if (fileRepository.startsWith("./")) { // NOI18N fileRepository = fileRepository.substring(2); } // otherwise the cvs is using relative repository path // must be a forward slash, regardless of the local filing system return repository + '/' + fileRepository; } /** * Update the Entries file using information in the Entries.Log file * (if present). If Entries.Log is not present, this method does * nothing. * @param directory the directory that contains the Entries file * @throws IOException if an error occurs reading or writing the files */ private void processEntriesDotLog(File directory) throws IOException { synchronized (ksEntries) { final File entriesDotLogFile = new File(directory, "Entries.Log"); //NOI18N if (!entriesDotLogFile.exists()) { return; } BufferedReader reader = new BufferedReader(new FileReader( entriesDotLogFile)); // make up a list of changes to be made based on what is in // the .log file. Then apply them all later List additionsList = new LinkedList(); HashSet removalSet = new HashSet(); String line; try { while ((line = reader.readLine()) != null) { if (line.startsWith("A ")) { //NOI18N final Entry entry = new Entry(line.substring(2)); additionsList.add(entry); } else if (line.startsWith("R ")) { //NOI18N final Entry entry = new Entry(line.substring(2)); removalSet.add(entry.getName()); } // otherwise ignore the line since we don't understand it } } finally { reader.close(); } if ((additionsList.size() > 0) || (removalSet.size() > 0)) { final File backup = new File(directory, "Entries.Backup"); //NOI18N final BufferedWriter writer = new BufferedWriter(new FileWriter( backup)); final File entriesFile = new File(directory, "Entries"); //NOI18N reader = new BufferedReader(new FileReader(entriesFile)); try { // maintain a count of the number of directories so that // we know whether to write the "D" line int directoryCount = 0; while ((line = reader.readLine()) != null) { // we will write out the directory "understanding" line // later, if necessary if (line.trim().equals("D")) { //NOI18N continue; } final Entry entry = new Entry(line); if (entry.isDirectory()) { directoryCount++; } if (!removalSet.contains(entry.getName())) { writer.write(entry.toString()); writer.newLine(); if (entry.isDirectory()) { directoryCount--; } } } Iterator it = additionsList.iterator(); while (it.hasNext()) { final Entry entry = (Entry)it.next(); if (entry.isDirectory()) { directoryCount++; } writer.write(entry.toString()); writer.newLine(); } if (directoryCount == 0) { writer.write("D"); //NOI18N writer.newLine(); } } finally { try { reader.close(); } finally { writer.close(); } } if (t9yBeforeRename != null) t9yBeforeRename.run(); FileUtils.renameFile(backup, entriesFile); } entriesDotLogFile.delete(); } } /** * Get all the files contained within a given * directory that are known to CVS. * @param directory the directory to look in * @return a set of all files. */ public Set getAllFiles(File directory) throws IOException { TreeSet fileSet = new TreeSet(); BufferedReader reader = null; try { final File entriesFile = seekEntries(directory); //NOI18N // if for any reason we don't have an Entries file just return // with the empty set. if (entriesFile == null) { return fileSet; // Premature return } reader = new BufferedReader(new FileReader(entriesFile)); String line; while ((line = reader.readLine()) != null) { final Entry entry = new Entry(line); if (entry.getName() != null) { final File f = new File(directory, entry.getName()); if (f.isFile()) { fileSet.add(f); } } } } finally { if (reader != null) { reader.close(); } } return fileSet; } // XXX where is pairing setStickyTagForDirectory? /** * Checks for presence of CVS/Tag file and returns it's value. * @return the value of CVS/Tag file for the specified directory * null if file doesn't exist */ public String getStickyTagForDirectory(File directory) { BufferedReader reader = null; File tagFile = new File(directory, "CVS/Tag"); //NOI18N try { reader = new BufferedReader(new FileReader(tagFile)); String tag = reader.readLine(); return tag; } catch (IOException ex) { // silently ignore?? } finally { if (reader != null) { try { reader.close(); } catch (IOException ex) { // silently ignore } } } return null; } /** * If Entries do not exist restore them from backup. * * @param folder path where to seek CVS/Entries * @return CVS/Entries file or null */ private static File seekEntries(File folder) { synchronized(ksEntries) { File entries = new File(folder, "CVS/Entries"); // NOI18N if (entries.exists()) { return entries; } else { File backup = new File(folder, "CVS/Entries.Backup"); // NOI18N if (backup.exists()) { try { if (t9yBeforeRename != null) t9yBeforeRename.run(); FileUtils.renameFile(backup, entries); return entries; } catch (IOException e) { // ignore } } } return null; } } private static File seekEntries(String folder) { return seekEntries(new File(folder)); } static void t9yBeforeRenameSync(Runnable run) { t9yBeforeRename = run; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/admin/Entry.java0000644000175300001440000004503511175416504025106 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.admin; import java.text.*; import java.util.*; /** * The class abstracts the CVS concept of an entry line. The entry * line is textually of the form:

* / name / version / conflict / options / tag_or_date *

These are explained in section 5.1 of the CVS protocol 1.10 document. * @author Robert Greig */ public final class Entry { /** * The dummy timestamp set the conflict information for added or removed * files. */ public static final String DUMMY_TIMESTAMP = "dummy timestamp"; //NOI18N public static final String DUMMY_TIMESTAMP_NEW_ENTRY = "dummy timestamp from new-entry"; //NOI18N public static final String MERGE_TIMESTAMP = "Result of merge"; //NOI18N /** * Indicates a sticky tag. */ private static final String TAG = "T"; //NOI18N /** * Indicates a sticky date. */ private static final String DATE = "D"; //NOI18N /** * The instance of the date formatter for sticky dates. */ private static SimpleDateFormat stickyDateFormatter; /** * Returns the instance of the date formatter for sticky dates. */ private static SimpleDateFormat getStickyDateFormatter() { if (stickyDateFormatter == null) { stickyDateFormatter = new SimpleDateFormat("yyyy.MM.dd.hh.mm.ss"); //NOI18N } return stickyDateFormatter; } /** * Indicates a binary file. */ private static final String BINARY_FILE = "-kb"; //NOI18N /** * Indicates that no user file is meant by the version details */ private static final String NO_USER_FILE = ""; //NOI18N /** * Indicates that a new user file is meant by the version details */ private static final String NEW_USER_FILE = "0"; //NOI18N /** * Indicates that the file is to be removed, in the version details */ private static final String REMOVE_USER_FILE = "-"; //NOI18N /** * Returns the instance of the Last-Modified-Date-Formatter. */ public static SimpleDateFormat getLastModifiedDateFormatter() { SimpleDateFormat df = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy", Locale.US); //NOI18N df.setTimeZone(getTimeZone()); return df; } /** * All entries times are by defaulf in Zulu/GMT0 */ public static TimeZone getTimeZone() { return TimeZone.getTimeZone("GMT"); //NOI18N } /** * Indicates that the file had conflicts. */ public static final char HAD_CONFLICTS = '+'; /** * Indicates that the timestamp matches the file. */ public static final char TIMESTAMP_MATCHES_FILE = '='; /** * Indicates that the file had conflicts and timestamp matches. * It likely means unresolved conflict. */ public static final String HAD_CONFLICTS_AND_TIMESTAMP_MATCHES_FILE = "+="; /** * Initial letter that indicates a directory entry. */ private static final String DIRECTORY_PREFIX = "D/"; /** * The name of the file. */ private String name; /** * The revision. There are constants defined for no user file, new user * file and user file has to be removed. */ private String revision; /** * The conflict information. There are constants defined for indicating * that conflicts occurred and that the timestamp matches the file */ private String conflict; /** * The last modified date of the file. */ private Date lastModified; /** * The options for signifying keyword expansion. */ private String options; /** * The tag. May be present in place of the date information. */ private String tag; /** * The date. May be present in place of the tag information. */ private Date date; /** * Indicates whether the entry is for a directory. */ private boolean directory; /** * Construct a new Entry from a given entry line. */ public Entry(String entryLine) { init(entryLine); } /** * Construct a new blank Entry. */ public Entry() { } /** * Initialise the Entry by parsing an entry line. * @param entryLine the entry line in standard CVS format */ protected void init(String entryLine) { //System.err.println("Constructing an entry line from: " + entryLine); // try to parse the entry line, if we get stuck just // throw an illegal argument exception if (entryLine.startsWith(DIRECTORY_PREFIX)) { directory = true; entryLine = entryLine.substring(1); } // first character is a slash, so name is read from position 1 // up to the next slash final int[] slashPositions = new int[5]; try { slashPositions[0] = 0; for (int i = 1; i < 5; i++) { slashPositions[i] = entryLine.indexOf('/', slashPositions[i - 1] + 1); } // Test if this is a D on its own, a special case indicating that // directories are understood and there are no subdirectories // in the current folder if (slashPositions[1] > 0) { // note that the parameters to substring are treated as follows: // (inclusive, exclusive) name = entryLine.substring(slashPositions[0] + 1, slashPositions[1]); revision = entryLine.substring(slashPositions[1] + 1, slashPositions[2]); if ((slashPositions[3] - slashPositions[2]) > 1) { String conflict = entryLine.substring(slashPositions[2] + 1, slashPositions[3]); setConflict(conflict); } if ((slashPositions[4] - slashPositions[3]) > 1) { options = entryLine.substring(slashPositions[3] + 1, slashPositions[4]); } if (slashPositions[4] != (entryLine.length() - 1)) { String tagOrDate = entryLine.substring(slashPositions[4] + 1); if (tagOrDate.startsWith(TAG)) { setTag(tagOrDate.substring(1)); } else if (tagOrDate.startsWith(DATE)) { //TODO process date into something useful // MK - I didn't notice any time conversions (according to timezone) // So I just convert it from String to Date and back. try { String dateString = tagOrDate.substring(DATE.length()); Date stickyDate = getStickyDateFormatter(). parse(dateString); setDate(stickyDate); } catch (ParseException exc) { System.err.println("We got another inconsistency in the library's date formatting."); //NOI18N } } } } } catch (Exception e) { System.err.println("Error parsing entry line: " + e); //NOI18N e.printStackTrace(); throw new IllegalArgumentException("Invalid entry line: " + //NOI18N entryLine); } } /** * Get the name of the associated file. * @return the file name */ public String getName() { return name; } /** * Set the name. * @param theName the filename to set */ public void setName(String name) { this.name = name; } /** * Get the revision. * @return the revision */ public String getRevision() { return revision; } /** * Set the revision. * @param theVersion the revision to set */ public void setRevision(String revision) { this.revision = revision; } /** * Get the last modification time. * * @return date.getTime() compatible with File.lastModified() */ public Date getLastModified() { return lastModified; } /** * Get the conflict information. * @return the conflict String */ public String getConflict() { return conflict; } /** * Set the conflict information. * @param theConflict the conflict information */ public void setConflict(String conflict) { this.conflict = conflict; this.lastModified = null; if (conflict == null || conflict.equals(DUMMY_TIMESTAMP) || conflict.equals(MERGE_TIMESTAMP) || conflict.equals(DUMMY_TIMESTAMP_NEW_ENTRY)) { return; } String dateString = conflict; // Look for the position of + which indicates a conflict int conflictIndex = dateString.indexOf(HAD_CONFLICTS); if (conflictIndex >= 0) { // if the timestamp matches the file, there will be an = following // the + int timeMatchIndex = dateString.indexOf(TIMESTAMP_MATCHES_FILE); conflictIndex = Math.max(conflictIndex, timeMatchIndex); } // At this point the conflict index tells us where the real conflict // string starts if (conflictIndex >= 0) { dateString = dateString.substring(conflictIndex + 1); } // if we have nothing after the = then don't try to parse it if (dateString.length() == 0) { return; } try { this.lastModified = getLastModifiedDateFormatter().parse(dateString); } catch (Exception ex) { lastModified = null; // System.err.println("[Entry] can't parse " + dateString); //NOI18N } } /** * Get the options information. * @return the options details */ public String getOptions() { return options; } /** * Set the options information. * @param theOptions the options */ public void setOptions(String options) { this.options = options; } /** * Get the sticky information. * It's either a tag, a date or null. */ public String getStickyInformation() { if (tag != null) { return tag; } return getDateFormatted(); } /** * Get the sticky tag information. * May return null if no tag information was present. If so, you should * check for date information. Note that tag and date information cannot * both be present. * @return the tag, or null if none is present */ public String getTag() { return tag; } /** * Set the sticky tag information. * Setting this will remove any date information that is set. * @param theTag the tag information */ public void setTag(String tag) { this.tag = tag; date = null; } /** * Get sticky date information. * May return null if no date information is available. If so, you should * check for tag informaton. Note that tag and date information cannot both * be present. * @return the date, or null if none is present */ public Date getDate() { return date; } /** * Gets the sticky date information as a string in the appropriate format. * Returns null if there ain't a sticky date assigned. */ public String getDateFormatted() { if (getDate() == null) { return null; } SimpleDateFormat format = getStickyDateFormatter(); String dateFormatted = format.format(getDate()); return dateFormatted; } /** * Set the sticky date information. * Note that setting this will remove any tag information that is currently set. * @param theDate the date to use. */ public void setDate(Date date) { this.date = date; tag = null; } /** * Determines whether the entry has a date (as opposed to a tag). * @return true if the entry has a date, false otherwise */ public boolean hasDate() { return (date != null); } /** * Determines whether the entry has a tag (as opposed to a date). * @return true if the entry has a tag, false otherwise */ public boolean hasTag() { return (tag != null); } /** * Determines whether the file is a binary file. */ public boolean isBinary() { return options != null && options.equals(BINARY_FILE); } /** * Determine whether there is no user file of that name. * @return true if there is no user file of that name */ public boolean isNoUserFile() { return revision == null || revision.equals(NO_USER_FILE); } /** * Determine whether there is a new user file of that name. * @return true if there is a new user file with that name */ public boolean isNewUserFile() { return revision != null && revision.startsWith(NEW_USER_FILE); } /** * Determine whether the user file of that name is to be removed. * @return true if the user file with this name is to be removed */ public boolean isUserFileToBeRemoved() { return revision != null && revision.startsWith(REMOVE_USER_FILE); } /** * Determines whether the entry is valid. * A valid entry has at least a name. */ public boolean isValid() { return getName() != null && getName().length() > 0; } /** * Determine whether the entry refers to a directory. */ public boolean isDirectory() { return directory; } /** * Set whether the entry refers to a directory. */ public void setDirectory(boolean directory) { this.directory = directory; } /** * Determine whether there were any conflicts. * @return true if there were conflicts, false otherwise */ public boolean hadConflicts() { if (conflict != null) { return conflict.indexOf(HAD_CONFLICTS) >= 0; } else { return false; } } /** * Determine whether the timestamp matches the file. * @return true if the timpestamp does match the file, false otherwise */ public boolean timestampMatchesFile() { return (conflict.charAt(1) == TIMESTAMP_MATCHES_FILE); } /** * Create a string representation of the entry line. * Create the standard CVS 1.10 entry line format. *

* Th eline format is suitable for writing into CVS/Entries file. * Conflict one must be transformed before sending to wire * {@link org.netbeans.lib.cvsclient.command.BasicCommand#sendEntryAndModifiedRequests}. */ public String toString() { StringBuffer buf = new StringBuffer(); if (directory) { buf.append(DIRECTORY_PREFIX); } else { buf.append('/'); } // if name is null, then this is a totally empty entry, so append // nothing further if (name != null) { buf.append(name); buf.append('/'); if (revision != null) { buf.append(revision); } buf.append('/'); if (conflict != null) { buf.append(conflict); } buf.append('/'); if (options != null) { buf.append(options); } buf.append('/'); // TODO: put in tag_or_date section!!! // MK - Added. Based on assumption "There can be only one" if (tag != null && date == null) { if ("HEAD".equals(tag) == false) { buf.append(TAG); buf.append(getTag()); } } else if (tag == null && date != null) { String dateString = getDateFormatted(); buf.append(DATE); buf.append(dateString); } } return buf.toString(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/0000755000175300001440000000000011175434236023463 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/BasicCommand.java0000644000175300001440000005204211175406776026661 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.command; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.admin.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * A class that provides common functionality for many of the CVS command * that send similar sequences of requests. * @author Robert Greig */ public abstract class BasicCommand extends BuildableCommand { /** * The requests that are sent and processed. */ protected List requests = new LinkedList(); /** * The client services that are provided to this command. */ protected ClientServices clientServices; /** * Whether to update recursively. */ private boolean recursive = true; /** * The files and/or directories to operate on. */ protected File[] files; /** * Gets the value of the recursive option. * @return true if recursive, false if not * @deprecated use isRecursive instead */ public boolean getRecursive() { return recursive; } /** * Gets the value of the recursive option. * @return true if recursive, false if not */ public boolean isRecursive() { return recursive; } /** * Sets the value of the recursive option. * @param recursive true if the command should recurse, false otherwise */ public void setRecursive(boolean recursive) { this.recursive = recursive; } /** * Set the files and/or directories on which to execute the command. * The way these are processed is:

*

* @param theFiles the files to operate on. May be null to indicate that the * local directory specified in the client should be used. Full, absolute * canonical pathnames must be supplied. */ public void setFiles(File[] theFiles) { // sort array.. files first, directories follow if (theFiles == null) { files = theFiles; return; } // assert theFiles.length > 0 : "Empty array causes random AIOOBEs!"; // ClientRuntime.java:119 files = new File[theFiles.length]; int fileCount = 0; int dirCount = 0; int totalCount = theFiles.length; for (int index = 0; index < totalCount; index++) { File currentFile = theFiles[index]; if (currentFile.isDirectory()) { files[totalCount - (1 + dirCount)] = currentFile; dirCount = dirCount + 1; } else { files[fileCount] = currentFile; fileCount = fileCount + 1; } } } /** * Get the files and/or directories specified for this command to operate * on. * @return the array of Files */ public File[] getFiles() { return files; } /** * Get a single file from the "files" list. returns only files, not directories. * This method is used from within the builders, because for single file requests, the * cvs server doesn't return us enough information to identify what file has been returned. * Thus we sort the "files" array (files come before directories. Then the response froms erver comes in the same order * and the files can be found this way. * * @param index the index of the file in the list. */ public File getXthFile(int index) { if (index < 0 || index >= files.length) { return null; } File file = files[index]; if (!file.isFile()) { return null; } return file; } /** * @param ending - the ending part of the file's pathname.. path separator is cvs's default '/' */ public File getFileEndingWith(String ending) { String locEnding = ending.replace('\\', '/'); String localDir = getLocalDirectory().replace('\\','/'); int index = 0; for (index = 0; index < files.length; index++) { String path = files[index].getAbsolutePath(); String parentPath = files[index].getParentFile().getAbsolutePath().replace('\\', '/'); path = path.replace('\\', '/'); if ((path.endsWith(locEnding) && locEnding.indexOf('/') >= 0) || (files[index].getName().equals(locEnding) && parentPath.equals(localDir))) { return files[index]; } } return null; } /** * Add the appropriate requests for a specified path. For a directory, * process all the files within that directory and for a single file, * just send it. For each directory, send a directory request. For each * file send an Entry request followed by a Modified request. * @param path the particular path to issue requests for. May be * either a file or a directory. */ private void addRequests(File path) throws FileNotFoundException, IOException, CommandAbortedException { if (path == null) { throw new IllegalArgumentException("Cannot add requests for a " + "null path."); } if (!path.exists() || path.isFile()) { addRequestsForFile(path); } else { addRequestsForDirectory(path); } } /** * Should return true if unchanged files should not be sent to server. * If false is returned, all files will be sent to server * This method is used by sendEntryAndModifiedRequests. */ protected boolean doesCheckFileTime() { return true; } /** * Send an Entry followed by a Modified or Unchanged request based on * whether the file has been untouched on the local machine. * * @param entry the entry for the file * @param file the file in question */ protected void sendEntryAndModifiedRequests(Entry entry, File file) { if (entry == null) { return; } // for deleted added files, don't send anything.. if (file != null && !file.exists() && entry.isNewUserFile()) { return; } Date entryLastModified = entry.getLastModified(); boolean hadConflicts = entry.hadConflicts(); if (!hadConflicts) { // we null out the conflict field if there is no conflict // because we use that field to store the timestamp of the // file (just like command-line CVS). There is no point // in sending this information to the CVS server, even // though it should be ignored by the server. entry.setConflict(null); } else if (fileRequiresConflictResolution(file, entry)) { // send entry in wire conflict format Entry clone = new Entry(entry.toString()); clone.setConflict(Entry.HAD_CONFLICTS_AND_TIMESTAMP_MATCHES_FILE); entry = clone; } addRequest(new EntryRequest(entry)); if (file == null || !file.exists() || entry.isUserFileToBeRemoved()) { return; } if (doesCheckFileTime() && !hadConflicts && entryLastModified != null) { if (DateComparator.getInstance().equals(file.lastModified(), entryLastModified.getTime())) { addRequest(new UnchangedRequest(file.getName())); return; } } addRequest(new ModifiedRequest(file, entry.isBinary())); } /** * When committing, we need to perform a check that will prevent the * unmodified conflicting files from being checked in. This is the behavior * of command line CVS client. This method checks the Entry for the file * against the time stamp. The user can optimally call this method only if * the Entry for the file indicates a conflict * @param entry The Entry object corresponding to the file * @param file The File object representing the file on the filesystem * @return boolean Returns true if the file's timestamp is same or less than * the time when the conflicting merge was done by CVS update as indicated * by the Entry. */ private final boolean fileRequiresConflictResolution(File file, Entry entry) { if (file == null) return false; // null file is set by clean copy boolean ret = false; if (entry.hadConflicts()) { // TODO introduce common timestamp comparation logic // We only test accuracy of upto a second (1000ms) because that is // the precision of the timestamp in the entries file long mergedTime = entry.getLastModified().getTime() / 1000; long timeStampOfFile = file.lastModified() / 1000; ret = timeStampOfFile <= mergedTime; } return ret; } /** * Adds the appropriate requests for a given directory. Sends a * directory request followed by as many Entry and Modified requests * as required * @param directory the directory to send requests for * @throws IOException if an error occurs constructing the requests */ protected void addRequestsForDirectory(File directory) throws IOException, CommandAbortedException { if (!clientServices.exists(directory)) { return; } if (clientServices.isAborted()) { throw new CommandAbortedException("Command aborted during request generation", "Command aborted during request generation"); } addDirectoryRequest(directory); File [] dirFiles = directory.listFiles(); List localFiles; if (dirFiles == null) { localFiles = new ArrayList(0); } else { localFiles = new ArrayList(Arrays.asList(dirFiles)); localFiles.remove(new File(directory, "CVS")); } List subDirectories = null; if (isRecursive()) { subDirectories = new LinkedList(); } // get all the entries we know about, and process them for (Iterator it = clientServices.getEntries(directory); it.hasNext();) { final Entry entry = (Entry)it.next(); final File file = new File(directory, entry.getName()); if (entry.isDirectory()) { if (isRecursive()) { subDirectories.add(new File(directory, entry.getName())); } } else { addRequestForFile(file, entry); } localFiles.remove(file); } // In case that CVS folder does not exist, we need to process all // directories that have CVS subfolders: if (isRecursive() && !new File(directory, "CVS").exists()) { File[] subFiles = directory.listFiles(); if (subFiles != null) { for (int i = 0; i < subFiles.length; i++) { if (subFiles[i].isDirectory() && new File(subFiles[i], "CVS").exists()) { subDirectories.add(subFiles[i]); } } } } for (Iterator it = localFiles.iterator(); it.hasNext();) { String localFileName = ((File)it.next()).getName(); if (!clientServices.shouldBeIgnored(directory, localFileName)) { addRequest(new QuestionableRequest(localFileName)); } } if (isRecursive()) { for (Iterator it = subDirectories.iterator(); it.hasNext();) { File subdirectory = (File)it.next(); File cvsSubDir = new File(subdirectory, "CVS"); //NOI18N if (clientServices.exists(cvsSubDir)) { addRequestsForDirectory(subdirectory); } } } } /** * This method is called for each explicit file and for files within a * directory. */ protected void addRequestForFile(File file, Entry entry) { sendEntryAndModifiedRequests(entry, file); } /** * Add the appropriate requests for a single file. A directory request * is sent, followed by an Entry and Modified request * @param file the file to send requests for * @throws IOException if an error occurs constructing the requests */ protected void addRequestsForFile(File file) throws IOException { addDirectoryRequest(file.getParentFile()); try { final Entry entry = clientServices.getEntry(file); // a non-null entry means the file does exist in the // Entries file for this directory if (entry != null) { addRequestForFile(file, entry); } else if (file.exists()) { // #50963 file exists locally without an entry AND the request is // for the file explicitly boolean unusedBinaryFlag = false; addRequest(new ModifiedRequest(file, unusedBinaryFlag)); } } catch (IOException ex) { System.err.println("An error occurred getting the Entry " + "for file " + file + ": " + ex); ex.printStackTrace(); } } /** * Adds a DirectoryRequest (and maybe a StickyRequest) to the request list. */ protected final void addDirectoryRequest(File directory) { // remove localPath prefix from directory. If left with // nothing, use dot (".") in the directory request String dir = getRelativeToLocalPathInUnixStyle(directory); try { String repository = clientServices.getRepositoryForDirectory( directory.getAbsolutePath()); addRequest(new DirectoryRequest(dir, repository)); String tag = clientServices.getStickyTagForDirectory(directory); if (tag != null) { addRequest(new StickyRequest(tag)); } } catch (FileNotFoundException ex) { // we can ignore this exception safely because it just means // that the user has deleted a directory referenced in a // CVS/Entries file } catch (IOException ex) { System.err.println("An error occurred reading the respository " + "for the directory " + dir + ": " + ex); ex.printStackTrace(); } } /** * Add the argument requests. The argument requests are created using * the original set of files/directories passed in. Subclasses of this * class should call this method at the appropriate point in their * execute() method. Note that arguments are appended to the list. */ protected void addArgumentRequests() { if (files == null) { return; } for (int i = 0; i < files.length; i++) { final File file = files[i]; String relativePath = getRelativeToLocalPathInUnixStyle(file); addRequest(new ArgumentRequest(relativePath, true)); } } /** * Execute a command. This implementation sends a Root request, followed * by as many Directory and Entry requests as is required by the recurse * setting and the file arguments that have been set. Subclasses should * call this first, and tag on the end of the requests list any further * requests and, finally, the actually request that does the command (e.g. *
update
,
status
etc.) * @param client the client services object that provides any necessary * services to this command, including the ability to actually process * all the requests * @throws CommandException if an error occurs executing the command */ public void execute(ClientServices client, EventManager em) throws CommandException, AuthenticationException { requests.clear(); clientServices = client; super.execute(client, em); if (client.isFirstCommand()) { addRequest(new RootRequest(client.getRepository())); } addFileRequests(); } private void addFileRequests() throws CommandException { try { if (files != null && files.length > 0) { for (int i = 0; i < files.length; i++) { addRequests(files[i]); } } else { // if no arguments have been specified, then specify the // local directory - the "top level" for this command if (assumeLocalPathWhenUnspecified()) { addRequests(new File(getLocalDirectory())); } } } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } } /** * The result from this command is used only when the getFiles() returns null or empty array. * in such a case and when this method returns true, it is assumed the localpath should be taken * as the 'default' file for the building of requests. * Generally assumed to be true. Can be overriden by subclasses. However make sure you know what you are doing. :) */ protected boolean assumeLocalPathWhenUnspecified() { return true; } /** * Adds the specified request to the request list. */ protected final void addRequest(Request request) { requests.add(request); } /** * Adds the request for the current working directory. */ protected final void addRequestForWorkingDirectory(ClientServices clientServices) throws IOException { addRequest(new DirectoryRequest(".", //NOI18N clientServices.getRepositoryForDirectory(getLocalDirectory()))); } /** * If the specified value is true, add a ArgumentRequest for the specified * argument. */ protected final void addArgumentRequest(boolean value, String argument) { if (!value) { return; } addRequest(new ArgumentRequest(argument)); } /** * Appends the file's names to the specified buffer. */ protected final void appendFileArguments(StringBuffer buffer) { File[] files = getFiles(); if (files == null) { return; } for (int index = 0; index < files.length; index++) { if (index > 0) { buffer.append(' '); } buffer.append(files[index].getName()); } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/BinaryBuilder.java0000644000175300001440000000524711175406776027101 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command; /** * Extended Builder interface. If implemented it's means * that farmework must call this interface {@link #parseBytes} * instead of {@link Builder#parseLine}. * * @author Petr Kuzel */ public interface BinaryBuilder { /** * Raw binary data from stream. One Mbinary * is typicaly splitted into several chunks. * * @param chunk one data chunk. It must be cloned * if builer wants to retain data after finishing * this callback. * @param len defines valid data length */ void parseBytes(byte[] chunk, int len); } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/BuildableCommand.java0000644000175300001440000001600511175406776027522 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.command; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import java.io.UnsupportedEncodingException; /** * A class that provides common functionality for many of the CVS command * that send similar sequences of requests. * @author Robert Greig */ public abstract class BuildableCommand extends Command { /** * An implementation of Builder interface that constructs a FileContainerInfo object from * the server's output.. */ protected Builder builder; private final StringBuffer taggedLineBuffer = new StringBuffer(); /** * A boolean value indicating if the user has used the setBuilder() method. */ private boolean builderSet; /** * Execute a command. This implementation sends a Root request, followed * by as many Directory and Entry requests as is required by the recurse * setting and the file arguments that have been set. Subclasses should * call this first, and tag on the end of the requests list any further * requests and, finally, the actually request that does the command (e.g. *
update
,
status
etc.) * @param client the client services object that provides any necessary * services to this command, including the ability to actually process * all the requests * @throws CommandException if an error occurs executing the command */ public void execute(ClientServices client, EventManager eventManager) throws CommandException, AuthenticationException { super.execute(client, eventManager); if (builder == null && !isBuilderSet()) { builder = createBuilder(eventManager); } } /** * Method that is called while the command is being executed. * Descendants can override this method to return a Builder instance * that will parse the server's output and create data structures. */ public Builder createBuilder(EventManager eventManager) { return null; } public void messageSent(BinaryMessageEvent e) { super.messageSent(e); if (builder == null) { return; } if (builder instanceof BinaryBuilder) { // XXX assert it? BinaryBuilder binaryBuilder = (BinaryBuilder) builder; binaryBuilder.parseBytes(e.getMessage(), e.getMessageLength()); } } public void messageSent(MessageEvent e) { super.messageSent(e); if (builder == null) { return; } if (e instanceof EnhancedMessageEvent) { EnhancedMessageEvent eEvent = (EnhancedMessageEvent)e; builder.parseEnhancedMessage(eEvent.getKey(), eEvent.getValue()); return; } if (e.isTagged()) { String message = MessageEvent.parseTaggedMessage(taggedLineBuffer, e.getMessage()); if (message != null) { builder.parseLine(message, false); taggedLineBuffer.setLength(0); } } else { if (taggedLineBuffer.length() > 0) { builder.parseLine(taggedLineBuffer.toString(), false); taggedLineBuffer.setLength(0); } //#67337 do not interpret piped data using platform default encoding // UTF-8 causes problems as raw data (non UTf-8) can contain confusing sequences // use safe encoding that does not interpret byte sequences if (builder instanceof PipedFilesBuilder && e.isError() == false) { try { String iso88591 = new String(e.getRawData(), "ISO-8859-1"); builder.parseLine(iso88591, e.isError()); } catch (UnsupportedEncodingException e1) { assert false; } } else { builder.parseLine(e.getMessage(), e.isError()); } } } /** * Returns whether the builder is set. */ protected boolean isBuilderSet() { return builderSet; } /** * Used for setting user-defined builder. * Can be also set null, in that case the builder mechanism is not used at * all. */ public void setBuilder(Builder builder) { this.builder = builder; builderSet = true; } /** * Called when server responses with "ok" or "error", (when the command finishes). */ public void commandTerminated(TerminationEvent e) { if (builder == null) { return; } if (taggedLineBuffer.length() > 0) { builder.parseLine(taggedLineBuffer.toString(), false); taggedLineBuffer.setLength(0); } builder.outputDone(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/Builder.java0000644000175300001440000000446011175406776025730 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command; /** * @author Milos Kleint */ public interface Builder { void parseLine(String line, boolean isErrorMessage); void parseEnhancedMessage(String key, Object value); void outputDone(); } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/Bundle.properties0000644000175300001440000000665411175406776027035 0ustar ludousers# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # # Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. # # The contents of this file are subject to the terms of either the GNU # General Public License Version 2 only ("GPL") or the Common # Development and Distribution License("CDDL") (collectively, the # "License"). You may not use this file except in compliance with the # License. You can obtain a copy of the License at # http://www.netbeans.org/cddl-gplv2.html # or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the # specific language governing permissions and limitations under the # License. When distributing the software, include this License Header # Notice in each file and include the License file at # nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this # particular file as subject to the "Classpath" exception as provided # by Sun in the GPL Version 2 section of the License file that # accompanied this code. If applicable, add the following below the # License Header, with the fields enclosed by brackets [] replaced by # your own identifying information: # "Portions Copyrighted [year] [name of copyright owner]" # # Contributor(s): # # The Original Software is NetBeans. The Initial Developer of the Original # Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun # Microsystems, Inc. All Rights Reserved. # # If you wish your version of this file to be governed by only the CDDL # or only the GPL Version 2, indicate your decision by adding # "[Contributor] elects to include this software in this distribution # under the [CDDL or GPL Version 2] license." If you do not indicate a # single choice of license, a recipient has the option to distribute # your version of this file under either the CDDL, the GPL Version 2 or # to extend the choice of license to its licensees as provided above. # However, if you add GPL Version 2 code and therefore, elected the GPL # Version 2 license, then the option applies only if the new code is # made subject to such option by the copyright holder. #-------------------------------------------------------------------- # ResourceBundle properties file AddCommand.noFilesSpecified=No files have been specified for addition. Client.commandAborted=Aborted during request processing. Client.connectionAborted=Aborted during connecting to the server. CommitCommand.logInfoFileNotExists=The file {0} that is used for commit log message doesn't exist. CommitCommand.errorReadingLogFile=Error while reading file {0} that is used for commit log message. CommandException.EndOfFile=Server closed connection. Check the output log for details. ImportCommand.messageEmptry=The message may not be null nor empty! ImportCommand.moduleEmpty=The module may not be null nor empty! ImportCommand.moduleEmpty.text= ImportCommand.releaseTagEmpty=The release tag may not be null nor empty! ImportCommand.releaseTagEmpty.text= ImportCommand.vendorTagEmpty=The vendor tag may not be null nor empty! ImportCommand.vendorTagEmpty.text= ExportCommand.moduleEmpty.text= RemoveCommand.noFilesSpecified=No files have been specified for removal. RemoveCommand.cannotDelete=Cannot delete file {0}. WrapperUtils.clientDotWrapper.text=the .cvswrappers file in the home directory on the client WrapperUtils.environmentWrapper.text=the environment variable CVSWRAPPERS WrapperUtils.wrapperError.text=An error occurred while processing wrapper information from {0}. netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/Command.java0000644000175300001440000002304111175406776025714 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.command; import java.io.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; /** * All commands must extend this class. A command is essentially a * collection of requests that make up what is logically known as a CVS * command (from a user's perspective). Commands correspond to operations the * user can perform with CVS, for example checkout a module or perform a * diff on two file versions.
* Commands are automatically added as CVS event listeners. They can act * on particular events and perhaps fire new events. * * @author Robert Greig */ public abstract class Command implements CVSListener, Cloneable { /** * The local directory from which the command is being run. * This gives us the ability to construct a full pathname for the file * which we are processing. The information from the responses alone is * not enough. */ protected String localDirectory; /** * The global options. */ private GlobalOptions globalOptions; private boolean failed = false; private String displayName; /** * Execute this command. * @param client the client services object that provides any necessary * services to this command, including the ability to actually * process all the requests * @param e the event manager. The command can use this to fire events * if necessary - for example, while parsing status responses. * @return Whether the execution was successfull */ public void execute(ClientServices client, EventManager eventManager) throws CommandException, CommandAbortedException, AuthenticationException { setLocalDirectory(client.getLocalPath()); this.globalOptions = client.getGlobalOptions(); } /** * This method returns how the command would looklike when typed on the * command line. * * Each command is responsible for constructing this information. * * @returns [] files/dirs. Example: checkout -p CvsCommand.java */ public abstract String getCVSCommand(); /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name. */ public abstract String getCVSArguments(); /** * Takes the arguments and sets the command. * To be mainly used for automatic settings (like parsing the .cvsrc file). * * @return true if the option (switch) was recognized and set */ public abstract boolean setCVSCommand(char opt, String optArg); /** * Resets all switches in the command to the default behaviour. * After calling this method, the command should behave defaultly. */ public abstract void resetCVSCommand(); /** * Returns a String that defines which options are available for this * particular command. */ public abstract String getOptString(); /** * This method just calls the Object.clone() and makes it public. */ public Object clone() { try { return super.clone(); } catch (CloneNotSupportedException ex) { return null; } } public boolean hasFailed() { return failed; } /** * Called when the server wants to send a message to be displayed to * the user. The message is only for information purposes and clients * can choose to ignore these messages if they wish. * @param e the event */ public void messageSent(MessageEvent e) { if (e.isError() && (e.getSource() instanceof org.netbeans.lib.cvsclient.response.ErrorResponse) || e.getSource() == this) { // We need to ignore ErrorMessageResponse failed = true; } } public void messageSent(BinaryMessageEvent e) { } /** * Called when a file has been added. * @param e the event */ public void fileAdded(FileAddedEvent e) { } /** * Called when a file is going to be removed. * @param e the event */ public void fileToRemove(FileToRemoveEvent e) { } /** * Called when a file is removed. * @param e the event */ public void fileRemoved(FileRemovedEvent e) { } /** * Called when a file has been updated. * @param e the event */ public void fileUpdated(FileUpdatedEvent e) { } /** * Called when file status information has been received. */ public void fileInfoGenerated(FileInfoEvent e) { } /** * Called when server responses with "ok" or "error", (when the command finishes). */ public void commandTerminated(TerminationEvent e) { } /** * This is called when the servers has responded to an expand-modules * request. */ public void moduleExpanded(ModuleExpansionEvent e) { } /** * Returns the local path the command is associated with. */ public final String getLocalDirectory() { return localDirectory; } /** * Returns the local path the command is associated with. * @deprecated Please use the getLocalDirectory() method instead. */ public final String getLocalPath() { return localDirectory; } /** * Get the global options. */ public final GlobalOptions getGlobalOptions() { return globalOptions; } /** * Returns the relative path of the specified file (relative to the set * local path). * Backward slashes will be replaced by forward slashes. */ public final String getRelativeToLocalPathInUnixStyle(File file) { String filePath = file.getAbsolutePath(); int startIndex = localDirectory.length() + 1; if (startIndex >= filePath.length()) { return "."; //NOI18N } String relativePath = filePath.substring(startIndex); return relativePath.replace('\\', '/'); } /** * Sets the local directory for the command. */ protected final void setLocalDirectory(String localDirectory) { this.localDirectory = localDirectory; } /** * Returns the trimmed version of the specified String s. * The returned String is null if the specified String is null or contains * only white spaces. */ protected static final String getTrimmedString(String s) { if (s == null) { return null; } s = s.trim(); if (s.length() == 0) { return null; } return s; } /** * Defines prefered display name or null. * Localized string should highlight command purpose (use verb in gerund). * E.g. UpdateCommand used to refresh statuses should * be named "Refreshing Status" rather than "cvs -N update", * "Updating" or "Status Refresh". */ public void setDisplayName(String name) { this.displayName = name; } /** * Returns localized name describing command purpose * or null. * * @see #getCVSCommand() */ public String getDisplayName() { return displayName; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/CommandAbortedException.java0000644000175300001440000000522311175406776031076 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.command; /** * This exception is thrown when a command is aborted during execution * @author Robert Greig */ public class CommandAbortedException extends CommandException { /** * Creates new CommandAbortedException. */ public CommandAbortedException(String message, String localizedMessage) { super(message, localizedMessage); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/CommandException.java0000644000175300001440000001177011175406776027601 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.command; import java.io.*; import java.text.*; import java.util.*; import org.netbeans.lib.cvsclient.util.*; /** * This exception is thrown when an error occurs while executing a command. * It is nearly always a container for another exception. * @author Robert Greig */ public class CommandException extends Exception { private Exception underlyingException; private String localizedMessage; private String message; public CommandException(Exception underlyingException, String localizedMessage) { this.underlyingException = underlyingException; this.localizedMessage = localizedMessage; } public CommandException(String message, String localizedMessage) { super(message); this.message = message; this.localizedMessage = localizedMessage; } public Exception getUnderlyingException() { return underlyingException; } public void printStackTrace() { if (underlyingException != null) { underlyingException.printStackTrace(); } else { super.printStackTrace(); } } public void printStackTrace(PrintStream stream) { if (underlyingException != null) { underlyingException.printStackTrace(stream); } else { super.printStackTrace(stream); } } public void printStackTrace(PrintWriter writer) { if (underlyingException != null) { underlyingException.printStackTrace(writer); } else { super.printStackTrace(writer); } } public String getLocalizedMessage() { if (localizedMessage == null) { return message; } return localizedMessage; } public String getMessage() { if (message == null) { return localizedMessage; } return message; } protected static String getBundleString(String key) { String value = null; try { ResourceBundle bundle = BundleUtilities.getResourceBundle(CommandException.class, "Bundle"); // NOI18N if (bundle != null) { value = bundle.getString(key); } } catch (MissingResourceException exc) { } return value; } public static String getLocalMessage(String key) { return getLocalMessage(key, null); } public static String getLocalMessage(String key, Object[] arguments) { String locMessage = CommandException.getBundleString(key); if (locMessage == null) { return null; } if (arguments != null) { locMessage = MessageFormat.format(locMessage, arguments); } return locMessage; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/CommandUtils.java0000644000175300001440000000711411175406776026740 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Thomas Singer. * Portions created by Robert Greig are Copyright (C) 2001. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Thomas Singer. *****************************************************************************/ package org.netbeans.lib.cvsclient.command; import java.util.*; /** * @author Thomas Singer */ public class CommandUtils { /** * Returns the directory relative to local path from the specified message. * This method returns null, if the specified message isn't a EXAM_DIR- * message. */ public static String getExaminedDirectory(String message, String examDirPattern) { final int index = message.indexOf(examDirPattern); final int startIndex = index + examDirPattern.length() + 1; if (index < 0 || message.length() < startIndex + 1) { return null; } return message.substring(startIndex); } /** * for a list of string will return the string that equals the name parameter. * To be used everywhere you need to have only one string occupying teh memory space, * eg. in Builders to have the revision number strings not repeatedly in memory. */ public static String findUniqueString(String name, List list) { if (name == null) { return null; } int index = list.indexOf(name); if (index >= 0) { return (String)list.get(index); } else { String newName = new String(name); list.add(newName); return newName; } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/DefaultFileInfoContainer.java0000644000175300001440000000774611175406776031217 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command; import java.io.*; /** * Describes checkout/tag/update information for a file. * The fields in instances of this object are populated by response handlers. * * @author Thomas Singer */ public class DefaultFileInfoContainer extends FileInfoContainer { public static final String PERTINENT_STATE = "Y"; //NOI18N public static final String MERGED_FILE = "G"; //NOI18N private File file; private String type; public DefaultFileInfoContainer() { } /** * Returns the associated file. */ public File getFile() { return file; } /** * Returns true if the associated file is a directory. */ public boolean isDirectory() { File file = getFile(); if (file == null) { return false; } return file.isDirectory(); } /** * Sets the associated file. */ public void setFile(File file) { this.file = file; } /** * Returns the type. * Mostly the type value equals to the states returned by update and tag command. * see description in cvs manual. * Some states are added: * G - file was merged (when using the cvs update -j command. * D - file was deleted - no longer pertinent. */ public String getType() { return type; } /** * Sets the type. */ public void setType(String type) { this.type = type; } /** * Return a string representation of this object. Useful for debugging. */ public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append(type); buffer.append(" "); //NOI18N if (isDirectory()) { buffer.append("Directory "); //NOI18N } buffer.append(file != null ? file.getAbsolutePath() : "null"); //NOI18N return buffer.toString(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/FileInfoContainer.java0000644000175300001440000000477311175406776027707 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command; import java.io.*; /** * It's a base class for all containers that store information being processed * during execution of cvs commands. * Such info is then transmitted via the event mechanism (CVSEvent) to the * appropriate UI classes that use this information to display it to the user. * * @author Milos Kleint */ public abstract class FileInfoContainer { public abstract File getFile(); } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/GlobalOptions.java0000644000175300001440000004513711175406776027124 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.command; import java.io.File; import java.util.*; import org.netbeans.lib.cvsclient.request.*; /** * Provides access to global options for a specific command. * These are options traditionally set in the command line CVS tool before the * command name, for example in the command: *
cvs -n update -dP
* -n is a global options but -dP are options specific to the update command. * *
Note that you can have different global options for each command you * execute (just like command-line CVS). * * @author Robert Greig */ public class GlobalOptions implements Cloneable { private List variables; /** * Determines whether no changes should be done to the local files. * This is useful to request files, that would be updated. */ private boolean doNoChanges; /** * Whether to make checked out files read only (read/write is the default). */ private boolean checkedOutFilesReadOnly; /** * The CVS root to use. */ private String cvsRoot; /** * Whether to use Gzip-compression. */ private boolean useGzip = true; /** * The gzip compression level. */ private int compressionLevel = 0; /** * Supresses logging of the command in CVSROOT/history in the repository. */ private boolean noHistoryLogging; /** * The cvs gets more quiet than without this switch. * However it still prints the important stuff. * Note: If this switch is used, the Builder stuff and parsing of the output * might break. */ private boolean moderatelyQuiet; /** * Is even more quiet. * Commands which primary function is to send info, still do print something * (diff, etc.), however other command are completely quiet. * Note: If this switch is used, the Builder stuff and parsing of the output * will break. */ private boolean veryQuiet; /** * Traces the execution of the command. Useful for tracing down what is * causing problems. * Note: If this switch is used, the Builder stuff and parsing of the output * might break. */ private boolean traceExecution; /** * Whether a help information should be displayed - usage of the command. */ private boolean showHelp; /** * Whether a version information should be displayed. */ private boolean showVersion; /** * Whether to use ~/.cvsrc file or ignore it. */ private boolean ignoreCvsrc; /** * The directory that is used for temporary files. */ private File tempDir; /** * The editor, that is used to edit the commit message. */ private String editor; /** * Explicitly lists files/folders that must be left intact by the command. */ private File[] exclusions; public GlobalOptions() { variables = new ArrayList(); } /** * Sets list of non-modifiable files/folders. The client will effectively ignore all server responses * that concern these files/folders or files beneath them. * * @param exclusions array of non-modifiable files/folders */ public void setExclusions(File[] exclusions) { this.exclusions = exclusions; } /** * Returns list of non-modifiable files/folders. The client effectively ignores all server responses * that concern these files/folders or files beneath them. * * @return File [] list of files/folders that must be left intact by the command. */ public File[] getExclusions() { return exclusions; } /** * Tests whether the file is not modifiable as set by {@link #setExclusions(java.io.File[])}. * * @param file file to test * @return true if the file must not be modified on disk, false otherwise */ public boolean isExcluded(File file) { if (exclusions != null) { for (int i = 0; i < exclusions.length; i++) { if (isParentOrEqual(exclusions[i], file)) return true; } } return false; } /** * Tests parent/child relationship of files. * * @param parent file to be parent of the second parameter * @param file file to be a child of the first parameter * @return true if the second parameter represents the same file as the first parameter OR is its descendant (child) */ private static boolean isParentOrEqual(File parent, File file) { for (; file != null; file = file.getParentFile()) { if (file.equals(parent)) return true; } return false; } /** * Creates a list of requests. * Only those global options are included that can be sent to server (-q, * -Q, -l, -t, -r, -n). * To be added to the request list sent to the server. */ public List createRequestList() { List requestList = new LinkedList(); if (variables.size() > 0) { Iterator it = variables.iterator(); while (it.hasNext()) { String keyValue = it.next().toString(); requestList.add(new SetRequest(keyValue)); } } if (isNoHistoryLogging()) { requestList.add(new GlobalOptionRequest("-l")); //NOI18N } if (isDoNoChanges()) { requestList.add(new GlobalOptionRequest("-n")); //NOI18N } if (isModeratelyQuiet()) { requestList.add(new GlobalOptionRequest("-q")); //NOI18N } if (isVeryQuiet()) { requestList.add(new GlobalOptionRequest("-Q")); //NOI18N } if (isTraceExecution()) { requestList.add(new GlobalOptionRequest("-t")); //NOI18N } return requestList; } /** * Returns a String that defines which options are available for global * options. */ public String getOptString() { return "Hvnfd:lqQtrws:z:T:e:"; //NOI18N } /** * EQUALS to Command.setCVSCommand() */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'n') { setDoNoChanges(true); } else if (opt == 'd') { setCVSRoot(optArg); } else if (opt == 'l') { setNoHistoryLogging(true); } else if (opt == 'q') { setModeratelyQuiet(true); } else if (opt == 'Q') { setVeryQuiet(true); } else if (opt == 't') { setTraceExecution(true); } else if (opt == 't') { setTraceExecution(true); } else if (opt == 'r') { setCheckedOutFilesReadOnly(true); } else if (opt == 'w') { setCheckedOutFilesReadOnly(false); } else if (opt == 's') { setCvsVariable(optArg); } else if (opt == 'z') { try { setCompressionLevel(Integer.parseInt(optArg)); } catch (NumberFormatException nfex) { } } else if (opt == 'H') { setShowHelp(true); } else if (opt == 'v') { setShowVersion(true); } else if (opt == 'f') { setIgnoreCvsrc(true); } else if (opt == 'T') { setTempDir(new File(optArg)); } else if (opt == 'e') { setEditor(optArg); } else { return false; } return true; } /** * Resets all switches in the command to the default behaviour. * After calling this method, the command should behave defaultly. * EQUALS to Command.resetCVSCommand() */ public void resetCVSCommand() { setCheckedOutFilesReadOnly(false); setDoNoChanges(false); setModeratelyQuiet(false); setNoHistoryLogging(false); setTraceExecution(false); setUseGzip(true); setCompressionLevel(0); setVeryQuiet(false); setShowHelp(false); setShowVersion(false); setIgnoreCvsrc(false); setTempDir(null); setEditor(null); setCVSRoot(""); clearCvsVariables(); } /** * Equals to the Command.getCVSCommand() functionality. * Returns all the current switches in the command-line cvs style. */ public String getCVSCommand() { StringBuffer switches = new StringBuffer(); if (isDoNoChanges()) { switches.append("-n "); //NOI18N } if (isNoHistoryLogging()) { switches.append("-l "); //NOI18N } if (isModeratelyQuiet()) { switches.append("-q "); //NOI18N } if (isVeryQuiet()) { switches.append("-Q "); //NOI18N } if (isTraceExecution()) { switches.append("-t "); //NOI18N } if (isCheckedOutFilesReadOnly()) { switches.append("-r "); //NOI18N } if (variables.size() > 0) { Iterator it = variables.iterator(); while (it.hasNext()) { String keyValue = it.next().toString(); switches.append("-s " + keyValue + " "); //NOI18N } } if (compressionLevel != 0) { switches.append("-z "); switches.append(Integer.toString(compressionLevel)); switches.append(" "); } if (isIgnoreCvsrc()) { switches.append("-f "); } if (tempDir != null) { switches.append("-T "); switches.append(tempDir.getAbsolutePath()); switches.append(" "); } if (editor != null) { switches.append("-e "); switches.append(editor); switches.append(" "); } return switches.toString(); } /** * Adds one cvs internal enviroment variable. * @param variable The format is NAME=VALUE. */ public void setCvsVariable(String variable) { variables.add(variable); } /** * Clears the list of cvs internal enviroment variables. */ public void clearCvsVariables() { this.variables.clear(); } /** * Sets the cvs internal enviroment variables. * It will clear any vrisables previously set. * @param variables array of strings in format "KEY=VALUE". */ public void setCvsVariables(String[] variables) { clearCvsVariables(); for (int i = 0; i < variables.length; i++) { String variable = variables[i]; this.variables.add(variable); } } public String[] getCvsVariables() { String[] vars = new String[variables.size()]; vars = (String[])variables.toArray(vars); return vars; } /** * Sets whether no changes should be done to the files. */ public void setDoNoChanges(boolean doNoChanges) { this.doNoChanges = doNoChanges; } /** * Returns whether no changes should be done to the files. */ public boolean isDoNoChanges() { return doNoChanges; } /** * Are checked out files read only. * @return the answer */ public boolean isCheckedOutFilesReadOnly() { return checkedOutFilesReadOnly; } /** * Set whether checked out files are read only. False is the default. * @param readOnly true for readonly, false for read/write (default) */ public void setCheckedOutFilesReadOnly(boolean readOnly) { checkedOutFilesReadOnly = readOnly; } /** * Get the CVS root * @return the CVS root value, e.g. :pserver:user@host@/usr/local/cvs */ public String getCVSRoot() { return cvsRoot; } /** * Set the CVS root * @param cvsRoot CVS root to use */ public void setCVSRoot(String cvsRoot) { this.cvsRoot = cvsRoot; } /** * Set whether to use Gzip for file transmission/reception * @param useGzip true if gzip should be used, false otherwise */ public void setUseGzip(boolean useGzip) { this.useGzip = useGzip; } /** * Get whether to use Gzip * @return true if Gzip should be used, false otherwise */ public boolean isUseGzip() { return useGzip; } /** * Getter for property compressionLevel. * @return Value of property compressionLevel. */ public int getCompressionLevel() { return compressionLevel; } /** * Setter for property compressionLevel. * @param compressionLevel New value of property compressionLevel. */ public void setCompressionLevel(int compressionLevel) { this.compressionLevel = compressionLevel; } /** Getter for property noHistoryLogging. * @return Value of property noHistoryLogging. */ public boolean isNoHistoryLogging() { return noHistoryLogging; } /** Setter for property noHistoryLogging. * @param noHistoryLogging New value of property noHistoryLogging. */ public void setNoHistoryLogging(boolean noHistoryLogging) { this.noHistoryLogging = noHistoryLogging; } /** Getter for property moderatelyQuiet. * @return Value of property moderatelyQuiet. */ public boolean isModeratelyQuiet() { return moderatelyQuiet; } /** Setter for property moderatelyQuiet. * @param moderatelyQuiet New value of property moderatelyQuiet. */ public void setModeratelyQuiet(boolean moderatelyQuiet) { this.moderatelyQuiet = moderatelyQuiet; } /** Getter for property veryQuiet. * @return Value of property veryQuiet. */ public boolean isVeryQuiet() { return veryQuiet; } /** Setter for property veryQuiet. * @param veryQuiet New value of property veryQuiet. */ public void setVeryQuiet(boolean veryQuiet) { this.veryQuiet = veryQuiet; } /** Getter for property traceExecution. * @return Value of property traceExecution. */ public boolean isTraceExecution() { return traceExecution; } /** Setter for property traceExecution. * @param traceExecution New value of property traceExecution. */ public void setTraceExecution(boolean traceExecution) { this.traceExecution = traceExecution; } /** * Getter for property showHelp. * @return Value of property showHelp. */ public boolean isShowHelp() { return showHelp; } /** * Setter for property showHelp. * @param showHelp New value of property showHelp. */ public void setShowHelp(boolean showHelp) { this.showHelp = showHelp; } /** * Getter for property showVersion. * @return Value of property showVersion. */ public boolean isShowVersion() { return showVersion; } /** * Setter for property showVersion. * @param showVersion New value of property showVersion. */ public void setShowVersion(boolean showVersion) { this.showVersion = showVersion; } /** * Getter for property ignoreCvsrc. * @return Value of property ignoreCvsrc. */ public boolean isIgnoreCvsrc() { return ignoreCvsrc; } /** * Setter for property ignoreCvsrc. * @param ignoreCvsrc New value of property ignoreCvsrc. */ public void setIgnoreCvsrc(boolean ignoreCvsrc) { this.ignoreCvsrc = ignoreCvsrc; } /** * Getter for property tempDir. * @return Value of property tempDir. */ public java.io.File getTempDir() { return tempDir; } /** * Setter for property tempDir. * @param tempDir New value of property tempDir. */ public void setTempDir(java.io.File tempDir) { this.tempDir = tempDir; } /** * Getter for property editor. * @return Value of property editor. */ public String getEditor() { return editor; } /** * Setter for property editor. * @param editor New value of property editor. */ public void setEditor(String editor) { this.editor = editor; } /** * This method just calls the Object.clone() and makes it public. */ public Object clone() { try { return super.clone(); } catch (CloneNotSupportedException ex) { // never can occur return null; } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/KeywordSubstitutionOptions.java0000644000175300001440000000725211175406776032001 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command; /** * @author Thomas Singer */ public final class KeywordSubstitutionOptions { public static final KeywordSubstitutionOptions DEFAULT = new KeywordSubstitutionOptions("kv"); //NOI18N public static final KeywordSubstitutionOptions DEFAULT_LOCKER = new KeywordSubstitutionOptions("kvl"); //NOI18N public static final KeywordSubstitutionOptions ONLY_KEYWORDS = new KeywordSubstitutionOptions("k"); //NOI18N public static final KeywordSubstitutionOptions ONLY_VALUES = new KeywordSubstitutionOptions("v"); //NOI18N public static final KeywordSubstitutionOptions OLD_VALUES = new KeywordSubstitutionOptions("o"); //NOI18N public static final KeywordSubstitutionOptions BINARY = new KeywordSubstitutionOptions("b"); //NOI18N public static KeywordSubstitutionOptions findKeywordSubstOption(String keyword) { if (BINARY.toString().equals(keyword)) { return BINARY; } if (DEFAULT.toString().equals(keyword)) { return DEFAULT; } if (DEFAULT_LOCKER.toString().equals(keyword)) { return DEFAULT_LOCKER; } if (OLD_VALUES.toString().equals(keyword)) { return OLD_VALUES; } if (ONLY_KEYWORDS.toString().equals(keyword)) { return ONLY_KEYWORDS; } if (ONLY_VALUES.toString().equals(keyword)) { return ONLY_VALUES; } return null; } private String value; private KeywordSubstitutionOptions(String value) { this.value = value; } public String toString() { return value; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/PipedFileInformation.java0000644000175300001440000001055711175406776030415 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command; import java.io.*; /** * Contains intercepted infomation from command standard output. * Actula data are held in temporary file. * */ public class PipedFileInformation extends FileInfoContainer { private File file; private String repositoryRevision; private String repositoryFileName; private File tempFile; private OutputStream tmpStream; public PipedFileInformation(File tempFile) { this.tempFile = tempFile; //this.tempFile.deleteOnExit(); try { tmpStream = new BufferedOutputStream(new FileOutputStream(tempFile)); } catch (IOException ex) { // TODO } } /** * Returns the original file. For piped content see {@link #getTempFile()}. */ public File getFile() { return file; } /** * Sets the original file. */ protected void setFile(File file) { this.file = file; } /** * Returns the revision of the incoming file. */ public String getRepositoryRevision() { return repositoryRevision; } /** * Sets the revision of the incoming file. */ protected void setRepositoryRevision(String repositoryRevision) { this.repositoryRevision = repositoryRevision; } /** * Returns the filename in the repository. */ public String getRepositoryFileName() { return repositoryFileName; } /** * Sets the repository filename. */ protected void setRepositoryFileName(String repositoryFileName) { this.repositoryFileName = repositoryFileName; } /** * Adds the specified line to the temporary file. */ protected void addToTempFile(byte[] bytes) throws IOException { if (tmpStream != null) { tmpStream.write(bytes); } } /** * Adds the specified line to the temporary file. */ public void addToTempFile(byte[] bytes, int len) throws IOException { if (tmpStream != null) { tmpStream.write(bytes, 0, len); } } protected void closeTempFile() throws IOException { if (tmpStream != null) { tmpStream.flush(); tmpStream.close(); } } public File getTempFile() { return tempFile; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/PipedFilesBuilder.java0000644000175300001440000001634011175406776027675 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command; import java.io.*; import org.netbeans.lib.cvsclient.event.*; /** * Handles the building of "checkout with -p switch" information object and storing of * the checked out file to the temporary file and the firing of * events when complete objects are built. * * @author Milos Kleint */ public class PipedFilesBuilder implements Builder, BinaryBuilder { private static final String ERR_START = "======="; //NOI18N private static final String ERR_CHECK = "Checking out "; //NOI18N private static final String ERR_RCS = "RCS: "; //NOI18N private static final String ERR_VERS = "VERS: "; //NOI18N private static final String EXAM_DIR = ": Updating"; //NOI18N private static final byte [] lineSeparator = System.getProperty("line.separator").getBytes(); /** * The module object that is currently being built. */ private PipedFileInformation fileInformation; /** * The event manager to use. */ private EventManager eventManager; /** * The directory in which the file being processed lives. * This is relative to the local directory. */ private String fileDirectory; private BuildableCommand command; private TemporaryFileCreator tempFileCreator; /** * Creates a new Builder for the PipeFileResponse. */ public PipedFilesBuilder(EventManager eventManager, BuildableCommand command, TemporaryFileCreator tempFileCreator) { this.eventManager = eventManager; this.command = command; this.tempFileCreator = tempFileCreator; } public void outputDone() { if (fileInformation == null) { return; } try { fileInformation.closeTempFile(); } catch (IOException exc) { //TODO } eventManager.fireCVSEvent(new FileInfoEvent(this, fileInformation)); fileInformation = null; } public void parseBytes(byte[] bytes, int len) { if (fileInformation == null) { // HOTFIX there is no header for :local: repositories (thereare two copies in this source) // XXX it might be dangerous because PipedFileInformation stays partialy unitialized try { fileInformation = new PipedFileInformation(File.createTempFile("checkout", null)); } catch (IOException e) { e.printStackTrace(); } } try { fileInformation.addToTempFile(bytes, len); } catch (IOException exc) { outputDone(); } } public void parseLine(String line, boolean isErrorMessage) { if (isErrorMessage) { if (line.indexOf(EXAM_DIR) >= 0) { fileDirectory = line.substring(line.indexOf(EXAM_DIR) + EXAM_DIR.length()).trim(); } else if (line.startsWith(ERR_CHECK)) { processFile(line); } else if (line.startsWith(ERR_RCS)) { if (fileInformation != null) { String repositoryName = line.substring(ERR_RCS.length()).trim(); fileInformation.setRepositoryFileName(repositoryName); } } else if (line.startsWith(ERR_VERS)) { if (fileInformation != null) { String repositoryRevision = line.substring(ERR_RCS.length()).trim(); fileInformation.setRepositoryRevision(repositoryRevision); } } // header stuff.. } else { if (fileInformation == null) { // HOTFIX there is no header for :local: repositories (thereare two copies in this source) // XXX it might be dangerous because PipedFileInformation stays partialy unitialized try { fileInformation = new PipedFileInformation(File.createTempFile("checkout", null)); } catch (IOException e) { e.printStackTrace(); } } if (fileInformation != null) { try { fileInformation.addToTempFile(line.getBytes("ISO-8859-1")); // see BuildableCommand fileInformation.addToTempFile(lineSeparator); } catch (IOException exc) { outputDone(); } } } } private void processFile(String line) { outputDone(); String filename = line.substring(ERR_CHECK.length()); try { File temporaryFile = tempFileCreator.createTempFile(filename); fileInformation = new PipedFileInformation(temporaryFile); } catch (IOException ex) { fileInformation = null; return; } fileInformation.setFile(createFile(filename)); } private File createFile(String fileName) { File file = new File(command.getLocalDirectory(), fileName); return file; } public void parseEnhancedMessage(String key, Object value) { } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/RepositoryCommand.java0000644000175300001440000002054611175406776030023 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.admin.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * A class that provides common functionality for CVS commands that * operate upon the repository. * * @author Martin Entlicher */ public abstract class RepositoryCommand extends BuildableCommand { /** * The requests that are sent and processed. */ protected List requests = new LinkedList(); /** * The client services that are provided to this command. */ protected ClientServices clientServices; /** * Whether to process recursively. */ private boolean recursive = true; /** * The modules to process. These names are unexpanded and will be passed * to a module-expansion request. */ protected final List modules = new LinkedList(); /** * The expanded modules. */ protected final List expandedModules = new LinkedList(); /** * Gets the value of the recursive option. * @return true if recursive, false if not */ public boolean isRecursive() { return recursive; } /** * Sets the value of the recursive option. * @param r true if the command should recurse, false otherwise */ public void setRecursive(boolean recursive) { this.recursive = recursive; } /** * Add a module to process. * @param module the name of the module to process */ public void addModule(String module) { modules.add(module); } /** * Set the modules to process. * @param modules the names of the modules to process */ public void setModules(String[] modules) { clearModules(); if (modules == null) { return; } for (int i = 0; i < modules.length; i++) { String module = modules[i]; this.modules.add(module); } } /** * Get the array of modules that are set to be processed. */ public String[] getModules() { String[] mods = new String[modules.size()]; mods = (String[])modules.toArray(mods); return mods; } /** * Clear the list of modules. */ public void clearModules() { this.modules.clear(); } /** * Add the argument requests. The argument requests are created using * the expanded set of modules passed in. Subclasses of this * class should call this method at the appropriate point in their * postExpansionExecute() method. Note that arguments are appended to the list. */ protected final void addArgumentRequests() { if (expandedModules.size() == 0) { return; } for (Iterator it = expandedModules.iterator(); it.hasNext(); ) { final String module = (String) it.next(); addRequest(new ArgumentRequest(module)); } } /** * This is called when the server has responded to an expand-modules * request. */ public final void moduleExpanded(ModuleExpansionEvent e) { expandedModules.add(e.getModule()); } /** * Execute this command. This method sends the ExpandModulesRequest in order * to expand the modules that were set. The actual execution is performed by * {@link #postExpansionExecute} method. * @param client the client services object that provides any necessary * services to this command, including the ability to actually process * all the requests */ public final void execute(ClientServices client, EventManager em) throws CommandException, AuthenticationException { client.ensureConnection(); requests.clear(); super.execute(client, em); clientServices = client; if (client.isFirstCommand()) { requests.add(new RootRequest(client.getRepository())); } for (Iterator it = modules.iterator(); it.hasNext();) { String module = (String)it.next(); requests.add(new ArgumentRequest(module)); } expandedModules.clear(); requests.add(new DirectoryRequest(".", client.getRepository())); //NOI18N requests.add(new ExpandModulesRequest()); try { client.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } requests.clear(); postExpansionExecute(client, em); } /** * Execute this command * @param client the client services object that provides any necessary * services to this command, including the ability to actually process * all the requests */ protected abstract void postExpansionExecute(ClientServices client, EventManager em) throws CommandException, AuthenticationException; /** * Adds the specified request to the request list. */ protected final void addRequest(Request request) { requests.add(request); } /** * Adds the request for the current working directory. */ protected final void addRequestForWorkingDirectory(ClientServices clientServices) throws IOException { addRequest(new DirectoryRequest(".", //NOI18N clientServices.getRepositoryForDirectory(getLocalDirectory()))); } /** * If the specified value is true, add a ArgumentRequest for the specified * argument. */ protected final void addArgumentRequest(boolean value, String argument) { if (!value) { return; } addRequest(new ArgumentRequest(argument)); } /** * Appends the file's names to the specified buffer. */ protected final void appendModuleArguments(StringBuffer buffer) { if (expandedModules.size() == 0) { return; } Iterator it = expandedModules.iterator(); buffer.append((String) it.next()); while (it.hasNext()) { buffer.append(' '); buffer.append((String) it.next()); } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/TemporaryFileCreator.java0000644000175300001440000000440211175406776030440 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command; import java.io.*; /** * @author Milos Kleint */ public interface TemporaryFileCreator { File createTempFile(String filename) throws IOException; } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/Watch.java0000644000175300001440000000720111175406776025404 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command; /** * @author Thomas Singer * @version Dec 2, 2001 */ public class Watch { public static final Watch EDIT = new Watch("edit", "E", // NOI18N new String[]{"edit"}); // NOI18N public static final Watch UNEDIT = new Watch("unedit", "U", // NOI18N new String[]{"unedit"}); // NOI18N public static final Watch COMMIT = new Watch("commit", "C", // NOI18N new String[]{"commit"}); // NOI18N public static final Watch ALL = new Watch("all", "EUC", // NOI18N new String[]{"edit", "unedit", "commit"}); // NOI18N public static final Watch NONE = new Watch("none", "", // NOI18N new String[0]); /** * Returns the temporary watch value used in the Notify request. */ public static String getWatchString(Watch watch) { if (watch == null) { return NONE.getValue(); } return watch.getValue(); } private final String name; private final String value; private final String[] arguments; private Watch(String name, String value, String[] arguments) { this.name = name; this.value = value; this.arguments = arguments; } public String[] getArguments() { return arguments; } public String toString() { return name; } private String getValue() { return value; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/add/0000755000175300001440000000000011175434236024213 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/add/AddBuilder.java0000644000175300001440000002064211175406776027071 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.add; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.event.*; /** * Handles the building of add information object and the firing of * events when complete objects are built. * * @author Milos Kleint */ public class AddBuilder implements Builder { private static final String UNKNOWN = ": nothing known about"; //NOI18N private static final String ADDED = " added to the repository"; //NOI18N private static final String WARNING = ": warning: "; //NOI18N private static final String ALREADY_ENTERED = " has already been entered"; //NOI18N private static final String SCHEDULING = ": scheduling file `"; //NOI18N private static final String USE_COMMIT = ": use 'cvs commit' "; //NOI18N private static final String DIRECTORY = "Directory "; //NOI18N private static final String READDING = ": re-adding file "; //NOI18N private static final String RESURRECTED = ", resurrected"; //NOI18N private static final String RESUR_VERSION = ", version "; //NOI18N private static final boolean DEBUG = false; /** * The status object that is currently being built. */ private AddInformation addInformation; /** * The event manager to use. */ private EventManager eventManager; /** * The directory in which the file being processed lives. * This is relative to the local directory */ private String fileDirectory; private AddCommand addCommand; private boolean readingTags; public AddBuilder(EventManager eventManager, AddCommand addCommand) { this.eventManager = eventManager; this.addCommand = addCommand; } public void outputDone() { if (addInformation != null) { FileInfoEvent event = new FileInfoEvent(this, addInformation); eventManager.fireCVSEvent(event); addInformation = null; } } public void parseLine(String line, boolean isErrorMessage) { if (line.endsWith(ADDED)) { String directory = line.substring(DIRECTORY.length(), line.indexOf(ADDED)); addDirectory(directory); } else if (line.indexOf(SCHEDULING) >= 0) { String filename = line.substring(line.indexOf(SCHEDULING) + SCHEDULING.length(), line.indexOf('\'')).trim(); addFile(filename); } else if (line.indexOf(READDING) >= 0) { String filename = line.substring(line.indexOf(READDING) + READDING.length(), line.indexOf('(')).trim(); addFile(filename); } else if (line.endsWith(RESURRECTED)) { String filename = line.substring(0, line.length() - RESURRECTED.length()); resurrectFile(filename); } // ignore the rest.. } private File createFile(String fileName) { File locFile = addCommand.getFileEndingWith(fileName); if (locFile == null) { // in case the exact match was not achieved using the getFileEndingWith method // let's try to find the best match possible. // iterate from the back of the filename string and try to match the endings // of getFiles(). the best match is picked then. // Works ok for files and directories in add, should not probably be used // elsewhere where it's possible to have recursive commands and where resulting files // are not listed in getFiles() String name = fileName.replace('\\', '/'); File[] files = addCommand.getFiles(); int maxLevel = name.length(); File bestMatch = null; String[] paths = new String[files.length]; for (int index = 0; index < files.length; index++) { paths[index] = files[index].getAbsolutePath().replace('\\', '/'); } int start = name.lastIndexOf('/'); String part = null; if (start < 0) { part = name; } else { part = name.substring(start + 1); } while (start >= 0 || part != null) { boolean wasMatch = false; for (int index = 0; index < paths.length; index++) { if (paths[index].endsWith(part)) { bestMatch = files[index]; wasMatch = true; } } start = name.lastIndexOf('/', start - 1); if (start < 0 || !wasMatch) { break; } part = name.substring(start + 1); } return bestMatch; } return locFile; } private void addDirectory(String name) { addInformation = new AddInformation(); addInformation.setType(AddInformation.FILE_ADDED); String dirName = name.replace('\\', '/'); /* int index = dirName.lastIndexOf('/'); if (index > 0) { dirName = dirName.substring(index + 1, dirName.length()); } */ addInformation.setFile(createFile(dirName)); outputDone(); } private void addFile(String name) { addInformation = new AddInformation(); addInformation.setFile(createFile(name)); addInformation.setType(AddInformation.FILE_ADDED); outputDone(); } private void resurrectFile(String line) { int versionIndex = line.lastIndexOf(RESUR_VERSION); String version = line.substring(versionIndex + RESUR_VERSION.length()).trim(); String cutLine = line.substring(0, versionIndex).trim(); int fileIndex = cutLine.lastIndexOf(' '); String name = cutLine.substring(fileIndex).trim(); if (DEBUG) { System.out.println("line1=" + line); //NOI18N System.out.println("versionIndex=" + versionIndex); //NOI18N System.out.println("version=" + version); //NOI18N System.out.println("fileindex=" + fileIndex); //NOI18N System.out.println("filename=" + name); //NOI18N } addInformation = new AddInformation(); addInformation.setType(AddInformation.FILE_RESURRECTED); addInformation.setFile(createFile(name)); outputDone(); } public void parseEnhancedMessage(String key, Object value) { } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/add/AddCommand.java0000644000175300001440000006200011175406776027053 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.command.add; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.util.SimpleStringPattern; import org.netbeans.lib.cvsclient.admin.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * Adds a file or directory. * @author Robert Greig */ public class AddCommand extends BuildableCommand { /** * Constants that identify a message that creates a directory in * repository. */ private static final String DIR_ADDED = " added to the repository"; //NOI18N private static final String DIRECTORY = "Directory "; //NOI18N /** * The requests that are sent and processed. */ private List requests; /** * The argument requests that are collected and sent in the end just before the * add request. */ private final List argumentRequests = new LinkedList(); /** * The list of new directories. */ /* private HashMap newDirList; */ private final List newDirList = new LinkedList(); /** * The client services that are provided to this command. */ private ClientServices clientServices; /** * The files and/or directories to operate on. */ private File[] files; /** * Holds value of property message, (add's switch -m). */ private String message; /** * Holds value of property keywordSubst. */ private KeywordSubstitutionOptions keywordSubst; /** *This is the merged wrapper map that contains has both server side *and client side wrapper settings merged except for the .cvswrappers *in the individual directories */ private Map wrapperMap; /** * Holds the cvswrappers map for each directory, keyed * by directory name */ private HashMap dir2WrapperMap = new HashMap(16); private static final Map EMPTYWRAPPER = new HashMap(1); /** * Constructor. */ public AddCommand() { resetCVSCommand(); } /** * Set the files and/or directories on which to execute the command. * Sorts the paameter so that directories are first and files follow. * That way a directory and it's content will be passed correctly. * The user of the library has to specify all the files+dirs being added though. * This is just a sanity check, so that no unnessesary errors occur. */ public void setFiles(File[] files) { this.files = files; if (files == null) { return; } // sort array: directories first, files follow this.files = new File[files.length]; int dirCount = 0; int fileCount = 0; int totalCount = files.length; for (int index = 0; index < totalCount; index++) { File currentFile = files[index]; if (currentFile.isDirectory()) { this.files[dirCount] = currentFile; dirCount++; } else { this.files[totalCount - (1 + fileCount)] = currentFile; fileCount++; } } } /** * Get the files and/or directories specified for this command to operate * on. * @return the array of Files */ public File[] getFiles() { return files; } /** * @param ending - the ending part of the file's pathname.. path separator is cvs's default '/' */ public File getFileEndingWith(String ending) { String locEnding = ending.replace('\\', '/'); String localDir = getLocalDirectory().replace('\\','/'); int index = 0; for (index = 0; index < files.length; index++) { String path = files[index].getAbsolutePath(); String parentPath = files[index].getParentFile().getAbsolutePath().replace('\\', '/'); path = path.replace('\\', '/'); if ((path.endsWith(locEnding) && locEnding.indexOf('/') >= 0) || (files[index].getName().equals(locEnding) && parentPath.equals(localDir))) { return files[index]; } } return null; } /** * Getter for property message. * @return Value of property message. */ public String getMessage() { return message; } /** * Setter for property message. * @param message New value of property message. */ public void setMessage(String message) { this.message = message; } /** * Getter for property keywordSubst. * @return Value of property keywordSubst. */ public KeywordSubstitutionOptions getKeywordSubst() { return keywordSubst; } /** * Setter for property keywordSubst. * @param keywordSubst New value of property keywordSubst. */ public void setKeywordSubst(KeywordSubstitutionOptions keywordSubst) { this.keywordSubst = keywordSubst; } /** * Add requests for a particular file or directory to be added. */ protected void addRequests(File file) throws IOException, CommandException { if (file.isDirectory()) { addRequestsForDirectory(file, false); } else { addRequestsForFile(file); } } /** * Add requests for a particular directory. * @param directory the directory to add * @param adding - for the directory to be added, set to true. * used internally to recurse Directory requests. * @throws IOException if an error occurs */ private void addRequestsForDirectory(File directory, boolean recursion) throws IOException { File parentDirectory = directory.getParentFile(); String dir = recursion ? getRelativeToLocalPathInUnixStyle(directory) : getRelativeToLocalPathInUnixStyle(parentDirectory); String partPath; if (dir.equals(".")) { //NOI18N partPath = directory.getName(); } else { // trim the leading slash from the pathname we end up with // (e.g. we end up with something like \banana\foo // and this gives us banana\foo). Also replace backslashes with // forward slashes. The standard CVS server doesn't like // backslashes very much. partPath = dir + "/" + directory.getName(); //NOI18N // recursively scroll back to the localPath.. addRequestsForDirectory(parentDirectory, true); } if (recursion) { partPath = dir; } // Note that the repository file for the directory being added has not // been created yet, so we are forced to read the repository for // the parent directory and build the appropriate entry by tagging // on the directory name (called partPath here) String repository; String tag; if (recursion) { repository = clientServices.getRepositoryForDirectory( directory.getAbsolutePath()); tag = clientServices.getStickyTagForDirectory(directory); } else { repository = clientServices.getRepositoryForDirectory( parentDirectory.getAbsolutePath()); if (repository.endsWith(".")) { repository = repository.substring(0, repository.length() - 1) + directory.getName(); } else { repository = repository + "/" + directory.getName(); //NOI18N } tag = clientServices.getStickyTagForDirectory(parentDirectory); } requests.add(new DirectoryRequest(partPath, repository)); if (tag != null) { requests.add(new StickyRequest(tag)); } if (!recursion) { argumentRequests.add(new ArgumentRequest(partPath)); /* newDirList.put(partPath, repository); */ newDirList.add(new Paths(partPath, repository)); } // MK argument after Dir request.. also with the rel path from the current working dir } /** * Add requests for a particular file. */ protected void addRequestsForFile(File file) throws IOException, CommandException { File directory = file.getParentFile(); String dir = getRelativeToLocalPathInUnixStyle(directory); String repository = clientServices.getRepositoryForDirectory( directory.getAbsolutePath()); requests.add(new DirectoryRequest(dir, repository)); String tag = clientServices.getStickyTagForDirectory(directory); if (tag != null) { requests.add(new StickyRequest(tag)); } Entry entry = clientServices.getEntry(file); if (entry != null) { requests.add(new EntryRequest(entry)); } else { Map directoryLevelWrapper = (Map) dir2WrapperMap.get(dir); if (directoryLevelWrapper == null) { // we have not parsed the cvs wrappers for this directory // read the wrappers for this directory File wrapperFile = new File(directory, ".cvswrappers"); // NOI18N if (wrapperFile.exists()) { directoryLevelWrapper = new HashMap(5); WrapperUtils.readWrappersFromFile(wrapperFile, directoryLevelWrapper); } else { directoryLevelWrapper = EMPTYWRAPPER; } // store the wrapper map indexed by directory name dir2WrapperMap.put(dir, directoryLevelWrapper); } boolean isBinary = isBinary(clientServices, file.getName(), directoryLevelWrapper); if (isBinary) { requests.add(new KoptRequest("-kb")); // NOI18N } requests.add(new IsModifiedRequest(file)); } if (dir.equals(".")) { //NOI18N argumentRequests.add(new ArgumentRequest(file.getName(), true)); } else { argumentRequests.add(new ArgumentRequest(dir + "/" + file.getName())); //NOI18N } } /** * Returns true, if the file for the specified filename should be treated as * a binary file. * * The information comes from the wrapper map and the set keywordsubstitution. */ private boolean isBinary(ClientServices client, String filename, Map directoryLevelWrappers) throws CommandException { KeywordSubstitutionOptions keywordSubstitutionOptions = getKeywordSubst(); if (keywordSubstitutionOptions == KeywordSubstitutionOptions.BINARY) { return true; } // The keyWordSubstitutions was set based on MIME-types by // CVSAdd which had no notion of cvswrappers. Therefore some // filetypes returned as text may actually be binary within CVS // We check for those files here boolean wrapperFound = false; if (wrapperMap == null) { // process the wrapper settings as we have not done it before. wrapperMap = WrapperUtils.mergeWrapperMap(client); } for (Iterator it = wrapperMap.keySet().iterator(); it.hasNext();) { SimpleStringPattern pattern = (SimpleStringPattern)it.next(); if (pattern.doesMatch(filename)) { keywordSubstitutionOptions = (KeywordSubstitutionOptions)wrapperMap.get(pattern); wrapperFound = true; break; } } // if no wrappers are found to match the server and local settings, try // the wrappers for this local directory if (!wrapperFound && (directoryLevelWrappers != null) && (directoryLevelWrappers!=EMPTYWRAPPER)) { for (Iterator it = directoryLevelWrappers.keySet().iterator(); it.hasNext();) { SimpleStringPattern pattern = (SimpleStringPattern)it.next(); if (pattern.doesMatch(filename)) { keywordSubstitutionOptions = (KeywordSubstitutionOptions)directoryLevelWrappers.get(pattern); wrapperFound = true; break; } } } return keywordSubstitutionOptions == KeywordSubstitutionOptions.BINARY; } /** * Execute a command. * @param client the client services object that provides any necessary * services to this command, including the ability to actually process * all the requests */ public void execute(ClientServices client, EventManager em) throws CommandException, AuthenticationException { if (files == null || files.length == 0) { throw new CommandException("No files have been specified for " + //NOI18N "adding.", CommandException.getLocalMessage("AddCommand.noFilesSpecified", null)); //NOI18N } client.ensureConnection(); clientServices = client; setLocalDirectory(client.getLocalPath()); String directory = client.getLocalPath(); File cvsfolder = new File(directory, "CVS"); if (!cvsfolder.isDirectory()) { //setFailed(); MessageEvent event = new MessageEvent(this, "cvs [add aborted]: there is no version here; do 'cvs checkout' first", true); messageSent(event); em.fireCVSEvent(event); return ; } /* newDirList = new HashMap(); */ newDirList.clear(); super.execute(client, em); requests = new LinkedList(); if (client.isFirstCommand()) { requests.add(new RootRequest(client.getRepository())); } // sets the message argument -m .. one for all files being sent.. String message = getMessage(); if (message != null) { message = message.trim(); } if (message != null && message.length() > 0) { addMessageRequest(message); } if (getKeywordSubst() != null && !getKeywordSubst().equals("")) { //NOI18N requests.add(new ArgumentRequest("-k" + getKeywordSubst())); //NOI18N } try { // current dir sent to server BEFORE and AFTER - kinda hack?? for (int i = 0; i < files.length; i++) { addRequests(files[i]); } // now add the request that indicates the working directory for the // command requests.add(new DirectoryRequest(".", //NOI18N client.getRepositoryForDirectory(getLocalDirectory()))); requests.addAll(argumentRequests); argumentRequests.clear(); // MK sanity check. requests.add(CommandRequest.ADD); client.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } finally { requests.clear(); } } private void addMessageRequest(String message) { requests.add(new ArgumentRequest("-m")); //NOI18N StringTokenizer token = new StringTokenizer(message, "\n", false); //NOI18N boolean first = true; while (token.hasMoreTokens()) { if (first) { requests.add(new ArgumentRequest(token.nextToken())); first = false; } else { requests.add(new ArgumentxRequest(token.nextToken())); } } } /** * This method returns how the command would look like when typed on the * command line. * Each command is responsible for constructing this information. * @returns [] files/dirs. Example: checkout -p CvsCommand.java */ public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("add "); //NOI18N toReturn.append(getCVSArguments()); File[] files = getFiles(); if (files != null) { for (int index = 0; index < files.length; index++) { toReturn.append(files[index].getName()); toReturn.append(' '); } } return toReturn.toString(); } /** * Method that is called while the command is being executed. * Descendants can override this method to return a Builder instance * that will parse the server's output and create data structures. */ public Builder createBuilder(EventManager eventManager) { return new AddBuilder(eventManager, this); } /** * Takes the arguments and sets the command. * To be mainly used for automatic settings (like parsing the .cvsrc file) * @return true if the option (switch) was recognized and set */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'm') { setMessage(optArg); } else if (opt == 'k') { KeywordSubstitutionOptions keywordSubst = KeywordSubstitutionOptions.findKeywordSubstOption(optArg); setKeywordSubst(keywordSubst); } else { return false; } return true; } /** * Returns a string indicating the available options. */ public String getOptString() { return "m:k:"; //NOI18N } /** * Listens for output of the command. * If new directory is added, executes the createCvsFiles() method. */ public void messageSent(MessageEvent e) { String str = e.getMessage(); if (str.endsWith(DIR_ADDED)) { str = str.substring(DIRECTORY.length(), str.indexOf(DIR_ADDED)).trim(); createCvsFiles(str); } super.messageSent(e); } /** * For new directory that was added to the repository, creates the admin * files in CVS subdir. */ private void createCvsFiles(String newDirInRepository) { String repository = newDirInRepository; String dirName = repository; if (dirName.lastIndexOf('/') >= 0) { dirName = dirName.substring(dirName.lastIndexOf('/') + 1, dirName.length()); } if (newDirList.size() == 0) { System.err.println("JavaCVS: Bug in AddCommand|createCvsFiles"); // NOI18N System.err.println(" newDirInRepository = " + newDirInRepository); // NOI18N return; } Paths paths = null; for (Iterator i = newDirList.iterator(); i.hasNext();) { paths = (Paths) i.next(); if (paths.getRepositoryPath().equals(newDirInRepository)) { i.remove(); break; } } String local = paths.getPartPath(); String part = paths.getRepositoryPath(); repository = paths.getRepositoryPath(); String tempDirName = part; if (part.lastIndexOf('/') >= 0) { tempDirName = part.substring(part.lastIndexOf('/') + 1, part.length()); } if (!tempDirName.equalsIgnoreCase(dirName)) { System.err.println("JavaCVS: Bug in AddCommand|createCvsFiles"); // NOI18N System.err.println(" newDirInRepository = " + newDirInRepository); // NOI18N System.err.println(" tempDirName = " + tempDirName); // NOI18N System.err.println(" dirName = " + dirName); // NOI18N return; } try { if (repository.startsWith(".")) { //NOI18N repository = repository.substring(1); } clientServices.updateAdminData(local, repository, null); createCvsTagFile(local, repository); } catch (IOException ex) { System.err.println("TODO: couldn't create/update Cvs admin files"); // NOI18N } /* Iterator it = newDirList.keySet().iterator(); while (it.hasNext()) { String local = (String)it.next(); String part = (String)newDirList.get(local); String tempDirName = part; if (part.lastIndexOf('/') >= 0) { tempDirName = part.substring(part.lastIndexOf('/') + 1, part.length()); } if (tempDirName.equalsIgnoreCase(dirName)) { try { clientServices.updateAdminData(local, repository, null); createCvsTagFile(local, repository); it.remove(); // hack.. in case 2 dirs being added have the same name?? break; } catch (IOException exc) { System.out.println("TODO: couldn't create/update Cvs admin files"); } } } */ } private void createCvsTagFile(String local, String repository) throws IOException { File current = new File(getLocalDirectory(), local); File parent = current.getParentFile(); String tag = clientServices.getStickyTagForDirectory(parent); if (tag != null) { File tagFile = new File(current, "CVS/Tag"); // NOI18N tagFile.createNewFile(); PrintWriter w = new PrintWriter(new BufferedWriter(new FileWriter(tagFile))); w.println(tag); w.close(); } } /** * resets all switches in the command. After calling this method, * the command should have no switches defined and should behave defaultly. */ public void resetCVSCommand() { setMessage(null); setKeywordSubst(null); } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name */ public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(); if (getMessage() != null) { toReturn.append("-m \""); //NOI18N toReturn.append(getMessage()); toReturn.append("\" "); //NOI18N } if (getKeywordSubst() != null) { toReturn.append("-k"); //NOI18N toReturn.append(getKeywordSubst().toString()); toReturn.append(" "); //NOI18N } return toReturn.toString(); } private static class Paths { private final String partPath; private final String repositoryPath; public Paths(String partPath, String repositoryPath) { this.partPath = partPath; this.repositoryPath = repositoryPath; } public String getPartPath() { return partPath; } public String getRepositoryPath() { return repositoryPath; } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/add/AddInformation.java0000644000175300001440000000510211175406776027762 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.add; import org.netbeans.lib.cvsclient.command.*; /** * Describes add information for a file. This is the result of doing a * cvs add command. The fields in instances of this object are populated * by response handlers. * @author Thomas Singer */ public class AddInformation extends DefaultFileInfoContainer { public static final String FILE_ADDED = "A"; //NOI18N public static final String FILE_RESURRECTED = "U"; //NOI18N public AddInformation() { } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/annotate/0000755000175300001440000000000011175434236025274 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/annotate/AnnotateBuilder.java0000644000175300001440000001370411175406776031234 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.annotate; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.event.*; /** * Handles the building of a annotate information object and the firing of * events when complete objects are built. * * @author Milos Kleint */ public class AnnotateBuilder implements Builder { private static final String UNKNOWN = ": nothing known about"; //NOI18N private static final String ANNOTATING = "Annotations for "; //NOI18N private static final String STARS = "***************"; //NOI18N /** * The Annotate object that is currently being built. */ private AnnotateInformation annotateInformation; /** * The event manager to use. */ private final EventManager eventManager; private final String localPath; private String relativeDirectory; private int lineNum; private File tempDir; public AnnotateBuilder(EventManager eventManager, BasicCommand annotateCommand) { this.eventManager = eventManager; this.localPath = annotateCommand.getLocalDirectory(); tempDir = annotateCommand.getGlobalOptions().getTempDir(); } public void outputDone() { if (annotateInformation == null) { return; } try { annotateInformation.closeTempFile(); } catch (IOException exc) { // ignore } eventManager.fireCVSEvent(new FileInfoEvent(this, annotateInformation)); annotateInformation = null; } public void parseLine(String line, boolean isErrorMessage) { if (isErrorMessage && line.startsWith(ANNOTATING)) { outputDone(); annotateInformation = new AnnotateInformation(tempDir); annotateInformation.setFile(createFile(line.substring(ANNOTATING.length()))); lineNum = 0; return; } if (isErrorMessage && line.startsWith(STARS)) { // skip return; } if (!isErrorMessage) { processLines(line); } } private File createFile(String fileName) { return new File(localPath, fileName); } public void parseEnhancedMessage(String key, Object value) { } private void processLines(String line) { if (annotateInformation != null) { try { annotateInformation.addToTempFile(line); } catch (IOException exc) { // just ignore, should not happen.. if it does the worst thing that happens is a annotate info without data.. } } /* AnnotateLine annLine = processLine(line); if (annotateInformation != null && annLine != null) { annLine.setLineNum(lineNum); annotateInformation.addLine(annLine); lineNum++; } */ } public static AnnotateLine processLine(String line) { int indexOpeningBracket = line.indexOf('('); int indexClosingBracket = line.indexOf(')'); AnnotateLine annLine = null; if (indexOpeningBracket > 0 && indexClosingBracket > indexOpeningBracket) { String revision = line.substring(0, indexOpeningBracket).trim(); String userDate = line.substring(indexOpeningBracket + 1, indexClosingBracket); String contents = line.substring(indexClosingBracket + 3); int lastSpace = userDate.lastIndexOf(' '); String user = userDate; String date = userDate; if (lastSpace > 0) { user = userDate.substring(0, lastSpace).trim(); date = userDate.substring(lastSpace).trim(); } annLine = new AnnotateLine(); annLine.setContent(contents); annLine.setAuthor(user); annLine.setDateString(date); annLine.setRevision(revision); } return annLine; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/annotate/AnnotateCommand.java0000644000175300001440000002335411175406776031226 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.annotate; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * The annotate command shows all lines of the file and annotates each line with cvs-related info. * @author Milos Kleint */ public class AnnotateCommand extends BasicCommand { /** * The event manager to use */ protected EventManager eventManager; /** * Use head revision if a revision meeting criteria set by switches -r/-D * (tag/date) is not found. */ private boolean useHeadIfNotFound; /** * equals the -D switch of command line cvs. */ private String annotateByDate; /** * Equals the -r switch of command-line cvs. */ private String annotateByRevision; /** * Construct a new diff command */ public AnnotateCommand() { } /** * Create a builder for this command. * @param eventMan the event manager used to receive events. */ public Builder createBuilder(EventManager eventMan) { return new AnnotateBuilder(eventMan, this); } /** * Execute a command * @param client the client services object that provides any necessary * services to this command, including the ability to actually process * all the requests. */ public void execute(ClientServices client, EventManager em) throws CommandException, AuthenticationException { eventManager = em; client.ensureConnection(); super.execute(client, em); excludeBinaryFiles(requests); try { if (useHeadIfNotFound) { requests.add(1, new ArgumentRequest("-f")); //NOI18N } if (annotateByDate != null && annotateByDate.length() > 0) { requests.add(1, new ArgumentRequest("-D")); //NOI18N requests.add(2, new ArgumentRequest(getAnnotateByDate())); } if (annotateByRevision != null && annotateByRevision.length() > 0) { requests.add(1, new ArgumentRequest("-r")); //NOI18N requests.add(2, new ArgumentRequest(getAnnotateByRevision())); } addRequestForWorkingDirectory(client); addArgumentRequests(); addRequest(CommandRequest.ANNOTATE); client.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } finally { requests.clear(); } } private void excludeBinaryFiles(java.util.List requests) { Iterator it = requests.iterator(); while (it.hasNext()) { Object obj = it.next(); if (obj instanceof EntryRequest) { EntryRequest req = (EntryRequest)obj; if (req.getEntry().isBinary()) { it.remove(); if (it.hasNext()) { // removes also the follwoing modified/unchanged request it.next(); it.remove(); } } } } } /** called when server responses with "ok" or "error", (when the command finishes) */ public void commandTerminated(TerminationEvent e) { if (builder != null) { builder.outputDone(); } } /** * Getter for property useHeadIfNotFound. * @return Value of property useHeadIfNotFound. */ public boolean isUseHeadIfNotFound() { return useHeadIfNotFound; } /** * Setter for property useHeadIfNotFound. * @param useHeadIfNotFound New value of property useHeadIfNotFound. */ public void setUseHeadIfNotFound(boolean useHeadIfNotFound) { this.useHeadIfNotFound = useHeadIfNotFound; } /** * Getter for property annotateByDate. * @return Value of property annotateByDate. */ public String getAnnotateByDate() { return annotateByDate; } /** * Setter for property annotateByDate. * @param annotateByDate New value of property annotateByDate. */ public void setAnnotateByDate(String annotateByDate) { this.annotateByDate = annotateByDate; } /** * Getter for property annotateByRevision. * @return Value of property annotateByRevision. */ public String getAnnotateByRevision() { return annotateByRevision; } /** * Setter for property annotateByRevision. * @param annotateByRevision New value of property annotateByRevision. */ public void setAnnotateByRevision(String annotateByRevision) { this.annotateByRevision = annotateByRevision; } /** * This method returns how the command would looklike when typed on the command line. * Each command is responsible for constructing this information. * @returns [] files/dirs. Example: checkout -p CvsCommand.java */ public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("annotate "); //NOI18N toReturn.append(getCVSArguments()); File[] files = getFiles(); if (files != null) { for (int index = 0; index < files.length; index++) { toReturn.append(files[index].getName() + " "); //NOI18N } } return toReturn.toString(); } /** takes the arguments and sets the command. To be mainly * used for automatic settings (like parsing the .cvsrc file) * @return true if the option (switch) was recognized and set */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'R') { setRecursive(true); } else if (opt == 'l') { setRecursive(false); } else if (opt == 'r') { setAnnotateByRevision(optArg); } else if (opt == 'D') { setAnnotateByDate(optArg); } else if (opt == 'f') { setUseHeadIfNotFound(true); } else { return false; } return true; } /** * String returned by this method defines which options are available for this particular command */ public String getOptString() { return "Rlr:D:f"; //NOI18N } /** * resets all switches in the command. After calling this method, * the command should have no switches defined and should behave defaultly. */ public void resetCVSCommand() { setRecursive(true); setAnnotateByDate(null); setAnnotateByRevision(null); setUseHeadIfNotFound(false); } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name */ public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(""); //NOI18N if (!isRecursive()) { toReturn.append("-l "); //NOI18N } if (getAnnotateByRevision() != null) { toReturn.append("-r "); //NOI18N toReturn.append(getAnnotateByRevision()); toReturn.append(" "); //NOI18N } if (getAnnotateByDate() != null) { toReturn.append("-D "); //NOI18N toReturn.append(getAnnotateByDate()); toReturn.append(" "); //NOI18N } if (isUseHeadIfNotFound()) { toReturn.append("-f "); //NOI18N } return toReturn.toString(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/annotate/AnnotateInformation.java0000644000175300001440000001371411175406776032134 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.annotate; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.command.*; /** * Describes annotate information for a file. This is the result of doing a * cvs annotate command. The fields in instances of this object are populated * by response handlers. * @author Milos Kleint */ public class AnnotateInformation extends FileInfoContainer { /** * The file, associated with thiz. */ private File file; /** * List of lines stored here. */ private List linesList; private Iterator iterator; private File tempFile; private File tempDir; private BufferedOutputStream tempOutStream; public AnnotateInformation() { this.tempDir = null; } public AnnotateInformation(File tempDir) { this.tempDir = tempDir; } /** * Getter for property file. * @return Value of property file. */ public File getFile() { return file; } /** * Setter for property file. * @param file New value of property file. */ public void setFile(File file) { this.file = file; } /** * Return a string representation of this object. Useful for debugging. */ public String toString() { StringBuffer buf = new StringBuffer(30); buf.append("\nFile: " + ((file != null)?file.getAbsolutePath():"null")); //NOI18N return buf.toString(); } public AnnotateLine createAnnotateLine() { return new AnnotateLine(); } public void addLine(AnnotateLine line) { linesList.add(line); } public AnnotateLine getFirstLine() { if (linesList == null) { linesList = createLinesList(); } iterator = linesList.iterator(); return getNextLine(); } public AnnotateLine getNextLine() { if (iterator == null) { return null; } if (!iterator.hasNext()) { return null; } return (AnnotateLine)iterator.next(); } /** * Adds the specified line to the temporary file. */ protected void addToTempFile(String line) throws IOException { if (tempOutStream == null) { try { tempFile = File.createTempFile("ann", ".cvs", tempDir); //NOI18N tempFile.deleteOnExit(); tempOutStream = new BufferedOutputStream( new FileOutputStream(tempFile)); } catch (IOException ex) { // TODO } } tempOutStream.write(line.getBytes()); tempOutStream.write('\n'); } protected void closeTempFile() throws IOException { if (tempOutStream == null) { return; } try { tempOutStream.flush(); } finally { tempOutStream.close(); } } public File getTempFile() { return tempFile; } private List createLinesList() { List toReturn = new LinkedList(); BufferedReader reader = null; if (tempFile == null) { return toReturn; } try { reader = new BufferedReader(new FileReader(tempFile)); String line = reader.readLine(); int lineNum = 1; while (line != null) { AnnotateLine annLine = AnnotateBuilder.processLine(line); if (annLine != null) { annLine.setLineNum(lineNum); toReturn.add(annLine); lineNum++; } line = reader.readLine(); } } catch (IOException exc) { } finally { try { if (reader != null) { reader.close(); } } catch (IOException ex2) { } } return toReturn; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/annotate/AnnotateLine.java0000644000175300001440000001050011175406776030524 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.annotate; import java.text.*; import java.util.*; /** * @author Thomas Singer */ public class AnnotateLine { private static final DateFormat DATE_FORMAT = new SimpleDateFormat("dd-MMM-yy", //NOI18N Locale.US); private String author; private String revision; private Date date; private String dateString; private String content; private int lineNum; public AnnotateLine() { } /** * Returns the author of this line. */ public String getAuthor() { return author; } /** * Sets the author of this line. */ public void setAuthor(String author) { this.author = author; } /** * Returns the revision of this line. */ public String getRevision() { return revision; } /** * Sets the revision of this line. */ public void setRevision(String revision) { this.revision = revision; } /** * Returns the date of this line. */ public Date getDate() { return date; } /** * Returns the date in original String-representation of this line. */ public String getDateString() { return dateString; } /** * Sets the date of this line. */ public void setDateString(String dateString) { this.dateString = dateString; try { this.date = DATE_FORMAT.parse(dateString); } catch (ParseException ex) { // print stacktrace, because it's a bug ex.printStackTrace(); } } /** * Return the line's content. */ public String getContent() { return content; } /** * Sets the line's content. */ public void setContent(String content) { this.content = content; } /** * Returns the line's number. It's 1 based. */ public int getLineNum() { return lineNum; } /** * Returns the line's number. */ public Integer getLineNumInteger() { return new Integer(lineNum); } /** * Sets the line's number. */ public void setLineNum(int lineNum) { this.lineNum = lineNum; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/annotate/RannotateCommand.java0000644000175300001440000002734311175406776031412 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.annotate; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * The rannotate command is similar to anootate, but doens't operate on currently checked * out sources. * * @author MIlos Kleint */ public class RannotateCommand extends BasicCommand { /** * The modules to checkout. These names are unexpanded and will be passed * to a module-expansion request. */ private final List modules = new LinkedList(); /** * The expanded modules. */ private final List expandedModules = new LinkedList(); /** * Use head revision if a revision meeting criteria set by switches -r/-D * (tag/date) is not found. */ private boolean useHeadIfNotFound; /** * equals the -D switch of command line cvs. */ private String annotateByDate; /** * Equals the -r switch of command-line cvs. */ private String annotateByRevision; /** * Holds value of property headerAndDescOnly. */ private boolean headerAndDescOnly; public RannotateCommand() { resetCVSCommand(); } /** * Set the modules to export. * @param theModules the names of the modules to export */ public void setModule(String module) { modules.add(module); } /** * clears the list of modules for export. */ public void clearModules() { this.modules.clear(); } /** * Set the modules to export. * @param theModules the names of the modules to export */ public void setModules(String[] modules) { clearModules(); if (modules == null) { return; } for (int i = 0; i < modules.length; i++) { String module = modules[i]; this.modules.add(module); } } public String[] getModules() { String[] mods = new String[modules.size()]; mods = (String[])modules.toArray(mods); return mods; } private void processExistingModules(String localPath) { if (expandedModules.size() == 0) { return; } String[] directories = new String[expandedModules.size()]; directories = (String[])expandedModules.toArray(directories); setModules(directories); } /** * Execute this command. * @param client the client services object that provides any necessary * services to this command, including the ability to actually process * all the requests */ public void execute(ClientServices client, EventManager em) throws CommandException, AuthenticationException { client.ensureConnection(); requests = new LinkedList(); if (client.isFirstCommand()) { requests.add(new RootRequest(client.getRepository())); } for (Iterator it = modules.iterator(); it.hasNext();) { String module = (String)it.next(); requests.add(new ArgumentRequest(module)); } expandedModules.clear(); requests.add(new DirectoryRequest(".", client.getRepository())); //NOI18N requests.add(new ExpandModulesRequest()); try { client.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } requests.clear(); postExpansionExecute(client, em); } /** * This is called when the server has responded to an expand-modules * request. */ public void moduleExpanded(ModuleExpansionEvent e) { expandedModules.add(e.getModule()); } /** * Execute this command * @param client the client services object that provides any necessary * services to this command, including the ability to actually process * all the requests */ private void postExpansionExecute(ClientServices client, EventManager em) throws CommandException, AuthenticationException { // processExistingModules(client.getLocalPath()); super.execute(client, em); // // moved modules code to the end of the other arguments --GAR // if (!isRecursive()) { requests.add(1, new ArgumentRequest("-l")); //NOI18N } if (useHeadIfNotFound) { requests.add(1, new ArgumentRequest("-f")); //NOI18N } if (annotateByDate != null && annotateByDate.length() > 0) { requests.add(1, new ArgumentRequest("-D")); //NOI18N requests.add(2, new ArgumentRequest(getAnnotateByDate())); } if (annotateByRevision != null && annotateByRevision.length() > 0) { requests.add(1, new ArgumentRequest("-r")); //NOI18N requests.add(2, new ArgumentRequest(getAnnotateByRevision())); } for (Iterator it = modules.iterator(); it.hasNext();) { String module = (String)it.next(); requests.add(new ArgumentRequest(module)); } requests.add(new DirectoryRequest(".", client.getRepository())); //NOI18N requests.add(CommandRequest.RANNOTATE); try { client.processRequests(requests); requests.clear(); } catch (CommandException ex) { throw ex; } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } } public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("rannotate "); //NOI18N toReturn.append(getCVSArguments()); if (modules != null && modules.size() > 0) { for (Iterator it = modules.iterator(); it.hasNext();) { String module = (String)it.next(); toReturn.append(module); toReturn.append(' '); } } else { String localizedMsg = CommandException.getLocalMessage("ExportCommand.moduleEmpty.text"); //NOI18N toReturn.append(" "); //NOI18N toReturn.append(localizedMsg); } return toReturn.toString(); } public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(""); //NOI18N if (!isRecursive()) { toReturn.append("-l "); //NOI18N } if (getAnnotateByRevision() != null) { toReturn.append("-r "); //NOI18N toReturn.append(getAnnotateByRevision()); toReturn.append(" "); //NOI18N } if (getAnnotateByDate() != null) { toReturn.append("-D "); //NOI18N toReturn.append(getAnnotateByDate()); toReturn.append(" "); //NOI18N } if (isUseHeadIfNotFound()) { toReturn.append("-f "); //NOI18N } return toReturn.toString(); } public boolean setCVSCommand(char opt, String optArg) { if (opt == 'R') { setRecursive(true); } else if (opt == 'l') { setRecursive(false); } else if (opt == 'r') { setAnnotateByRevision(optArg); } else if (opt == 'D') { setAnnotateByDate(optArg); } else if (opt == 'f') { setUseHeadIfNotFound(true); } else { return false; } return true; } public void resetCVSCommand() { setRecursive(true); setAnnotateByDate(null); setAnnotateByRevision(null); setUseHeadIfNotFound(false); } /** * String returned by this method defines which options are available for this particular command */ public String getOptString() { return "Rlr:D:f"; //NOI18N } /** * Create a builder for this command. * @param eventMan the event manager used to receive events. */ public Builder createBuilder(EventManager eventMan) { return new AnnotateBuilder(eventMan, this); } /** called when server responses with "ok" or "error", (when the command finishes) */ public void commandTerminated(TerminationEvent e) { if (builder != null) { builder.outputDone(); } } /** * Getter for property useHeadIfNotFound. * @return Value of property useHeadIfNotFound. */ public boolean isUseHeadIfNotFound() { return useHeadIfNotFound; } /** * Setter for property useHeadIfNotFound. * @param useHeadIfNotFound New value of property useHeadIfNotFound. */ public void setUseHeadIfNotFound(boolean useHeadIfNotFound) { this.useHeadIfNotFound = useHeadIfNotFound; } /** * Getter for property annotateByDate. * @return Value of property annotateByDate. */ public String getAnnotateByDate() { return annotateByDate; } /** * Setter for property annotateByDate. * @param annotateByDate New value of property annotateByDate. */ public void setAnnotateByDate(String annotateByDate) { this.annotateByDate = annotateByDate; } /** * Getter for property annotateByRevision. * @return Value of property annotateByRevision. */ public String getAnnotateByRevision() { return annotateByRevision; } /** * Setter for property annotateByRevision. * @param annotateByRevision New value of property annotateByRevision. */ public void setAnnotateByRevision(String annotateByRevision) { this.annotateByRevision = annotateByRevision; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/checkout/0000755000175300001440000000000011175434236025270 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/checkout/CheckoutCommand.java0000644000175300001440000007315111175406776031216 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.command.checkout; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.command.update.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * The checkout command. * This handles the sending of the requests and the processing of the responses * from the server. * * @author Robert Greig */ public class CheckoutCommand extends BasicCommand implements TemporaryFileCreator { private static final String UPDATING = ": Updating "; // NOI18N /** * A store of potentially empty directories. When a directory has a file * in it, it is removed from this set. This set allows the prune option * to be implemented. */ private final Set emptyDirectories = new HashSet(); /** * The modules to checkout. These names are unexpanded and will be passed * to a module-expansion request. */ private final List modules = new LinkedList(); /** * The expanded modules. */ private final List expandedModules = new LinkedList(); /** * Will force the checkout command to display only a list of modules. */ private boolean showModules; /** * if set, will display just a list of modules with statuses. */ private boolean showModulesWithStatus; /** * if set, will redirect the output of the command to standard output. */ private boolean pipeToOutput; /** * Whether to prune directories, i.e. remove any directories that do not * contain any files. This is the -P option in command-line CVS. */ private boolean pruneDirectories; /** * Resets any sticky tags/dates/options imposed on the updated file(s). */ private boolean resetStickyOnes; /** * Use head revision if a revision meeting criteria set by switches -r/-D * (tag/date) is not found. */ private boolean useHeadIfNotFound; /** * Don't shorten module paths if -d specified. */ private boolean notShortenPaths; /** * Whether notShortenPaths was explicitly set. */ private boolean isNotShortenSet; /** * Forces a checkout of a revision that was current at specified date. */ private String checkoutByDate; /** * Forces a checkout of specified revision. Can be a number/tag/branch */ private String checkoutByRevision; /** * performs checkout to specified directory other then the module. */ private String checkoutDirectory; /** * Use this keyword substitution for the command. * does not include the -k switch part. */ private KeywordSubstitutionOptions keywordSubst; /** * Do not run module program (if any). */ private boolean notRunModuleProgram; /** Active during execute. */ private ClientServices client; /** * Construct a new checkout command. * @param recursive whether to do a recursive checkout * @param modules an array of modules names to checkout */ public CheckoutCommand(boolean recursive, String[] modules) { resetCVSCommand(); setRecursive(recursive); setModules(modules); } /** * Construct a new checkout command. * @param recursive whether to do a recursive checkout * @param module the module to checkout */ public CheckoutCommand(boolean recursive, String module) { resetCVSCommand(); setRecursive(recursive); setModule(module); } /** * Construct a checkout command, with default values for options. */ public CheckoutCommand() { resetCVSCommand(); setRecursive(true); } /** * Set the modules to checkout. * @param theModules the names (it's like relative path) of the modules to checkout */ public void setModule(String module) { modules.add(module); } /** * clears the list of modules for checkout. */ public void clearModules() { this.modules.clear(); } /** * Set the modules to checkout. * @param theModules the names of the modules to checkout */ public void setModules(String[] modules) { clearModules(); for (int i = 0; i < modules.length; i++) { String module = modules[i]; this.modules.add(module); } } public String[] getModules() { String[] mods = new String[modules.size()]; mods = (String[])modules.toArray(mods); return mods; } /** * Handle modules that are already checked out. We check whether a * module has been checked out and if so we add it to the list of * directories that the superclass must send Modified requests for etc. */ private void processExistingModules(String localPath) { if (expandedModules.size() == 0) { return; } List list = new ArrayList(expandedModules.size()); for (Iterator it = expandedModules.iterator(); it.hasNext();) { String moduleName = (String)it.next(); if (moduleName.equals(".")) { //NOI18N list.add(new File(localPath)); break; } File moduleDir = null; final File moduleFile = new File(localPath, moduleName); if (moduleFile.isFile()) { moduleDir = moduleFile.getParentFile(); } else { moduleDir = moduleFile; } final File moduleCVSDir = new File(moduleDir, "CVS/Repository"); //NOI18N if (moduleCVSDir.exists()) { list.add(moduleFile); } } File[] directories = new File[list.size()]; directories = (File[])list.toArray(directories); setFiles(directories); } /** * Execute this command. * @param client the client services object that provides any necessary * services to this command, including the ability to actually process * all the requests */ public void execute(ClientServices client, EventManager em) throws CommandException, AuthenticationException { client.ensureConnection(); this.client = client; try { requests = new LinkedList(); if (client.isFirstCommand()) { requests.add(new RootRequest(client.getRepository())); } if (showModules || showModulesWithStatus) { // we need to initialize the builder first (is done in BuildableCommand.execute() // but we can't run it because of teh BasicCommand's execute and // it's feature that adds the files request to the request list. if (builder == null && !isBuilderSet()) { builder = createBuilder(em); } // special handling for -c -s switches. if (showModules) { requests.add(new ArgumentRequest("-c")); //NOI18N } if (showModulesWithStatus) { requests.add(new ArgumentRequest("-s")); //NOI18N } requests.add(CommandRequest.CHECKOUT); try { client.processRequests(requests); requests.clear(); } catch (CommandException ex) { throw ex; } catch (EOFException ex) { throw new CommandException(ex, CommandException.getLocalMessage("CommandException.EndOfFile", null)); //NOI18N } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } return; } for (Iterator it = modules.iterator(); it.hasNext();) { String module = (String)it.next(); requests.add(new ArgumentRequest(module)); } expandedModules.clear(); requests.add(new DirectoryRequest(".", client.getRepository())); //NOI18N requests.add(new RootRequest(client.getRepository())); requests.add(new ExpandModulesRequest()); try { client.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } requests.clear(); postExpansionExecute(client, em); } finally { this.client = null; } } /** * The result from this command is used only when the getFiles() returns null or empty array. * in such a case and when this method returns true, it is assumed the localpath should be taken * as the 'default' file for the building of requests. * in checkout we operate with modules rather then files. This produces problems in the following situation. * If you have something already checked out and want to checkout another module that is not checked out yet, * then there's nothing to be translated from modules to files. and in such a case the localpathis assumed, * which includes non-relevant already checked out directories.. */ protected boolean assumeLocalPathWhenUnspecified() { return false; } /** * This is called when the server has responded to an expand-modules * request. */ public void moduleExpanded(ModuleExpansionEvent e) { expandedModules.add(e.getModule()); } /** * Execute this command * @param client the client services object that provides any necessary * services to this command, including the ability to actually process * all the requests */ private void postExpansionExecute(ClientServices client, EventManager em) throws CommandException, AuthenticationException { // we first test whether the modules specified actually exist // checked out already. If so, we must work something like an update // command and send modified files to the server. processExistingModules(client.getLocalPath()); // the sending of the Modified requests and so on is handled in the // superclass. super.execute(client, em); // // moved modules code to the end of the other arguments --GAR // int index = requests.size(); final int FIRST_INDEX = 0; final int SECOND_INDEX = 1; if (!isRecursive()) { requests.add(FIRST_INDEX, new ArgumentRequest("-l")); //NOI18N } if (pipeToOutput) { requests.add(FIRST_INDEX, new ArgumentRequest("-p")); //NOI18N } if (resetStickyOnes) { requests.add(FIRST_INDEX, new ArgumentRequest("-A")); //NOI18N } if (useHeadIfNotFound) { requests.add(FIRST_INDEX, new ArgumentRequest("-f")); //NOI18N } if (isNotShortenPaths()) { requests.add(FIRST_INDEX, new ArgumentRequest("-N")); //NOI18N } if (notRunModuleProgram) { requests.add(FIRST_INDEX, new ArgumentRequest("-n")); //NOI18N } if (checkoutByDate != null && checkoutByDate.length() > 0) { requests.add(FIRST_INDEX, new ArgumentRequest("-D")); //NOI18N requests.add(SECOND_INDEX, new ArgumentRequest(getCheckoutByDate())); } if (checkoutByRevision != null && checkoutByRevision.length() > 0) { requests.add(FIRST_INDEX, new ArgumentRequest("-r")); //NOI18N requests.add(SECOND_INDEX, new ArgumentRequest(getCheckoutByRevision())); } if (checkoutDirectory != null && (!checkoutDirectory.equals(""))) { requests.add(FIRST_INDEX, new ArgumentRequest("-d")); //NOI18N requests.add(SECOND_INDEX, new ArgumentRequest(getCheckoutDirectory())); } if (getKeywordSubst() != null) { requests.add(FIRST_INDEX, new ArgumentRequest("-k" + getKeywordSubst())); //NOI18N } index = requests.size() - index; // The end of our arguments // Add a -- before the first file name just in case it looks like an option. requests.add(index++, new ArgumentRequest("--")); // NOI18N // Note that modules might be null and still be valid because // for -c, -s switches no module has to be selected // You might also think that we should pass in expandedModules here // but according to the spec that would be wrong because of the -d // flag. for (Iterator it = modules.iterator(); it.hasNext();) { String module = (String)it.next(); requests.add(index++, new ArgumentRequest(module)); } requests.add(new DirectoryRequest(".", client.getRepository())); //NOI18N requests.add(CommandRequest.CHECKOUT); try { client.processRequests(requests); if (pruneDirectories) { pruneEmptyDirectories(); } requests.clear(); } catch (CommandException ex) { throw ex; } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } } /** * Getter for property showModules. * @return Value of property showModules. */ public boolean isShowModules() { return showModules; } /** * Setter for property showModules. * @param showModules New value of property showModules. */ public void setShowModules(boolean showModules) { this.showModules = showModules; } /** * Getter for property showModulesWithStatus. * @return Value of property showModulesWithStatus. */ public boolean isShowModulesWithStatus() { return showModulesWithStatus; } /** * Setter for property showModulesWithStatus. * @param showModulesWithStatus New value of property showModulesWithStatus. */ public void setShowModulesWithStatus(boolean showModulesWithStatus) { this.showModulesWithStatus = showModulesWithStatus; } /** * Set whether to prune directories. * This is the -P option in the command-line CVS. */ public void setPruneDirectories(boolean pruneDirectories) { this.pruneDirectories = pruneDirectories; } /** * Get whether to prune directories. * @return true if directories should be removed if they contain no files, * false otherwise. */ public boolean getPruneDirectories() { return pruneDirectories; } /** * Getter for property pipeToOutput. * @return Value of property pipeToOutput. */ public boolean isPipeToOutput() { return pipeToOutput; } /** * Setter for property pipeToOutput. * @param pipeToOutput New value of property pipeToOutput. */ public void setPipeToOutput(boolean pipeToOutput) { this.pipeToOutput = pipeToOutput; } /** * Getter for property resetStickyOnes. * @return Value of property resetStickyOnes. */ public boolean isResetStickyOnes() { return resetStickyOnes; } /** * Setter for property resetStickyOnes. * @param resetStickyOnes New value of property resetStickyOnes. */ public void setResetStickyOnes(boolean resetStickyOnes) { this.resetStickyOnes = resetStickyOnes; } /** * Getter for property useHeadIfNotFound. * @return Value of property useHeadIfNotFound. */ public boolean isUseHeadIfNotFound() { return useHeadIfNotFound; } /** * Setter for property useHeadIfNotFound. * @param useHeadIfNotFound New value of property useHeadIfNotFound. */ public void setUseHeadIfNotFound(boolean useHeadIfNotFound) { this.useHeadIfNotFound = useHeadIfNotFound; } /** * Getter for property notShortenPaths. * @return Value of property notShortenPaths. */ public boolean isNotShortenPaths() { // Use the same logic as cvs from cvshome.org. return notShortenPaths || (!isNotShortenSet && checkoutDirectory == null); } /** * Setter for property notShortenPaths. * @param notShortenPaths New value of property notShortenPaths. */ public void setNotShortenPaths(boolean notShortenPaths) { this.notShortenPaths = notShortenPaths; isNotShortenSet = true; } /** * Getter for property notRunModuleProgram. * @return Value of property notRunModuleProgram. */ public boolean isNotRunModuleProgram() { return notRunModuleProgram; } /** * Setter for property notRunModuleProgram. * @param notRunModuleProgram New value of property notRunModuleProgram. */ public void setNotRunModuleProgram(boolean notRunModuleProgram) { this.notRunModuleProgram = notRunModuleProgram; } /** * Getter for property checkoutByDate. * @return Value of property checkoutByDate. */ public String getCheckoutByDate() { return checkoutByDate; } /** * Setter for property checkoutByDate. * @param checkoutByDate New value of property checkoutByDate. */ public void setCheckoutByDate(String checkoutByDate) { this.checkoutByDate = checkoutByDate; } /** * Getter for property checkoutByRevision. * @return Value of property checkoutByRevision. */ public String getCheckoutByRevision() { return checkoutByRevision; } /** * Setter for property checkoutByRevision. * @param checkoutByRevision New value of property checkoutByRevision. */ public void setCheckoutByRevision(String checkoutByRevision) { this.checkoutByRevision = checkoutByRevision; } /** Getter for property checkoutDirectory. * @return Value of property checkoutDirectory. */ public String getCheckoutDirectory() { return this.checkoutDirectory; } /** Setter for property checkoutDirectory. * @param checkoutDirectory New value of property checkoutDirectory. */ public void setCheckoutDirectory(String checkoutDirectory) { this.checkoutDirectory = checkoutDirectory; } /** * Getter for property keywordSubst. * @return Value of property keywordSubst. */ public KeywordSubstitutionOptions getKeywordSubst() { return keywordSubst; } /** * Setter for property keywordSubst. * @param keywordSubst New value of property keywordSubst. */ public void setKeywordSubst(KeywordSubstitutionOptions keywordSubst) { this.keywordSubst = keywordSubst; } public Builder createBuilder(EventManager eventMan) { if (isShowModules() || isShowModulesWithStatus()) { return new ModuleListBuilder(eventMan, this); } if (isPipeToOutput()) { return new PipedFilesBuilder(eventMan, this, this); } return new UpdateBuilder(eventMan, getLocalDirectory()); } public File createTempFile(String filename) throws IOException { File temp = File.createTempFile("cvs", ".dff", getGlobalOptions().getTempDir()); //NOI18N temp.deleteOnExit(); return temp; } /** * This method returns how the command would looklike when typed on the command line. * Each command is responsible for constructing this information. * @returns [] files/dirs. Example: checkout -p CvsCommand.java */ public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("checkout "); //NOI18N toReturn.append(getCVSArguments()); if (!isShowModules() && !isShowModulesWithStatus()) { for (Iterator it = modules.iterator(); it.hasNext();) { String module = (String)it.next(); toReturn.append(module); toReturn.append(' '); } } return toReturn.toString(); } /** * Takes the arguments and sets the command. * To be mainly used for automatic settings (like parsing the .cvsrc file). * @return true if the option (switch) was recognized and set */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'c') { setShowModules(true); } else if (opt == 's') { setShowModulesWithStatus(true); } else if (opt == 'p') { setPipeToOutput(true); } else if (opt == 'R') { setRecursive(true); } else if (opt == 'l') { setRecursive(false); } else if (opt == 'A') { setResetStickyOnes(true); } else if (opt == 'f') { setUseHeadIfNotFound(true); } else if (opt == 'P') { setPruneDirectories(true); } else if (opt == 'D') { setCheckoutByDate(optArg.trim()); } else if (opt == 'r') { setCheckoutByRevision(optArg.trim()); } else if (opt == 'd') { setCheckoutDirectory(optArg); } else if (opt == 'N') { setNotShortenPaths(true); } else if (opt == 'n') { setNotRunModuleProgram(true); } else if (opt == 'k') { KeywordSubstitutionOptions keywordSubst = KeywordSubstitutionOptions.findKeywordSubstOption(optArg); setKeywordSubst(keywordSubst); } else { return false; } return true; } /** * String returned by this method defines which options are available for this particular command */ public String getOptString() { return "cnpslNPRAD:r:fk:d:"; //NOI18N } /** * Resets all switches in the command. * After calling this method, the command should have no switches defined * and should behave defaultly. */ public void resetCVSCommand() { setShowModules(false); setShowModulesWithStatus(false); setPipeToOutput(false); setRecursive(true); setResetStickyOnes(false); setUseHeadIfNotFound(false); setCheckoutByDate(null); setCheckoutByRevision(null); setKeywordSubst(null); setPruneDirectories(false); setNotShortenPaths(false); isNotShortenSet = false; setNotRunModuleProgram(false); setCheckoutDirectory(null); } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name */ public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(""); //NOI18N if (isShowModules()) { toReturn.append("-c "); //NOI18N } if (isShowModulesWithStatus()) { toReturn.append("-s "); //NOI18N } if (isPipeToOutput()) { toReturn.append("-p "); //NOI18N } if (!isRecursive()) { toReturn.append("-l "); //NOI18N } if (isResetStickyOnes()) { toReturn.append("-A "); //NOI18N } if (isUseHeadIfNotFound()) { toReturn.append("-f "); //NOI18N } if (getPruneDirectories()) { toReturn.append("-P "); //NOI18N } if (isNotShortenPaths()) { toReturn.append("-N "); // NOI18N } if (isNotRunModuleProgram()) { toReturn.append("-n "); // NOI18N } if (getKeywordSubst() != null) { toReturn.append("-k"); //NOI18N toReturn.append(getKeywordSubst()); toReturn.append(' '); } if (getCheckoutByRevision() != null && getCheckoutByRevision().length() > 0) { toReturn.append("-r "); //NOI18N toReturn.append(getCheckoutByRevision()); toReturn.append(' '); } if (getCheckoutByDate() != null && getCheckoutByDate().length() > 0) { toReturn.append("-D "); //NOI18N toReturn.append(getCheckoutByDate()); toReturn.append(' '); } if (getCheckoutDirectory() != null) { toReturn.append("-d "); //NOI18N toReturn.append(getCheckoutDirectory()); toReturn.append(" "); //NOI18N } return toReturn.toString(); } /** * Called when the server wants to send a message to be displayed to * the user. The message is only for information purposes and clients * can choose to ignore these messages if they wish. * @param e the event */ public void messageSent(MessageEvent e) { super.messageSent(e); // we use this event to determine which directories need to be checked // for updating if (pruneDirectories && e.getMessage().indexOf(UPDATING) > 0) { String relPath = e.getMessage().substring(e.getMessage().indexOf(UPDATING) + UPDATING.length()); File file = new File(getLocalDirectory(), relPath); // do not consider the topmost directory for pruning if (relPath.indexOf('/') != -1) { emptyDirectories.add(file); } } } /** * Prunes a directory, recursively pruning its subdirectories * @param directory the directory to prune */ private boolean pruneEmptyDirectory(File directory) throws IOException { boolean empty = true; final File[] contents = directory.listFiles(); // should never be null, but just in case... if (contents != null) { for (int i = 0; i < contents.length; i++) { if (contents[i].isFile()) { empty = false; } else { if (!contents[i].getName().equals("CVS")) { //NOI18N empty = pruneEmptyDirectory(contents[i]); } } if (!empty) { break; } } if (empty) { // check this is a CVS directory and not some directory the user // has stupidly called CVS... final File entriesFile = new File(directory, "CVS/Entries"); //NOI18N if (entriesFile.exists()) { final File adminDir = new File(directory, "CVS"); //NOI18N final File[] adminFiles = adminDir.listFiles(); for (int i = 0; i < adminFiles.length; i++) { adminFiles[i].delete(); } adminDir.delete(); directory.delete(); client.removeEntry(directory); } } } return empty; } /** * Remove any directories that don't contain any files */ private void pruneEmptyDirectories() throws IOException { final Iterator it = emptyDirectories.iterator(); while (it.hasNext()) { final File dir = (File)it.next(); // we might have deleted it already (due to recursive delete) // so we need to check existence if (dir.exists()) { pruneEmptyDirectory(dir); } } emptyDirectories.clear(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/checkout/ModuleListBuilder.java0000644000175300001440000001030311175406776031530 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.checkout; import java.util.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.event.*; /** * Handles the building of module list information object and the firing of * events when complete objects are built. * * @author Milos Kleint */ public class ModuleListBuilder implements Builder { /** * The module object that is currently being built. */ private ModuleListInformation moduleInformation; /** * The event manager to use. */ private final EventManager eventManager; private final CheckoutCommand checkoutCommand; public ModuleListBuilder(EventManager eventMan, CheckoutCommand comm) { eventManager = eventMan; checkoutCommand = comm; } public void outputDone() { if (moduleInformation != null) { eventManager.fireCVSEvent(new FileInfoEvent(this, moduleInformation)); moduleInformation = null; } } public void parseLine(String line, boolean isErrorMessage) { line = line.replace('\t', ' '); if (!line.startsWith(" ")) { //NOI18N processModule(line, true); } else { processModule(line, false); } } protected void processModule(String line, boolean firstLine) { StringTokenizer tok = new StringTokenizer(line, " ", false); //NOI18N if (firstLine) { outputDone(); moduleInformation = new ModuleListInformation(); String modName = tok.nextToken(); moduleInformation.setModuleName(modName); if (checkoutCommand.isShowModulesWithStatus()) { String stat = tok.nextToken(); moduleInformation.setModuleStatus(stat); } } while (tok.hasMoreTokens()) { String nextTok = tok.nextToken(); if (nextTok.startsWith("-")) { //NOI18N moduleInformation.setType(nextTok); continue; } moduleInformation.addPath(nextTok); } } public void parseEnhancedMessage(String key, Object value) { } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/checkout/ModuleListInformation.java0000644000175300001440000000653511175406776032443 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.checkout; import java.io.*; import org.netbeans.lib.cvsclient.command.*; /** * Object containing information about various modules defined in the repository. * Is parsed from the output of cvs checkout -c and cvs checkout -s. * @author Milos Kleint */ public class ModuleListInformation extends FileInfoContainer { private String moduleName; private String moduleStatus; private final StringBuffer paths = new StringBuffer(); private String type; public ModuleListInformation() { } public String getModuleName() { return moduleName; } public void setModuleName(String moduleName) { this.moduleName = moduleName; } public String getModuleStatus() { return moduleStatus; } public void setModuleStatus(String moduleStatus) { this.moduleStatus = moduleStatus; } public String getPaths() { return paths.toString(); } public void addPath(String path) { if (paths.length() > 0) { paths.append(' '); } paths.append(path); } public File getFile() { return null; } public String getType() { return type; } public void setType(String type) { this.type = type; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/commit/0000755000175300001440000000000011175434236024753 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/commit/CommitBuilder.java0000644000175300001440000002503011175406777030366 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.commit; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.event.*; /** * Handles the building of update information object and the firing of * events when complete objects are built. * * @author Milos Kleint */ public class CommitBuilder implements Builder { /** * Parsing constants. */ public static final String UNKNOWN = "commit: nothing known about `"; //NOI18N public static final String EXAM_DIR = ": Examining"; //NOI18N public static final String REMOVING = "Removing "; //NOI18N public static final String NEW_REVISION = "new revision:"; //NOI18N public static final String INITIAL_REVISION = "initial revision:"; //NOI18N public static final String DELETED_REVISION = "delete"; //NOI18N public static final String DONE = "done"; //NOI18N public static final String RCS_FILE = "RCS file: "; //NOI18N public static final String ADD = "commit: use `cvs add' to create an entry for "; //NOI18N public static final String COMMITTED = " <-- "; // NOI18N /** * The status object that is currently being built. */ private CommitInformation commitInformation; /** * The directory in which the file being processed lives. This is * absolute inside the local directory */ private File fileDirectory; /** * The event manager to use. */ private final EventManager eventManager; private final String localPath; private final String repositoryRoot; private boolean isAdding; public CommitBuilder(EventManager eventManager, String localPath, String repositoryRoot) { this.eventManager = eventManager; this.localPath = localPath; this.repositoryRoot = repositoryRoot; } public void outputDone() { if (commitInformation != null) { eventManager.fireCVSEvent(new FileInfoEvent(this, commitInformation)); commitInformation = null; } } public void parseLine(String line, boolean isErrorMessage) { int c; if (line.indexOf(UNKNOWN) >= 0) { outputDone(); processUnknownFile(line.substring(line.indexOf(UNKNOWN) + UNKNOWN.length()).trim()); } else if (line.indexOf(ADD) > 0) { processToAddFile(line.substring(line.indexOf(ADD) + ADD.length()).trim()); } else if ((c = line.indexOf(COMMITTED)) > 0) { outputDone(); String fileName = line.substring(c + COMMITTED.length()).trim(); int nameIndex = fileName.lastIndexOf('/'); if (nameIndex != -1) { //#73181 happens with 1.12 servers: /usr/cvsrepo/Java112/nbproject/project.properties,v <-- nbproject/project.properties fileName = fileName.substring(nameIndex+1); } File file; if (fileDirectory == null) { String reposPath = line.substring(0, c).trim(); if (reposPath.startsWith(repositoryRoot)) { reposPath = reposPath.substring(repositoryRoot.length()); if (reposPath.startsWith("/")) reposPath = reposPath.substring(1); } c = reposPath.lastIndexOf('/'); if (c > 0) reposPath = reposPath.substring(0, c); // remove the file name file = findFile(fileName, reposPath); } else { file = new File(fileDirectory, fileName); } processFile(file); if (isAdding) { commitInformation.setType(CommitInformation.ADDED); isAdding = false; } else { commitInformation.setType(CommitInformation.CHANGED); } } else if (line.startsWith(REMOVING)) { outputDone(); processFile(line.substring(REMOVING.length(), line.length() - 1)); // - 1 means to cut the ';' character commitInformation.setType(CommitInformation.REMOVED); } else if (line.indexOf(EXAM_DIR) >= 0) { fileDirectory = new File(localPath, line.substring(line.indexOf(EXAM_DIR) + EXAM_DIR.length()).trim()); } else if (line.startsWith(RCS_FILE)) { isAdding = true; } else if (line.startsWith(DONE)) { outputDone(); } else if (line.startsWith(INITIAL_REVISION)) { processRevision(line.substring(INITIAL_REVISION.length())); commitInformation.setType(CommitInformation.ADDED); } else if (line.startsWith(NEW_REVISION)) { processRevision(line.substring(NEW_REVISION.length())); } } private File createFile(String fileName) { return new File(localPath, fileName); } private void processUnknownFile(String line) { commitInformation = new CommitInformation(); commitInformation.setType(CommitInformation.UNKNOWN); int index = line.indexOf('\''); String fileName = line.substring(0, index).trim(); commitInformation.setFile(createFile(fileName)); outputDone(); } private void processToAddFile(String line) { commitInformation = new CommitInformation(); commitInformation.setType(CommitInformation.TO_ADD); String fileName = line.trim(); if (fileName.endsWith(";")) { //NOI18N fileName = fileName.substring(0, fileName.length() - 2); } commitInformation.setFile(createFile(fileName)); outputDone(); } private void processFile(String filename) { if (commitInformation == null) { commitInformation = new CommitInformation(); } if (filename.startsWith("no file")) { //NOI18N filename = filename.substring(8); } commitInformation.setFile(createFile(filename)); } private void processFile(File file) { if (commitInformation == null) { commitInformation = new CommitInformation(); } commitInformation.setFile(file); } private void processRevision(String revision) { int index = revision.indexOf(';'); if (index >= 0) { revision = revision.substring(0, index); } revision = revision.trim(); if (DELETED_REVISION.equals(revision)) { commitInformation.setType(CommitInformation.REMOVED); } commitInformation.setRevision(revision); } public void parseEnhancedMessage(String key, Object value) { } private File findFile(String fileName, String reposPath) { File dir = new File(localPath); // happens when adding a new file to a branch if (reposPath.endsWith("/Attic")) { reposPath = reposPath.substring(0, reposPath.length() - 6); } // use quick finder and fallback to original algorithm just in case File file = quickFindFile(dir, fileName, reposPath); if (file != null) return file; return findFile(dir, fileName, reposPath); } private File findFile(File dir, String fileName, String reposPath) { if (isWorkForRepository(dir, reposPath)) { return new File(dir, fileName); } else { File file = null; File[] subFiles = dir.listFiles(); if (subFiles != null) { for (int i = 0; i < subFiles.length; i++) { if (subFiles[i].isDirectory()) { file = findFile(subFiles[i], fileName, reposPath); if (file != null) break; } } } return file; } } private File quickFindFile(File dir, String fileName, String reposPath) { for (;;) { File deepDir = new File(dir, reposPath); if (isWorkForRepository(deepDir, reposPath)) { return new File(deepDir, fileName); } dir = dir.getParentFile(); if (dir == null) return null; } } private boolean isWorkForRepository(File dir, String reposPath) { try { String repository = eventManager.getClientServices().getRepositoryForDirectory(dir); String root = eventManager.getClientServices().getRepository(); if (repository.startsWith(root)) repository = repository.substring(root.length() + 1); return reposPath.equals(repository); } catch (IOException e) { return false; } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/commit/CommitCommand.java0000644000175300001440000004773111175406777030372 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.command.commit; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.admin.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * The command to commit any changes that have been made. * @author Robert Greig */ public class CommitCommand extends BasicCommand { /** * The argument requests that must be added at the end. * These argument requests indicate the files to be committed */ private final List argumentRequests = new LinkedList(); /** * The log message used for the commit. */ private String message; /** * Forces the commit of the file(s) even if no changes were done. * the standard behaviour is NOT-TO-BE recursive in this case. */ private boolean forceCommit; /** * The filename for the file that defines the message. */ private String logMessageFromFile; /** * Determines that no module program should run on the server. */ private boolean noModuleProgram; /** Holds value of property toRevisionOrBranch. */ private String toRevisionOrBranch; /** * Construct a CommitCommand. */ public CommitCommand() { resetCVSCommand(); } /** * Returns the commit message. */ public String getMessage() { return message; } /** * Sets the commit message. */ public void setMessage(String message) { this.message = message; } /** * Indicates whether the commit should be forced even if there are no * changes. */ public boolean isForceCommit() { return forceCommit; } /** * Sets whether the commit should be forced even if there are no changes. */ public void setForceCommit(boolean forceCommit) { this.forceCommit = forceCommit; } /** * Adds the appropriate requests for a given directory. * Sends a directory request followed by as many Entry and Modified requests * as required. * @param directory the directory to send requests for * @throws IOException if an error occurs constructing the requests */ protected void addRequestsForDirectory(File directory) throws IOException { if (!directory.exists()) { return; } // remove localPath prefix from directory. If left with // nothing, use dot (".") in the directory request. Also remove the // trailing slash String dir = getRelativeToLocalPathInUnixStyle(directory); try { String repository = clientServices.getRepositoryForDirectory( directory.getAbsolutePath()); requests.add(new DirectoryRequest(dir, repository)); String tag = clientServices.getStickyTagForDirectory(directory); if (tag != null) { requests.add(new StickyRequest(tag)); } } catch (IOException ex) { System.err.println("An error occurred reading the respository " + "for the directory " + dir + ": " + ex); ex.printStackTrace(); } // Obtain a set of all files known to CVS. We union // this set with the set of files in the actual filesystem directory // to obtain a set of files to commit (or at least attempt to commit). Set set = clientServices.getAllFiles(directory); // We must add the local files (and directories) because the above // command does *not* return cvs controlled directories final File[] files = directory.listFiles(); // get the union of the files in the directory and the files retrieved // from the Entries file. set.addAll(Arrays.asList(files)); List subdirectories = null; if (isRecursive()) { subdirectories = new LinkedList(); } for (Iterator it = set.iterator(); it.hasNext();) { File file = (File)it.next(); if (file.getName().equals("CVS")) { //NOI18N continue; } try { final Entry entry = clientServices.getEntry(file); // a non-null entry means the file does exist in the // Entries file for this directory if (entry == null) { continue; } // here file.isFile() is *not* used, because not existing // files (removed ones) should also be sent if (file.isFile()) { sendEntryAndModifiedRequests(entry, file); } else if (isRecursive() && file.isDirectory()) { File cvsSubDir = new File(file, "CVS"); //NOI18N if (cvsSubDir.exists()) { subdirectories.add(file); } } } catch (IOException ex) { System.err.println("An error occurred getting the " + "Entry for file " + file + ": " + ex); ex.printStackTrace(); } } if (isRecursive()) { for (Iterator it = subdirectories.iterator(); it.hasNext();) { File subdirectory = (File)it.next(); addRequestsForDirectory(subdirectory); } } } /** * Add the appropriate requests for a single file. * A directory request is sent, followed by an Entry and Modified request. * @param file the file to send requests for * @throws IOException if an error occurs constructing the requests */ protected void addRequestsForFile(File file) throws IOException { final File parentDirectory = file.getParentFile(); // remove localPath prefix from directory. If left with // nothing, use dot (".") in the directory request String dir = getRelativeToLocalPathInUnixStyle(parentDirectory); try { // send a argument request indicating the file to update requests.add(new DirectoryRequest(dir, clientServices. getRepositoryForDirectory(parentDirectory. getAbsolutePath()))); String tag = clientServices.getStickyTagForDirectory(parentDirectory); if (tag != null) { requests.add(new StickyRequest(tag)); } } catch (IOException ex) { System.err.println("An error occurred reading the respository " + "for the directory " + dir + ": " + ex); ex.printStackTrace(); } try { final Entry entry = clientServices.getEntry(file); // a non-null entry means the file does exist in the // Entries file for this directory if (entry != null) { sendEntryAndModifiedRequests(entry, file); } } catch (IOException ex) { System.err.println("An error occurred getting the Entry " + "for file " + file + ": " + ex); ex.printStackTrace(); } } /** * Should return true if unchanged files should not be sent to server. * If false is returned, all files will be sent to server * This method is used by sendEntryAndModifiedRequests. */ protected boolean doesCheckFileTime() { return !isForceCommit(); } /** * Execute the command. * @param client the client services object that provides any necessary * services to this command, including the ability to actually * process all the requests */ public void execute(ClientServices client, EventManager em) throws CommandException, AuthenticationException { client.ensureConnection(); super.execute(client, em); try { // add arguments. if (isForceCommit()) { requests.add(1, new ArgumentRequest("-f")); //NOI18N if (isRecursive()) { requests.add(1, new ArgumentRequest("-R")); //NOI18N } } if (isNoModuleProgram()) { requests.add(1, new ArgumentRequest("-n")); //NOI18N } if (getToRevisionOrBranch() != null) { requests.add(1, new ArgumentRequest("-r")); //NOI18N requests.add(2, new ArgumentRequest(getToRevisionOrBranch())); } // build the message to send String message = getMessage(); if (getLogMessageFromFile() != null) { message = loadLogFile(getLogMessageFromFile()); } if (message != null) { message = message.trim(); } if (message == null || message.length() == 0) { message = "no message"; //NOI18N } addMessageRequest(message); addRequestForWorkingDirectory(client); requests.addAll(argumentRequests); argumentRequests.clear(); // MK sanity check. addArgumentRequests(); requests.add(CommandRequest.COMMIT); client.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } finally { requests.clear(); } } protected void addArgumentRequests() { if (isForceCommit()) { Iterator it = requests.iterator(); String directory = ""; List args = new LinkedList(); while (it.hasNext()) { Object req = it.next(); if (req instanceof org.netbeans.lib.cvsclient.request.DirectoryRequest) { org.netbeans.lib.cvsclient.request.DirectoryRequest dirReq = (org.netbeans.lib.cvsclient.request.DirectoryRequest)req; // haven't checked but I'm almost sure that within the Argument request always the local directory is used. directory = dirReq.getLocalDirectory(); } else if (req instanceof org.netbeans.lib.cvsclient.request.EntryRequest) { org.netbeans.lib.cvsclient.request.EntryRequest entReq = (org.netbeans.lib.cvsclient.request.EntryRequest)req; String argument = null; if (directory.length() == 0) { argument = entReq.getEntry().getName(); } else { argument = directory + '/' + entReq.getEntry().getName(); } args.add(new ArgumentRequest(argument)); } } it = args.iterator(); while (it.hasNext()) { requests.add(it.next()); } } else { super.addArgumentRequests(); } } /** * This method returns how the command would looklike when typed on the command line. * Example: checkout -p CvsCommand.java * @returns [] files/dirs */ public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("commit "); //NOI18N toReturn.append(getCVSArguments()); File[] files = getFiles(); if (files != null) { for (int index = 0; index < files.length; index++) { toReturn.append(files[index].getName() + " "); //NOI18N } } return toReturn.toString(); } /** * Takes the arguments and sets the command. * To be mainly used for automatic settings (like parsing the .cvsrc file). * @return true if the option (switch) was recognized and set */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'm') { setMessage(optArg); } else if (opt == 'l') { setRecursive(false); } else if (opt == 'R') { setRecursive(true); } else if (opt == 'f') { setForceCommit(true); } else if (opt == 'F') { setLogMessageFromFile(optArg); } else if (opt == 'r') { setToRevisionOrBranch(optArg); } else if (opt == 'n') { setNoModuleProgram(true); } else { return false; } return true; } /** * Returns a String defining which options are available for this command. */ public String getOptString() { return "m:flRnF:r:"; //NOI18N } /** * Method that is called while the command is being executed. * Descendants can override this method to return a Builder instance * that will parse the server's output and create data structures. */ public Builder createBuilder(EventManager eventMan) { return new CommitBuilder(eventMan, getLocalDirectory(), clientServices.getRepository()); } /** * Generates the Argument/Argumentx series of requests depending * on the number of lines in the message request. */ private void addMessageRequest(String message) { requests.add(new ArgumentRequest("-m")); //NOI18N StringTokenizer token = new StringTokenizer(message, "\n", false); //NOI18N boolean first = true; while (token.hasMoreTokens()) { if (first) { requests.add(new ArgumentRequest(token.nextToken())); first = false; } else { requests.add(new ArgumentxRequest(token.nextToken())); } } } /** * Returns the filename for the file that defines the message. */ public String getLogMessageFromFile() { return logMessageFromFile; } /** * Sets the filename for the file that defines the message. */ public void setLogMessageFromFile(String logMessageFromFile) { this.logMessageFromFile = logMessageFromFile; } /** * Returns whether no module program should be executed on the server. */ public boolean isNoModuleProgram() { return noModuleProgram; } /** * Sets whether no module program should run on the server */ public void setNoModuleProgram(boolean noModuleProgram) { this.noModuleProgram = noModuleProgram; } /** Getter for property toRevisionOrBranch. * @return Value of property toRevisionOrBranch. */ public String getToRevisionOrBranch() { return toRevisionOrBranch; } /** Setter for property toRevisionOrBranch. * @param toRevisionOrBranch New value of property toRevisionOrBranch. */ public void setToRevisionOrBranch(String toRevBranch) { this.toRevisionOrBranch = toRevBranch; } private String loadLogFile(String fileName) throws CommandException { StringBuffer buffer = new StringBuffer(); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(fileName)); String line; while ((line = reader.readLine()) != null) { buffer.append(line + "\n"); //NOI18N } } catch (FileNotFoundException ex) { throw new CommandException(ex, CommandException.getLocalMessage("CommitCommand.logInfoFileNotExists", new Object[]{fileName})); //NOI18N } catch (IOException ex) { throw new CommandException(ex, CommandException.getLocalMessage("CommitCommand.errorReadingLogFile", new Object[]{fileName})); //NOI18N } finally { if (reader != null) { try { reader.close(); } catch (IOException exc) { } } } return buffer.toString(); } /** * Resets all switches in the command. * After calling this method, the command should have no switches defined * and should behave defaultly. */ public void resetCVSCommand() { setMessage(null); setRecursive(true); setForceCommit(false); setLogMessageFromFile(null); setNoModuleProgram(false); setToRevisionOrBranch(null); } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name. */ public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(); if (!isRecursive()) { toReturn.append("-l "); //NOI18N } if (isForceCommit()) { toReturn.append("-f "); //NOI18N if (isRecursive()) { toReturn.append("-R "); } } if (isNoModuleProgram()) { toReturn.append("-n "); //NOI18N } if (getToRevisionOrBranch() != null) { toReturn.append("-r "); //NOI18N toReturn.append(getToRevisionOrBranch() + " "); //NOI18N } if (getLogMessageFromFile() != null) { toReturn.append("-F "); //NOI18N toReturn.append(getLogMessageFromFile()); toReturn.append(" "); //NOI18N } if (getMessage() != null) { toReturn.append("-m \""); //NOI18N toReturn.append(getMessage()); toReturn.append("\" "); //NOI18N } return toReturn.toString(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/commit/CommitInformation.java0000644000175300001440000000634711175406777031277 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.commit; import org.netbeans.lib.cvsclient.command.*; /** * Describes commit information for a file. This is the result of doing a * cvs commit command. The fields in instances of this object are populated * by response handlers. * * @author Milos Kleint */ public class CommitInformation extends DefaultFileInfoContainer { public static final String ADDED = "Added"; //NOI18N public static final String REMOVED = "Removed"; //NOI18N public static final String CHANGED = "Changed"; //NOI18N public static final String UNKNOWN = "Unknown"; //NOI18N public static final String TO_ADD = "To-be-added"; //NOI18N /** * The new revision (for "Added" and "Changed") or old revision (for "Removed"). */ private String revision; public CommitInformation() { } /** Getter for property revision. * @return Value of property revision. */ public String getRevision() { return revision; } /** Setter for property revision. * @param revision New value of property revision. */ public void setRevision(String revision) { this.revision = revision; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/diff/0000755000175300001440000000000011175434236024373 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/diff/DiffCommand.java0000644000175300001440000003741111175406777027424 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.diff; import java.io.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * The status command looks up the status of files in the repository * @author Robert Greig */ public class DiffCommand extends BasicCommand { /** * The event manager to use */ protected EventManager eventManager; /** * Holds value of property beforeDate. */ private String beforeDate1; /** * Holds value of property firstRevision. */ private String revision1; /** * Holds value of property secondRevision. */ private String revision2; /** * Holds value of property beforeDate2. */ private String beforeDate2; /** * Keyword substitution. The -k switch in command line cvs. */ private String keywordSubst; /** Holds value of property ignoreAllWhitespace. */ private boolean ignoreAllWhitespace; /** Holds value of property ignoreBlankLines. */ private boolean ignoreBlankLines; /** Holds value of property ignoreCase. */ private boolean ignoreCase; /** Holds value of property ignoreSpaceChange. */ private boolean ignoreSpaceChange; /** Holds value of property contextDiff. */ private boolean contextDiff; /** Holds value of property unifiedDiff. */ private boolean unifiedDiff; /** * Construct a new diff command */ public DiffCommand() { } /** * Create a builder for this command. * @param eventMan the event manager used to receive events. */ public Builder createBuilder(EventManager eventMan) { if (isContextDiff() || isUnifiedDiff()) { return null; } return new SimpleDiffBuilder(eventMan, this); } /** * Execute a command * @param client the client services object that provides any necessary * services to this command, including the ability to actually process * all the requests. */ public void execute(ClientServices client, EventManager em) throws CommandException, AuthenticationException { client.ensureConnection(); eventManager = em; super.execute(client, em); try { // parameters come now.. addRDSwitches(); if (getKeywordSubst() != null && !getKeywordSubst().equals("")) { //NOI18N requests.add(new ArgumentRequest("-k" + getKeywordSubst())); //NOI18N } addArgumentRequest(isIgnoreAllWhitespace(), "-w"); //NOI18N addArgumentRequest(isIgnoreBlankLines(), "-B"); //NOI18N addArgumentRequest(isIgnoreSpaceChange(), "-b"); //NOI18N addArgumentRequest(isIgnoreCase(), "-i"); //NOI18N addArgumentRequest(isContextDiff(), "-c"); //NOI18N addArgumentRequest(isUnifiedDiff(), "-u"); //NOI18N addRequestForWorkingDirectory(client); addArgumentRequests(); addRequest(CommandRequest.DIFF); client.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } finally { requests.clear(); } } /** * includes the logic of setting the -r and -D switches to the diff command */ private void addRDSwitches() { if (getRevision2() != null) { requests.add(1, new ArgumentRequest("-r")); //NOI18N requests.add(2, new ArgumentRequest(getRevision2())); } else { if (getBeforeDate2() != null) { requests.add(1, new ArgumentRequest("-D " + getBeforeDate2())); //NOI18N } } // -r switch has precendence over the -d switch - is that right?? if (getRevision1() != null) { requests.add(1, new ArgumentRequest("-r")); //NOI18N requests.add(2, new ArgumentRequest(getRevision1())); } else { if (getBeforeDate1() != null) { requests.add(1, new ArgumentRequest("-D " + getBeforeDate1())); //NOI18N } else { // when neither revision nor flag is set for the command, it is assumed // that the second parameters are not set either.. return; } } } /** called when server responses with "ok" or "error", (when the command finishes) */ public void commandTerminated(TerminationEvent e) { if (builder != null) { builder.outputDone(); } } /** Getter for property beforeDate. * @return Value of property beforeDate. */ public String getBeforeDate1() { return beforeDate1; } /** Setter for property beforeDate. * @param beforeDate New value of property beforeDate. */ public void setBeforeDate1(String beforeDate) { this.beforeDate1 = beforeDate; } /** Getter for property firstRevision. * @return Value of property firstRevision. */ public String getRevision1() { return revision1; } /** Setter for property firstRevision. * @param firstRevision New value of property firstRevision. */ public void setRevision1(String firstRevision) { revision1 = firstRevision; } /** Getter for property secondRevision. * @return Value of property secondRevision. */ public String getRevision2() { return revision2; } /** Setter for property secondRevision. * @param secondRevision New value of property secondRevision. */ public void setRevision2(String secondRevision) { this.revision2 = secondRevision; } /** Getter for property beforeDate2. * @return Value of property beforeDate2. */ public String getBeforeDate2() { return beforeDate2; } /** Setter for property beforeDate2. * @param beforeDate2 New value of property beforeDate2. */ public void setBeforeDate2(String beforeDate2) { this.beforeDate2 = beforeDate2; } /** * Getter for property keywordSubst. * @return Value of property keywordSubst. */ public String getKeywordSubst() { return keywordSubst; } /** * Setter for property keywordSubst. * @param keywordSubst New value of property keywordSubst. */ public void setKeywordSubst(String keywordSubst) { this.keywordSubst = keywordSubst; } /** This method returns how the command would looklike when typed on the command line. * Each command is responsible for constructing this information. * @returns [] files/dirs. Example: checkout -p CvsCommand.java * */ public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("diff "); //NOI18N toReturn.append(getCVSArguments()); File[] files = getFiles(); if (files != null) { for (int index = 0; index < files.length; index++) { toReturn.append(files[index].getName() + " "); //NOI18N } } return toReturn.toString(); } /** takes the arguments and sets the command. To be mainly * used for automatic settings (like parsing the .cvsrc file) * @return true if the option (switch) was recognized and set */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'R') { setRecursive(true); } else if (opt == 'l') { setRecursive(false); } else if (opt == 'r') { if (getRevision1() == null) { setRevision1(optArg); } else { setRevision2(optArg); } } else if (opt == 'D') { if (getBeforeDate1() == null) { setBeforeDate1(optArg); } else { setBeforeDate2(optArg); } } else if (opt == 'k') { setKeywordSubst(optArg); } else if (opt == 'w') { setIgnoreAllWhitespace(true); } else if (opt == 'b') { setIgnoreSpaceChange(true); } else if (opt == 'B') { setIgnoreBlankLines(true); } else if (opt == 'i') { setIgnoreCase(true); } else if (opt == 'c') { setContextDiff(true); } else if (opt == 'u') { setUnifiedDiff(true); } else { return false; } return true; } /** * String returned by this method defines which options are available for this particular command */ public String getOptString() { return "Rlr:D:k:wBbicu"; //NOI18N } /** * resets all switches in the command. After calling this method, * the command should have no switches defined and should behave defaultly. */ public void resetCVSCommand() { setRecursive(true); setRevision1(null); setRevision2(null); setBeforeDate1(null); setBeforeDate2(null); setKeywordSubst(null); setIgnoreAllWhitespace(false); setIgnoreBlankLines(false); setIgnoreCase(false); setIgnoreSpaceChange(false); setContextDiff(false); setUnifiedDiff(false); } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name */ public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(""); //NOI18N if (getKeywordSubst() != null && getKeywordSubst().length() > 0) { toReturn.append("-k" + getKeywordSubst() + " "); //NOI18N } if (!isRecursive()) { toReturn.append("-l "); //NOI18N } if (getRevision1() != null) { toReturn.append("-r " + getRevision1() + " "); //NOI18N } if (getBeforeDate1() != null) { toReturn.append("-D " + getBeforeDate1() + " "); //NOI18N } if (getRevision2() != null) { toReturn.append("-r " + getRevision2() + " "); //NOI18N } if (getBeforeDate2() != null) { toReturn.append("-D " + getBeforeDate2() + " "); //NOI18N } if (isIgnoreAllWhitespace()) { toReturn.append("-w "); //NOI18N } if (isIgnoreBlankLines()) { toReturn.append("-B "); //NOI18N } if (isIgnoreCase()) { toReturn.append("-i "); //NOI18N } if (isIgnoreSpaceChange()) { toReturn.append("-b "); //NOI18N } if (isContextDiff()) { toReturn.append("-c ");//NOI18N } if (isUnifiedDiff()) { toReturn.append("-u ");//NOI18N } return toReturn.toString(); } /** true if all the whitespace differences should be ignored. (-w) * @return Value of property ignoreAllWhitespace. */ public boolean isIgnoreAllWhitespace() { return this.ignoreAllWhitespace; } /** Setter for property ignoreAllWhitespace. * true if all the whitespace differences should be ignored. (-w) * @param ignoreAllWhitespace New value of property ignoreAllWhitespace. */ public void setIgnoreAllWhitespace(boolean ignoreAllWhitespace) { this.ignoreAllWhitespace = ignoreAllWhitespace; } /** Getter for property ignoreBlankLines. * @return Value of property ignoreBlankLines. */ public boolean isIgnoreBlankLines() { return this.ignoreBlankLines; } /** Setter for property ignoreBlankLines. * @param ignoreBlankLines New value of property ignoreBlankLines. */ public void setIgnoreBlankLines(boolean ignoreBlankLines) { this.ignoreBlankLines = ignoreBlankLines; } /** Getter for property ignoreCase. * @return Value of property ignoreCase. */ public boolean isIgnoreCase() { return this.ignoreCase; } /** Setter for property ignoreCase. * @param ignoreCase New value of property ignoreCase. */ public void setIgnoreCase(boolean ignoreCase) { this.ignoreCase = ignoreCase; } /** Getter for property ignoreSpaceChange. * @return Value of property ignoreSpaceChange. */ public boolean isIgnoreSpaceChange() { return this.ignoreSpaceChange; } /** Setter for property ignoreSpaceChange. * @param ignoreSpaceChange New value of property ignoreSpaceChange. */ public void setIgnoreSpaceChange(boolean ignoreSpaceChange) { this.ignoreSpaceChange = ignoreSpaceChange; } /** * equals to the -c switch of cvs * Getter for property contextDiff. * @return Value of property contextDiff. */ public boolean isContextDiff() { return this.contextDiff; } /** * equals to the -c switch of cvs * Setter for property contextDiff. * @param contextDiff New value of property contextDiff. */ public void setContextDiff(boolean contextDiff) { this.contextDiff = contextDiff; } /** * equals to the -u switch of cvs * Getter for property unifiedDiff. * @return Value of property unifiedDiff. */ public boolean isUnifiedDiff() { return this.unifiedDiff; } /** * equals to the -u switch of cvs. * Setter for property unifiedDiff. * @param unifiedDiff New value of property unifiedDiff. */ public void setUnifiedDiff(boolean unifiedDiff) { this.unifiedDiff = unifiedDiff; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/diff/DiffInformation.java0000644000175300001440000002025711175406777030333 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.diff; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.command.*; /** * Describes diff information for 2 fversions of a file. This is the result of doing a * cvs diff command. The fields in instances of this object are populated * by response handlers. * @author Milos Kleint */ public class DiffInformation extends FileInfoContainer { private File file; private String repositoryFileName; private String rightRevision; private String leftRevision; private String parameters; /** * List of changes stored here */ private final List changesList = new ArrayList(); private Iterator iterator; public DiffInformation() { } /** * Getter for property file. * @return Value of property file. */ public File getFile() { return file; } /** * Setter for property file. * @param file New value of property file. */ public void setFile(File file) { this.file = file; } /** * Getter for property repositoryFileName. * @return Value of property repositoryFileName. */ public String getRepositoryFileName() { return repositoryFileName; } /** * Setter for property repositoryFileName. * @param repositoryRevision New value of property repositoryFileName. */ public void setRepositoryFileName(String repositoryFileName) { this.repositoryFileName = repositoryFileName; } /** * Return a string representation of this object. Useful for debugging. */ public String toString() { StringBuffer buf = new StringBuffer(30); buf.append("\nFile: " + ((file != null)?file.getAbsolutePath():"null")); //NOI18N buf.append("\nRCS file: " + repositoryFileName); //NOI18N buf.append("\nRevision: " + leftRevision); //NOI18N if (rightRevision != null) { buf.append("\nRevision: " + rightRevision); //NOI18N } buf.append("\nParameters: " + parameters); //NOI18N // buf.append(differences.toString()); return buf.toString(); } /** Getter for property rightRevision. * @return Value of property rightRevision. */ public String getRightRevision() { return rightRevision; } /** Setter for property rightRevision. * @param rightRevision New value of property rightRevision. */ public void setRightRevision(String rightRevision) { this.rightRevision = rightRevision; } /** Getter for property leftRevision. * @return Value of property leftRevision. */ public String getLeftRevision() { return leftRevision; } /** Setter for property leftRevision. * @param leftRevision New value of property leftRevision. */ public void setLeftRevision(String leftRevision) { this.leftRevision = leftRevision; } public String getParameters() { return parameters; } public void setParameters(String parameters) { this.parameters = parameters; } public DiffChange createDiffChange() { return new DiffChange(); } public void addChange(DiffChange change) { changesList.add(change); } public DiffChange getFirstChange() { iterator = changesList.iterator(); return getNextChange(); } public DiffChange getNextChange() { if (iterator == null) { return null; } if (!iterator.hasNext()) { return null; } return (DiffChange)iterator.next(); } public class DiffChange { public static final int ADD = 0; public static final int DELETE = 1; public static final int CHANGE = 2; protected int type; private int leftBeginning = -1; private int leftEnd = -1; private final List leftDiff = new ArrayList(); private int rightBeginning = -1; private int rightEnd = -1; private final List rightDiff = new ArrayList(); public DiffChange() { } public void setType(int typeChange) { // System.out.println("type=" + typeChange); type = typeChange; } public int getType() { return type; } public void setLeftRange(int min, int max) { // System.out.println("setLeftRange() min=" + min + " max=" +max); leftBeginning = min; leftEnd = max; } public void setRightRange(int min, int max) { // System.out.println("setRightRange() min=" + min + " max=" +max); rightBeginning = min; rightEnd = max; } public int getMainBeginning() { return rightBeginning; } public int getRightMin() { return rightBeginning; } public int getRightMax() { return rightEnd; } public int getLeftMin() { return leftBeginning; } public int getLeftMax() { return leftEnd; } public boolean isInRange(int number, boolean left) { if (left) { return (number >= leftBeginning && number <= leftEnd); } return (number >= rightBeginning && number <= rightEnd); } public String getLine(int number, boolean left) { if (left) { int index = number - leftBeginning; if (index < 0 || index >= leftDiff.size()) { return null; } String line = (String)leftDiff.get(index); return line; } else { int index = number - rightBeginning; if (index < 0 || index >= rightDiff.size()) { return null; } String line = (String)rightDiff.get(index); return line; } } public void appendLeftLine(String diffLine) { leftDiff.add(diffLine); } public void appendRightLine(String diffLine) { rightDiff.add(diffLine); } } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/diff/SimpleDiffBuilder.java0000644000175300001440000002275311175406777030611 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.diff; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.event.*; /** * Handles the building of a diff information object and the firing of * events when complete objects are built. * @author Milos Kleint */ public class SimpleDiffBuilder implements Builder { /** * The event manager to use */ protected EventManager eventManager; protected DiffCommand diffCommand; /** * The diff object that is currently being built */ protected DiffInformation diffInformation; /** * The directory in which the file being processed lives. This is * relative to the local directory */ protected String fileDirectory; protected boolean readingDiffs = false; private static final String UNKNOWN = ": I know nothing about"; //NOI18N private static final String CANNOT_FIND = ": cannot find"; //NOI18N private static final String UNKNOWN_TAG = ": tag"; //NOI18N private static final String EXAM_DIR = ": Diffing"; //NOI18N private static final String FILE = "Index: "; //NOI18N private static final String RCS_FILE = "RCS file: "; //NOI18N private static final String REVISION = "retrieving revision "; //NOI18N private static final String PARAMETERS = "diff "; //NOI18N private DiffInformation.DiffChange currentChange; public SimpleDiffBuilder(EventManager eventMan, DiffCommand diffComm) { eventManager = eventMan; diffCommand = diffComm; } public void outputDone() { if (diffInformation != null) { if (currentChange != null) { diffInformation.addChange(currentChange); currentChange = null; } eventManager.fireCVSEvent(new FileInfoEvent(this, diffInformation)); diffInformation = null; readingDiffs = false; } } public void parseLine(String line, boolean isErrorMessage) { if (readingDiffs) { if (line.startsWith(FILE)) { outputDone(); } else { processDifferences(line); return; } } if (line.indexOf(UNKNOWN) >= 0) { eventManager.fireCVSEvent(new FileInfoEvent(this, diffInformation)); diffInformation = null; return; } if (line.indexOf(EXAM_DIR) >= 0) { fileDirectory = line.substring(line.indexOf(EXAM_DIR) + EXAM_DIR.length()).trim(); return; } if (line.startsWith(FILE)) { processFile(line.substring(FILE.length())); return; } if (line.startsWith(RCS_FILE)) { processRCSfile(line.substring(RCS_FILE.length())); return; } if (line.startsWith(REVISION)) { processRevision(line.substring(REVISION.length())); return; } if (line.startsWith(PARAMETERS)) { processParameters(line.substring(PARAMETERS.length())); readingDiffs = true; return; } } /* protected void processDifferences(String line) { diffInformation.addToDifferences(line); } */ protected void processFile(String line) { outputDone(); diffInformation = createDiffInformation(); String fileName = line.trim(); if (fileName.startsWith("no file")) { //NOI18N fileName = fileName.substring(8); } diffInformation.setFile(new File(diffCommand.getLocalDirectory(), // ((fileDirectory!=null)?fileDirectory: "") + File.separator + fileName)); } protected void processRCSfile(String line) { if (diffInformation == null) { return; } diffInformation.setRepositoryFileName(line.trim()); } protected void processRevision(String line) { if (diffInformation == null) { return; } line = line.trim(); // first REVISION line is the from-file, the second is the to-file if (diffInformation.getLeftRevision() != null) { diffInformation.setRightRevision(line); } else { diffInformation.setLeftRevision(line); } } protected void processParameters(String line) { if (diffInformation == null) { return; } diffInformation.setParameters(line.trim()); } public DiffInformation createDiffInformation() { return new DiffInformation(); } protected void assignType(DiffInformation.DiffChange change, String line) { int index = 0; int cIndex = line.indexOf('c'); if (cIndex > 0) { // change type of change change.setType(DiffInformation.DiffChange.CHANGE); index = cIndex; } else { int aIndex = line.indexOf('a'); if (aIndex > 0) { // add type of change change.setType(DiffInformation.DiffChange.ADD); index = aIndex; } else { int dIndex = line.indexOf('d'); if (dIndex > 0) { // delete type of change change.setType(DiffInformation.DiffChange.DELETE); index = dIndex; } } } String left = line.substring(0, index); // System.out.println("left part of change=" + left); change.setLeftRange(getMin(left), getMax(left)); String right = line.substring(index + 1); // System.out.println("right part of change=" + right); change.setRightRange(getMin(right), getMax(right)); } private int getMin(String line) { String nums = line; int commaIndex = nums.indexOf(','); if (commaIndex > 0) { nums = nums.substring(0, commaIndex); } int min; try { min = Integer.parseInt(nums); } catch (NumberFormatException exc) { min = 0; } // System.out.println("Min=" + min); return min; } private int getMax(String line) { String nums = line; int commaIndex = nums.indexOf(','); if (commaIndex > 0) { nums = nums.substring(commaIndex + 1); } int max; try { max = Integer.parseInt(nums); } catch (NumberFormatException exc) { max = 0; } // System.out.println("Max=" + max); return max; } protected void processDifferences(String line) { char firstChar = line.charAt(0); if (firstChar >= '0' && firstChar <= '9') { // we got a new difference here // System.out.println("new Change=" + line); if (currentChange != null) { diffInformation.addChange(currentChange); } currentChange = diffInformation.createDiffChange(); assignType(currentChange, line); } if (firstChar == '<') { // System.out.println("Left line=" + line); currentChange.appendLeftLine(line.substring(2)); } if (firstChar == '>') { // System.out.println("right line=" + line); currentChange.appendRightLine(line.substring(2)); } } public void parseEnhancedMessage(String key, Object value) { } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/edit/0000755000175300001440000000000011175434236024410 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/edit/EditCommand.java0000644000175300001440000002506511175406777027460 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.edit; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.admin.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.file.*; import org.netbeans.lib.cvsclient.request.*; /** * @author Thomas Singer */ public class EditCommand extends BasicCommand { /** * Returns the file used for backup the specified file in the edit command. */ public static File getEditBackupFile(File file) { return new File(file.getParent(), "CVS/Base/" + file.getName()); // NOI18N } private boolean checkThatUnedited; private boolean forceEvenIfEdited; private Watch temporaryWatch; private transient ClientServices clientServices; /** * Construct a new editors command. */ public EditCommand() { resetCVSCommand(); } /** * Executes this command. * * @param client the client services object that provides any necessary * services to this command, including the ability to actually * process all the requests. */ public void execute(ClientServices clientServices, EventManager eventManager) throws CommandException { this.clientServices = clientServices; try { clientServices.ensureConnection(); super.execute(clientServices, eventManager); addArgumentRequest(isCheckThatUnedited(), "-c"); // NOI18N addArgumentRequest(isForceEvenIfEdited(), "-f"); // NOI18N // now add the request that indicates the working directory for the // command addRequestForWorkingDirectory(clientServices); addRequest(CommandRequest.NOOP); clientServices.processRequests(requests); } catch (AuthenticationException ex) { //TODO: handle case, where connection wasn't possible to establish } catch (CommandException ex) { throw ex; } catch (EOFException ex) { throw new CommandException(ex, CommandException.getLocalMessage("CommandException.EndOfFile", null)); //NOI18N } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } finally { requests.clear(); this.clientServices = null; } } protected void addRequestForFile(File file, Entry entry) { String temporaryWatch = Watch.getWatchString(getTemporaryWatch()); requests.add(new NotifyRequest(file, "E", temporaryWatch)); // NOI18N try { editFile(clientServices, file); } catch (IOException ex) { // ignore } } /** * Called when server responses with "ok" or "error", (when the command * finishes). */ public void commandTerminated(TerminationEvent e) { if (builder != null) { builder.outputDone(); } } /** * This method returns how the tag command would looklike when typed on the * command line. */ public String getCVSCommand() { StringBuffer cvsCommandLine = new StringBuffer("edit "); //NOI18N cvsCommandLine.append(getCVSArguments()); appendFileArguments(cvsCommandLine); return cvsCommandLine.toString(); } /** * Takes the arguments and sets the command. * To be mainly used for automatic settings (like parsing the .cvsrc file) * @return true if the option (switch) was recognized and set */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'R') { setRecursive(true); } else if (opt == 'l') { setRecursive(false); } else { return false; } return true; } /** * String returned by this method defines which options are available for * this command. */ public String getOptString() { return "Rl"; //NOI18N } /** * Resets all switches in the command. * After calling this method, the command should have no switches defined * and should behave defaultly. */ public void resetCVSCommand() { setRecursive(true); setCheckThatUnedited(false); setForceEvenIfEdited(true); setTemporaryWatch(null); } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name */ public String getCVSArguments() { StringBuffer cvsArguments = new StringBuffer(); if (!isRecursive()) { cvsArguments.append("-l "); //NOI18N } return cvsArguments.toString(); } /** * Returns whether to check for unedited files. */ public boolean isCheckThatUnedited() { return checkThatUnedited; } /** * Sets whether to check for unedited files. * This is cvs' -c option. */ public void setCheckThatUnedited(boolean checkThatUnedited) { this.checkThatUnedited = checkThatUnedited; } /** * Returns whether the edit is forces even if the files are edited. */ public boolean isForceEvenIfEdited() { return forceEvenIfEdited; } /** * Sets whether the edit is forces even if the files are edited. * This is cvs' -f option. */ public void setForceEvenIfEdited(boolean forceEvenIfEdited) { this.forceEvenIfEdited = forceEvenIfEdited; } /** * Returns the temporary watch. */ public Watch getTemporaryWatch() { return temporaryWatch; } /** * Sets the temporary watch. * This is cvs' -a option. */ public void setTemporaryWatch(Watch temporaryWatch) { this.temporaryWatch = temporaryWatch; } private void editFile(ClientServices clientServices, File file) throws IOException { addBaserevEntry(clientServices, file); FileUtils.copyFile(file, EditCommand.getEditBackupFile(file)); FileUtils.setFileReadOnly(file, false); } /** * Create file CVS/Baserev with entries like * BEntry.java/1.2/ */ private void addBaserevEntry(ClientServices clientServices, File file) throws IOException { final Entry entry = clientServices.getEntry(file); if (entry == null || entry.getRevision() == null || entry.isNewUserFile() || entry.isUserFileToBeRemoved()) { throw new IllegalArgumentException("File does not have an Entry or Entry is invalid!"); // NOI18N } File baserevFile = new File(file.getParentFile(), "CVS/Baserev"); // NOI18N File backupFile = new File(baserevFile.getAbsolutePath() + '~'); BufferedReader reader = null; BufferedWriter writer = null; boolean append = true; boolean writeFailed = true; final String entryStart = 'B' + file.getName() + '/'; try { writer = new BufferedWriter(new FileWriter(backupFile)); writeFailed = false; reader = new BufferedReader(new FileReader(baserevFile)); for (String line = reader.readLine(); line != null; line = reader.readLine()) { if (line.startsWith(entryStart)) { append = false; } writeFailed = true; writer.write(line); writer.newLine(); writeFailed = false; } } catch (IOException ex) { if (writeFailed) { throw ex; } } finally { if (reader != null) { try { reader.close(); } catch (IOException ex) { // ignore } } if (writer != null) { try { if (append && !writeFailed) { writer.write(entryStart + entry.getRevision() + '/'); writer.newLine(); } } finally { try { writer.close(); } catch (IOException ex) { // ignore } } } } baserevFile.delete(); backupFile.renameTo(baserevFile); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/editors/0000755000175300001440000000000011175434236025134 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/editors/EditorsBuilder.java0000644000175300001440000001450511175406777030735 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.editors; import java.io.*; import java.text.*; import java.util.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.event.*; /** * @author Thomas Singer * @version Nov 11, 2001 */ public class EditorsBuilder implements Builder { // Constants ============================================================== private static final DateFormat DATE_FORMAT = new SimpleDateFormat("MMM dd hh:mm:ss yyyy"); // private static final DateFormat DATE_FORMAT = new SimpleDateFormat("EEE MMM dd hh:mm:ss yyyy zzz"); // Fields ================================================================= private final EventManager eventManager; private String editorsFileName; // Setup ================================================================== EditorsBuilder(EventManager eventManager) { this.editorsFileName=null; this.eventManager = eventManager; } // Implemented ============================================================ public void parseLine(String line, boolean isErrorMessage) { if (!isErrorMessage) { parseLine(line); } } public void parseEnhancedMessage(String key, Object value) { } public void outputDone() { } // Utils ================================================================== private boolean parseLine(String line) { StringTokenizer tokenizer = new StringTokenizer(line, "\t"); if (!tokenizer.hasMoreTokens()) { return false; } //check whether line is the first editors line for this file. //persist for later lines. if(!line.startsWith("\t")) { editorsFileName = tokenizer.nextToken(); if (!tokenizer.hasMoreTokens()) { return false; } } //must have a filename associated with the line, // either from this line or a previous one else if(editorsFileName==null) { return false; } final String user = tokenizer.nextToken(); if (!tokenizer.hasMoreTokens()) { return false; } final String dateString = tokenizer.nextToken(); if (!tokenizer.hasMoreTokens()) { return false; } final String clientName = tokenizer.nextToken(); if (!tokenizer.hasMoreTokens()) { return false; } final String localDirectory = tokenizer.nextToken(); try { FileInfoContainer fileInfoContainer = parseEntries(localDirectory, editorsFileName, user, dateString, clientName); final CVSEvent event = new FileInfoEvent(this, fileInfoContainer); eventManager.fireCVSEvent(event); return true; } catch (ParseException ex) { return false; } } private EditorsFileInfoContainer parseEntries(String localDirectory, String fileName, String user, String dateString, String clientName) throws ParseException { int lastSlashIndex = fileName.lastIndexOf('/'); if (lastSlashIndex >= 0) { fileName = fileName.substring(lastSlashIndex + 1); } final Date date = parseDate(dateString); final File file = new File(localDirectory, fileName); return new EditorsFileInfoContainer(file, user, date, clientName); } private Date parseDate(String dateString) throws ParseException { int firstSpaceIndex = Math.max(dateString.indexOf(' '), 0); int lastSpaceIndex = Math.min(dateString.lastIndexOf(' '), dateString.length()); // dateString = dateString.substring(0, lastSpaceIndex).trim(); dateString = dateString.substring(firstSpaceIndex, lastSpaceIndex).trim(); return DATE_FORMAT.parse(dateString); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/editors/EditorsCommand.java0000644000175300001440000001371311175406777030725 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.editors; import java.io.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * @author Thomas Singer */ public class EditorsCommand extends BasicCommand { /** * Construct a new editors command. */ public EditorsCommand() { resetCVSCommand(); } /** * Creates the EditorsBuilder. * @param eventManager the event manager used to received cvs events */ public Builder createBuilder(EventManager eventManager) { return new EditorsBuilder(eventManager); } /** * Execute the command. * * @param client the client services object that provides any necessary * services to this command, including the ability to actually * process all the requests. */ public void execute(ClientServices clientServices, EventManager eventManager) throws CommandException, AuthenticationException { clientServices.ensureConnection(); super.execute(clientServices, eventManager); try { addRequestForWorkingDirectory(clientServices); addArgumentRequests(); addRequest(CommandRequest.EDITORS); clientServices.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (EOFException ex) { throw new CommandException(ex, CommandException.getLocalMessage("CommandException.EndOfFile", null)); //NOI18N } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } finally { requests.clear(); } } /** * Called when server responses with "ok" or "error", (when the command * finishes). */ public void commandTerminated(TerminationEvent e) { if (builder != null) { builder.outputDone(); } } /** * This method returns how the tag command would looklike when typed on the * command line. */ public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("editors "); //NOI18N toReturn.append(getCVSArguments()); File[] files = getFiles(); if (files != null) { for (int index = 0; index < files.length; index++) { toReturn.append(files[index].getName()); toReturn.append(' '); } } return toReturn.toString(); } /** * Takes the arguments and sets the command. * To be mainly used for automatic settings (like parsing the .cvsrc file) * @return true if the option (switch) was recognized and set */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'R') { setRecursive(true); } else if (opt == 'l') { setRecursive(false); } else { return false; } return true; } /** * String returned by this method defines which options are available for * this command. */ public String getOptString() { return "Rl"; //NOI18N } /** * Resets all switches in the command. * After calling this method, the command should have no switches defined * and should behave defaultly. */ public void resetCVSCommand() { setRecursive(true); } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name */ public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(); if (!isRecursive()) { toReturn.append("-l "); //NOI18N } return toReturn.toString(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/editors/EditorsFileInfoContainer.java0000644000175300001440000000562511175406777032710 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.editors; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.command.*; /** * Data object created by parsing the output of the Editors command. * @author Thomas Singer */ public class EditorsFileInfoContainer extends FileInfoContainer { private final String client; private final Date date; private final File file; private final String user; EditorsFileInfoContainer(File file, String user, Date date, String client) { this.file = file; this.user = user; this.date = date; this.client = client; } public File getFile() { return file; } public String getClient() { return client; } public Date getDate() { return date; } public String getUser() { return user; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/export/0000755000175300001440000000000011175434236025004 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/export/ExportBuilder.java0000644000175300001440000000753211175406777030457 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.export; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.event.*; /** * @author Milos Kleint */ public class ExportBuilder implements Builder { private static final String FILE_INFOS = "MUARC?"; //NOI18N private final EventManager eventManager; private final String localPath; private DefaultFileInfoContainer fileInfoContainer; public ExportBuilder(EventManager eventManager, ExportCommand exportCommand) { this.eventManager = eventManager; this.localPath = exportCommand.getLocalDirectory(); } public void outputDone() { if (fileInfoContainer == null) { return; } FileInfoEvent event = new FileInfoEvent(this, fileInfoContainer); eventManager.fireCVSEvent(event); fileInfoContainer = null; } public void parseLine(String line, boolean isErrorMessage) { if (line.length() > 2 && line.charAt(1) == ' ') { String firstChar = line.substring(0, 1); if (FILE_INFOS.indexOf(firstChar) >= 0) { String filename = line.substring(2).trim(); processFile(firstChar, filename); } else { error(line); } } } public void parseEnhancedMessage(String key, Object value) { } private void error(String line) { System.err.println("Don't know anything about: " + line); } private void processFile(String type, String filename) { outputDone(); File file = new File(localPath, filename); fileInfoContainer = new DefaultFileInfoContainer(); fileInfoContainer.setType(type); fileInfoContainer.setFile(file); outputDone(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/export/ExportCommand.java0000644000175300001440000004226111175406777030445 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.export; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * The export command exports the projects (modules in the repository) * to the local directory structure. * * @author MIlos Kleint */ public class ExportCommand extends RepositoryCommand { private final String UPDATING = ": Updating "; // NOI18N /** * A store of potentially empty directories. When a directory has a file * in it, it is removed from this set. This set allows the prune option * to be implemented. */ private final Set emptyDirectories = new HashSet(); private boolean pruneDirectories; private KeywordSubstitutionOptions keywordSubstitutionOptions; /** Holds value of property exportByDate. */ private String exportByDate; /** Holds value of property exportByRevision. */ private String exportByRevision; /** Holds value of property exportDirectory. */ private String exportDirectory; /** Holds value of property useHeadIfNotFound. */ private boolean useHeadIfNotFound; /** Don't shorten module paths if -d specified. */ private boolean notShortenPaths; /** Do not run module program (if any). */ private boolean notRunModuleProgram; public ExportCommand() { resetCVSCommand(); } /** * Returns the keyword substitution option. */ public KeywordSubstitutionOptions getKeywordSubstitutionOptions() { return keywordSubstitutionOptions; } /** * Sets the keywords substitution option. */ public void setKeywordSubstitutionOptions(KeywordSubstitutionOptions keywordSubstitutionOptions) { this.keywordSubstitutionOptions = keywordSubstitutionOptions; } /** * Set whether to prune directories. * This is the -P option in the command-line CVS. */ public void setPruneDirectories(boolean pruneDirectories) { this.pruneDirectories = pruneDirectories; } /** * Get whether to prune directories. * @return true if directories should be removed if they contain no files, * false otherwise. */ public boolean isPruneDirectories() { return pruneDirectories; } /** * Execute this command * @param client the client services object that provides any necessary * services to this command, including the ability to actually process * all the requests */ protected void postExpansionExecute(ClientServices client, EventManager em) throws CommandException, AuthenticationException { // // moved modules code to the end of the other arguments --GAR // final int FIRST_INDEX = 0; final int SECOND_INDEX = 1; if (!isRecursive()) { requests.add(FIRST_INDEX, new ArgumentRequest("-l")); //NOI18N } if (useHeadIfNotFound) { requests.add(FIRST_INDEX, new ArgumentRequest("-f")); //NOI18N } if (exportDirectory != null && (!exportDirectory.equals(""))) { requests.add(FIRST_INDEX, new ArgumentRequest("-d")); //NOI18N requests.add(SECOND_INDEX, new ArgumentRequest(getExportDirectory())); } if (exportByDate != null && exportByDate.length() > 0) { requests.add(FIRST_INDEX, new ArgumentRequest("-D")); //NOI18N requests.add(SECOND_INDEX, new ArgumentRequest(getExportByDate())); } if (exportByRevision != null && exportByRevision.length() > 0) { requests.add(FIRST_INDEX, new ArgumentRequest("-r")); //NOI18N requests.add(SECOND_INDEX, new ArgumentRequest(getExportByRevision())); } if (notShortenPaths) { requests.add(FIRST_INDEX, new ArgumentRequest("-N")); //NOI18N } if (notRunModuleProgram) { requests.add(FIRST_INDEX, new ArgumentRequest("-n")); //NOI18N } if (getKeywordSubstitutionOptions() != null) { requests.add(new ArgumentRequest("-k" + getKeywordSubstitutionOptions())); //NOI18N } addArgumentRequests(); requests.add(new DirectoryRequest(".", client.getRepository())); //NOI18N requests.add(CommandRequest.EXPORT); try { client.processRequests(requests); if (pruneDirectories) { pruneEmptyDirectories(); } requests.clear(); } catch (CommandException ex) { throw ex; } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } finally { removeAllCVSAdminFiles(); } } private void removeAllCVSAdminFiles() { File rootDirect = null; if (getExportDirectory() != null) { rootDirect = new File(getLocalDirectory(), getExportDirectory()); deleteCVSSubDirs(rootDirect); } else { rootDirect = new File(getLocalDirectory()); Iterator mods = expandedModules.iterator(); while (mods.hasNext()) { String mod = mods.next().toString(); File modRoot = new File(rootDirect.getAbsolutePath(), mod); deleteCVSSubDirs(modRoot); } } } private void deleteCVSSubDirs(File root) { if (root.isDirectory()) { File[] subDirs = root.listFiles(); if (subDirs == null) { return; } for (int i = 0; i < subDirs.length; i++) { if (subDirs[i].isDirectory()) { if (subDirs[i].getName().equalsIgnoreCase("CVS")) { //NOI18N final File[] adminFiles = subDirs[i].listFiles(); for (int j = 0; j < adminFiles.length; j++) { adminFiles[j].delete(); } subDirs[i].delete(); } else { deleteCVSSubDirs(subDirs[i]); } } } } } public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("export "); //NOI18N toReturn.append(getCVSArguments()); if (modules != null && modules.size() > 0) { for (Iterator it = modules.iterator(); it.hasNext();) { String module = (String)it.next(); toReturn.append(module); toReturn.append(' '); } } else { String localizedMsg = CommandException.getLocalMessage("ExportCommand.moduleEmpty.text"); //NOI18N toReturn.append(" "); //NOI18N toReturn.append(localizedMsg); } return toReturn.toString(); } public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(""); //NOI18N if (!isRecursive()) { toReturn.append("-l "); //NOI18N } if (isUseHeadIfNotFound()) { toReturn.append("-f "); //NOI18N } if (getExportByDate() != null) { toReturn.append("-D "); //NOI18N toReturn.append(getExportByDate()); toReturn.append(" "); //NOI18N } if (getExportByRevision() != null) { toReturn.append("-r "); //NOI18N toReturn.append(getExportByRevision()); toReturn.append(" "); //NOI18N } if (isPruneDirectories()) { toReturn.append("-P "); //NOI18N } if (isNotShortenPaths()) { toReturn.append("-N "); // NOI18N } if (isNotRunModuleProgram()) { toReturn.append("-n "); // NOI18N } if (getExportDirectory() != null) { toReturn.append("-d "); //NOI18N toReturn.append(getExportDirectory()); toReturn.append(" "); //NOI18N } if (getKeywordSubstitutionOptions() != null) { toReturn.append("-k"); //NOI18N toReturn.append(getKeywordSubstitutionOptions().toString()); toReturn.append(" "); //NOI18N } return toReturn.toString(); } public boolean setCVSCommand(char opt, String optArg) { if (opt == 'k') { setKeywordSubstitutionOptions(KeywordSubstitutionOptions.findKeywordSubstOption(optArg)); } else if (opt == 'r') { setExportByRevision(optArg); } else if (opt == 'f') { setUseHeadIfNotFound(true); } else if (opt == 'D') { setExportByDate(optArg); } else if (opt == 'd') { setExportDirectory(optArg); } else if (opt == 'P') { setPruneDirectories(true); } else if (opt == 'N') { setNotShortenPaths(true); } else if (opt == 'n') { setNotRunModuleProgram(true); } else if (opt == 'l') { setRecursive(false); } else if (opt == 'R') { setRecursive(true); } else { return false; } return true; } public void resetCVSCommand() { setModules(null); setKeywordSubstitutionOptions(null); setPruneDirectories(false); setRecursive(true); setExportByDate(null); setExportByRevision(null); setExportDirectory(null); setUseHeadIfNotFound(false); setNotShortenPaths(false); setNotRunModuleProgram(false); } public String getOptString() { return "k:r:D:NPlRnd:f"; //NOI18N } /** * Creates the ExportBuilder. */ public Builder createBuilder(EventManager eventManager) { return new ExportBuilder(eventManager, this); } /** * Called when the server wants to send a message to be displayed to * the user. The message is only for information purposes and clients * can choose to ignore these messages if they wish. * @param e the event */ public void messageSent(MessageEvent e) { super.messageSent(e); // we use this event to determine which directories need to be checked // for updating if (pruneDirectories && e.getMessage().indexOf(UPDATING) > 0) { File file = new File(getLocalDirectory(), e.getMessage().substring(e.getMessage().indexOf(UPDATING) + UPDATING.length())); emptyDirectories.add(file); } } /** * Prunes a directory, recursively pruning its subdirectories * @param directory the directory to prune */ private boolean pruneEmptyDirectory(File directory) throws IOException { boolean empty = true; final File[] contents = directory.listFiles(); // should never be null, but just in case... if (contents != null) { for (int i = 0; i < contents.length; i++) { if (contents[i].isFile()) { empty = false; } else { if (!contents[i].getName().equals("CVS")) { //NOI18N empty = pruneEmptyDirectory(contents[i]); } } if (!empty) { break; } } if (empty) { // check this is a CVS directory and not some directory the user // has stupidly called CVS... final File entriesFile = new File(directory, "CVS/Entries"); //NOI18N if (entriesFile.exists()) { final File adminDir = new File(directory, "CVS"); //NOI18N final File[] adminFiles = adminDir.listFiles(); for (int i = 0; i < adminFiles.length; i++) { adminFiles[i].delete(); } adminDir.delete(); directory.delete(); } } } return empty; } /** * Remove any directories that don't contain any files */ private void pruneEmptyDirectories() throws IOException { final Iterator it = emptyDirectories.iterator(); while (it.hasNext()) { final File dir = (File)it.next(); // we might have deleted it already (due to recursive delete) // so we need to check existence if (dir.exists()) { pruneEmptyDirectory(dir); } } emptyDirectories.clear(); } /** Getter for property exportByDate. * @return Value of property exportByDate. */ public String getExportByDate() { return this.exportByDate; } /** Setter for property exportByDate. * @param exportByDate New value of property exportByDate. */ public void setExportByDate(String exportByDate) { this.exportByDate = exportByDate; } /** Getter for property exportByRevision. * @return Value of property exportByRevision. */ public String getExportByRevision() { return this.exportByRevision; } /** Setter for property exportByRevision. * @param exportByRevision New value of property exportByRevision. */ public void setExportByRevision(String exportByRevision) { this.exportByRevision = exportByRevision; } /** Getter for property exportDirectory. * @return Value of property exportDirectory. */ public String getExportDirectory() { return this.exportDirectory; } /** Setter for property exportDirectory. * @param exportDirectory New value of property exportDirectory. */ public void setExportDirectory(String exportDirectory) { this.exportDirectory = exportDirectory; } /** Getter for property useHeadIfNotFound. * @return Value of property useHeadIfNotFound. */ public boolean isUseHeadIfNotFound() { return this.useHeadIfNotFound; } /** Setter for property useHeadIfNotFound. * @param useHeadIfNotFound New value of property useHeadIfNotFound. */ public void setUseHeadIfNotFound(boolean useHeadIfNotFound) { this.useHeadIfNotFound = useHeadIfNotFound; } /** * Getter for property notShortenPaths. * @return Value of property notShortenPaths. */ public boolean isNotShortenPaths() { return notShortenPaths; } /** * Setter for property notShortenPaths. * @param notShortenPaths New value of property notShortenPaths. */ public void setNotShortenPaths(boolean notShortenPaths) { this.notShortenPaths = notShortenPaths; } /** * Getter for property notRunModuleProgram. * @return Value of property notRunModuleProgram. */ public boolean isNotRunModuleProgram() { return notRunModuleProgram; } /** * Setter for property notRunModuleProgram. * @param notRunModuleProgram New value of property notRunModuleProgram. */ public void setNotRunModuleProgram(boolean notRunModuleProgram) { this.notRunModuleProgram = notRunModuleProgram; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/history/0000755000175300001440000000000011175434236025164 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/history/HistoryCommand.java0000644000175300001440000005472711175406777031017 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.history; import java.util.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * The history command provides information history of activities in repository. * @author Milos Kleint */ public class HistoryCommand extends Command { /** * The requests that are sent and processed. */ private final List requests = new LinkedList(); /** * The event manager to use */ private EventManager eventManager; /** Holds value of property forAllUsers. */ private boolean forAllUsers; /** Holds value of property goBackToRecord. */ private String showBackToRecordContaining; /** Holds value of property reportCommits. */ private boolean reportCommits; /** Holds value of property sinceDate. */ private String sinceDate; /** Holds value of property reportEverything. */ private boolean reportEverything; /** Holds value of property lastEventOfProject. */ private boolean lastEventOfProject; /** Holds value of property reportCheckout. */ private boolean reportCheckouts; /** Holds value of property sinceRevision. */ private String sinceRevision; /** Holds value of property reportTags. */ private boolean reportTags; /** Holds value of property sinceTag. */ private String sinceTag; /** Holds value of property forWorkingDirectory. */ private boolean forWorkingDirectory; /** Holds value of property reportEventType. */ private String reportEventType; /** Holds value of property timeZone. */ private String timeZone; /** Holds value of property lastEventForFile. */ private String[] lastEventForFile; /** Holds value of property reportOnModule. */ private String[] reportOnModule; /** Holds value of property reportLastEventForModule. */ private String[] reportLastEventForModule; /** Holds value of property forUsers. */ private String[] forUsers; /** * Construct a new history command */ public HistoryCommand() { } /** * Create a builder for this command. * @param eventMan the event manager used to receive events. */ public Builder createBuilder(EventManager eventMan) { return null; } /** * Execute a command * @param client the client services object that provides any necessary * services to this command, including the ability to actually process * all the requests. */ public void execute(ClientServices client, EventManager em) throws CommandException, AuthenticationException { client.ensureConnection(); eventManager = em; requests.clear(); super.execute(client, em); try { if (client.isFirstCommand()) { requests.add(new RootRequest(client.getRepository())); requests.add(new UseUnchangedRequest()); } addBooleanArgument(requests, isForAllUsers(), "-a"); //NOI18N addBooleanArgument(requests, isForWorkingDirectory(), "-w"); //NOI18N addBooleanArgument(requests, isLastEventOfProject(), "-l"); //NOI18N addBooleanArgument(requests, isReportCheckouts(), "-o"); //NOI18N addBooleanArgument(requests, isReportCommits(), "-c"); //NOI18N addBooleanArgument(requests, isReportEverything(), "-e"); //NOI18N addBooleanArgument(requests, isReportTags(), "-T"); //NOI18N addStringArgument(requests, getReportEventType(), "-x"); //NOI18N addStringArgument(requests, getShowBackToRecordContaining(), "-b"); //NOI18N addStringArgument(requests, getSinceDate(), "-D"); //NOI18N addStringArgument(requests, getSinceRevision(), "-r"); //NOI18N addStringArgument(requests, getSinceTag(), "-t"); //NOI18N addStringArrayArgument(requests, getForUsers(), "-u"); //NOI18N addStringArrayArgument(requests, getReportLastEventForModule(), "-n"); //NOI18N addStringArrayArgument(requests, getReportOnModule(), "-m"); //NOI18N addStringArrayArgument(requests, getLastEventForFile(), "-f"); //NOI18N if (!isReportCheckouts() && !isReportCommits() && !isReportTags() && !isReportEverything() && getReportEventType() == null && getReportOnModule() == null) { // this is the default switch if nothing else is specified. addBooleanArgument(requests, true, "-c"); //NOI18N } if (getTimeZone() != null) { addStringArgument(requests, getTimeZone(), "-z"); //NOI18N } else { addStringArgument(requests, "+0000", "-z"); //NOI18N } requests.add(CommandRequest.HISTORY); client.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } finally { requests.clear(); } } private void addStringArgument(List reqList, String property, String cvsSwitch) { if (property != null) { reqList.add(new ArgumentRequest(cvsSwitch)); reqList.add(new ArgumentRequest(property)); } } private void addStringArrayArgument(List reqList, String[] property, String cvsSwitch) { if (property != null) { for (int i = 0; i < property.length; i++) { reqList.add(new ArgumentRequest(cvsSwitch)); reqList.add(new ArgumentRequest(property[i])); } } } private void addBooleanArgument(List reqList, boolean property, String cvsSwitch) { if (property == true) { reqList.add(new ArgumentRequest(cvsSwitch)); } } /** called when server responses with "ok" or "error", (when the command finishes) */ public void commandTerminated(TerminationEvent e) { } /** This method returns how the command would looklike when typed on the command line. * Each command is responsible for constructing this information. * @returns [] files/dirs. Example: checkout -p CvsCommand.java * */ public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("history "); //NOI18N toReturn.append(getCVSArguments()); return toReturn.toString(); } /** takes the arguments and sets the command. To be mainly * used for automatic settings (like parsing the .cvsrc file) * @return true if the option (switch) was recognized and set */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'a') { setForAllUsers(true); } else if (opt == 'b') { setShowBackToRecordContaining(optArg); } else if (opt == 'c') { setReportCommits(true); } else if (opt == 'D') { setSinceDate(optArg); } else if (opt == 'e') { setReportEverything(true); } else if (opt == 'l') { setLastEventOfProject(true); } else if (opt == 'o') { setReportCheckouts(true); } else if (opt == 'r') { setSinceRevision(optArg); } else if (opt == 'T') { setReportTags(true); } else if (opt == 't') { setSinceTag(optArg); } else if (opt == 'w') { setForWorkingDirectory(true); } else if (opt == 'x') { setReportEventType(optArg); } else if (opt == 'z') { setTimeZone(optArg); } else if (opt == 'f') { addLastEventForFile(optArg); } else if (opt == 'm') { addReportOnModule(optArg); } else if (opt == 'n') { addReportLastEventForModule(optArg); } else if (opt == 'u') { addForUsers(optArg); } else { return false; } return true; } /** * String returned by this method defines which options are available for this particular command */ public String getOptString() { return "ab:cD:ef:lm:n:or:Tt:u:wx:z:"; //NOI18N } /** * resets all switches in the command. After calling this method, * the command should have no switches defined and should behave defaultly. */ public void resetCVSCommand() { setForAllUsers(false); setForUsers(null); setForWorkingDirectory(false); setLastEventForFile(null); setLastEventOfProject(false); setReportCheckouts(false); setReportCommits(false); setReportEventType(null); setReportEverything(false); setReportLastEventForModule(null); setReportOnModule(null); setReportTags(false); setShowBackToRecordContaining(null); setSinceDate(null); setSinceRevision(null); setSinceTag(null); setTimeZone(null); } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name */ public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(""); //NOI18N if (isForAllUsers()) { toReturn.append("-a "); //NOI18N } if (isForWorkingDirectory()) { toReturn.append("-w "); //NOI18N } if (isLastEventOfProject()) { toReturn.append("-l "); //NOI18N } if (isReportCheckouts()) { toReturn.append("-o "); //NOI18N } if (isReportCommits()) { toReturn.append("-c "); //NOI18N } if (isReportEverything()) { toReturn.append("-e "); //NOI18N } if (isReportTags()) { toReturn.append("-T "); //NOI18N } if (getForUsers() != null) { appendArrayToSwitches(toReturn, getForUsers(), "-u "); //NOI18N } if (getLastEventForFile() != null) { appendArrayToSwitches(toReturn, getLastEventForFile(), "-f "); //NOI18N } if (getReportEventType() != null) { toReturn.append("-x "); //NOI18N toReturn.append(getReportEventType()); toReturn.append(" "); //NOI18N } if (getReportLastEventForModule() != null) { appendArrayToSwitches(toReturn, getReportLastEventForModule(), "-n "); //NOI18N } if (getReportOnModule() != null) { appendArrayToSwitches(toReturn, getReportOnModule(), "-m "); //NOI18N } if (getShowBackToRecordContaining() != null) { toReturn.append("-b "); //NOI18N toReturn.append(getShowBackToRecordContaining()); toReturn.append(" "); //NOI18N } if (getSinceDate() != null) { toReturn.append("-D "); //NOI18N toReturn.append(getSinceDate()); toReturn.append(" "); //NOI18N } if (getSinceRevision() != null) { toReturn.append("-r "); //NOI18N toReturn.append(getSinceRevision()); toReturn.append(" "); //NOI18N } if (getSinceTag() != null) { toReturn.append("-t "); //NOI18N toReturn.append(getSinceTag()); toReturn.append(" "); //NOI18N } if (getTimeZone() != null) { toReturn.append("-z "); //NOI18N toReturn.append(getTimeZone()); toReturn.append(" "); //NOI18N } return toReturn.toString(); } private void appendArrayToSwitches(StringBuffer buff, String[] arr, String cvsSwitch) { if (arr == null) { return; } for (int i = 0; i < arr.length; i++) { buff.append(cvsSwitch); buff.append(arr[i]); buff.append(" "); //NOI18N } } /** Getter for property forAllUsers. (cvs switch -a) * @return Value of property forAllUsers. */ public boolean isForAllUsers() { return this.forAllUsers; } /** Setter for property forAllUsers. (cvs switch -a) * @param forAllUsers New value of property forAllUsers. */ public void setForAllUsers(boolean forAllUsers) { this.forAllUsers = forAllUsers; } /** Getter for property goBackToRecord. (cvs switch -b) * @return Value of property goBackToRecord. */ public String getShowBackToRecordContaining() { return this.showBackToRecordContaining; } /** Setter for property goBackToRecord. (cvs switch -b) * @param goBackToRecord New value of property goBackToRecord. */ public void setShowBackToRecordContaining(String goBackToRecord) { this.showBackToRecordContaining = goBackToRecord; } /** Getter for property reportCommits. (cvs switch -c) * @return Value of property reportCommits. */ public boolean isReportCommits() { return this.reportCommits; } /** Setter for property reportCommits. (cvs switch -b) * @param reportCommits New value of property reportCommits. */ public void setReportCommits(boolean reportCommits) { this.reportCommits = reportCommits; } /** Getter for property sinceDate. (cvs switch -D) * @return Value of property sinceDate. */ public String getSinceDate() { return this.sinceDate; } /** Setter for property sinceDate. (cvs switch -D) * @param sinceDate New value of property sinceDate. */ public void setSinceDate(String sinceDate) { this.sinceDate = sinceDate; } /** Getter for property reportEverything. (cvs switch -e) * @return Value of property reportEverything. */ public boolean isReportEverything() { return this.reportEverything; } /** Setter for property reportEverything. (cvs switch -e) * @param reportEverything New value of property reportEverything. */ public void setReportEverything(boolean reportEverything) { this.reportEverything = reportEverything; } /** Getter for property lastEventOfProject. (cvs switch -l) * @return Value of property lastEventOfProject. */ public boolean isLastEventOfProject() { return this.lastEventOfProject; } /** Setter for property lastEventOfProject. (cvs switch -l) * @param lastEventOfProject New value of property lastEventOfProject. */ public void setLastEventOfProject(boolean lastEventOfProject) { this.lastEventOfProject = lastEventOfProject; } /** Getter for property reportCheckout. (cvs switch -o) * @return Value of property reportCheckout. */ public boolean isReportCheckouts() { return this.reportCheckouts; } /** Setter for property reportCheckout. (cvs switch -o) * @param reportCheckout New value of property reportCheckout. */ public void setReportCheckouts(boolean reportCheckout) { this.reportCheckouts = reportCheckout; } /** Getter for property sinceRevision. (cvs switch -r) * @return Value of property sinceRevision. */ public String getSinceRevision() { return this.sinceRevision; } /** Setter for property sinceRevision. (cvs switch -r) * @param sinceRevision New value of property sinceRevision. */ public void setSinceRevision(String sinceRevision) { this.sinceRevision = sinceRevision; } /** Getter for property reportTags. (cvs switch -T) * @return Value of property reportTags. */ public boolean isReportTags() { return this.reportTags; } /** Setter for property reportTags. (cvs switch -T) * @param reportTags New value of property reportTags. */ public void setReportTags(boolean reportTags) { this.reportTags = reportTags; } /** Getter for property sinceTag. (cvs switch -t) * @return Value of property sinceTag. */ public String getSinceTag() { return this.sinceTag; } /** Setter for property sinceTag. (cvs switch -t) * @param sinceTag New value of property sinceTag. */ public void setSinceTag(String sinceTag) { this.sinceTag = sinceTag; } /** Getter for property forWorkingDirectory. (cvs switch -w) * @return Value of property forWorkingDirectory. */ public boolean isForWorkingDirectory() { return this.forWorkingDirectory; } /** Setter for property forWorkingDirectory. (cvs switch -w) * @param forWorkingDirectory New value of property forWorkingDirectory. */ public void setForWorkingDirectory(boolean forWorkingDirectory) { this.forWorkingDirectory = forWorkingDirectory; } /** Getter for property reportEventType. (cvs switch -x) * @return Value of property reportEventType. */ public String getReportEventType() { return this.reportEventType; } /** Setter for property reportEventType. (cvs switch -x) * @param reportEventType New value of property reportEventType. */ public void setReportEventType(String reportEventType) { this.reportEventType = reportEventType; } /** Getter for property timeZone. (cvs switch -z) * @return Value of property timeZone. */ public String getTimeZone() { return this.timeZone; } /** Setter for property timeZone. (cvs switch -z) * @param timeZone New value of property timeZone. */ public void setTimeZone(String timeZone) { this.timeZone = timeZone; } /** Getter for property lastEventForFile. (cvs switch -f) * @return Value of property lastEventForFile. */ public String[] getLastEventForFile() { return this.lastEventForFile; } /** Setter for property lastEventForFile. (cvs switch -f) * @param lastEventForFile New value of property lastEventForFile. */ public void setLastEventForFile(String[] lastEventForFile) { this.lastEventForFile = lastEventForFile; } public void addLastEventForFile(String newFile) { this.lastEventForFile = addNewValue(this.lastEventForFile, newFile); } /** Getter for property reportOnModule. (cvs switch -m) * @return Value of property reportOnModule. */ public String[] getReportOnModule() { return this.reportOnModule; } /** Setter for property reportOnModule. (cvs switch -m) * @param reportOnModule New value of property reportOnModule. */ public void setReportOnModule(String[] reportOnModule) { this.reportOnModule = reportOnModule; } public void addReportOnModule(String newReportOnModule) { this.reportOnModule = addNewValue(this.reportOnModule, newReportOnModule); } /** Getter for property reportLastEventForModule. (cvs switch -n) * @return Value of property reportLastEventForModule. */ public String[] getReportLastEventForModule() { return this.reportLastEventForModule; } /** Setter for property reportLastEventForModule. (cvs switch -n) * @param reportLastEventForModule New value of property reportLastEventForModule. */ public void setReportLastEventForModule(String[] reportLastEventForModule) { this.reportLastEventForModule = reportLastEventForModule; } public void addReportLastEventForModule(String newModule) { this.reportLastEventForModule = addNewValue(this.reportLastEventForModule, newModule); } /** Getter for property forUsers. (cvs switch -u) * @return Value of property forUsers. */ public String[] getForUsers() { return this.forUsers; } /** Setter for property forUsers. (cvs switch -u) * @param forUsers New value of property forUsers. */ public void setForUsers(String[] forUsers) { this.forUsers = forUsers; } public void addForUsers(String forUser) { this.forUsers = addNewValue(this.forUsers, forUser); } private String[] addNewValue(String[] arr, String newVal) { if (arr == null) { arr = new String[]{newVal}; return arr; } String[] newValue = new String[arr.length + 1]; for (int i = 0; i < arr.length; i++) { newValue[i] = arr[i]; } newValue[newValue.length] = newVal; return newValue; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/importcmd/0000755000175300001440000000000011175434236025461 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/importcmd/ImportBuilder.java0000644000175300001440000001024511175406777031120 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.importcmd; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.event.*; /** * @author Thomas Singer */ public class ImportBuilder implements Builder { private static final String NO_CONFLICTS = "No conflicts created by this import"; //NOI18N private static final String FILE_INFOS = "NUCIL?"; //NOI18N private final EventManager eventManager; private final String localPath; private final String module; private DefaultFileInfoContainer fileInfoContainer; public ImportBuilder(EventManager eventManager, ImportCommand importCommand) { this.eventManager = eventManager; this.localPath = importCommand.getLocalDirectory(); this.module = importCommand.getModule(); } public void outputDone() { if (fileInfoContainer == null) { return; } FileInfoEvent event = new FileInfoEvent(this, fileInfoContainer); eventManager.fireCVSEvent(event); fileInfoContainer = null; } public void parseLine(String line, boolean isErrorMessage) { if (line.length() > 2 && line.charAt(1) == ' ') { String firstChar = line.substring(0, 1); if (FILE_INFOS.indexOf(firstChar) >= 0) { String filename = line.substring(2).trim(); processFile(firstChar, filename); } else { error(line); } } else if (line.startsWith(NO_CONFLICTS)) { outputDone(); } } public void parseEnhancedMessage(String key, Object value) { } private void error(String line) { System.err.println("Don't know anything about: " + line); } private void processFile(String type, String filename) { outputDone(); filename = filename.substring(module.length()); File file = new File(localPath, filename); fileInfoContainer = new DefaultFileInfoContainer(); fileInfoContainer.setType(type); fileInfoContainer.setFile(file); outputDone(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/importcmd/ImportCommand.java0000644000175300001440000004731111175406777031114 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.importcmd; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; import org.netbeans.lib.cvsclient.response.WrapperSendResponse; import org.netbeans.lib.cvsclient.util.*; /** * The import command imports local directory structures into the repository. * * @author Thomas Singer */ public class ImportCommand extends BuildableCommand { private Map wrapperMap = new HashMap(); private String logMessage; private String module; private String releaseTag; private String vendorBranch; private String vendorTag; private String importDirectory; private KeywordSubstitutionOptions keywordSubstitutionOptions; private boolean useFileModifTime; private List ignoreList = new LinkedList(); public ImportCommand() { resetCVSCommand(); } public void addWrapper(String filenamePattern, KeywordSubstitutionOptions keywordSubstitutionOptions) { if (keywordSubstitutionOptions == null) { throw new IllegalArgumentException("keywordSubstitutionOptions must not be null"); } wrapperMap.put(new SimpleStringPattern(filenamePattern), keywordSubstitutionOptions); } public void addWrapper(StringPattern filenamePattern, KeywordSubstitutionOptions keywordSubstitutionOptions) { if (keywordSubstitutionOptions == null) { throw new IllegalArgumentException("keywordSubstitutionOptions must not be null"); } wrapperMap.put(filenamePattern, keywordSubstitutionOptions); } /** * Compliant method to addWrapper. It replaces the whole list of cvswrappers. * The Map's structure should be following: * Key: instance of StringPattern(fileName wildpattern) * Value: instance of KeywordSubstitutionOptions */ public void setWrappers(Map wrapperMap) { this.wrapperMap = wrapperMap; } /** * Returns a map with all wrappers. * For map descriptions see setWrapper() */ public Map getWrappers() { return wrapperMap; } /** * Returns the keyword substitution option. */ public KeywordSubstitutionOptions getKeywordSubstitutionOptions() { return keywordSubstitutionOptions; } /** * Sets the keywords substitution option. */ public void setKeywordSubstitutionOptions(KeywordSubstitutionOptions keywordSubstitutionOptions) { this.keywordSubstitutionOptions = keywordSubstitutionOptions; } /** * Returns the release tag. */ public String getReleaseTag() { return releaseTag; } /** * Sets the necessary release tag. */ public void setReleaseTag(String releaseTag) { this.releaseTag = getTrimmedString(releaseTag); } /** * Returns the log message. */ public String getLogMessage() { return logMessage; } /** * Sets the log message. */ public void setLogMessage(String logMessage) { this.logMessage = getTrimmedString(logMessage); } /** * Returns the module (the in-repository path, where the files should be * stored. */ public String getModule() { return module; } /** * Sets the module (the in-repository path, where the files should be * stored). */ public void setModule(String module) { this.module = getTrimmedString(module); } /** * Pints to directoty to import. */ public void setImportDirectory(String directory) { importDirectory = directory; } public String getImportDirectory() { return importDirectory; } /** * Returns the vendor branch. */ public String getVendorBranch() { return vendorBranch; } /** * Returns the vendor branch. * If not set, then 1.1.1 is returned. */ private String getVendorBranchNotNull() { if (vendorBranch == null) { return "1.1.1"; //NOI18N } return vendorBranch; } /** * Sets the vendor branch. * If null is set, the default branch 1.1.1 is used automatically. */ public void setVendorBranch(String vendorBranch) { this.vendorBranch = getTrimmedString(vendorBranch); } /** * Returns the vendor tag. */ public String getVendorTag() { return vendorTag; } /** * Sets the necessary vendor tag. */ public void setVendorTag(String vendorTag) { this.vendorTag = getTrimmedString(vendorTag); } /** * Tells, whether the file modification time is to be used as the time of the import. */ public boolean isUseFileModifTime() { return useFileModifTime; } /** * Sets whether the file modification time is to be used as the time of the import. */ public void setUseFileModifTime(boolean useFileModifTime) { this.useFileModifTime = useFileModifTime; } /** * Get a list of files that are ignored by import. */ public List getIgnoreFiles() { return Collections.unmodifiableList(ignoreList); } /** * Add a file name that is to be ignored by the import. */ public void addIgnoredFile(String ignoredFileName) { ignoreList.add(ignoredFileName); } /** * Executes thiz command using the set options. */ public void execute(ClientServices client, EventManager eventManager) throws CommandException, AuthenticationException { // check necessary fields if (getLogMessage() == null) { String localizedMsg = CommandException.getLocalMessage("ImportCommand.messageEmpty"); //NOI18N throw new CommandException("message may not be null nor empty", //NOI18N localizedMsg); } if (getModule() == null) { String localizedMsg = CommandException.getLocalMessage("ImportCommand.moduleEmpty"); //NOI18N throw new CommandException("module may not be null nor empty", //NOI18N localizedMsg); } if (getReleaseTag() == null) { String localizedMsg = CommandException.getLocalMessage("ImportCommand.releaseTagEmpty"); //NOI18N throw new CommandException("release tag may not be null nor empty", //NOI18N localizedMsg); } if (getVendorTag() == null) { String localizedMsg = CommandException.getLocalMessage("ImportCommand.vendorTagEmpty"); //NOI18N throw new CommandException("vendor tag may not be null nor empty", //NOI18N localizedMsg); } client.ensureConnection(); // get the connection wrappers here Map allWrappersMap = new HashMap(client.getWrappersMap()); allWrappersMap.putAll(getWrappers()); setWrappers(allWrappersMap); // start working super.execute(client, eventManager); assert getLocalDirectory() != null : "local directory may not be null"; List requestList = new ArrayList(); try { // add requests requestList.add(new ArgumentRequest("-b")); //NOI18N requestList.add(new ArgumentRequest(getVendorBranchNotNull())); if (getKeywordSubstitutionOptions() != null) { requestList.add(new ArgumentRequest("-k")); //NOI18N requestList.add(new ArgumentRequest(getKeywordSubstitutionOptions().toString())); } addMessageRequests(requestList, getLogMessage()); addWrapperRequests(requestList, this.wrapperMap); if (isUseFileModifTime()) { requestList.add(new ArgumentRequest("-d")); //NOI18N } for (int i = 0; i < ignoreList.size(); i++) { requestList.add(new ArgumentRequest("-I")); //NOI18N requestList.add(new ArgumentRequest((String) ignoreList.get(i))); } requestList.add(new ArgumentRequest(getModule())); requestList.add(new ArgumentRequest(getVendorTag())); requestList.add(new ArgumentRequest(getReleaseTag())); addFileRequests(new File(getLocalDirectory()), requestList, client); requestList.add(new DirectoryRequest(".", getRepositoryRoot(client))); //NOI18N requestList.add(CommandRequest.IMPORT); // process the requests client.processRequests(requestList); } catch (CommandException ex) { throw ex; } catch (EOFException ex) { String localizedMsg = CommandException.getLocalMessage("CommandException.EndOfFile", null); //NOI18N throw new CommandException(ex, localizedMsg); } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } } public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("import "); //NOI18N toReturn.append(getCVSArguments()); if (getModule() != null) { toReturn.append(" "); //NOI18N toReturn.append(getModule()); } else { String localizedMsg = CommandException.getLocalMessage("ImportCommand.moduleEmpty.text"); //NOI18N toReturn.append(" "); //NOI18N toReturn.append(localizedMsg); } if (getVendorTag() != null) { toReturn.append(" "); //NOI18N toReturn.append(getVendorTag()); } else { String localizedMsg = CommandException.getLocalMessage("ImportCommand.vendorTagEmpty.text"); //NOI18N toReturn.append(" "); //NOI18N toReturn.append(localizedMsg); } if (getReleaseTag() != null) { toReturn.append(" "); //NOI18N toReturn.append(getReleaseTag()); } else { String localizedMsg = CommandException.getLocalMessage("ImportCommand.releaseTagEmpty.text"); //NOI18N toReturn.append(" "); //NOI18N toReturn.append(localizedMsg); } return toReturn.toString(); } public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(""); //NOI18N if (getLogMessage() != null) { toReturn.append("-m \""); //NOI18N toReturn.append(getLogMessage()); toReturn.append("\" "); //NOI18N } if (getKeywordSubstitutionOptions() != null) { toReturn.append("-k"); //NOI18N toReturn.append(getKeywordSubstitutionOptions().toString()); toReturn.append(" "); //NOI18N } if (getVendorBranch() != null) { toReturn.append("-b "); //NOI18N toReturn.append(getVendorBranch()); toReturn.append(" "); //NOI18N } if (isUseFileModifTime()) { toReturn.append("-d "); // NOI18N } if (wrapperMap.size() > 0) { Iterator it = wrapperMap.keySet().iterator(); while (it.hasNext()) { StringPattern pattern = (StringPattern)it.next(); KeywordSubstitutionOptions keywordSubstitutionOptions = (KeywordSubstitutionOptions)wrapperMap.get(pattern); toReturn.append("-W "); //NOI18N toReturn.append(pattern.toString()); toReturn.append(" -k '"); //NOI18N toReturn.append(keywordSubstitutionOptions.toString()); toReturn.append("' "); //NOI18N } } for (Iterator it = ignoreList.iterator(); it.hasNext(); ) { toReturn.append("-I "); //NOI18N toReturn.append((String) it.next()); toReturn.append(" "); //NOI18N } return toReturn.toString(); } public boolean setCVSCommand(char opt, String optArg) { if (opt == 'b') { setVendorBranch(optArg); } else if (opt == 'm') { setLogMessage(optArg); } else if (opt == 'k') { setKeywordSubstitutionOptions(KeywordSubstitutionOptions.findKeywordSubstOption(optArg)); } else if (opt == 'W') { Map wrappers = WrapperSendResponse.parseWrappers(optArg); for (Iterator it = wrappers.keySet().iterator(); it.hasNext(); ) { StringPattern pattern = (StringPattern) it.next(); KeywordSubstitutionOptions keywordOption = (KeywordSubstitutionOptions) wrappers.get(pattern); addWrapper(pattern, keywordOption); } } else if (opt == 'd') { setUseFileModifTime(true); } else if (opt == 'I') { addIgnoredFile(optArg); } else { return false; } return true; } public void resetCVSCommand() { setLogMessage(null); setModule(null); setReleaseTag(null); setVendorTag(null); setVendorBranch(null); setUseFileModifTime(false); ignoreList.clear(); wrapperMap.clear(); } public String getOptString() { return "m:W:b:k:dI:"; //NOI18N } /** * Adds requests for the specified logMessage to the specified requestList. */ private void addMessageRequests(List requestList, String logMessage) { requestList.add(new ArgumentRequest("-m")); //NOI18N StringTokenizer token = new StringTokenizer(logMessage, "\n", false); //NOI18N boolean first = true; while (token.hasMoreTokens()) { if (first) { requestList.add(new ArgumentRequest(token.nextToken())); first = false; } else { requestList.add(new ArgumentxRequest(token.nextToken())); } } } /** * Adds requests for specified wrappers to the specified requestList. */ private void addWrapperRequests(List requestList, Map wrapperMap) { for (Iterator it = wrapperMap.keySet().iterator(); it.hasNext();) { StringPattern pattern = (StringPattern) it.next(); KeywordSubstitutionOptions keywordSubstitutionOptions = (KeywordSubstitutionOptions)wrapperMap.get(pattern); StringBuffer buffer = new StringBuffer(); buffer.append(pattern.toString()); buffer.append(" -k '"); //NOI18N buffer.append(keywordSubstitutionOptions.toString()); buffer.append("'"); //NOI18N requestList.add(new ArgumentRequest("-W")); //NOI18N requestList.add(new ArgumentRequest(buffer.toString())); } } /** * Adds recursively all request for files and directories in the specified * directory to the specified requestList. */ private void addFileRequests(File directory, List requestList, ClientServices clientServices) throws IOException { String relativePath = getRelativeToLocalPathInUnixStyle(directory); String repository = getRepositoryRoot(clientServices); if (!relativePath.equals(".")) { //NOI18N repository += '/' + relativePath; } requestList.add(new DirectoryRequest(relativePath, repository)); File[] files = directory.listFiles(); if (files == null) { return; } List subdirectories = null; for (int i = 0; i < files.length; i++) { File file = files[i]; String filename = file.getName(); if (clientServices.shouldBeIgnored(directory, filename)) { continue; } if (file.isDirectory()) { if (subdirectories == null) { subdirectories = new LinkedList(); } subdirectories.add(file); } else { boolean isBinary = isBinary(filename); requestList.add(new ModifiedRequest(file, isBinary)); } } if (subdirectories != null) { for (Iterator it = subdirectories.iterator(); it.hasNext();) { File subdirectory = (File)it.next(); addFileRequests(subdirectory, requestList, clientServices); } } } /** * Returns the used root path in the repository. * It's built from the repository stored in the clientService and the * module. */ private String getRepositoryRoot(ClientServices clientServices) { String repository = clientServices.getRepository() + '/' + getModule(); return repository; } /** * Returns true, if the file for the specified filename should be treated as * a binary file. * * The information comes from the wrapper map and the set keywordsubstitution. */ private boolean isBinary(String filename) { KeywordSubstitutionOptions keywordSubstitutionOptions = getKeywordSubstitutionOptions(); for (Iterator it = wrapperMap.keySet().iterator(); it.hasNext();) { StringPattern pattern = (StringPattern)it.next(); if (pattern.doesMatch(filename)) { keywordSubstitutionOptions = (KeywordSubstitutionOptions)wrapperMap.get(pattern); break; } } return keywordSubstitutionOptions == KeywordSubstitutionOptions.BINARY; } /** * Creates the ImportBuilder. */ public Builder createBuilder(EventManager eventManager) { return new ImportBuilder(eventManager, this); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/log/0000755000175300001440000000000011175434236024244 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/log/LogBuilder.java0000644000175300001440000003236511175406777027161 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.log; import java.io.*; import java.util.*; import java.text.SimpleDateFormat; import java.text.ParseException; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.util.*; /** * Handles the building of a log information object and the firing of * events when complete objects are built. * @author Milos Kleint */ public class LogBuilder implements Builder { private static final String LOGGING_DIR = ": Logging "; //NOI18N private static final String RCS_FILE = "RCS file: "; //NOI18N private static final String WORK_FILE = "Working file: "; //NOI18N private static final String REV_HEAD = "head: "; //NOI18N private static final String BRANCH = "branch: "; //NOI18N private static final String LOCKS = "locks: "; //NOI18N private static final String ACCESS_LIST = "access list: "; //NOI18N private static final String SYM_NAME = "symbolic names:"; //NOI18N private static final String KEYWORD_SUBST = "keyword substitution: "; //NOI18N private static final String TOTAL_REV = "total revisions: "; //NOI18N private static final String SEL_REV = ";\tselected revisions: "; //NOI18N private static final String DESCRIPTION = "description:"; //NOI18N private static final String REVISION = "revision "; //NOI18N private static final String DATE = "date: "; //NOI18N private static final String BRANCHES = "branches: "; //NOI18N private static final String AUTHOR = "author: "; //NOI18N private static final String STATE = "state: "; //NOI18N private static final String LINES = "lines: "; //NOI18N private static final String COMMITID = "commitid: "; //NOI18N private static final String SPLITTER = "----------------------------"; //NOI18N private static final String FINAL_SPLIT = "============================================================================="; //NOI18N private static final String ERROR = ": nothing known about "; //NOI18N private static final String NO_FILE = "no file"; //NOI18N /** * The event manager to use */ protected EventManager eventManager; protected BasicCommand logCommand; /** * The log object that is currently being built */ protected LogInformation logInfo; protected LogInformation.Revision revision; /** * The directory in which the file being processed lives. This is * relative to the local directory */ protected String fileDirectory; private boolean addingSymNames; private boolean addingDescription; private boolean addingLogMessage; private StringBuffer tempBuffer = null; private List messageList; private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); //NOI18N public LogBuilder(EventManager eventMan, BasicCommand command) { logCommand = command; eventManager = eventMan; addingSymNames = false; addingDescription = false; addingLogMessage = false; logInfo = null; revision = null; messageList = new ArrayList(500); } public void outputDone() { if (logInfo != null) { eventManager.fireCVSEvent(new FileInfoEvent(this, logInfo)); logInfo = null; messageList = null; } } public void parseLine(String line, boolean isErrorMessage) { if (line.equals(FINAL_SPLIT)) { if (addingDescription) { addingDescription = false; logInfo.setDescription(tempBuffer.toString()); } if (addingLogMessage) { addingLogMessage = false; revision.setMessage(CommandUtils.findUniqueString(tempBuffer.toString(), messageList)); } if (revision != null) { logInfo.addRevision(revision); revision = null; } // fire the event and exit if (logInfo != null) { eventManager.fireCVSEvent(new FileInfoEvent(this, logInfo)); logInfo = null; tempBuffer = null; } return; } if (addingLogMessage) { // first check for the branches tag if (line.startsWith(BRANCHES)) { processBranches(line.substring(BRANCHES.length())); } else { processLogMessage(line); return; } } if (addingSymNames) { processSymbolicNames(line); } if (addingDescription) { processDescription(line); } // revision stuff first -> will be the most common to parse if (line.startsWith(REVISION)) { processRevisionStart(line); } if (line.startsWith(DATE)) { processRevisionDate(line); } if (line.startsWith(KEYWORD_SUBST)) { logInfo.setKeywordSubstitution(line.substring(KEYWORD_SUBST.length()).trim().intern()); addingSymNames = false; return; } if (line.startsWith(DESCRIPTION)) { tempBuffer = new StringBuffer(line.substring(DESCRIPTION.length())); addingDescription = true; } if (line.indexOf(LOGGING_DIR) >= 0) { fileDirectory = line.substring(line.indexOf(LOGGING_DIR) + LOGGING_DIR.length()).trim(); return; } if (line.startsWith(RCS_FILE)) { processRcsFile(line.substring(RCS_FILE.length())); return; } if (line.startsWith(WORK_FILE)) { processWorkingFile(line.substring(WORK_FILE.length())); return; } if (line.startsWith(REV_HEAD)) { logInfo.setHeadRevision(line.substring(REV_HEAD.length()).trim().intern()); return; } if (line.startsWith(BRANCH)) { logInfo.setBranch(line.substring(BRANCH.length()).trim().intern()); } if (line.startsWith(LOCKS)) { logInfo.setLocks(line.substring(LOCKS.length()).trim().intern()); } if (line.startsWith(ACCESS_LIST)) { logInfo.setAccessList(line.substring(ACCESS_LIST.length()).trim().intern()); } if (line.startsWith(SYM_NAME)) { addingSymNames = true; } if (line.startsWith(TOTAL_REV)) { int ind = line.indexOf(';'); if (ind < 0) { // no selected revisions here.. logInfo.setTotalRevisions(line.substring(TOTAL_REV.length()).trim().intern()); logInfo.setSelectedRevisions("0"); //NOI18N } else { String total = line.substring(0, ind); String select = line.substring(ind, line.length()); logInfo.setTotalRevisions(total.substring(TOTAL_REV.length()).trim().intern()); logInfo.setSelectedRevisions(select.substring(SEL_REV.length()).trim().intern()); } } } private String findUniqueString(String name, List list) { if (name == null) { return null; } int index = list.indexOf(name); if (index >= 0) { return (String)list.get(index); } else { String newName = name; list.add(newName); return newName; } } private void processRcsFile(String line) { if (logInfo != null) { //do fire logcreated event; } logInfo = new LogInformation(); logInfo.setRepositoryFilename(line.trim()); } private void processWorkingFile(String line) { String fileName = line.trim(); if (fileName.startsWith(NO_FILE)) { fileName = fileName.substring(8); } logInfo.setFile(createFile(line)); } private void processBranches(String line) { int ind = line.lastIndexOf(';'); if (ind > 0) { line = line.substring(0, ind); } revision.setBranches(line.trim()); } private void processLogMessage(String line) { if (line.startsWith(SPLITTER)) { addingLogMessage = false; revision.setMessage(findUniqueString(tempBuffer.toString(), messageList)); return; } tempBuffer.append(line + "\n"); //NOI18N } private void processSymbolicNames(String line) { if (!line.startsWith(KEYWORD_SUBST)) { line = line.trim(); int index = line.indexOf(':'); if (index > 0) { String symName = line.substring(0, index).trim(); String revName = line.substring(index + 1, line.length()).trim(); logInfo.addSymbolicName(symName.intern(), revName.intern()); } } } private void processDescription(String line) { if (line.startsWith(SPLITTER)) { addingDescription = false; logInfo.setDescription(tempBuffer.toString()); return; } tempBuffer.append(line); } private void processRevisionStart(String line) { if (revision != null) { logInfo.addRevision(revision); } revision = logInfo.createNewRevision( line.substring(REVISION.length()).intern()); } private void processRevisionDate(String line) { StringTokenizer tokenizer = new StringTokenizer(line, ";", false); //NOI18N while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken().trim(); if (token.startsWith(DATE)) { String dateString = token.substring(DATE.length()); Date date = null; try { // some servers use dashes to separate date components, so replace with slashes // also add a default GMT timezone at the end, if the server already put one in this one will be ignored by the parser dateString = dateString.replace('/', '-') + " +0000"; //NOI18N date = dateFormat.parse(dateString); } catch (ParseException e) { BugLog.getInstance().bug("Couldn't parse date " + dateString); //NOI18N } revision.setDate(date, dateString); } else if (token.startsWith(AUTHOR)) revision.setAuthor(token.substring(AUTHOR.length())); else if (token.startsWith(STATE)) revision.setState(token.substring(STATE.length())); else if (token.startsWith(LINES)) revision.setLines(token.substring(LINES.length())); else if (token.startsWith(COMMITID)) revision.setCommitID(token.substring(COMMITID.length())); } addingLogMessage = true; tempBuffer = new StringBuffer(); } /** * @param fileName relative URL-path to command execution directory */ protected File createFile(String fileName) { StringBuffer path = new StringBuffer(); path.append(logCommand.getLocalDirectory()); path.append(File.separator); path.append(fileName.replace('/', File.separatorChar)); // NOI18N return new File(path.toString()); } public void parseEnhancedMessage(String key, Object value) { } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/log/LogCommand.java0000644000175300001440000003262311175406777027146 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.log; import java.io.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * The log command looks up the log(history) of file(s) in the repository * @author Milos Kleint */ public class LogCommand extends BasicCommand { /** * The event manager to use. */ protected EventManager eventManager; /** * Holds value of property defaultBranch. */ private boolean defaultBranch; /** * Holds value of property dateFilter. */ private String dateFilter; /** * Holds value of property headerOnly. */ private boolean headerOnly; /** * Holds value of property noTags. */ private boolean noTags; /** * Holds value of property revisionFilter. */ private String revisionFilter; /** * Holds value of property stateFilter. */ private String stateFilter; /** * Holds value of property userFilter. */ private String userFilter; /** * Holds value of property headerAndDescOnly. */ private boolean headerAndDescOnly; /** * Construct a new status command */ public LogCommand() { resetCVSCommand(); } /** * Create a builder for this command. * @param eventMan the event manager used to receive events. */ public Builder createBuilder(EventManager eventMan) { return new LogBuilder(eventMan, this); } /** * Execute a command * @param client the client services object that provides any necessary * services to this command, including the ability to actually process * all the requests. */ public void execute(ClientServices client, EventManager em) throws CommandException, AuthenticationException { client.ensureConnection(); eventManager = em; super.execute(client, em); try { // first send out all possible parameters.. if (defaultBranch) { requests.add(1, new ArgumentRequest("-b")); //NOI18N } if (headerAndDescOnly) { requests.add(1, new ArgumentRequest("-t")); //NOI18N } if (headerOnly) { requests.add(1, new ArgumentRequest("-h")); //NOI18N } if (noTags) { requests.add(1, new ArgumentRequest("-N")); //NOI18N } if (userFilter != null) { requests.add(1, new ArgumentRequest("-w" + userFilter)); //NOI18N } if (revisionFilter != null) { requests.add(1, new ArgumentRequest("-r" + revisionFilter)); //NOI18N } if (stateFilter != null) { requests.add(1, new ArgumentRequest("-s" + stateFilter)); //NOI18N } if (dateFilter != null) { requests.add(1, new ArgumentRequest("-d" + dateFilter)); //NOI18N } addRequestForWorkingDirectory(client); addArgumentRequests(); addRequest(CommandRequest.LOG); client.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } finally { requests.clear(); if (!isBuilderSet()) { builder = null; } } } /** * called when server responses with "ok" or "error", (when the command * finishes) */ public void commandTerminated(TerminationEvent e) { if (builder != null) { builder.outputDone(); } } /** * Getter for property defaultBranch, equals the command-line CVS switch * "-b". * @return Value of property defaultBranch. */ public boolean isDefaultBranch() { return defaultBranch; } /** * Setter for property defaultBranch, equals the command-line CVS switch * "-b". * @param defaultBranch New value of property defaultBranch. */ public void setDefaultBranch(boolean defaultBranch) { this.defaultBranch = defaultBranch; } /** * Getter for property dateFilter, equals the command-line CVS switch "-d". * @return Value of property dateFilter. */ public String getDateFilter() { return dateFilter; } /** Setter for property dateFilter, equals the command-line CVS switch "-d". * @param dateFilter New value of property dateFilter. */ public void setDateFilter(String dateFilter) { this.dateFilter = dateFilter; } /** Getter for property headerOnly, equals the command-line CVS switch "-h". * @return Value of property headerOnly. */ public boolean isHeaderOnly() { return headerOnly; } /** Setter for property headerOnly, equals the command-line CVS switch "-h". * @param headerOnly New value of property headerOnly. */ public void setHeaderOnly(boolean headerOnly) { this.headerOnly = headerOnly; } /** Getter for property noTags, equals the command-line CVS switch "-N". * @return Value of property noTags. */ public boolean isNoTags() { return noTags; } /** Setter for property noTags, equals the command-line CVS switch "-N". * @param noTags New value of property noTags. */ public void setNoTags(boolean noTags) { this.noTags = noTags; } /** Getter for property revisionFilter, equals the command-line CVS switch "-r". * @return Value of property revisionFilter. */ public String getRevisionFilter() { return revisionFilter; } /** Setter for property revisionFilter, equals the command-line CVS switch "-r". * @param revisionFilter New value of property revisionFilter. empty string means latest revision of default branch. */ public void setRevisionFilter(String revisionFilter) { this.revisionFilter = revisionFilter; } /** Getter for property stateFilter, equals the command-line CVS switch "-s". * @return Value of property stateFilter. */ public String getStateFilter() { return stateFilter; } /** Setter for property stateFilter, equals the command-line CVS switch "-s". * @param stateFilter New value of property stateFilter. */ public void setStateFilter(String stateFilter) { this.stateFilter = stateFilter; } /** Getter for property userFilter, equals the command-line CVS switch "-w". * @return Value of property userFilter, empty string means the current user. */ public String getUserFilter() { return userFilter; } /** Setter for property userFilter, equals the command-line CVS switch "-w". * @param userFilter New value of property userFilter. */ public void setUserFilter(String userFilter) { this.userFilter = userFilter; } /** Getter for property headerAndDescOnly, equals the command-line CVS switch "-t". * @return Value of property headerAndDescOnly. */ public boolean isHeaderAndDescOnly() { return headerAndDescOnly; } /** Setter for property headerAndDescOnly, equals the command-line CVS switch "-t". * @param headerAndDescOnly New value of property headerAndDescOnly. */ public void setHeaderAndDescOnly(boolean headerAndDescOnly) { this.headerAndDescOnly = headerAndDescOnly; } /** This method returns how the command would looklike when typed on the command line. * Each command is responsible for constructing this information. * @returns [] files/dirs. Example: checkout -p CvsCommand.java * */ public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("log "); //NOI18N toReturn.append(getCVSArguments()); File[] files = getFiles(); if (files != null) { for (int index = 0; index < files.length; index++) { toReturn.append(files[index].getName()); toReturn.append(' '); } } return toReturn.toString(); } /** takes the arguments and sets the command. To be mainly * used for automatic settings (like parsing the .cvsrc file) * @return true if the option (switch) was recognized and set */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'R') { setRecursive(true); } else if (opt == 'l') { setRecursive(false); } else if (opt == 'b') { setDefaultBranch(true); } else if (opt == 'h') { setHeaderOnly(true); } else if (opt == 't') { setHeaderAndDescOnly(true); } else if (opt == 'N') { setNoTags(true); } else if (opt == 'd') { setDateFilter(optArg); } else if (opt == 'r') { setRevisionFilter(optArg == null ? "" : optArg); //NOI18N // for switches with optional args do that.. ^^^^ } else if (opt == 's') { setStateFilter(optArg); } else if (opt == 'w') { setUserFilter(optArg == null ? "" : optArg); //NOI18N } else { return false; } return true; } public void resetCVSCommand() { setRecursive(true); setDefaultBranch(false); setHeaderOnly(false); setHeaderAndDescOnly(false); setNoTags(false); setDateFilter(null); setRevisionFilter(null); setStateFilter(null); setUserFilter(null); } /** * String returned by this method defines which options are available for this particular command */ public String getOptString() { return "RlbhtNd:r:s:w:"; //NOI18N4 } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name */ public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(""); //NOI18N if (isDefaultBranch()) { toReturn.append("-b "); //NOI18N } if (isHeaderAndDescOnly()) { toReturn.append("-t "); //NOI18N } if (isHeaderOnly()) { toReturn.append("-h "); //NOI18N } if (isNoTags()) { toReturn.append("-N "); //NOI18N } if (!isRecursive()) { toReturn.append("-l "); //NOI18N } if (userFilter != null) { toReturn.append("-w"); //NOI18N toReturn.append(userFilter); toReturn.append(' '); } if (revisionFilter != null) { toReturn.append("-r"); //NOI18N toReturn.append(revisionFilter); toReturn.append(' '); } if (stateFilter != null) { toReturn.append("-s"); //NOI18N toReturn.append(stateFilter); toReturn.append(' '); } if (dateFilter != null) { toReturn.append("-d"); //NOI18N toReturn.append(dateFilter); toReturn.append(' '); } return toReturn.toString(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/log/LogInformation.java0000644000175300001440000003672411175406777030063 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.log; import java.io.*; import java.util.*; import java.text.SimpleDateFormat; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.util.*; /** * Describes log information for a file. This is the result of doing a * cvs log command. The fields in instances of this object are populated * by response handlers. * @author Milos Kleint */ public class LogInformation extends FileInfoContainer { private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); //NOI18N private File file; private String repositoryFilename; private String headRevision; private String branch; private String accessList; private String keywordSubstitution; private String totalRevisions; private String selectedRevisions; private String description; private String locks; private final List revisions = new ArrayList(); private final List symbolicNames = new ArrayList(); public LogInformation() { } /** Getter for property file. * @return Value of property file. */ public File getFile() { return file; } /** Setter for property file. * @param file New value of property file. */ public void setFile(File file) { this.file = file; } /** Getter for property repositoryFilename. * @return Value of property repositoryFilename. */ public String getRepositoryFilename() { return repositoryFilename; } /** Setter for property repositoryFilename. * @param repositoryFilename New value of property repositoryFilename. */ public void setRepositoryFilename(String repositoryFilename) { this.repositoryFilename = repositoryFilename; } /** Getter for property headRevision. * @return Value of property headRevision. */ public String getHeadRevision() { return headRevision; } /** Setter for property headRevision. * @param headRevision New value of property headRevision. */ public void setHeadRevision(String headRevision) { this.headRevision = headRevision; } /** Getter for property branch. * @return Value of property branch. */ public String getBranch() { return branch; } /** Setter for property branch. * @param branch New value of property branch. */ public void setBranch(String branch) { this.branch = branch; } /** Getter for property accessList. * @return Value of property accessList. */ public String getAccessList() { return accessList; } /** Setter for property accessList. * @param accessList New value of property accessList. */ public void setAccessList(String accessList) { this.accessList = accessList; } /** Getter for property keywordSubstitution. * @return Value of property keywordSubstitution. */ public String getKeywordSubstitution() { return keywordSubstitution; } /** Setter for property keywordSubstitution. * @param keywordSubstitution New value of property keywordSubstitution. */ public void setKeywordSubstitution(String keywordSubstitution) { this.keywordSubstitution = keywordSubstitution; } /** Getter for property totalRevisions. * @return Value of property totalRevisions. */ public String getTotalRevisions() { return totalRevisions; } /** Setter for property totalRevisions. * @param totalRevisions New value of property totalRevisions. */ public void setTotalRevisions(String totalRevisions) { this.totalRevisions = totalRevisions; } /** Getter for property selectedRevisions. * @return Value of property selectedRevisions. */ public String getSelectedRevisions() { return selectedRevisions; } /** Setter for property selectedRevisions. * @param selectedRevisions New value of property selectedRevisions. */ public void setSelectedRevisions(String selectedRevisions) { this.selectedRevisions = selectedRevisions; } /** Getter for property description. * @return Value of property description. */ public String getDescription() { return description; } /** Setter for property description. * @param description New value of property description. */ public void setDescription(String description) { this.description = description; } /** Getter for property locks. * @return Value of property locks. */ public String getLocks() { return locks; } /** Setter for property locks. * @param locks New value of property locks. */ public void setLocks(String locks) { this.locks = locks; } /** adds a revision info to the LogInformation instance */ public void addRevision(LogInformation.Revision newRevision) { revisions.add(newRevision); } /** return the all revisions attached to this log * (if more sophisticated method are supplied, this might get obsolete) */ public List getRevisionList() { return revisions; } /** Search the revisions by number of revision. If not found, return null. */ public LogInformation.Revision getRevision(String number) { Iterator it = revisions.iterator(); LogInformation.Revision item; while (it.hasNext()) { item = (LogInformation.Revision)it.next(); if (item.getNumber().equals(number)) { return item; } } return null; } /** * Add a symbolic name to the list of names and attaches it to a revision number. */ public void addSymbolicName(String symName, String revisionNumber) { SymName newName = new SymName(); newName.setName(symName); newName.setRevision(revisionNumber); symbolicNames.add(newName); } public List getAllSymbolicNames() { return symbolicNames; } /** Search the symbolic names by number of revision. If not found, return null. */ public List getSymNamesForRevision(String revNumber) { Iterator it = symbolicNames.iterator(); LogInformation.SymName item; List list = new LinkedList(); while (it.hasNext()) { item = (LogInformation.SymName)it.next(); if (item.getRevision().equals(revNumber)) { list.add(item); } } return list; } /** Search the symbolic names by name of tag (symbolic name). If not found, return null. */ public LogInformation.SymName getSymName(String symName) { Iterator it = symbolicNames.iterator(); LogInformation.SymName item; while (it.hasNext()) { item = (LogInformation.SymName)it.next(); if (item.getName().equals(symName)) { return item; } } return null; } public Revision createNewRevision(String number) { Revision rev = new Revision(); rev.setNumber(number); return rev; } /** * Return a string representation of this object. Useful for debugging. */ public String toString() { StringBuffer buf = new StringBuffer(30); buf.append("\nFile: " + ((file != null)?file.getAbsolutePath():"null")); //NOI18N buf.append("\nRepositoryFile: " + repositoryFilename); //NOI18N buf.append("\nHead revision: " + headRevision); //NOI18N return buf.toString(); } public class SymName { private String name; private String revision; public SymName() { } public String getName() { return name; } public void setName(String symName) { name = symName; } public void setRevision(String rev) { revision = rev; } public String getRevision() { return revision; } /** * Determines if given name represents a branch tag * test is based on revision num parsing and looking * for trailing 0.# (1.1.0.2, 1.2.4.5.0.6, ,..). */ public final boolean isBranch() { boolean branch = false; String[] nums = revision.split("\\."); if (nums.length > 2 && (nums.length % 2) == 0) { String lastButOne = nums[nums.length -2]; branch = "0".equals(lastButOne); // NOI18N } return branch; } } public class Revision { /** * The revision number. */ private String number; /** * The parsed date. */ private Date date; /** * The String representation of the date. */ private String dateString; /** * The author of the revision. */ private String author; /** * The state. */ private String state; /** * The added/removed lines. */ private String lines; /** * The commit ID, as generated and reported by some servers. */ private String commitID; /** * The commit log-message. */ private String message; /** * The branches for this revision. */ private String branches; public Revision() { /** * Since these have to be initialized when correctly parsing the * command's output, then initializing them to empty strings * is a safety measure against bad parsing errors. * what about backward compatibility here?? * state = ""; lines = ""; message = ""; branches = ""; */ } public LogInformation getLogInfoHeader() { return LogInformation.this; } public String getNumber() { return number; } public void setNumber(String number) { this.number = number; } public Date getDate() { return date; } public String getDateString() { return dateString; } /** * @deprecated This method uses a static parser to parse dates which is not thread safe, use #setDate instead */ public void setDateString(String dateString) { this.dateString = dateString; if (dateString == null) { this.date = null; return; } // Parse the date ... try { // some servers use dashes to separate date components, so replace with slashes // also add a default GMT timezone at the end, if the server already put one in this one will be ignored by the parser dateString = dateString.replace('/', '-') + " +0000"; this.date = DATE_FORMAT.parse(dateString); } catch (Exception ex) { BugLog.getInstance().bug("Couldn't parse date " + dateString); } } public void setDate(Date date, String dateString) { this.dateString = dateString; this.date = date; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } public String getState() { return state; } public void setState(String state) { this.state = state; } public String getLines() { return lines; } public void setLines(String lines) { this.lines = lines; } public String getCommitID() { return commitID; } public void setCommitID(String commitID) { this.commitID = commitID; } /** * Returns how many lines were added in this revision. */ public int getAddedLines() { if (lines != null) { int start = lines.indexOf('+'); int end = lines.indexOf(' '); if (start >= 0 && end > start) { String added = lines.substring(start + 1, end); try { int toReturn = Integer.parseInt(added); return toReturn; } catch (NumberFormatException exc) { //TODO BUGLog.. } } } return 0; } public int getRemovedLines() { if (lines != null) { int start = lines.indexOf('-'); if (start >= 0) { String removed = lines.substring(start + 1); try { int toReturn = Integer.parseInt(removed); return toReturn; } catch (NumberFormatException exc) { //TODO BUGLog.. } } } return 0; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public String getBranches() { return branches; } public void setBranches(String branches) { this.branches = branches; } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/log/RlogCommand.java0000644000175300001440000003535411175406777027334 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.log; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * The rlog command is similar to log, but doens't operate on currently checked * out sources. * * @author MIlos Kleint */ public class RlogCommand extends BasicCommand { /** * The modules to rlog. */ private final List modules = new LinkedList(); /** * Holds value of property defaultBranch. */ private boolean defaultBranch; /** * Holds value of property dateFilter. */ private String dateFilter; /** * Holds value of property headerOnly. */ private boolean headerOnly; /** * Holds value of property suppressHeader. */ private boolean suppressHeader; /** * Holds value of property noTags. */ private boolean noTags; /** * Holds value of property revisionFilter. */ private String revisionFilter; /** * Holds value of property stateFilter. */ private String stateFilter; /** * Holds value of property userFilter. */ private String userFilter; /** * Holds value of property headerAndDescOnly. */ private boolean headerAndDescOnly; public RlogCommand() { resetCVSCommand(); } /** * Set the modules to export. * @param theModules the names of the modules to export */ public void setModule(String module) { modules.add(module); } /** * clears the list of modules for export. */ public void clearModules() { this.modules.clear(); } /** * Set the modules to export. * @param theModules the names of the modules to export */ public void setModules(String[] modules) { clearModules(); if (modules == null) { return; } for (int i = 0; i < modules.length; i++) { String module = modules[i]; this.modules.add(module); } } public String[] getModules() { String[] mods = new String[modules.size()]; mods = (String[])modules.toArray(mods); return mods; } /** * Getter for property defaultBranch, equals the command-line CVS switch * "-b". * @return Value of property defaultBranch. */ public boolean isDefaultBranch() { return defaultBranch; } /** * Setter for property defaultBranch, equals the command-line CVS switch * "-b". * @param defaultBranch New value of property defaultBranch. */ public void setDefaultBranch(boolean defaultBranch) { this.defaultBranch = defaultBranch; } /** * Getter for property dateFilter, equals the command-line CVS switch "-d". * @return Value of property dateFilter. */ public String getDateFilter() { return dateFilter; } /** Setter for property dateFilter, equals the command-line CVS switch "-d". * @param dateFilter New value of property dateFilter. */ public void setDateFilter(String dateFilter) { this.dateFilter = dateFilter; } /** Getter for property headerOnly, equals the command-line CVS switch "-h". * @return Value of property headerOnly. */ public boolean isHeaderOnly() { return headerOnly; } /** Setter for property headerOnly, equals the command-line CVS switch "-h". * @param headerOnly New value of property headerOnly. */ public void setHeaderOnly(boolean headerOnly) { this.headerOnly = headerOnly; } /** Getter for property suppressHeader, equals the command-line CVS switch "-S". * @return Value of property suppressHeader. */ public boolean isSuppressHeader() { return suppressHeader; } /** Setter for property headerOnly, equals the command-line CVS switch "-S". * @param suppressHeader New value of property suppressHeader. */ public void setSuppressHeader(boolean suppressHeader) { this.suppressHeader = suppressHeader; } /** Getter for property noTags, equals the command-line CVS switch "-N". * @return Value of property noTags. */ public boolean isNoTags() { return noTags; } /** Setter for property noTags, equals the command-line CVS switch "-N". * @param noTags New value of property noTags. */ public void setNoTags(boolean noTags) { this.noTags = noTags; } /** Getter for property revisionFilter, equals the command-line CVS switch "-r". * @return Value of property revisionFilter. */ public String getRevisionFilter() { return revisionFilter; } /** Setter for property revisionFilter, equals the command-line CVS switch "-r". * @param revisionFilter New value of property revisionFilter. empty string means latest revision of default branch. */ public void setRevisionFilter(String revisionFilter) { this.revisionFilter = revisionFilter; } /** Getter for property stateFilter, equals the command-line CVS switch "-s". * @return Value of property stateFilter. */ public String getStateFilter() { return stateFilter; } /** Setter for property stateFilter, equals the command-line CVS switch "-s". * @param stateFilter New value of property stateFilter. */ public void setStateFilter(String stateFilter) { this.stateFilter = stateFilter; } /** Getter for property userFilter, equals the command-line CVS switch "-w". * @return Value of property userFilter, empty string means the current user. */ public String getUserFilter() { return userFilter; } /** Setter for property userFilter, equals the command-line CVS switch "-w". * @param userFilter New value of property userFilter. */ public void setUserFilter(String userFilter) { this.userFilter = userFilter; } /** Getter for property headerAndDescOnly, equals the command-line CVS switch "-t". * @return Value of property headerAndDescOnly. */ public boolean isHeaderAndDescOnly() { return headerAndDescOnly; } /** Setter for property headerAndDescOnly, equals the command-line CVS switch "-t". * @param headerAndDescOnly New value of property headerAndDescOnly. */ public void setHeaderAndDescOnly(boolean headerAndDescOnly) { this.headerAndDescOnly = headerAndDescOnly; } /** * Execute this command. * @param client the client services object that provides any necessary * services to this command, including the ability to actually process * all the requests */ public void execute(ClientServices client, EventManager em) throws CommandException, AuthenticationException { client.ensureConnection(); super.execute(client, em); // // moved modules code to the end of the other arguments --GAR // if (!isRecursive()) { requests.add(new ArgumentRequest("-l")); //NOI18N } // first send out all possible parameters.. if (defaultBranch) { requests.add(new ArgumentRequest("-b")); //NOI18N } if (headerAndDescOnly) { requests.add(new ArgumentRequest("-t")); //NOI18N } if (headerOnly) { requests.add(new ArgumentRequest("-h")); //NOI18N } if (suppressHeader) { requests.add(new ArgumentRequest("-S")); //NOI18IN } if (noTags) { requests.add(new ArgumentRequest("-N")); //NOI18N } if (userFilter != null) { requests.add(new ArgumentRequest("-w" + userFilter)); //NOI18N } if (revisionFilter != null) { requests.add(new ArgumentRequest("-r" + revisionFilter)); //NOI18N } if (stateFilter != null) { requests.add(new ArgumentRequest("-s" + stateFilter)); //NOI18N } if (dateFilter != null) { requests.add(new ArgumentRequest("-d" + dateFilter)); //NOI18N } for (Iterator it = modules.iterator(); it.hasNext();) { String module = (String)it.next(); requests.add(new ArgumentRequest(module)); } requests.add(CommandRequest.RLOG); try { client.processRequests(requests); requests.clear(); } catch (CommandException ex) { throw ex; } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } } /** * Don't send status of local files prior to executing command, as it's not * needed. */ protected boolean assumeLocalPathWhenUnspecified() { return false; } public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("rlog "); //NOI18N toReturn.append(getCVSArguments()); if (modules != null && modules.size() > 0) { for (Iterator it = modules.iterator(); it.hasNext();) { String module = (String)it.next(); toReturn.append(module); toReturn.append(' '); } } else { String localizedMsg = CommandException.getLocalMessage("ExportCommand.moduleEmpty.text"); //NOI18N toReturn.append(" "); //NOI18N toReturn.append(localizedMsg); } return toReturn.toString(); } public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(""); //NOI18N if (isDefaultBranch()) { toReturn.append("-b "); //NOI18N } if (isHeaderAndDescOnly()) { toReturn.append("-t "); //NOI18N } if (isHeaderOnly()) { toReturn.append("-h "); //NOI18N } if (isSuppressHeader()) { toReturn.append("-S "); //NOI18N } if (isNoTags()) { toReturn.append("-N "); //NOI18N } if (!isRecursive()) { toReturn.append("-l "); //NOI18N } if (userFilter != null) { toReturn.append("-w"); //NOI18N toReturn.append(userFilter); toReturn.append(' '); } if (revisionFilter != null) { toReturn.append("-r"); //NOI18N toReturn.append(revisionFilter); toReturn.append(' '); } if (stateFilter != null) { toReturn.append("-s"); //NOI18N toReturn.append(stateFilter); toReturn.append(' '); } if (dateFilter != null) { toReturn.append("-d"); //NOI18N toReturn.append(dateFilter); toReturn.append(' '); } return toReturn.toString(); } public boolean setCVSCommand(char opt, String optArg) { if (opt == 'R') { setRecursive(true); } else if (opt == 'l') { setRecursive(false); } else if (opt == 'b') { setDefaultBranch(true); } else if (opt == 'h') { setHeaderOnly(true); } else if (opt == 't') { setHeaderAndDescOnly(true); } else if (opt == 'S') { setSuppressHeader(true); } else if (opt == 'N') { setNoTags(true); } else if (opt == 'd') { setDateFilter(optArg); } else if (opt == 'r') { setRevisionFilter(optArg == null ? "" : optArg); //NOI18N // for switches with optional args do that.. ^^^^ } else if (opt == 's') { setStateFilter(optArg); } else if (opt == 'w') { setUserFilter(optArg == null ? "" : optArg); //NOI18N } else { return false; } return true; } public void resetCVSCommand() { setRecursive(true); setDefaultBranch(false); setHeaderOnly(false); setHeaderAndDescOnly(false); setSuppressHeader(false); setNoTags(false); setDateFilter(null); setRevisionFilter(null); setStateFilter(null); setUserFilter(null); } /** * String returned by this method defines which options are available for this particular command */ public String getOptString() { return "RlbhStNd:r:s:w:"; //NOI18N4 } /** * Create a builder for this command. * @param eventMan the event manager used to receive events. */ public Builder createBuilder(EventManager eventMan) { return new LogBuilder(eventMan, this); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/remove/0000755000175300001440000000000011175434236024760 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/remove/RemoveBuilder.java0000644000175300001440000001343611175407000030363 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.remove; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.event.*; /** * Handles the building of remove information object and the firing of * events when complete objects are built. * * @author Milos Kleint */ public class RemoveBuilder implements Builder { private static final String UNKNOWN = ": nothing known about"; //NOI18N private static final String WARNING = ": warning: "; //NOI18N private static final String SCHEDULING = ": scheduling `"; //NOI18N private static final String USE_COMMIT = ": use 'cvs commit' "; //NOI18N private static final String DIRECTORY = ": Removing "; //NOI18N private static final String STILL_IN_WORKING = ": file `"; //NOI18N private static final String REMOVE_FIRST = "first"; //NOI18N private static final String UNKNOWN_FILE = "?"; //NOI18N /** * The status object that is currently being built */ private RemoveInformation removeInformation; /** * The directory in which the file being processed lives. This is * relative to the local directory */ private String fileDirectory; /** * The event manager to use */ private final EventManager eventManager; private final RemoveCommand removeCommand; public RemoveBuilder(EventManager eventManager, RemoveCommand removeCommand) { this.eventManager = eventManager; this.removeCommand = removeCommand; } public void outputDone() { if (removeInformation != null) { eventManager.fireCVSEvent(new FileInfoEvent(this, removeInformation)); removeInformation = null; } } public void parseLine(String line, boolean isErrorMessage) { if (line.indexOf(SCHEDULING) >= 0) { int endingIndex = line.indexOf('\''); String fn = line.substring(line.indexOf(SCHEDULING) + SCHEDULING.length(), endingIndex).trim(); addFile(fn); removeInformation.setRemoved(true); outputDone(); } if (line.startsWith(UNKNOWN_FILE)) { addFile(line.substring(UNKNOWN_FILE.length())); removeInformation.setRemoved(false); outputDone(); } if (line.indexOf(STILL_IN_WORKING) >= 0) { int endingIndex = line.indexOf('\''); String fn = line.substring(line.indexOf(STILL_IN_WORKING) + STILL_IN_WORKING.length(), endingIndex).trim(); addFile(fn); removeInformation.setRemoved(false); outputDone(); } // ignore the rest.. } protected File createFile(String fileName) { StringBuffer path = new StringBuffer(); path.append(removeCommand.getLocalDirectory()); path.append(File.separator); if (fileDirectory == null) { // happens for single files only // (for directories, the dir name is always sent before the actual files) File locFile = removeCommand.getFileEndingWith(fileName); if (locFile == null) { path.append(fileName); } else { path = new StringBuffer(locFile.getAbsolutePath()); } } else { // path.append(fileDirectory); // path.append(File.separator); path.append(fileName); } String toReturn = path.toString(); toReturn = toReturn.replace('/', File.separatorChar); return new File(path.toString()); } protected void addFile(String name) { removeInformation = new RemoveInformation(); removeInformation.setFile(createFile(name)); } public void parseEnhancedMessage(String key, Object value) { } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/remove/RemoveCommand.java0000644000175300001440000002324611175407000030353 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.command.remove; import java.io.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.admin.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; import org.netbeans.lib.cvsclient.util.*; /** * The remove command is used to remove files and directories from the * repository. * @author Robert Greig */ public class RemoveCommand extends BasicCommand { /** * If true, will delete the file in working dir before it gets removed. */ private boolean deleteBeforeRemove; private boolean ignoreLocallyExistingFiles; /** * Returns true if the local files will be deleted automatically. */ public boolean isDeleteBeforeRemove() { return deleteBeforeRemove; } /** * Sets whether the local files will be deleted before. */ public void setDeleteBeforeRemove(boolean deleteBeforeRemove) { this.deleteBeforeRemove = deleteBeforeRemove; } /** * Returns true to indicate that locally existing files are treated as they * would not exist. * This is a extension to the standard cvs-behaviour! * @deprecated */ public boolean doesIgnoreLocallyExistingFiles() { return ignoreLocallyExistingFiles; } /** * Returns true to indicate that locally existing files are treated as they * would not exist. * This is a extension to the standard cvs-behaviour! */ public boolean isIgnoreLocallyExistingFiles() { return ignoreLocallyExistingFiles; } /** * Sets whether locally existing files will be treated as they were deleted * before. * This is a extension to the standard cvs-behaviour! */ public void setIgnoreLocallyExistingFiles(boolean ignoreLocallyExistingFiles) { this.ignoreLocallyExistingFiles = ignoreLocallyExistingFiles; } /** * Method that is called while the command is being executed. * Descendants can override this method to return a Builder instance * that will parse the server's output and create data structures. */ public Builder createBuilder(EventManager eventMan) { return new RemoveBuilder(eventMan, this); } /** * Executes this command. * * @param client the client services object that provides any necessary * services to this command, including the ability to actually * process all the requests */ public void execute(ClientServices client, EventManager em) throws CommandException, AuthenticationException { if (files == null || files.length == 0) { throw new CommandException("No files have been specified for " + //NOI18N "removal.", CommandException.getLocalMessage("RemoveCommand.noFilesSpecified", null)); //NOI18N } client.ensureConnection(); if (isDeleteBeforeRemove()) { removeAll(files); } super.execute(client, em); try { addRequestForWorkingDirectory(client); addArgumentRequests(); addRequest(CommandRequest.REMOVE); client.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } finally { requests.clear(); } } protected void sendEntryAndModifiedRequests(Entry entry, File file) { super.sendEntryAndModifiedRequests(entry, isIgnoreLocallyExistingFiles() ? null : file); if (entry.getRevision().equals("0")) { // zero means a locally added file, not yet commited. try { clientServices.removeEntry(file); } catch (IOException exc) { BugLog.getInstance().showException(exc); } } } /** * This method returns how the command would looks like when typed on the * command line. * Each command is responsible for constructing this information. * @returns [] files/dirs. Example: checkout -p CvsCommand.java */ public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("remove "); //NOI18N toReturn.append(getCVSArguments()); File[] files = getFiles(); if (files != null) { for (int index = 0; index < files.length; index++) { toReturn.append(files[index].getName() + " "); //NOI18N } } return toReturn.toString(); } /** * Takes the arguments and sets the command. * To be mainly used for automatic settings (like parsing the .cvsrc file). * @return true if the option (switch) was recognized and set */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'l') { setRecursive(false); } else if (opt == 'R') { setRecursive(true); } else if (opt == 'f') { setDeleteBeforeRemove(true); } else { return false; } return true; } /** * Deletes all files being removed from the working directory. * Doesn't delete directories. * Attempts a recursive delete * @throws CommandException - in case the file cannot be deleted. */ private void removeAll(File[] filesToDel) throws CommandException { if (filesToDel == null) { return; } for (int index = 0; index < filesToDel.length; index++) { File file = filesToDel[index]; if (file.exists() && file.isFile()) { if (!file.delete()) { throw new CommandException("Cannot delete file " + file.getAbsolutePath(), //NOI18N CommandException.getLocalMessage("RemoveCommand.cannotDelete", new Object[]{file.getAbsolutePath()})); //NOI18N } } else { // For directories remove only it's files. // Preserve the cvs structure though. if (isRecursive() && !file.getName().equalsIgnoreCase("CVS")) { //NOI18N removeAll(file.listFiles()); } } } } /** * String returned by this method defines which options are available for this particular command */ public String getOptString() { return "flR"; //NOI18N } /** * resets all switches in the command. After calling this method, * the command should have no switches defined and should behave defaultly. */ public void resetCVSCommand() { setRecursive(true); setDeleteBeforeRemove(false); } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name */ public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(""); //NOI18N if (!isRecursive()) { toReturn.append("-l "); //NOI18N } if (isDeleteBeforeRemove()) { toReturn.append("-f "); //NOI18N } return toReturn.toString(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/remove/RemoveInformation.java0000644000175300001440000000623011175407000031254 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.remove; import java.io.*; import org.netbeans.lib.cvsclient.command.*; /** * Describes remove information for a file. This is the result of doing a * cvs remove command. The fields in instances of this object are populated * by response handlers. * * @author Milos Kleint */ public class RemoveInformation extends FileInfoContainer { private File file; private boolean removed; public RemoveInformation() { } public File getFile() { return file; } public void setFile(File file) { this.file = file; } public void setRemoved(boolean rem) { removed = rem; } public boolean isRemoved() { return removed; } /** * Return a string representation of this object. Useful for debugging. */ public String toString() { StringBuffer buf = new StringBuffer(30); buf.append(" "); //NOI18N buf.append((file != null) ? file.getAbsolutePath() :"null"); //NOI18N return buf.toString(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/status/0000755000175300001440000000000011175434236025006 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/status/StatusBuilder.java0000644000175300001440000002511411175407000030433 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.status; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.file.*; /** * Handles the building of a status information object and the firing of * events when complete objects are built. * * @author Milos Kleint * @author Thomas Singer */ public class StatusBuilder implements Builder { private static final String UNKNOWN = ": nothing known about"; //NOI18N private static final String EXAM_DIR = ": Examining"; //NOI18N private static final String NOT_IN_REPOSITORY = "No revision control file"; //NOI18N private static final String FILE = "File: "; //NOI18N private static final String STATUS = "Status:"; //NOI18N private static final String NO_FILE_FILENAME = "no file"; //NOI18N private static final String WORK_REV = " Working revision:"; //NOI18N private static final String REP_REV = " Repository revision:"; //NOI18N private static final String TAG = " Sticky Tag:"; //NOI18N private static final String DATE = " Sticky Date:"; //NOI18N private static final String OPTIONS = " Sticky Options:"; //NOI18N private static final String EXISTING_TAGS = " Existing Tags:"; //NOI18N private static final String EMPTY_BEFORE_TAGS = " "; //NOI18N private static final String NO_TAGS = " No Tags Exist"; //NOI18N private static final String UNKNOWN_FILE = "? "; //NOI18N /** * The status object that is currently being built. */ private StatusInformation statusInformation; /** * The event manager to use. */ private EventManager eventManager; private final StatusCommand statusCommand; private String relativeDirectory; private final String localPath; private boolean beginning; private boolean readingTags; private final File[] fileArray; /** * Creates a StatusBuilder. */ public StatusBuilder(EventManager eventManager, StatusCommand statusCommand) { this.eventManager = eventManager; this.statusCommand = statusCommand; File[] fileArray = statusCommand.getFiles(); if (fileArray != null) { this.fileArray = new File[fileArray.length]; System.arraycopy(fileArray, 0, this.fileArray, 0, fileArray.length); } else { this.fileArray = null; } this.localPath = statusCommand.getLocalDirectory(); this.beginning = true; } public void outputDone() { if (statusInformation != null) { eventManager.fireCVSEvent(new FileInfoEvent(this, statusInformation)); statusInformation = null; readingTags = false; } } public void parseLine(String line, boolean isErrorMessage) { if (readingTags) { if (line.startsWith(NO_TAGS)) { outputDone(); return; } int bracket = line.indexOf("\t("); if (bracket > 0) { // it's another tag.. String tag = line.substring(0, bracket).trim(); String rev = line.substring(bracket + 2, line.length() - 1); if (statusInformation == null) { statusInformation = new StatusInformation(); } statusInformation.addExistingTag(tag, rev); } else { outputDone(); return; } } if (line.startsWith(UNKNOWN_FILE) && beginning) { File file = new File(localPath, line.substring(UNKNOWN_FILE.length())); statusInformation = new StatusInformation(); statusInformation.setFile(file); statusInformation.setStatusString(FileStatus.UNKNOWN.toString()); outputDone(); } if (line.startsWith(UNKNOWN)) { outputDone(); beginning = false; } else if (line.indexOf(EXAM_DIR) >= 0) { relativeDirectory = line.substring(line.indexOf(EXAM_DIR) + EXAM_DIR.length()).trim(); beginning = false; } else if (line.startsWith(FILE)) { outputDone(); statusInformation = new StatusInformation(); processFileAndStatusLine(line.substring(FILE.length())); beginning = false; } else if (line.startsWith(WORK_REV)) { processWorkRev(line.substring(WORK_REV.length())); } else if (line.startsWith(REP_REV)) { processRepRev(line.substring(REP_REV.length())); /* if (statusInformation.getRepositoryRevision().startsWith(NOT_IN_REPOSITORY)) { outputDone(); } */ } else if (line.startsWith(TAG)) { processTag(line.substring(TAG.length())); } else if (line.startsWith(DATE)) { processDate(line.substring(DATE.length())); } else if (line.startsWith(OPTIONS)) { processOptions(line.substring(OPTIONS.length())); if (!statusCommand.isIncludeTags()) { outputDone(); } } else if (line.startsWith(EXISTING_TAGS)) { readingTags = true; } } private File createFile(String fileName) { File file = null; if (relativeDirectory != null) { if (relativeDirectory.trim().equals(".")) { //NOI18N file = new File(localPath, fileName); } else { file = new File(localPath, relativeDirectory + '/' + fileName); } } else if (fileArray != null) { for (int i = 0; i < fileArray.length; i++) { File currentFile = fileArray[i]; if (currentFile == null || currentFile.isDirectory()) { continue; } String currentFileName = currentFile.getName(); if (fileName.equals(currentFileName)) { fileArray[i] = null; file = currentFile; break; } } } if (file == null) { System.err.println("JAVACVS ERROR!! wrong algorithm for assigning path to single files(1)!!"); } return file; } private void processFileAndStatusLine(String line) { int statusIndex = line.lastIndexOf(STATUS); String fileName = line.substring(0, statusIndex).trim(); if (fileName.startsWith(NO_FILE_FILENAME)) { fileName = fileName.substring(8); } statusInformation.setFile(createFile(fileName)); String status = new String(line.substring(statusIndex + 8).trim()); statusInformation.setStatusString(status); } private boolean assertNotNull() { if (statusInformation == null) { System.err.println("Bug: statusInformation must not be null!"); return false; } return true; } private void processWorkRev(String line) { if (!assertNotNull()) { return; } statusInformation.setWorkingRevision(line.trim().intern()); } private void processRepRev(String line) { if (!assertNotNull()) { return; } line = line.trim(); if (line.startsWith(NOT_IN_REPOSITORY)) { statusInformation.setRepositoryRevision(line.trim().intern()); return; } int firstSpace = line.indexOf('\t'); if (firstSpace > 0) { statusInformation.setRepositoryRevision( line.substring(0, firstSpace).trim().intern()); statusInformation.setRepositoryFileName( new String(line.substring(firstSpace).trim())); } else { statusInformation.setRepositoryRevision(""); //NOI18N statusInformation.setRepositoryFileName(""); //NOI18N } } private void processTag(String line) { if (!assertNotNull()) { return; } statusInformation.setStickyTag(line.trim().intern()); } private void processDate(String line) { if (!assertNotNull()) { return; } statusInformation.setStickyDate(line.trim().intern()); } private void processOptions(String line) { if (!assertNotNull()) { return; } statusInformation.setStickyOptions(line.trim().intern()); } public void parseEnhancedMessage(String key, Object value) { } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/status/StatusCommand.java0000644000175300001440000001575311175407000030433 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.command.status; import java.io.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * The status command looks up the status of files in the repository * @author Robert Greig */ public class StatusCommand extends BasicCommand { /** * The event manager to use */ private EventManager eventManager; /** * Holds value of property includeTags. */ private boolean includeTags; /** * Construct a new status command */ public StatusCommand() { } /** * Create a builder for this command. * @param eventMan the event manager used to receive events. */ public Builder createBuilder(EventManager eventManager) { return new StatusBuilder(eventManager, this); } /** * Execute a command * @param client the client services object that provides any necessary * services to this command, including the ability to actually process * all the requests. */ public void execute(ClientServices client, EventManager em) throws CommandException, AuthenticationException { client.ensureConnection(); eventManager = em; super.execute(client, em); try { // parameters come now.. if (includeTags) { requests.add(1, new ArgumentRequest("-v")); //NOI18N } addRequestForWorkingDirectory(client); addArgumentRequests(); addRequest(CommandRequest.STATUS); client.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (Exception e) { throw new CommandException(e, e.getLocalizedMessage()); } finally { requests.clear(); } } /** * Getter for property includeTags. * @return Value of property includeTags. */ public boolean isIncludeTags() { return includeTags; } /** * Setter for property includeTags. * @param includeTags New value of property includeTags. */ public void setIncludeTags(boolean inclTags) { includeTags = inclTags; } /** * called when server responses with "ok" or "error", (when the command finishes) */ public void commandTerminated(TerminationEvent e) { if (builder != null) { builder.outputDone(); } } /** * This method returns how the command would looklike when typed on the command line. * Each command is responsible for constructing this information. * @returns [] files/dirs. Example: checkout -p CvsCommand.java */ public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("status "); //NOI18N toReturn.append(getCVSArguments()); File[] files = getFiles(); if (files != null) { for (int index = 0; index < files.length; index++) { toReturn.append(files[index].getName()); toReturn.append(' '); } } return toReturn.toString(); } /** * takes the arguments and sets the command. To be mainly * used for automatic settings (like parsing the .cvsrc file) * @return true if the option (switch) was recognized and set */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'R') { setRecursive(true); } else if (opt == 'l') { setRecursive(false); } else if (opt == 'v') { setIncludeTags(true); } else { return false; } return true; } /** * String returned by this method defines which options are available for this particular command */ public String getOptString() { return "Rlv"; //NOI18N } /** * resets all switches in the command. After calling this method, * the command should have no switches defined and should behave defaultly. */ public void resetCVSCommand() { setRecursive(true); setIncludeTags(false); } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name */ public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(""); //NOI18N if (isIncludeTags()) { toReturn.append("-v "); //NOI18N } if (!isRecursive()) { toReturn.append("-l "); //NOI18N } return toReturn.toString(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/status/StatusInformation.java0000644000175300001440000002617211175407000031337 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.command.status; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.file.*; /** * Describes status information for a file. This is the result of doing a * cvs status command. The fields in instances of this object are populated * by response handlers. * @author Robert Greig */ public class StatusInformation extends FileInfoContainer { // Fields ================================================================= private File file; private FileStatus status; private String workingRevision; private String repositoryRevision; private String repositoryFileName; private String stickyDate; private String stickyOptions; private String stickyTag; /** * Hold key pairs of existing tags. */ private List tags; private StringBuffer symNamesBuffer; public StatusInformation() { setAllExistingTags(null); } /** * Getter for property file. * @return Value of property file. */ public File getFile() { return file; } /** * Setter for property file. * @param file New value of property file. */ public void setFile(File file) { this.file = file; } /** * Getter for property status. * @return Value of property status. */ public FileStatus getStatus() { return status; } /** * Setter for property status. * @param status New value of property status. */ public void setStatus(FileStatus status) { this.status = status; } /** * Returns the status as a String. * The String returned are definitely the static-final-instances. */ public String getStatusString() { if (status == null) { return null; } return status.toString(); } /** * Sets the status by the specified string. */ public void setStatusString(String statusString) { setStatus(FileStatus.getStatusForString(statusString)); } /** * Getter for property workingRevision. * @return Value of property workingRevision. */ public String getWorkingRevision() { return workingRevision; } /** * Setter for property workingRevision. * @param workingRevision New value of property workingRevision. */ public void setWorkingRevision(String workingRevision) { this.workingRevision = workingRevision; } /** * Getter for property repositoryRevision. * @return Value of property repositoryRevision. */ public String getRepositoryRevision() { return repositoryRevision; } /** * Setter for property repositoryRevision. * @param repositoryRevision New value of property repositoryRevision. */ public void setRepositoryRevision(String repositoryRevision) { this.repositoryRevision = repositoryRevision; } /** * Getter for property repositoryFileName. * @return Value of property repositoryFileName. */ public String getRepositoryFileName() { return repositoryFileName; } /** * Setter for property repositoryFileName. * @param repositoryRevision New value of property repositoryFileName. */ public void setRepositoryFileName(String repositoryFileName) { this.repositoryFileName = repositoryFileName; } /** * Getter for property stickyTag. * @return Value of property stickyTag. */ public String getStickyTag() { return stickyTag; } /** * Setter for property stickyTag. * @param stickyTag New value of property stickyTag. */ public void setStickyTag(String stickyTag) { this.stickyTag = stickyTag; } /** * Getter for property stickyDate. * @return Value of property stickyDate. */ public String getStickyDate() { return stickyDate; } /** * Setter for property stickyDate. * @param stickyDate New value of property stickyDate. */ public void setStickyDate(String stickyDate) { this.stickyDate = stickyDate; } /** * Getter for property stickyOptions. * @return Value of property stickyOptions. */ public String getStickyOptions() { return stickyOptions; } /** * Setter for property stickyOptions. * @param stickyOptions New value of property stickyOptions. */ public void setStickyOptions(String stickyOptions) { this.stickyOptions = stickyOptions; } public void addExistingTag(String tagName, String revisionNumber) { if (symNamesBuffer == null) { symNamesBuffer = new StringBuffer(); } symNamesBuffer.append(tagName); symNamesBuffer.append(" "); //NOI18N symNamesBuffer.append(revisionNumber); symNamesBuffer.append("\n"); //NOI18N } private void createSymNames() { tags = new LinkedList(); if (symNamesBuffer == null) { return; } int length = 0; int lastLength = 0; while (length < symNamesBuffer.length()) { while (length < symNamesBuffer.length() && symNamesBuffer.charAt(length) != '\n') { length++; } if (length > lastLength) { String line = symNamesBuffer.substring(lastLength, length); String symName = line.substring(0, line.indexOf(' ')); String revisionNumber = line.substring(line.indexOf(' ') + 1); SymName newName = new SymName(); newName.setTag(symName); newName.setRevision(revisionNumber); tags.add(newName); lastLength = length + 1; length++; } } symNamesBuffer = null; } public List getAllExistingTags() { if (tags == null) { createSymNames(); } return tags; } public void setAllExistingTags(List tags) { this.tags = tags; } /** Search the symbolic names by number of revision. If not found, return null. */ public List getSymNamesForRevision(String revNumber) { if (tags == null) { createSymNames(); } List list = new LinkedList(); for (Iterator it = tags.iterator(); it.hasNext();) { StatusInformation.SymName item = (StatusInformation.SymName)it.next(); if (item.getRevision().equals(revNumber)) { list.add(item); } } return list; } /** * Search the symbolic names by name of tag (symbolic name). * If not found, return null. */ public StatusInformation.SymName getSymNameForTag(String tagName) { if (tags == null) { createSymNames(); } for (Iterator it = tags.iterator(); it.hasNext();) { StatusInformation.SymName item = (StatusInformation.SymName)it.next(); if (item.getTag().equals(tagName)) { return item; } } return null; } /** * Return a string representation of this object. Useful for debugging. */ public String toString() { StringBuffer buf = new StringBuffer(); buf.append("\nFile: "); //NOI18N buf.append((file != null) ? file.getAbsolutePath() : "null"); //NOI18N buf.append("\nStatus is: "); //NOI18N buf.append(getStatusString()); buf.append("\nWorking revision: "); //NOI18N buf.append(workingRevision); buf.append("\nRepository revision: "); //NOI18N buf.append("\nSticky date: "); //NOI18N buf.append(stickyDate); buf.append("\nSticky options: "); //NOI18N buf.append(stickyOptions); buf.append("\nSticky tag: "); //NOI18N buf.append(stickyTag); if (tags != null && tags.size() > 0) { // we are having some tags to print buf.append("\nExisting Tags:"); //NOI18N for (Iterator it = tags.iterator(); it.hasNext();) { buf.append("\n "); //NOI18N buf.append(it.next().toString()); } } return buf.toString(); } /** * An inner class storing information about a symbolic name. * Consists of a pair of Strings. tag + revision. */ public static class SymName { private String tag; private String revision; public SymName() { } public String getTag() { return tag; } public void setTag(String symName) { tag = symName; } public void setRevision(String rev) { revision = rev; } public String getRevision() { return revision; } public String toString() { return getTag() + " : " + getRevision(); //NOI18N } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/tag/0000755000175300001440000000000011175434236024236 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/tag/RtagCommand.java0000644000175300001440000003052511175407000027267 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.tag; import java.io.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * The rtag command adds or deletes a tag to the specified files/directories in * the repository. * * @author Martin Entlicher */ public class RtagCommand extends RepositoryCommand { /** * The event manager to use. */ private EventManager eventManager; private boolean clearFromRemoved; private boolean deleteTag; private boolean makeBranchTag; private boolean overrideExistingTag; private boolean matchHeadIfRevisionNotFound; private boolean noExecTagProgram; private String tag; private String tagByDate; private String tagByRevision; /** * Construct a new tag command. */ public RtagCommand() { } /** * Creates the TagBuilder. * @param eventManager the event manager used to received cvs events */ public Builder createBuilder(EventManager eventManager) { return new TagBuilder(eventManager, getLocalDirectory()); } /** * Returns true if the tag from removed files is cleared. */ public boolean isClearFromRemoved() { return clearFromRemoved; } /** * Clear tag from removed files */ public void setClearFromRemoved(boolean clearFromRemoved) { this.clearFromRemoved = clearFromRemoved; } /** * Returns true if the tag should be deleted (otherwise added). */ public boolean isDeleteTag() { return deleteTag; } /** * Sets whether the tag should be deleted (true) or added (false). */ public void setDeleteTag(boolean deleteTag) { this.deleteTag = deleteTag; } /** * Returns true if the tag should be a branch tag. */ public boolean isMakeBranchTag() { return makeBranchTag; } /** * Sets whether the tag should be a branch tag. */ public void setMakeBranchTag(boolean makeBranchTag) { this.makeBranchTag = makeBranchTag; } /** * Returns true to indicate that existing tag will be overridden. */ public boolean isOverrideExistingTag() { return overrideExistingTag; } /** * Sets whether existing tags should be overridden. */ public void setOverrideExistingTag(boolean overrideExistingTag) { this.overrideExistingTag = overrideExistingTag; } public boolean isMatchHeadIfRevisionNotFound() { return matchHeadIfRevisionNotFound; } public void setMatchHeadIfRevisionNotFound(boolean matchHeadIfRevisionNotFound) { this.matchHeadIfRevisionNotFound = matchHeadIfRevisionNotFound; } public boolean isNoExecTagProgram() { return noExecTagProgram; } public void setNoExecTagProgram(boolean noExecTagProgram) { this.noExecTagProgram = noExecTagProgram; } /** * Returns the tag that should be added or deleted. */ public String getTag() { return tag; } /** * Sets the tag that should be added or deleted. */ public void setTag(String tag) { this.tag = tag; } /** * Returns the latest date of a revision to be tagged. * @return date value. the latest Revision not later ten date is tagged. */ public String getTagByDate() { return tagByDate; } /** * Sets the latest date of a revision to be tagged. * @param tagDate New value of property tagDate. */ public void setTagByDate(String tagDate) { tagByDate = tagDate; } /** * Sets the latest date of a revision to be tagged. Can be both a number and a tag. * @return Value of property tagRevision. */ public String getTagByRevision() { return tagByRevision; } /** * Sets the latest date of a revision to be tagged. Can be both a number and a tag. * @param tagRevision New value of property tagRevision. */ public void setTagByRevision(String tagRevision) { tagByRevision = tagRevision; } /** * Execute the command. * * @param client the client services object that provides any necessary * services to this command, including the ability to actually * process all the requests. */ protected void postExpansionExecute(ClientServices client, EventManager eventManager) throws CommandException, AuthenticationException { client.ensureConnection(); this.eventManager = eventManager; try { if (clearFromRemoved) { requests.add(new ArgumentRequest("-a")); //NOI18N } if (overrideExistingTag) { requests.add(new ArgumentRequest("-F")); //NOI18N } if (matchHeadIfRevisionNotFound) { requests.add(new ArgumentRequest("-f")); // NOI18N } if (makeBranchTag) { requests.add(new ArgumentRequest("-b")); //NOI18N } if (deleteTag) { requests.add(new ArgumentRequest("-d")); //NOI18N } if (noExecTagProgram) { requests.add(new ArgumentRequest("-n ")); // NOI18N } if (tagByDate != null && tagByDate.length() > 0) { requests.add(new ArgumentRequest("-D")); //NOI18N requests.add(new ArgumentRequest(getTagByDate())); } if (tagByRevision != null && tagByRevision.length() > 0) { requests.add(new ArgumentRequest("-r")); //NOI18N requests.add(new ArgumentRequest(getTagByRevision())); } requests.add(new ArgumentRequest(getTag())); //addRequestForWorkingDirectory(client); addArgumentRequests(); addRequest(CommandRequest.RTAG); client.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (EOFException ex) { throw new CommandException(ex, CommandException.getLocalMessage("CommandException.EndOfFile", null)); //NOI18N } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } finally { requests.clear(); } } /** * Called when server responses with "ok" or "error", (when the command * finishes). */ public void commandTerminated(TerminationEvent e) { if (builder != null) { builder.outputDone(); } } /** * This method returns how the tag command would looklike when typed on the * command line. */ public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("rtag "); //NOI18N toReturn.append(getCVSArguments()); if (getTag() != null) { toReturn.append(getTag()); toReturn.append(" "); //NOI18N } appendModuleArguments(toReturn); return toReturn.toString(); } /** * Takes the arguments and sets the command. * To be mainly used for automatic settings (like parsing the .cvsrc file) * @return true if the option (switch) was recognized and set */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'R') { setRecursive(true); } else if (opt == 'l') { setRecursive(false); } else if (opt == 'a') { setClearFromRemoved(true); } else if (opt == 'd') { setDeleteTag(true); } else if (opt == 'F') { setOverrideExistingTag(true); } else if (opt == 'f') { setMatchHeadIfRevisionNotFound(true); } else if (opt == 'b') { setMakeBranchTag(true); } else if (opt == 'n') { setNoExecTagProgram(true); } else if (opt == 'D') { setTagByDate(optArg.trim()); } else if (opt == 'r') { setTagByRevision(optArg.trim()); } else { return false; } return true; } /** * String returned by this method defines which options are available for * this command. */ public String getOptString() { return "RlaFfbdnD:r:"; //NOI18N } /** * Resets all switches in the command. * After calling this method, the command should have no switches defined * and should behave defaultly. */ public void resetCVSCommand() { setRecursive(true); setClearFromRemoved(false); setDeleteTag(false); setMakeBranchTag(false); setOverrideExistingTag(false); setMatchHeadIfRevisionNotFound(false); setNoExecTagProgram(false); } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name */ public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(); if (!isRecursive()) { toReturn.append("-l "); //NOI18N } if (isClearFromRemoved()) { toReturn.append("-a "); //NOI18N } if (isOverrideExistingTag()) { toReturn.append("-F "); //NOI18N } if (isMatchHeadIfRevisionNotFound()) { toReturn.append("-f "); } if (isMakeBranchTag()) { toReturn.append("-b "); //NOI18N } if (isDeleteTag()) { toReturn.append("-d "); //NOI18N } if (isNoExecTagProgram()) { toReturn.append("-n "); // NOI18N } if (getTagByRevision() != null && getTagByRevision().length() > 0) { toReturn.append("-r "); //NOI18N toReturn.append(getTagByRevision()); toReturn.append(" "); //NOI18N } if (getTagByDate() != null && getTagByDate().length() > 0) { toReturn.append("-D "); //NOI18N toReturn.append(getTagByDate()); toReturn.append(" "); //NOI18N } return toReturn.toString(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/tag/TagBuilder.java0000644000175300001440000001040111175407000027104 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.tag; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.event.*; /** * @author Thomas Singer */ public class TagBuilder implements Builder { public static final String STATES = "T D ? "; //NOI18N public static final String CVS_SERVER = "server: "; //NOI18N public static final String EXAM_DIR = "server: "; //NOI18N /** * The status object that is currently being built. */ private DefaultFileInfoContainer fileInfoContainer; /** * The event manager to use. */ private EventManager eventManager; /** * The local path the command run in. */ private String localPath; public TagBuilder(EventManager eventManager, String localPath) { this.eventManager = eventManager; this.localPath = localPath; } public void outputDone() { if (fileInfoContainer != null) { eventManager.fireCVSEvent(new FileInfoEvent(this, fileInfoContainer)); fileInfoContainer = null; } } public void parseLine(String line, boolean isErrorMessage) { if (isErrorMessage) { return; } if (line.indexOf(CVS_SERVER) < 0) { if (line.length() < 3) { return; } String firstChar = line.substring(0, 2); if (STATES.indexOf(firstChar) >= 0) { processFile(line); } } } private void processFile(String line) { if (fileInfoContainer == null) { fileInfoContainer = new DefaultFileInfoContainer(); } fileInfoContainer.setType(line.substring(0, 1)); String fileName = line.substring(2).trim(); if (fileName.startsWith("no file")) { //NOI18N fileName = fileName.substring(8); } fileInfoContainer.setFile(createFile(fileName)); eventManager.fireCVSEvent(new FileInfoEvent(this, fileInfoContainer)); fileInfoContainer = null; } private File createFile(String fileName) { return new File(localPath, fileName); } public void parseEnhancedMessage(String key, Object value) { } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/tag/TagCommand.java0000644000175300001440000003164311175407000027107 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Thomas Singer. * Portions created by Robert Greig are Copyright (C) 2001. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Thomas Singer. *****************************************************************************/ package org.netbeans.lib.cvsclient.command.tag; import java.io.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * The tag command adds or deleted a tag to the specified files/directories. * * @author Thomas Singer */ public class TagCommand extends BasicCommand { /** * The event manager to use. */ private EventManager eventManager; private boolean checkThatUnmodified; private boolean deleteTag; private boolean makeBranchTag; private boolean overrideExistingTag; private boolean matchHeadIfRevisionNotFound; private String tag; private String tagByDate; private String tagByRevision; /** * Construct a new tag command. */ public TagCommand() { } /** * Creates the TagBuilder. * @param eventManager the event manager used to received cvs events */ public Builder createBuilder(EventManager eventManager) { return new TagBuilder(eventManager, getLocalDirectory()); } /** * Returns true if checking for unmodified files is enabled. * @deprecated */ public boolean doesCheckThatUnmodified() { return checkThatUnmodified; } /** * Returns true if checking for unmodified files is enabled. */ public boolean isCheckThatUnmodified() { return checkThatUnmodified; } /** * Enabled the check for unmodified files. */ public void setCheckThatUnmodified(boolean checkThatUnmodified) { this.checkThatUnmodified = checkThatUnmodified; } /** * Returnes true if the tag should be deleted (otherwise added). * @deprecated */ public boolean doesDeleteTag() { return deleteTag; } /** * Returnes true if the tag should be deleted (otherwise added). */ public boolean isDeleteTag() { return deleteTag; } /** * Sets whether the tag should be deleted (true) or added (false). */ public void setDeleteTag(boolean deleteTag) { this.deleteTag = deleteTag; } /** * Returns true if the tag should be a branch tag. * @deprecated */ public boolean doesMakeBranchTag() { return makeBranchTag; } /** * Returns true if the tag should be a branch tag. */ public boolean isMakeBranchTag() { return makeBranchTag; } /** * Sets whether the tag should be a branch tag. */ public void setMakeBranchTag(boolean makeBranchTag) { this.makeBranchTag = makeBranchTag; } /** * Returns true to indicate that existing tag will be overridden. * @deprecated */ public boolean doesOverrideExistingTag() { return overrideExistingTag; } /** * Returns true to indicate that existing tag will be overridden. */ public boolean isOverrideExistingTag() { return overrideExistingTag; } /** * Sets whether existing tags should be overridden. */ public void setOverrideExistingTag(boolean overrideExistingTag) { this.overrideExistingTag = overrideExistingTag; } public boolean isMatchHeadIfRevisionNotFound() { return matchHeadIfRevisionNotFound; } public void setMatchHeadIfRevisionNotFound(boolean matchHeadIfRevisionNotFound) { this.matchHeadIfRevisionNotFound = matchHeadIfRevisionNotFound; } /** * Returns the tag that should be added or deleted. */ public String getTag() { return tag; } /** * Sets the tag that should be added or deleted. */ public void setTag(String tag) { this.tag = tag; } /** * Returns the latest date of a revision to be tagged. * @return date value. the latest Revision not later ten date is tagged. */ public String getTagByDate() { return tagByDate; } /** * Sets the latest date of a revision to be tagged. * @param tagDate New value of property tagDate. */ public void setTagByDate(String tagDate) { tagByDate = tagDate; } /** * Sets the latest date of a revision to be tagged. Can be both a number and a tag. * @return Value of property tagRevision. */ public String getTagByRevision() { return tagByRevision; } /** * Sets the latest date of a revision to be tagged. Can be both a number and a tag. * @param tagRevision New value of property tagRevision. */ public void setTagByRevision(String tagRevision) { tagByRevision = tagRevision; } /** * Execute the command. * * @param client the client services object that provides any necessary * services to this command, including the ability to actually * process all the requests. */ public void execute(ClientServices client, EventManager eventManager) throws CommandException, AuthenticationException { client.ensureConnection(); this.eventManager = eventManager; super.execute(client, eventManager); try { requests.add(1, new ArgumentRequest(getTag())); if (checkThatUnmodified) { requests.add(1, new ArgumentRequest("-c")); //NOI18N } if (overrideExistingTag) { requests.add(1, new ArgumentRequest("-F")); //NOI18N } if (matchHeadIfRevisionNotFound) { requests.add(1, new ArgumentRequest("-f")); // NOI18N } if (makeBranchTag) { requests.add(1, new ArgumentRequest("-b")); //NOI18N } if (deleteTag) { requests.add(1, new ArgumentRequest("-d")); //NOI18N } if (tagByDate != null && tagByDate.length() > 0) { requests.add(1, new ArgumentRequest("-D")); //NOI18N requests.add(2, new ArgumentRequest(getTagByDate())); } if (tagByRevision != null && tagByRevision.length() > 0) { requests.add(1, new ArgumentRequest("-r")); //NOI18N requests.add(2, new ArgumentRequest(getTagByRevision())); } addRequestForWorkingDirectory(client); addArgumentRequests(); addRequest(CommandRequest.TAG); client.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (EOFException ex) { throw new CommandException(ex, CommandException.getLocalMessage("CommandException.EndOfFile", null)); //NOI18N } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } finally { requests.clear(); } } /** * Called when server responses with "ok" or "error", (when the command * finishes). */ public void commandTerminated(TerminationEvent e) { if (builder != null) { builder.outputDone(); } } /** * This method returns how the tag command would looklike when typed on the * command line. */ public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("tag "); //NOI18N toReturn.append(getCVSArguments()); if (getTag() != null) { toReturn.append(getTag()); toReturn.append(" "); //NOI18N } File[] files = getFiles(); if (files != null) { for (int index = 0; index < files.length; index++) { toReturn.append(files[index].getName()); toReturn.append(' '); } } return toReturn.toString(); } /** * Takes the arguments and sets the command. * To be mainly used for automatic settings (like parsing the .cvsrc file) * @return true if the option (switch) was recognized and set */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'R') { setRecursive(true); } else if (opt == 'l') { setRecursive(false); } else if (opt == 'c') { setCheckThatUnmodified(true); } else if (opt == 'd') { setDeleteTag(true); } else if (opt == 'F') { setOverrideExistingTag(true); } else if (opt == 'f') { setMatchHeadIfRevisionNotFound(true); } else if (opt == 'b') { setMakeBranchTag(true); } else if (opt == 'D') { setTagByDate(optArg.trim()); } else if (opt == 'r') { setTagByRevision(optArg.trim()); } else { return false; } return true; } /** * String returned by this method defines which options are available for * this command. */ public String getOptString() { return "RlcFfbdD:r:"; //NOI18N } /** * Resets all switches in the command. * After calling this method, the command should have no switches defined * and should behave defaultly. */ public void resetCVSCommand() { setRecursive(true); setCheckThatUnmodified(false); setDeleteTag(false); setMakeBranchTag(false); setOverrideExistingTag(false); setMatchHeadIfRevisionNotFound(false); } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name */ public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(); if (!isRecursive()) { toReturn.append("-l "); //NOI18N } if (isCheckThatUnmodified()) { toReturn.append("-c "); //NOI18N } if (isOverrideExistingTag()) { toReturn.append("-F "); //NOI18N } if (isMatchHeadIfRevisionNotFound()) { toReturn.append("-f "); } if (isMakeBranchTag()) { toReturn.append("-b "); //NOI18N } if (isDeleteTag()) { toReturn.append("-d "); //NOI18N } if (getTagByRevision() != null && getTagByRevision().length() > 0) { toReturn.append("-r "); //NOI18N toReturn.append(getTagByRevision()); toReturn.append(" "); //NOI18N } if (getTagByDate() != null && getTagByDate().length() > 0) { toReturn.append("-D "); //NOI18N toReturn.append(getTagByDate()); toReturn.append(" "); //NOI18N } return toReturn.toString(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/unedit/0000755000175300001440000000000011175434236024753 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/unedit/UneditCommand.java0000644000175300001440000002000711175407000030331 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.unedit; import java.io.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.admin.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.command.edit.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.file.*; import org.netbeans.lib.cvsclient.request.*; /** * @author Thomas Singer */ public class UneditCommand extends BasicCommand { private Watch temporaryWatch; /** * Construct a new editors command. */ public UneditCommand() { resetCVSCommand(); } /** * Execute the command. * * @param client the client services object that provides any necessary * services to this command, including the ability to actually * process all the requests. */ public void execute(ClientServices clientServices, EventManager eventManager) throws CommandException, AuthenticationException { clientServices.ensureConnection(); try { super.execute(clientServices, eventManager); addRequestForWorkingDirectory(clientServices); addRequest(CommandRequest.NOOP); clientServices.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (EOFException ex) { throw new CommandException(ex, CommandException.getLocalMessage("CommandException.EndOfFile", null)); //NOI18N } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } finally { requests.clear(); } } protected void addRequestForFile(File file, Entry entry) { String temporaryWatch = Watch.getWatchString(getTemporaryWatch()); requests.add(new NotifyRequest(file, "U", temporaryWatch)); // NOI18N try { uneditFile(file); } catch (IOException ex) { // ignore } } /** * Called when server responses with "ok" or "error", (when the command * finishes). */ public void commandTerminated(TerminationEvent e) { if (builder != null) { builder.outputDone(); } } /** * This method returns how the tag command would looklike when typed on the * command line. */ public String getCVSCommand() { StringBuffer cvsCommandLine = new StringBuffer("unedit "); //NOI18N cvsCommandLine.append(getCVSArguments()); appendFileArguments(cvsCommandLine); return cvsCommandLine.toString(); } /** * Takes the arguments and sets the command. * To be mainly used for automatic settings (like parsing the .cvsrc file) * @return true if the option (switch) was recognized and set */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'R') { setRecursive(true); } else if (opt == 'l') { setRecursive(false); } else { return false; } return true; } /** * String returned by this method defines which options are available for * this command. */ public String getOptString() { return "Rl"; //NOI18N } /** * Resets all switches in the command. * After calling this method, the command should have no switches defined * and should behave defaultly. */ public void resetCVSCommand() { setRecursive(true); } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name */ public String getCVSArguments() { StringBuffer cvsArguments = new StringBuffer(); if (!isRecursive()) { cvsArguments.append("-l "); //NOI18N } return cvsArguments.toString(); } /** * Returns the temporary watch. */ public Watch getTemporaryWatch() { return temporaryWatch; } /** * Sets the temporary watch. */ public void setTemporaryWatch(Watch temporaryWatch) { this.temporaryWatch = temporaryWatch; } private void uneditFile(File file) throws IOException { removeBaserevEntry(file); EditCommand.getEditBackupFile(file).delete(); FileUtils.setFileReadOnly(file, true); } private void removeBaserevEntry(File file) throws IOException { File baserevFile = new File(file.getParentFile(), "CVS/Baserev"); // NOI18N File backupFile = new File(baserevFile.getAbsolutePath() + '~'); BufferedReader reader = null; BufferedWriter writer = null; final String entryStart = 'B' + file.getName() + '/'; try { writer = new BufferedWriter(new FileWriter(backupFile)); reader = new BufferedReader(new FileReader(baserevFile)); for (String line = reader.readLine(); line != null; line = reader.readLine()) { if (line.startsWith(entryStart)) { continue; } writer.write(line); writer.newLine(); } } catch (FileNotFoundException ex) { // ignore } finally { if (writer != null) { try { writer.close(); } catch (IOException ex) { // ignore } } if (reader != null) { try { reader.close(); } catch (IOException ex) { // ignore } } } baserevFile.delete(); if (backupFile.length() > 0) { backupFile.renameTo(baserevFile); } else { backupFile.delete(); } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/update/0000755000175300001440000000000011175434236024745 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/update/UpdateBuilder.java0000644000175300001440000002635511175407000030341 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.update; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.event.*; /** * Handles the building of update information object and the firing of * events when complete objects are built. * * @author Milos Kleint, Thomas Singer */ public class UpdateBuilder implements Builder { /** * Parsing constants.. */ public static final String UNKNOWN = ": nothing known about"; //NOI18N public static final String EXAM_DIR = ": Updating"; //NOI18N public static final String TO_ADD = ": use `cvs add' to create an entry for"; //NOI18N public static final String STATES = "U P A R M C ? "; //NOI18N public static final String WARNING = ": warning: "; //NOI18N public static final String SERVER = "server: "; //NOI18N public static final String PERTINENT = "is not (any longer) pertinent"; //NOI18N public static final String REMOVAL = "for removal"; //NOI18N public static final String SERVER_SCHEDULING = "server: scheduling"; //NOI18N private static final String SERVER_SCHEDULING_12 = "update: scheduling `"; //NOI18N private static final String REMOVAL_12 = "' for removal"; //NOI18N public static final String CONFLICTS = "rcsmerge: warning: conflicts during merge"; //NOI18N public static final String NOT_IN_REPOSITORY = "is no longer in the repository"; //NOI18N; //cotacao/src/client/net/riobranco/common/client/gui/BaseDialogThinlet.java already contains the differences between 1.17 and 1.18 private static final String MERGE_SAME = " already contains the differences between"; private static final String MERGED = "Merging differences between"; //NOI18N; /** * The status object that is currently being built. */ private DefaultFileInfoContainer fileInfoContainer; /** * The event manager to use. */ private EventManager eventManager; /** * The local path the command run in. */ private final String localPath; private String diagnostics; /** * Holds 'G' or 'C' if the current file was merged or conflicted, respectively. */ private String fileMergedOrConflict; public UpdateBuilder(EventManager eventManager, String localPath) { this.eventManager = eventManager; this.localPath = localPath; } public void outputDone() { fileMergedOrConflict = null; if (fileInfoContainer != null) { if (fileInfoContainer.getFile() == null) { System.err.println("#65387 CVS: firing invalid event while processing: " + diagnostics); } eventManager.fireCVSEvent(new FileInfoEvent(this, fileInfoContainer)); fileInfoContainer = null; } } public void parseLine(String line, boolean isErrorMessage) { diagnostics = line; if (line.indexOf(UNKNOWN) >= 0) { processUnknownFile(line, line.indexOf(UNKNOWN) + UNKNOWN.length()); } else if (line.indexOf(TO_ADD) >= 0) { processUnknownFile(line, line.indexOf(TO_ADD) + TO_ADD.length()); } else if (line.indexOf(EXAM_DIR) >= 0) { // never comes with :local; connection method return; } else if (line.startsWith(CONFLICTS)) { if (fileInfoContainer != null) { fileInfoContainer.setType("C"); //NOI18N // fire from Merged response which follows } fileMergedOrConflict = "C"; } else if (line.indexOf(WARNING) >= 0) { if (line.indexOf(PERTINENT) > 0) { String filename = line.substring(line.indexOf(WARNING) + WARNING.length(), line.indexOf(PERTINENT)).trim(); processNotPertinent(filename); } } else if (line.indexOf(SERVER_SCHEDULING_12) >= 0) { if (line.indexOf(REMOVAL_12) > 0) { String filename = line.substring(line.indexOf(SERVER_SCHEDULING_12) + SERVER_SCHEDULING_12.length(), line.indexOf(REMOVAL_12)).trim(); processNotPertinent(filename); } } else if (line.indexOf(SERVER_SCHEDULING) >= 0) { if (line.indexOf(REMOVAL) > 0) { String filename = line.substring(line.indexOf(SERVER_SCHEDULING) + SERVER_SCHEDULING.length(), line.indexOf(REMOVAL)).trim(); processNotPertinent(filename); } } else if (line.indexOf(MERGE_SAME) >= 0) { // not covered by parseEnhancedMessage ensureExistingFileInfoContainer(); fileInfoContainer.setType(DefaultFileInfoContainer.MERGED_FILE); String path = line.substring(0, line.indexOf(MERGE_SAME)); fileInfoContainer.setFile(createFile(path)); outputDone(); } else if (line.startsWith(MERGED)) { // not covered by parseEnhancedMessage outputDone(); fileMergedOrConflict = "G"; } else if (line.indexOf(NOT_IN_REPOSITORY) > 0) { String filename = line.substring(line.indexOf(SERVER) + SERVER.length(), line.indexOf(NOT_IN_REPOSITORY)).trim(); processNotPertinent(filename); return; } else { // otherwise if (line.length() > 2) { String firstChar = line.substring(0, 2); if (STATES.indexOf(firstChar) >= 0) { processFile(line); return; } } } } private File createFile(String fileName) { if (fileName.length() > 1 && fileName.charAt(0) == '`' && fileName.charAt(fileName.length() - 1) == '\'') { fileName = fileName.substring(1, fileName.length() - 1); } return new File(localPath, fileName); } private void ensureExistingFileInfoContainer() { if (fileInfoContainer != null) { return; } fileInfoContainer = new DefaultFileInfoContainer(); } private void processUnknownFile(String line, int index) { outputDone(); fileInfoContainer = new DefaultFileInfoContainer(); fileInfoContainer.setType("?"); //NOI18N String fileName = (line.substring(index)).trim(); fileInfoContainer.setFile(createFile(fileName)); } private void processFile(String line) { String fileName = line.substring(2).trim(); if (fileName.startsWith("no file")) { //NOI18N fileName = fileName.substring(8); } if (fileName.startsWith("./")) { //NOI18N fileName = fileName.substring(2); } File file = createFile(fileName); if (fileInfoContainer != null) { // sometimes (when locally modified.. the merged response is followed by mesage M or C .. // check the file.. if equals.. it's the same one.. don't send again.. the prior type has preference if (fileInfoContainer.getFile() == null) { // is null in case the global switch -n is used - then no Enhanced message is sent, and no // file is assigned the merged file.. fileInfoContainer.setFile(file); } if (file.equals(fileInfoContainer.getFile())) { // if the previous information does not say anything, prefer newer one if (fileInfoContainer.getType().equals("?")) { fileInfoContainer = null; } else { outputDone(); return; } } } if (fileMergedOrConflict != null && line.charAt(0) == 'M') { line = fileMergedOrConflict; // can be done this way, see below } outputDone(); ensureExistingFileInfoContainer(); fileInfoContainer.setType(line.substring(0, 1)); fileInfoContainer.setFile(file); } private void processNotPertinent(String fileName) { outputDone(); File fileToDelete = createFile(fileName); ensureExistingFileInfoContainer(); // HACK - will create a non-cvs status in order to be able to have consistent info format fileInfoContainer.setType(DefaultFileInfoContainer.PERTINENT_STATE); fileInfoContainer.setFile(fileToDelete); } /** Merged response handler. */ public void parseEnhancedMessage(String key, Object value) { if (key.equals(EnhancedMessageEvent.MERGED_PATH)) { ensureExistingFileInfoContainer(); String path = value.toString(); File newFile = new File(path); // #70106 Merged responce must not rewrite CONFLICTS if (newFile.equals(fileInfoContainer.getFile()) == false) { fileInfoContainer.setFile(newFile); fileInfoContainer.setType(DefaultFileInfoContainer.MERGED_FILE); if (fileMergedOrConflict != null) { fileInfoContainer.setType(fileMergedOrConflict); } } outputDone(); } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/update/UpdateCommand.java0000644000175300001440000006062511175407000030327 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.command.update; import java.io.*; import java.text.*; import java.util.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.file.FileUtils; import org.netbeans.lib.cvsclient.admin.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * The Update command. Updates files that have previously been checked out * from the repository with the checkout command. Modified files are not * overwritten. * @author Robert Greig */ public class UpdateCommand extends BasicCommand implements TemporaryFileCreator { // This format possibly may be set by the user of the library later. private static final String RENAME_FORMAT = "{0}/.#{1}.{2}"; //NOI18N private static final Object[] FORMAT_PARAMETER = new Object[3]; // { path, filename, revision } /** * A store of potentially empty directories. When a directory has a file * in it, it is removed from this set. This set allows the prune option * to be implemented. */ private final Set emptyDirectories = new HashSet(); /** * Whether to build directories, like checkout does (this is the -d option * in command-line CVS). */ private boolean buildDirectories; /** * Determines whether to get a clean copy from the server. * This overrides even locally modified files. */ private boolean cleanCopy; /** * Whether to prune directories, i.e. remove any directories that do not * contain any files. This is the -P option in command-line CVS). */ private boolean pruneDirectories; /** * Determines wheather the output of the command is processed on standard output. * Default is false. If true, nothing is done to local working files. */ private boolean pipeToOutput; /** * Resets any sticky tags/dates/options imposed on the updated file(s). */ private boolean resetStickyOnes; /** * Use head revision if a revision meeting criteria set by switches -r/-D * (tag/date) is not found. */ private boolean useHeadIfNotFound; /** * equals the -D switch of command line cvs. */ private String updateByDate; /** * Equals the -r switch of command-line cvs. */ private String updateByRevision; /** * Use this keyword substitution for the command. * does not include the -k switch part. */ private KeywordSubstitutionOptions keywordSubst; /** * First of the 2 possible -j switches that merge 2 different revisions. * If only this property is set, the current working file is merged * with the specified one. */ private String mergeRevision1; /** * Second of the 2 possible -j switches that merge 2 different revisions. * Assumes the first -j switch (mergeRevision1 property) is set. * Then the update commands merges the sources of these 2 revisons specified * by the -j switches. */ private String mergeRevision2; /** * Construct a new update command. */ public UpdateCommand() { // TODO: move up the hierarchy ? resetCVSCommand(); } /** * Method that is called while the command is being executed. * Descendants can override this method to return a Builder instance * that will parse the server's output and create data structures. */ public Builder createBuilder(EventManager eventManager) { if (isPipeToOutput()) { return new PipedFilesBuilder(eventManager, this, this); } return new UpdateBuilder(eventManager, getLocalDirectory()); } /** * If getCleanCopy() returns true, the files will be treated * as not existing. */ protected void sendEntryAndModifiedRequests(Entry entry, File file) { if (isCleanCopy() && file != null && entry != null) { if (!isPipeToOutput()) { FORMAT_PARAMETER[0] = file.getParent(); FORMAT_PARAMETER[1] = file.getName(); FORMAT_PARAMETER[2] = entry.getRevision(); String filename = MessageFormat.format(RENAME_FORMAT, FORMAT_PARAMETER); try { FileUtils.copyFile(file, new File(filename)); } catch (IOException e) { // backup copy will not be created } } file = null; } super.sendEntryAndModifiedRequests(entry, file); } /** * Set whether to build directories. This is the -d option in command-line * CVS. */ public void setBuildDirectories(boolean buildDirectories) { this.buildDirectories = buildDirectories; } /** * Returns whether to build directories. * @return true if directories are to be built, false otherwise */ public boolean isBuildDirectories() { return buildDirectories; } /** * Sets whether to get a clean copy from the server. * Even locally modified files will not merged but overridden. * This is the -C option in the command-line CVS. */ public void setCleanCopy(boolean cleanCopy) { this.cleanCopy = cleanCopy; } /** * Returns whether to get a clean copy from the server. */ public boolean isCleanCopy() { return cleanCopy; } /** * Set whether to prune directories. This is the -P option in the command- * line CVS. */ public void setPruneDirectories(boolean pruneDirectories) { this.pruneDirectories = pruneDirectories; } /** * Returns whether to prune directories. * @return true if directories should be removed if they contain no files, * false otherwise. */ public boolean isPruneDirectories() { return pruneDirectories; } /** * Execute the command. * @param client the client services object that provides any necessary * services to this command, including the ability to actually * process all the requests */ public void execute(ClientServices client, EventManager eventManager) throws CommandException, AuthenticationException { client.ensureConnection(); super.execute(client, eventManager); emptyDirectories.clear(); try { // now add the request that indicates the working directory for the // command if (!isRecursive()) { requests.add(1, new ArgumentRequest("-l")); //NOI18N } if (isBuildDirectories()) { requests.add(1, new ArgumentRequest("-d")); //NOI18N } if (isCleanCopy() && !isPipeToOutput()) { requests.add(1, new ArgumentRequest("-C")); //NOI18N } if (isPipeToOutput()) { requests.add(1, new ArgumentRequest("-p")); //NOI18N } if (isResetStickyOnes()) { requests.add(1, new ArgumentRequest("-A")); //NOI18N } if (isUseHeadIfNotFound()) { requests.add(1, new ArgumentRequest("-f")); //NOI18N } if (getUpdateByDate() != null) { requests.add(1, new ArgumentRequest("-D")); //NOI18N requests.add(2, new ArgumentRequest(getUpdateByDate())); } else if (getUpdateByRevision() != null) { requests.add(1, new ArgumentRequest("-r")); //NOI18N requests.add(2, new ArgumentRequest(getUpdateByRevision())); } if (getMergeRevision1() != null) { requests.add(1, new ArgumentRequest("-j")); //NOI18N requests.add(2, new ArgumentRequest(getMergeRevision1())); if (getMergeRevision2() != null) { requests.add(3, new ArgumentRequest("-j")); //NOI18N requests.add(4, new ArgumentRequest(getMergeRevision2())); } } if (getKeywordSubst() != null) { requests.add(1, new ArgumentRequest("-k")); //NOI18N requests.add(2, new ArgumentRequest(getKeywordSubst().toString())); } requests.add(1, new ArgumentRequest("-u")); //NOI18N addRequestForWorkingDirectory(client); addArgumentRequests(); addRequest(CommandRequest.UPDATE); // hack - now check for the entry request for removed files // only when p with -r or -D is on if (isPipeToOutput() && (getUpdateByRevision() != null || getUpdateByDate() != null)) { ListIterator it = requests.listIterator(); while (it.hasNext()) { Object req = it.next(); if (req instanceof EntryRequest) { EntryRequest eReq = (EntryRequest)req; Entry entry = eReq.getEntry(); if (entry.getRevision().startsWith("-")) {//NOI18N entry.setRevision(entry.getRevision().substring(1)); } it.set(new EntryRequest(entry)); it.add(new UnchangedRequest(entry.getName())); } } } // end of hack.. client.processRequests(requests); if (pruneDirectories && (getGlobalOptions() == null || !getGlobalOptions().isDoNoChanges())) { pruneEmptyDirectories(client); } } catch (CommandException ex) { throw ex; } catch (EOFException ex) { throw new CommandException(ex, CommandException.getLocalMessage("CommandException.EndOfFile", null)); //NOI18N } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } finally { requests.clear(); } } /** * Getter for property pipeToOutput. * @return Value of property pipeToOutput. */ public boolean isPipeToOutput() { return pipeToOutput; } /** * Setter for property pipeToOutput. * @param pipeToOutput New value of property pipeToOutput. */ public void setPipeToOutput(boolean pipeToOutput) { this.pipeToOutput = pipeToOutput; } /** * Getter for property resetStickyOnes. * @return Value of property resetStickyOnes. */ public boolean isResetStickyOnes() { return resetStickyOnes; } /** * Setter for property resetStickyOnes. * @param resetStickyOnes New value of property resetStickyOnes. */ public void setResetStickyOnes(boolean resetStickyOnes) { this.resetStickyOnes = resetStickyOnes; } /** * Getter for property useHeadIfNotFound. * @return Value of property useHeadIfNotFound. */ public boolean isUseHeadIfNotFound() { return useHeadIfNotFound; } /** * Setter for property useHeadIfNotFound. * @param useHeadIfNotFound New value of property useHeadIfNotFound. */ public void setUseHeadIfNotFound(boolean useHeadIfNotFound) { this.useHeadIfNotFound = useHeadIfNotFound; } /** * Getter for property updateByDate. * @return Value of property updateByDate. */ public String getUpdateByDate() { return updateByDate; } /** * Setter for property updateByDate. * @param updateByDate New value of property updateByDate. */ public void setUpdateByDate(String updateByDate) { this.updateByDate = getTrimmedString(updateByDate); } /** * Getter for property updateByRevision. * @return Value of property updateByRevision. */ public String getUpdateByRevision() { return updateByRevision; } /** * Setter for property updateByRevision. * @param updateByRevision New value of property updateByRevision. */ public void setUpdateByRevision(String updateByRevision) { this.updateByRevision = getTrimmedString(updateByRevision); } /** * Getter for property keywordSubst. * @return Value of property keywordSubst. */ public KeywordSubstitutionOptions getKeywordSubst() { return keywordSubst; } /** * Setter for property keywordSubst. * @param keywordSubst New value of property keywordSubst. */ public void setKeywordSubst(KeywordSubstitutionOptions keywordSubst) { this.keywordSubst = keywordSubst; } /** * Method that creates a temporary file. */ public File createTempFile(String filename) throws IOException { File temp = File.createTempFile("cvs", ".dff", getGlobalOptions().getTempDir()); //NOI18N temp.deleteOnExit(); return temp; } /** * This method returns how the command would looklike when typed on the * command line. * Each command is responsible for constructing this information. * @returns [] files/dirs. * Example: checkout -p CvsCommand.java */ public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("update "); //NOI18N toReturn.append(getCVSArguments()); File[] files = getFiles(); if (files != null) { for (int index = 0; index < files.length; index++) { toReturn.append(files[index].getName()); toReturn.append(' '); } } return toReturn.toString(); } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name */ public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(""); //NOI18N if (isPipeToOutput()) { toReturn.append("-p "); //NOI18N } if (isCleanCopy()) { toReturn.append("-C "); //NOI18N } if (!isRecursive()) { toReturn.append("-l "); //NOI18N } if (isBuildDirectories()) { toReturn.append("-d "); //NOI18N } if (isPruneDirectories()) { toReturn.append("-P "); //NOI18N } if (isResetStickyOnes()) { toReturn.append("-A "); //NOI18N } if (isUseHeadIfNotFound()) { toReturn.append("-f "); //NOI18N } if (getKeywordSubst() != null) { toReturn.append("-k"); //NOI18N toReturn.append(getKeywordSubst().toString()); toReturn.append(' '); } if (getUpdateByRevision() != null) { toReturn.append("-r "); //NOI18N toReturn.append(getUpdateByRevision()); toReturn.append(' '); } if (getUpdateByDate() != null) { toReturn.append("-D "); //NOI18N toReturn.append(getUpdateByDate()); toReturn.append(' '); } if (getMergeRevision1() != null) { toReturn.append("-j "); //NOI18N toReturn.append(getMergeRevision1()); toReturn.append(' '); if (getMergeRevision2() != null) { toReturn.append("-j "); //NOI18N toReturn.append(getMergeRevision2()); toReturn.append(' '); } } return toReturn.toString(); } /** * Takes the arguments and by parsing them, sets the command. To be mainly * used for automatic settings (like parsing the .cvsrc file) */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'R') { setRecursive(true); } else if (opt == 'C') { setCleanCopy(true); } else if (opt == 'l') { setRecursive(false); } else if (opt == 'd') { setBuildDirectories(true); } else if (opt == 'P') { setPruneDirectories(true); } else if (opt == 'A') { setResetStickyOnes(true); } else if (opt == 'f') { setUseHeadIfNotFound(true); } else if (opt == 'D') { setUpdateByDate(optArg.trim()); } else if (opt == 'r') { setUpdateByRevision(optArg.trim()); } else if (opt == 'k') { KeywordSubstitutionOptions keywordSubst = KeywordSubstitutionOptions.findKeywordSubstOption(optArg); setKeywordSubst(keywordSubst); } else if (opt == 'p') { setPipeToOutput(true); } else if (opt == 'j') { if (getMergeRevision1() == null) { setMergeRevision1(optArg); } else { setMergeRevision2(optArg); } } else { // TODO - now silently ignores not recognized switches. return false; } return true; } /** * Resets all switches in the command. * After calling this method, the command should have no switches defined * and should behave defaultly. */ public void resetCVSCommand() { setRecursive(true); setCleanCopy(false); setBuildDirectories(false); setPruneDirectories(false); setResetStickyOnes(false); setUseHeadIfNotFound(false); setUpdateByDate(null); setUpdateByRevision(null); setKeywordSubst(null); setPipeToOutput(false); setMergeRevision1(null); setMergeRevision2(null); } /** * Called when the server wants to send a message to be displayed to * the user. The message is only for information purposes and clients * can choose to ignore these messages if they wish. * @param e the event */ public void messageSent(MessageEvent e) { super.messageSent(e); // we use this event to determine which directories need to be checked // for updating if (!pruneDirectories) { return; } final String relativePath = CommandUtils.getExaminedDirectory(e.getMessage(), UpdateBuilder.EXAM_DIR); if (relativePath == null) { return; } // dont delete the current directory, even if it's empty if (relativePath.equals(".")) { //NOI18N return; } emptyDirectories.add(new File(getLocalDirectory(), relativePath)); } /** * Prunes a directory, recursively pruning its subdirectories * @param directory the directory to prune */ private boolean pruneEmptyDirectory(File directory, ClientServices client) throws IOException { final File[] contents = directory.listFiles(); // should never be null, but just in case... if (contents == null) { return true; } for (int i = 0; i < contents.length; i++) { if (contents[i].isFile()) { return false; } // Skip the cvs directory if (contents[i].getName().equals("CVS")) { //NOI18N continue; } if (!pruneEmptyDirectory(contents[i], client)) { return false; } } // check this is a CVS directory and not some directory the user // has stupidly called CVS... if (new File(directory, "CVS/Entries").isFile() && new File(directory, "CVS/Repository").isFile()) { final File adminDir = new File(directory, "CVS"); //NOI18N // we must NOT delete a directory if it contains valuable entries for (Iterator i = clientServices.getEntries(directory); i.hasNext(); ) { Entry entry = (Entry) i.next(); if (entry.getName() != null && entry.isUserFileToBeRemoved()) return false; } deleteRecursively(adminDir); directory.delete(); // if the client still makes this directory's entries available, do not delete its entry if (!client.exists(directory)) client.removeEntry(directory); return true; } return false; } /** * Deletes a directory and all files and directories inside the directory. * * @param dir directory to delete */ private void deleteRecursively(File dir) { File [] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { File file = files[i]; if (file.isDirectory()) { deleteRecursively(file); } else { file.delete(); } } dir.delete(); } /** * Remove any directories that don't contain any files */ private void pruneEmptyDirectories(ClientServices client) throws IOException { for (Iterator it = emptyDirectories.iterator(); it.hasNext();) { final File dir = (File)it.next(); // we might have deleted it already (due to recursive delete) // so we need to check existence if (dir.exists()) { pruneEmptyDirectory(dir, client); } } emptyDirectories.clear(); } /** * String returned by this method defines which options are available for this particular command */ public String getOptString() { return "RCnldPAfD:r:pj:k:"; //NOI18N } /** Getter for property mergeRevision1. * @return Value of property mergeRevision1. */ public String getMergeRevision1() { return mergeRevision1; } /** Setter for property mergeRevision1. * @param mergeRevision1 New value of property mergeRevision1. */ public void setMergeRevision1(String mergeRevision1) { this.mergeRevision1 = getTrimmedString(mergeRevision1); } /** Getter for property mergeRevision2. * @return Value of property mergeRevision2. */ public String getMergeRevision2() { return mergeRevision2; } /** Setter for property mergeRevision2. * @param mergeRevision2 New value of property mergeRevision2. */ public void setMergeRevision2(String mergeRevision2) { this.mergeRevision2 = getTrimmedString(mergeRevision2); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/watch/0000755000175300001440000000000011175434236024571 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/watch/WatchCommand.java0000644000175300001440000001652611175407000030000 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.watch; import java.io.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; import org.netbeans.lib.cvsclient.util.*; /** * @author Thomas Singer */ public class WatchCommand extends BasicCommand { private WatchMode watchMode; private Watch watch; /** * Construct a new WatchCommand. */ public WatchCommand() { resetCVSCommand(); } /** * Executes this command. * * @param client the client services object that provides any necessary * services to this command, including the ability to actually * process all the requests * @param eventManager the EventManager used for sending events * * @throws IllegalStateException if the commands options aren't set correctly * @throws AuthenticationException if the connection could not be established * @throws CommandException if some other thing gone wrong */ public void execute(ClientServices client, EventManager eventManager) throws CommandException, AuthenticationException { checkState(); client.ensureConnection(); try { super.execute(client, eventManager); if (getWatchMode().isWatchOptionAllowed()) { String[] arguments = getWatchNotNull().getArguments(); for (int i = 0; i < arguments.length; i++) { addRequest(new ArgumentRequest("-a")); // NOI18N addRequest(new ArgumentRequest(arguments[i])); } } addRequestForWorkingDirectory(client); addArgumentRequests(); addRequest(getWatchMode().getCommand()); client.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } finally { requests.clear(); } } /** * If a builder was set-up, it's outputDone() method is called. * This method is called, when the server responses with "ok" or "error" * (== when the command finishes). */ public void commandTerminated(TerminationEvent e) { if (builder != null) { builder.outputDone(); } } /** * Uses the specified argument to set the appropriate properties. * To be mainly used for automatic settings (like parsing the .cvsrc file) * * @return whether the option (switch) was recognized and set */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'R') { setRecursive(true); } else if (opt == 'l') { setRecursive(false); } else { return false; } return true; } /** * String returned by this method defines which options are available for * this command. */ public String getOptString() { return "Rl"; //NOI18N } /** * Resets all switches in this command. * After calling this method, the command behaves like newly created. */ public void resetCVSCommand() { setRecursive(true); setWatch(null); } /** * Returns how this command would look like when typed on the command line. */ public String getCVSCommand() { StringBuffer cvsCommand = new StringBuffer("watch "); //NOI18N cvsCommand.append(getCVSArguments()); appendFileArguments(cvsCommand); return cvsCommand.toString(); } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name */ public String getCVSArguments() { checkState(); StringBuffer cvsArguments = new StringBuffer(); cvsArguments.append(getWatchMode().toString()); cvsArguments.append(' '); if (!isRecursive()) { cvsArguments.append("-l "); //NOI18N } if (getWatchMode().isWatchOptionAllowed()) { cvsArguments.append("-a "); cvsArguments.append(getWatchNotNull().toString()); } return cvsArguments.toString(); } /** * Returns the WatchMode. */ public WatchMode getWatchMode() { return watchMode; } /** * Sets the WatchMode. */ public void setWatchMode(WatchMode watchMode) { this.watchMode = watchMode; } /** * Returns the watch. */ public Watch getWatch() { return watch; } private Watch getWatchNotNull() { if (watch == null) { return Watch.ALL; } return watch; } /** * Sets the watch. * If the WatchMode ADD or REMOVE is used, null is the same as Watch.ALL. * If the WatchMode ON or OFF is used, this option isn't used at all. */ public void setWatch(Watch watch) { this.watch = watch; } private void checkState() { if (getWatchMode() == null) { throw new IllegalStateException("Watch mode expected!"); } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/watch/WatchMode.java0000644000175300001440000001034411175407000027276 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.watch; import org.netbeans.lib.cvsclient.request.*; /** * @author Thomas Singer * @version Dec 29, 2001 */ public class WatchMode { /** * This is the WatchMode that enables watching. */ public static final WatchMode ON = new WatchMode("on", // NOI18N CommandRequest.WATCH_ON, false); /** * This is the WatchMode that disables watching. */ public static final WatchMode OFF = new WatchMode("off", // NOI18N CommandRequest.WATCH_OFF, false); /** * This is the WatchMode that adds watching for the specified Watch. */ public static final WatchMode ADD = new WatchMode("add", // NOI18N CommandRequest.WATCH_ADD, true); /** * This is the WatchMode that removes watching for the specified Watch. */ public static final WatchMode REMOVE = new WatchMode("remove", // NOI18N CommandRequest.WATCH_REMOVE, true); private final String name; private final CommandRequest command; private final boolean watchOptionAllowed; private WatchMode(String name, CommandRequest command, boolean watchOptionAllowed) { this.name = name; this.command = command; this.watchOptionAllowed = watchOptionAllowed; } /** * Returns the CommandRequest that is used when executing the WatchCommand * with this WatchMode. */ public CommandRequest getCommand() { return command; } /** * Indicated, whether a non-null watch-option is allowed in the WatchCommand. */ public boolean isWatchOptionAllowed() { return watchOptionAllowed; } /** * Returns the name of this WatchMode ("on", "off", "add", "remove"). */ public String toString() { return name; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/watchers/0000755000175300001440000000000011175434236025303 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/watchers/WatchersBuilder.java0000644000175300001440000001111711175407000031223 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.watchers; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.util.*; /** * Handles the building of a watchers information object and the firing of * events when complete objects are built. * * @author Milos Kleint */ public class WatchersBuilder implements Builder { private static final String UNKNOWN_FILE = "? "; //NOI18N /** * The status object that is currently being built. */ private WatchersInformation watchersInfo; /** * The event manager to use. */ private final EventManager eventManager; /** * The directory where the command was executed. * Used to compute absolute path to the file. */ private final String localPath; /** * Creates a WatchersBuilder. * @param eventManager the event manager that will fire events. * @param localPath absolute path to the directory where the command was executed. */ public WatchersBuilder(EventManager eventManager, String localPath) { this.eventManager = eventManager; this.localPath = localPath; } public void outputDone() { if (watchersInfo != null) { eventManager.fireCVSEvent(new FileInfoEvent(this, watchersInfo)); watchersInfo = null; } } public void parseLine(String line, boolean isErrorMessage) { if (line.startsWith(UNKNOWN_FILE)) { File file = new File(localPath, line.substring(UNKNOWN_FILE.length())); watchersInfo = new WatchersInformation(file); outputDone(); return; } if (isErrorMessage) { return; } if (line.startsWith(" ") || line.startsWith("\t")) { // NOI18N BugLog.getInstance().assertNotNull(watchersInfo); watchersInfo.addWatcher(line); return; } // the line starts with file.. outputDone(); String trimmedLine = line.trim().replace('\t', ' '); int spaceIndex = trimmedLine.indexOf(' '); BugLog.getInstance().assertTrue(spaceIndex > 0, "Wrong line = " + line); File file = new File(localPath, trimmedLine.substring(0, spaceIndex)); String watcher = trimmedLine.substring(spaceIndex + 1); watchersInfo = new WatchersInformation(file); watchersInfo.addWatcher(watcher); } public void parseEnhancedMessage(String key, Object value) { } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/watchers/WatchersCommand.java0000644000175300001440000001404411175407000031215 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.watchers; import java.io.*; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.request.*; /** * The watchers command looks up who is watching this file, * who is interested in it. * * @author Milos Kleint * @author Thomas Singer */ public class WatchersCommand extends BasicCommand { /** * Construct a new watchers command. */ public WatchersCommand() { resetCVSCommand(); } /** * Creates and returns the WatchersBuilder. * * @param eventMan the event manager used to receive events. */ public Builder createBuilder(EventManager eventManager) { return new WatchersBuilder(eventManager, getLocalDirectory()); } /** * Executes this command. * * @param client the client services object that provides any necessary * services to this command, including the ability to actually * process all the requests */ public void execute(ClientServices client, EventManager eventManager) throws CommandException, AuthenticationException { client.ensureConnection(); super.execute(client, eventManager); try { addRequestForWorkingDirectory(client); addArgumentRequests(); addRequest(CommandRequest.WATCHERS); client.processRequests(requests); } catch (CommandException ex) { throw ex; } catch (Exception ex) { throw new CommandException(ex, ex.getLocalizedMessage()); } finally { requests.clear(); } } /** * called when server responses with "ok" or "error", (when the command finishes) */ public void commandTerminated(TerminationEvent e) { if (builder != null) { builder.outputDone(); } } /** * This method returns how the command would looklike when typed on the command line. * Each command is responsible for constructing this information. * @returns [] files/dirs. Example: checkout -p CvsCommand.java */ public String getCVSCommand() { StringBuffer toReturn = new StringBuffer("watchers "); //NOI18N toReturn.append(getCVSArguments()); File[] files = getFiles(); if (files != null) { for (int index = 0; index < files.length; index++) { toReturn.append(files[index].getName()); toReturn.append(' '); } } return toReturn.toString(); } /** * takes the arguments and sets the command. To be mainly * used for automatic settings (like parsing the .cvsrc file) * @return true if the option (switch) was recognized and set */ public boolean setCVSCommand(char opt, String optArg) { if (opt == 'R') { setRecursive(true); } else if (opt == 'l') { setRecursive(false); } else { return false; } return true; } /** * String returned by this method defines which options are available for this particular command */ public String getOptString() { return "Rl"; //NOI18N } /** * resets all switches in the command. After calling this method, * the command should have no switches defined and should behave defaultly. */ public void resetCVSCommand() { setRecursive(true); } /** * Returns the arguments of the command in the command-line style. * Similar to getCVSCommand() however without the files and command's name */ public String getCVSArguments() { StringBuffer toReturn = new StringBuffer(); if (!isRecursive()) { toReturn.append("-l "); //NOI18N } return toReturn.toString(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/watchers/WatchersInformation.java0000644000175300001440000001637611175407001032137 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command.watchers; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.util.*; /** * Describes "cvs watchers" commands' parsed information for a file. * The fields in instances of this object are populated * by response handlers. * * @author Milos Kleint */ public class WatchersInformation extends FileInfoContainer { public static final String WATCH_EDIT = "edit"; //NOI18N public static final String WATCH_UNEDIT = "unedit"; //NOI18N public static final String WATCH_COMMIT = "commit"; //NOI18N public static final String WATCH_TEMP_EDIT = "tedit"; //NOI18N public static final String WATCH_TEMP_UNEDIT = "tunedit"; //NOI18N public static final String WATCH_TEMP_COMMIT = "tcommit"; //NOI18N /** * Holds the file that this info belongs to. */ private final File file; /** * List of users (Watchers instances) that are listening * on events for this file. */ private final List userList = new LinkedList(); /** * Creates new istance of the WatchersInformation class. */ public WatchersInformation(File file) { this.file = file; } /** * Getter for file concerned in this instance. */ public File getFile() { return file; } /** * Adds a watcher to the watchers list. * @param watchingInfo a String that's first word is a user name and the * rest are watching types. */ void addWatcher(String watchingInfo) { String temp = watchingInfo.trim(); temp = temp.replace('\t', ' '); int spaceIndex = temp.indexOf(' '); if (spaceIndex < 0) { //BUGLOG assert. } else { String user = temp.substring(0, spaceIndex); String watches = temp.substring(spaceIndex + 1); this.userList.add(new WatchersInformation.Watcher(user, watches)); } } /** * Returns the Iterator with WatchersInformation.Watcher instances. * Never returns null. */ public Iterator getWatchersIterator() { return this.userList.iterator(); } /** * Inner class that holds information about single user and his watches * on the file. */ public static class Watcher { private final String userName; private final String watches; private boolean watchingEdit; private boolean watchingUnedit; private boolean watchingCommit; private boolean temporaryEdit; private boolean temporaryUnedit; private boolean temporaryCommit; /** * Package private constuctor that creates a new instance of the Watcher. * To Be called from outerclass only. */ Watcher(String userName, String watches) { this.userName = userName; this.watches = watches; final StringTokenizer tok = new StringTokenizer(watches, " ", false); while (tok.hasMoreTokens()) { String token = tok.nextToken(); if (WATCH_EDIT.equals(token)) { watchingEdit = true; } else if (WATCH_UNEDIT.equals(token)) { watchingUnedit = true; } else if (WATCH_COMMIT.equals(token)) { watchingCommit = true; } else if (WATCH_TEMP_COMMIT.equals(token)) { temporaryCommit = true; } else if (WATCH_TEMP_EDIT.equals(token)) { temporaryEdit = true; } else if (WATCH_TEMP_UNEDIT.equals(token)) { temporaryUnedit = true; } else { BugLog.getInstance().bug("unknown = " + token); } } } /** * Gets the user that is watching the file. */ public String getUserName() { return userName; } /** * Returns all the watches defined on the file. */ public String getWatches() { return watches; } /** * User is/isn't watching commit opration. */ public boolean isWatchingCommit() { return watchingCommit; } /** * User is/isn't watching edit opration. */ public boolean isWatchingEdit() { return watchingEdit; } /** * User is/isn't watching unedit opration. */ public boolean isWatchingUnedit() { return watchingUnedit; } /** * User is/isn't temporary watching commit opration. */ public boolean isTempWatchingCommit() { return temporaryCommit; } /** * User is/isn't temporary watching edit opration. */ public boolean isTempWatchingEdit() { return temporaryEdit; } /** * User is/isn't temporary watching unedit opration. */ public boolean isTempWatchingUnedit() { return temporaryUnedit; } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/command/WrapperUtils.java0000644000175300001440000001506011175416504026767 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.command; import org.netbeans.lib.cvsclient.util.SimpleStringPattern; import org.netbeans.lib.cvsclient.ClientServices; import java.io.*; import java.util.Map; import java.util.StringTokenizer; /** * Support for .cvswrappers parsing and merging. */ public class WrapperUtils { /** * Reads the wrappers from the specified source and populates the specified * map * * @param reader The source of wrappers which is being processed * @param theMap The map which is being updated */ private static void parseWrappers(BufferedReader reader, Map theMap) throws IOException { String line; while ((line = reader.readLine()) != null){ StringTokenizer tokenizer = new StringTokenizer(line); // the first token is the pattern SimpleStringPattern pattern = new SimpleStringPattern(tokenizer.nextToken()); // it is followed by option value pairs String option, value; while (tokenizer.hasMoreTokens()) { option = tokenizer.nextToken(); value = tokenizer.nextToken(); // do not bother with the -m Options now if (option.equals("-k")) { //NOI18N // This is a keyword substitution option // strip the quotes int first = value.indexOf('\''); int last = value.lastIndexOf('\''); if (first >=0 && last >= 0) { value = value.substring(first+1, last); } KeywordSubstitutionOptions keywordOption = KeywordSubstitutionOptions.findKeywordSubstOption(value); if (!theMap.containsKey(pattern)) { theMap.put(pattern, keywordOption); } } } } } /** * Reads the wrappers from the specified file and populates the specified * map * * @param file The File object corresponding to the file which is being processed * @param wrapperMap The map which is being updated */ public static void readWrappersFromFile(File file, Map wrapperMap) throws IOException, FileNotFoundException{ parseWrappers(new BufferedReader(new FileReader(file)), wrapperMap); } /** * Reads the wrappers from the specified System property and populates the specified * map. The map is unchanged if the property is not set. * * @param envVar The system variable name * @param wrapperMap The map which is being updated */ private static void readWrappersFromProperty(String envVar, Map wrapperMap) throws IOException { String propertyValue = System.getenv(envVar); if (propertyValue != null) { parseWrappers(new BufferedReader(new StringReader(propertyValue)), wrapperMap); } } /** * This method consolidates the wrapper map so that it follows CVS prioritization * rules for the wrappers. Both AddCommand and ImportCommand will be calling * this. */ public static Map mergeWrapperMap(ClientServices client) throws CommandException { String wrapperSource = null; Map wrappersMap = new java.util.HashMap(client.getWrappersMap()); try { File home = new File(System.getProperty("user.home")); // NOI18N File wrappers = new File(home, "./cvswrappers"); //NOI18N wrapperSource = CommandException.getLocalMessage("WrapperUtils.clientDotWrapper.text"); //NOI18N if (wrappers.exists()) { readWrappersFromFile(wrappers, wrappersMap); } wrapperSource = CommandException.getLocalMessage("WrapperUtils.environmentWrapper.text"); //NOI18N //process the Environment variable CVSWRAPPERS readWrappersFromProperty("CVSWRAPPERS", wrappersMap); //NOI18N } catch (FileNotFoundException fnex) { // should not happen as we check for file existence. Even if it does // it just means the .cvswrappers are not there and can be ignored } catch (Exception ioex) { Object [] parms = new Object[1]; parms[0] = wrapperSource; String localizedMessage = CommandException.getLocalMessage("WrapperUtils.wrapperError.text", parms); //NOI18N throw new CommandException(ioex, localizedMessage); } return wrappersMap; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/0000755000175300001440000000000011175434236024273 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/BasicListener.java0000644000175300001440000001114211175407001027652 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.commandLine; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.event.*; /** * A basic implementation of a CVS listener. Is really only interested in * message events. This listener is suitable for command line clients and * clients that don't "persist". * @author Robert Greig */ public class BasicListener extends CVSAdapter { private final StringBuffer taggedLine = new StringBuffer(); private PrintStream stdout; private PrintStream stderr; public BasicListener() { this(System.out, System.err); } public BasicListener(PrintStream stdout, PrintStream stderr) { this.stdout = stdout; this.stderr = stderr; } /** * Called when the server wants to send a message to be displayed to * the user. The message is only for information purposes and clients * can choose to ignore these messages if they wish. * @param e the event */ public void messageSent(MessageEvent e) { String line = e.getMessage(); if (e instanceof EnhancedMessageEvent) { return ; } PrintStream stream = e.isError() ? stderr : stdout; if (e.isTagged()) { String message = MessageEvent.parseTaggedMessage(taggedLine, e.getMessage()); if (message != null) { stream.println(message); } } else { stream.println(line); } } /** * Called when the server wants to send a binary message to be displayed to * the user. The message is only for information purposes and clients * can choose to ignore these messages if they wish. * @param e the event */ public void messageSent(BinaryMessageEvent e) { byte[] bytes = e.getMessage(); int len = e.getMessageLength(); stdout.write(bytes, 0, len); } /** * Called when file status information has been received */ public void fileInfoGenerated(FileInfoEvent e) { // FileInfoContainer fileInfo = e.getInfoContainer(); // if (fileInfo.getClass().equals(StatusInformation.class)) { // System.err.println("A file status event was received."); // System.err.println("The status information object is: " + // fileInfo); // } } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/Bundle.properties0000644000175300001440000000662211175407001027616 0ustar ludousers# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # # Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. # # The contents of this file are subject to the terms of either the GNU # General Public License Version 2 only ("GPL") or the Common # Development and Distribution License("CDDL") (collectively, the # "License"). You may not use this file except in compliance with the # License. You can obtain a copy of the License at # http://www.netbeans.org/cddl-gplv2.html # or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the # specific language governing permissions and limitations under the # License. When distributing the software, include this License Header # Notice in each file and include the License file at # nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this # particular file as subject to the "Classpath" exception as provided # by Sun in the GPL Version 2 section of the License file that # accompanied this code. If applicable, add the following below the # License Header, with the fields enclosed by brackets [] replaced by # your own identifying information: # "Portions Copyrighted [year] [name of copyright owner]" # # Contributor(s): # # The Original Software is NetBeans. The Initial Developer of the Original # Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun # Microsystems, Inc. All Rights Reserved. # # If you wish your version of this file to be governed by only the CDDL # or only the GPL Version 2, indicate your decision by adding # "[Contributor] elects to include this software in this distribution # under the [CDDL or GPL Version 2] license." If you do not indicate a # single choice of license, a recipient has the option to distribute # your version of this file under either the CDDL, the GPL Version 2 or # to extend the choice of license to its licensees as provided above. # However, if you add GPL Version 2 code and therefore, elected the GPL # Version 2 license, then the option applies only if the new code is # made subject to such option by the copyright holder. #-------------------------------------------------------------------- # ResourceBundle properties file MSG_HelpUsage=Usage: cvs [global options] command [command-options-and-arguments]\n\ \ specify {0} for a list of global options\n\ \ specify {1} for a list of possible commands\n\ \ specify {2} for a list of command synonyms MSG_HelpOptions=\ CVS global options (specified before the command name) are:\n\ \ -H Displays usage information for command.\n\ \ -q Cause CVS to be somewhat quiet.\n\ \ -Q Cause CVS to be really quiet.\n\ \ -r Make checked-out files read-only.\n\ \ -w Make checked-out files read-write (default).\n\ \ -l Turn history logging off.\n\ \ -n Do not execute anything that will change the disk.\n\ \ -t Show trace of program execution -- try with -n.\n\ \ -v Display JavaCVS version.\n\ \ -T tmpdir Use 'tmpdir' for temporary files.\n\ \ -e editor Use 'editor' for editing log information.\n\ \ -d CVS_root Overrides $CVSROOT as the root of the CVS tree.\n\ \ -f Do not use the ~/.cvsrc file.\n\ \ -z # Use compression level '#' for net traffic.\n\ \ -s VAR=VAL Set CVS user variable. MSG_CVSCommands=CVS commands are: MSG_CVSSynonyms=CVS command synonyms are: MSG_UnknownCommand=Unknown command: ''{0}'' netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/CVSCommand.java0000644000175300001440000006103011175407001027056 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.commandLine; import java.io.*; import java.text.MessageFormat; import java.util.Arrays; import java.util.Comparator; import java.util.ResourceBundle; import org.netbeans.lib.cvsclient.*; import org.netbeans.lib.cvsclient.CVSRoot; import org.netbeans.lib.cvsclient.admin.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.commandLine.command.CommandProvider; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.connection.StandardScrambler; import org.netbeans.lib.cvsclient.event.CVSListener; /** * An implementation of the standard CVS client utility (command line tool) * in Java * @author Robert Greig */ public class CVSCommand { private static final String HELP_OPTIONS = "--help-options"; // NOI18N private static final String HELP_COMMANDS = "--help-commands"; // NOI18N private static final String HELP_SYNONYMS = "--help-synonyms"; // NOI18N /** * The path to the repository on the server */ private String repository; /** * The local path to use to perform operations (the top level) */ private String localPath; /** * The connection to the server */ private Connection connection; /** * The client that manages interactions with the server */ private Client client; /** * The global options being used. GlobalOptions are only global for a * particular command. */ private GlobalOptions globalOptions; /** * The port number that is used to connect to the remote server. * It is taken into account only when it's value is greater then zero. */ private int port = 0; /** * Execute a configured CVS command * @param command the command to execute * @throws CommandException if there is an error running the command */ public boolean executeCommand(Command command, PrintStream stderr) throws CommandException, AuthenticationException { client.setErrorStream(stderr); return client.executeCommand(command, globalOptions); } public void setRepository(String repository) { this.repository = repository; } public void setLocalPath(String localPath) { this.localPath = localPath; } public void setGlobalOptions(GlobalOptions globalOptions) { this.globalOptions = globalOptions; } /** * Creates the connection and the client and connects. */ private void connect(CVSRoot root, String password) throws IllegalArgumentException, AuthenticationException, CommandAbortedException { connection = ConnectionFactory.getConnection(root); if (CVSRoot.METHOD_PSERVER.equals(root.getMethod())) { ((PServerConnection) connection).setEncodedPassword(password); if (port > 0) ((PServerConnection) connection).setPort(port); } connection.open(); client = new Client(connection, new StandardAdminHandler()); client.setLocalPath(localPath); } private void addListener(CVSListener listener) { if (client != null) { // add a listener to the client client.getEventManager().addCVSListener(listener); } } private void close(PrintStream stderr) { try { connection.close(); } catch (IOException e) { stderr.println("Unable to close connection: " + e); //e.printStackTrace(); } } /** * 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; BufferedReader r = null; if (workingDir == null) { workingDir = System.getProperty("user.dir"); } try { File f = new File(workingDir); File rootFile = new File(f, "CVS/Root"); if (rootFile.exists()) { r = new BufferedReader(new FileReader(rootFile)); root = r.readLine(); } } catch (IOException e) { // ignore } finally { try { if (r != null) r.close(); } catch (IOException e) { System.err.println("Warning: could not close CVS/Root file!"); } } if (root == null) { root = System.getProperty("cvs.root"); } return root; } /** * 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, PrintStream stderr) { final String getOptString = globalOptions.getOptString(); GetOpt go = new GetOpt(args, getOptString); int ch = -1; boolean usagePrint = false; while ((ch = go.getopt()) != go.optEOF) { //System.out.println("Global option '"+((char) ch)+"', '"+go.optArgGet()+"'"); boolean success = globalOptions.setCVSCommand((char) ch, go.optArgGet()); if (!success) usagePrint = true; } if (usagePrint) { showUsage(stderr); return -10; } return go.optIndexGet(); } private static void showUsage(PrintStream stderr) { String usageStr = ResourceBundle.getBundle(CVSCommand.class.getPackage().getName()+".Bundle").getString("MSG_HelpUsage"); // NOI18N stderr.println(MessageFormat.format(usageStr, new Object[] { HELP_OPTIONS, HELP_COMMANDS, HELP_SYNONYMS })); //stderr.println("Usage: cvs [global options] command [command-options-and-arguments]"); //stderr.println(" specify "+HELP_OPTIONS+" for a list of options"); //stderr.println(" specify "+HELP_COMMANDS+" for a list of commands"); //stderr.println(" specify "+HELP_SYNONYMS+" for a list of command synonyms"); } /** * Perform the 'login' command, asking the user for a password. If the * login is successful, the password is written to a file. The file's * location is user.home, unless the cvs.passfile option is set. * @param userName the userName * @param hostName the host */ private static boolean performLogin(String userName, String hostName, String repository, int port, GlobalOptions globalOptions) { PServerConnection c = new PServerConnection(); c.setUserName(userName); String password = null; try { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter password: "); password = in.readLine(); } catch (IOException e) { System.err.println("Could not read password: " + e); return false; } String encodedPassword = StandardScrambler.getInstance().scramble( password); c.setEncodedPassword(encodedPassword); c.setHostName(hostName); c.setRepository(repository); if (port > 0) c.setPort(port); try { c.verify(); } catch (AuthenticationException e) { System.err.println("Could not login to host " + hostName); return false; } // was successful, so write the appropriate file out // we look for cvs.passfile being set, but if not use user.dir // as the default String root = globalOptions.getCVSRoot(); try { PasswordsFile.storePassword(root, encodedPassword); System.err.println("Logged in successfully to " + repository + " on host " + hostName); return true; } catch (IOException e) { System.err.println("Error: could not write password file."); return false; } } /** * 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, String CVSRootWithPort, PrintStream stderr) { File passFile = new File(System.getProperty("cvs.passfile", System.getProperty("user.home") + "/.cvspass")); BufferedReader reader = null; String password = null; try { reader = new BufferedReader(new FileReader(passFile)); String line; while ((line = reader.readLine()) != null) { if (line.startsWith("/1 ")) line = line.substring("/1 ".length()); if (line.startsWith(CVSRoot+" ")) { password = line.substring(CVSRoot.length() + 1); break; } else if (line.startsWith(CVSRootWithPort+" ")) { password = line.substring(CVSRootWithPort.length() + 1); break; } } } catch (IOException e) { stderr.println("Could not read password for host: " + e); return null; } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { stderr.println("Warning: could not close password file."); } } } if (password == null) { stderr.println("Didn't find password for CVSROOT '"+CVSRoot+"'."); } return password; } /** * Execute the CVS command and exit JVM. */ public static void main(String[] args) { if (processCommand(args, null, System.getProperty("user.dir"), System.out, System.err)) { System.exit(0); } else { System.exit(1); } } /** * 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 localPath The local working directory * @param stdout The standard output of the command * @param stderr The error output of the command. */ public static boolean processCommand(String[] args, File[] files, String localPath, PrintStream stdout, PrintStream stderr) { return processCommand(args, files, localPath, 0, stdout, stderr); } /** * 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 localPath The local working directory * @param port The port number that is used to connect to the remote server. * It is taken into account only when it's value is greater then zero. * @param stdout The standard output of the command * @param stderr The error output of the command. * @return whether the command was processed successfully */ public static boolean processCommand(String[] args, File[] files, String localPath, int port, PrintStream stdout, PrintStream stderr) { assert stdout != null: "The output stream must be defined."; // NOI18N assert stderr != null: "The error stream must be defined."; // NOI18N // Provide help if requested if (args.length > 0) { if (HELP_OPTIONS.equals(args[0])) { printHelpOptions(stdout); return true; } else if (HELP_COMMANDS.equals(args[0])) { printHelpCommands(stdout); return true; } else if (HELP_SYNONYMS.equals(args[0])) { printHelpSynonyms(stdout); return true; } } try { // Adjust the local path localPath = new File(localPath).getCanonicalPath(); } catch (IOException ioex) {} // Set up the CVSRoot. Note that it might still be null after this // call if the user has decided to set it with the -d command line // global option GlobalOptions globalOptions = new GlobalOptions(); globalOptions.setCVSRoot(getCVSRoot(localPath)); // Set up any global options specified. These occur before the // name of the command to run int commandIndex = -1; try { commandIndex = processGlobalOptions(args, globalOptions, stderr); if (commandIndex == -10) return true; } catch (IllegalArgumentException e) { stderr.println("Invalid argument: " + e); return false; } if (globalOptions.isShowHelp()) { printHelp(commandIndex, args, stdout, stderr); return true; } if (globalOptions.isShowVersion()) { printVersion(stdout, stderr); return true; } // if we don't have a CVS root by now, the user has messed up if (globalOptions.getCVSRoot() == null) { stderr.println("No CVS root is set. Use the cvs.root " + "property, e.g. java -Dcvs.root=\":pserver:user@host:/usr/cvs\"" + " or start the application in a directory containing a CVS subdirectory" + " or use the -d command switch."); return false; } // parse the CVS root into its constituent parts CVSRoot root = null; final String cvsRoot = globalOptions.getCVSRoot(); try { root = CVSRoot.parse(cvsRoot); } catch (IllegalArgumentException e) { stderr.println("Incorrect format for CVSRoot: " + cvsRoot + "\nThe correct format is: "+ "[:method:][[user][:password]@][hostname:[port]]/path/to/repository" + "\nwhere \"method\" is pserver."); return false; } // if we had some options without any command, then the user messed up if (commandIndex >= args.length) { showUsage(stderr); return false; } final String command = args[commandIndex]; if (command.equals("login")) { if (CVSRoot.METHOD_PSERVER.equals(root.getMethod())) { return performLogin(root.getUserName(), root.getHostName(), root.getRepository(), root.getPort(), globalOptions); } else { stderr.println("login does not apply for connection type " + "\'" + root.getMethod() + "\'"); return false; } } // this is not login, but a 'real' cvs command, so construct it, // set the options, and then connect to the server and execute it Command c = null; try { c = CommandFactory.getDefault().createCommand(command, args, ++commandIndex, globalOptions, localPath); } catch (IllegalArgumentException e) { stderr.println("Illegal argument: " + e.getMessage()); return false; } if (files != null && c instanceof BasicCommand) { ((BasicCommand) c).setFiles(files); } String password = null; if (CVSRoot.METHOD_PSERVER.equals(root.getMethod())) { password = root.getPassword(); if (password != null) { password = StandardScrambler.getInstance().scramble(password); } else { if (port > 0) root.setPort(port); password = lookupPassword(cvsRoot, root.toString(), stderr); if (password == null) { password = StandardScrambler.getInstance().scramble(""); // an empty password } } } CVSCommand cvsCommand = new CVSCommand(); cvsCommand.setGlobalOptions(globalOptions); cvsCommand.setRepository(root.getRepository()); if (port > 0) { cvsCommand.port = port; } // the local path is just the path where we executed the // command. This is the case for command-line CVS but not // usually for GUI front-ends cvsCommand.setLocalPath(localPath); try { cvsCommand.connect(root, password); CVSListener list; if (c instanceof ListenerProvider) { list = ((ListenerProvider)c).createCVSListener(stdout, stderr); } else { list = new BasicListener(stdout, stderr); } cvsCommand.addListener(list); boolean status = cvsCommand.executeCommand(c, stderr); return status; } catch (AuthenticationException aex) { stderr.println(aex.getLocalizedMessage()); return false; } catch (CommandAbortedException caex) { stderr.println("Error: " + caex); Thread.currentThread().interrupt(); return false; } catch (Exception t) { stderr.println("Error: " + t); t.printStackTrace(stderr); return false; } finally { if (cvsCommand != null) { cvsCommand.close(stderr); } } } private static void printHelpOptions(PrintStream stdout) { String options = ResourceBundle.getBundle(CVSCommand.class.getPackage().getName()+".Bundle").getString("MSG_HelpOptions"); // NOI18N stdout.println(options); } private static void printHelpCommands(PrintStream stdout) { String msg = ResourceBundle.getBundle(CVSCommand.class.getPackage().getName()+".Bundle").getString("MSG_CVSCommands"); // NOI18N stdout.println(msg); CommandProvider[] providers = CommandFactory.getDefault().getCommandProviders(); Arrays.sort(providers, new CommandProvidersComparator()); int maxNameLength = 0; for (int i = 0; i < providers.length; i++) { int l = providers[i].getName().length(); if (maxNameLength < l) { maxNameLength = l; } } maxNameLength += 2; // Two spaces from the longest name for (int i = 0; i < providers.length; i++) { stdout.print("\t"+providers[i].getName()); char spaces[] = new char[maxNameLength - providers[i].getName().length()]; Arrays.fill(spaces, ' '); stdout.print(new String(spaces)); providers[i].printShortDescription(stdout); stdout.println(); } } private static void printHelpSynonyms(PrintStream stdout) { String msg = ResourceBundle.getBundle(CVSCommand.class.getPackage().getName()+".Bundle").getString("MSG_CVSSynonyms"); // NOI18N stdout.println(msg); CommandProvider[] providers = CommandFactory.getDefault().getCommandProviders(); Arrays.sort(providers, new CommandProvidersComparator()); int maxNameLength = 0; for (int i = 0; i < providers.length; i++) { int l = providers[i].getName().length(); if (maxNameLength < l) { maxNameLength = l; } } maxNameLength += 2; // Two spaces from the longest name for (int i = 0; i < providers.length; i++) { String[] synonyms = providers[i].getSynonyms(); if (synonyms.length > 0) { stdout.print("\t"+providers[i].getName()); char spaces[] = new char[maxNameLength - providers[i].getName().length()]; Arrays.fill(spaces, ' '); stdout.print(new String(spaces)); for (int j = 0; j < synonyms.length; j++) { stdout.print(synonyms[j]+" "); } stdout.println(); } } } private static void printHelp(int commandIndex, String[] args, PrintStream stdout, PrintStream stderr) { if (commandIndex >= args.length) { showUsage(stdout); } else { String cmdName = args[commandIndex]; CommandProvider provider = CommandFactory.getDefault().getCommandProvider(cmdName); if (provider == null) { printUnknownCommand(cmdName, stderr); } else { provider.printLongDescription(stdout); } } } private static void printVersion(PrintStream stdout, PrintStream stderr) { String version = CVSCommand.class.getPackage().getSpecificationVersion(); stdout.println("Java Concurrent Versions System (JavaCVS) "+version+" (client)"); } private static void printUnknownCommand(String commandName, PrintStream out) { String msg = ResourceBundle.getBundle(CVSCommand.class.getPackage().getName()+".Bundle").getString("MSG_UnknownCommand"); // NOI18N out.println(MessageFormat.format(msg, new Object[] { commandName })); printHelpCommands(out); } private static final class CommandProvidersComparator implements Comparator { public int compare(Object o1, Object o2) { if (!(o1 instanceof CommandProvider) || !(o2 instanceof CommandProvider)) { throw new IllegalArgumentException("Can not compare objects "+o1+" and "+o2); } return ((CommandProvider) o1).getName().compareTo(((CommandProvider) o2).getName()); } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/CommandFactory.java0000644000175300001440000001735211175407001030042 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.commandLine; import java.lang.reflect.*; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.commandLine.command.CommandProvider; /** * A factory for commands. Given a command name, and any arguments passed to * that command on the command line, it will return a configured Command * object, ready for execution. * @author Robert Greig * @see org.netbeans.lib.cvsclient.command.Command */ public class CommandFactory { private static final String[] COMMAND_CLASSES = new String[] { "Import", "add", "annotate", "checkout", "commit", "diff", "export", "locbundlecheck", "log", "rannotate", "remove", "rlog", "rtag", "status", "tag", "update" }; private static CommandFactory instance; private Map commandProvidersByNames; private CommandFactory() { createCommandProviders(); } private void createCommandProviders() { commandProvidersByNames = new HashMap(); String packageName = CommandFactory.class.getPackage().getName() + ".command."; for (int i = 0; i < COMMAND_CLASSES.length; i++) { Class providerClass; try { providerClass = Class.forName(packageName + COMMAND_CLASSES[i]); CommandProvider provider = (CommandProvider) providerClass.newInstance(); commandProvidersByNames.put(provider.getName(), provider); String[] synonyms = provider.getSynonyms(); for (int j = 0; j < synonyms.length; j++) { commandProvidersByNames.put(synonyms[j], provider); } } catch (Exception e) { System.err.println("Creation of command '"+COMMAND_CLASSES[i]+"' failed:"); e.printStackTrace(System.err); continue; } } } /** * Get the default instance of CommandFactory. */ public static synchronized CommandFactory getDefault() { if (instance == null) { instance = new CommandFactory(); } return instance; } /** * Create a CVS command. * @param commandName The name of the command to create * @param args The array of arguments * @param startingIndex The index of the first argument of the command in the array * @param workingDir The working directory */ public Command createCommand(String commandName, String[] args, int startingIndex, GlobalOptions gopt, String workingDir) throws IllegalArgumentException { CommandProvider provider = (CommandProvider) commandProvidersByNames.get(commandName); if (provider == null) { throw new IllegalArgumentException("Unknown command: '"+commandName+"'"); } return provider.createCommand(args, startingIndex, gopt, workingDir); } /** * Get the provider of a command. * @param name The name of the command to get the provider for. */ public CommandProvider getCommandProvider(String name) { return (CommandProvider) commandProvidersByNames.get(name); } /** * Get the array of all command providers. */ public CommandProvider[] getCommandProviders() { Set providers = new HashSet(commandProvidersByNames.values()); return (CommandProvider[]) providers.toArray(new CommandProvider[0]); } /* public static Command getCommand(String commandName, String[] args, int startingIndex, String workingDir) throws IllegalArgumentException { Class helper; try { helper = Class.forName("org.netbeans.lib.cvsclient.commandLine." + "command." + commandName); } catch (Exception e) { commandName = Character.toUpperCase(commandName.charAt(0)) + commandName.substring(1); try { helper = Class.forName("org.netbeans.lib.cvsclient.commandLine." + "command." + commandName); } catch (Exception ex) { System.err.println("Exception is: " + ex); throw new IllegalArgumentException("Unknown command " + commandName); } } // the method invoked can throw an exception try { Method m = helper.getMethod("createCommand", new Class[]{ String[].class, Integer.class, String.class}); return (Command) m.invoke(null, new Object[] { args, new Integer(startingIndex), workingDir }); } catch (IllegalArgumentException e) { throw e; } catch (InvocationTargetException ite) { Throwable t = ite.getCause(); if (t instanceof IllegalArgumentException) { throw (IllegalArgumentException) t; } else { IllegalArgumentException iaex = new IllegalArgumentException(t.getMessage()); iaex.initCause(t); throw iaex; } } catch (Exception e) { IllegalArgumentException iaex = new IllegalArgumentException(e.getMessage()); iaex.initCause(e); throw iaex; } } */ }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/GetOpt.java0000644000175300001440000004004511175407001026331 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.commandLine; /** *

Overview

* * GetOpt provides a general means for a Java program to parse command * line arguments in accordance with the standard Unix conventions; * it is analogous to, and based on, getopt(3) for C programs. * (The following documentation is based on the man page for getopt(3).) *

Description

* * GetOpt is a Java class that provides one method, getopt, * and some variables that control behavior of or return additional * information from getopt. *

* GetOpt interprets command arguments in accordance with the standard * Unix conventions: option arguments of a command are introduced by "-" * followed by a key character, and a non-option argument terminates * the processing of options. GetOpt's option interpretation is controlled * by its parameter optString, which specifies what characters designate * legal options and which of them require associated values. *

* The getopt method returns the next, moving left to right, option letter * in the command line arguments that matches a letter in optString. * optString must contain the option letters the command using getopt * will recognize. For example, getopt("ab") specifies that the command * line should contain no options, only "-a", only "-b", or both "-a" and * "-b" in either order. (The command line can also contain non-option * arguments after any option arguments.) Multiple options per argument * are allowed, e.g., "-ab" for the last case above. *

* If a letter in optString is followed by a colon, the option is expected * to have an argument. The argument may or may not be separated by * whitespace from the option letter. For example, getopt("w:") allows * either "-w 80" or "-w80". The variable optArg is set to the option * argument, e.g., "80" in either of the previous examples. Conversion * functions such as Integer.parseInt(), etc., can then be applied to * optArg. *

* getopt places in the variable optIndex the index of the next command * line argument to be processed; optIndex is automatically initialized * to 1 before the first call to getopt. *

* When all options have been processed (that is, up to the first * non-option argument), getopt returns optEOF (-1). getopt recognizes the * command line argument "--" (i.e., two dashes) to delimit the end of * the options; getopt returns optEOF and skips "--". Subsequent, * non-option arguments can be retrieved using the String array passed to * main(), beginning with argument number optIndex. * *

Diagnostics

* * getopt prints an error message on System.stderr and returns a question * mark ('?') when it encounters an option letter in a command line argument * that is not included in optString. Setting the variable optErr to * false disables this error message. *

Notes

* * The following notes describe GetOpt's behavior in a few interesting * or special cases; these behaviors are consistent with getopt(3)'s * behaviors. * -- A '-' by itself is treated as a non-option argument. * -- If optString is "a:" and the command line arguments are "-a -x", * then "-x" is treated as the argument associated with the "-a". * -- Duplicate command line options are allowed; it is up to user to * deal with them as appropriate. * -- A command line option like "-b-" is considered as the two options * "b" and "-" (so "-" should appear in option string); this differs * from "-b --". * -- Sun and DEC getopt(3)'s differ w.r.t. how "---" is handled. * Sun treats "---" (or anything starting with "--") the same as "--" * DEC treats "---" as two separate "-" options * (so "-" should appear in option string). * Java GetOpt follows the DEC convention. * -- An option `letter' can be a letter, number, or most special character. * Like getopt(3), GetOpt disallows a colon as an option letter. * * @author Anonymous *****************************************************************************/ public class GetOpt { private String[] theArgs = null; private int argCount = 0; private String optString = null; public GetOpt(String[] args, String opts) { theArgs = args; argCount = theArgs.length; optString = opts; } // user can toggle this to control printing of error messages public boolean optErr = false; public int processArg(String arg, int n) { int value; try { value = Integer.parseInt(arg); } catch (NumberFormatException e) { if (optErr) System.err.println("processArg cannot process " + arg //NOI18N + " as an integer"); //NOI18N return n; } return value; } public int tryArg(int k, int n) { int value; try { value = processArg(theArgs[k], n); } catch (ArrayIndexOutOfBoundsException e) { if (optErr) System.err.println("tryArg: no theArgs[" + k + "]"); //NOI18N return n; } return value; } public long processArg(String arg, long n) { long value; try { value = Long.parseLong(arg); } catch (NumberFormatException e) { if (optErr) System.err.println("processArg cannot process " + arg //NOI18N + " as a long"); //NOI18N return n; } return value; } public long tryArg(int k, long n) { long value; try { value = processArg(theArgs[k], n); } catch (ArrayIndexOutOfBoundsException e) { if (optErr) System.err.println("tryArg: no theArgs[" + k + "]"); //NOI18N return n; } return value; } public double processArg(String arg, double d) { double value; try { value = Double.valueOf(arg).doubleValue(); } catch (NumberFormatException e) { if (optErr) System.err.println("processArg cannot process " + arg //NOI18N + " as a double"); //NOI18N return d; } return value; } public double tryArg(int k, double d) { double value; try { value = processArg(theArgs[k], d); } catch (ArrayIndexOutOfBoundsException e) { if (optErr) System.err.println("tryArg: no theArgs[" + k + "]"); //NOI18N return d; } return value; } public float processArg(String arg, float f) { float value; try { value = Float.valueOf(arg).floatValue(); } catch (NumberFormatException e) { if (optErr) System.err.println("processArg cannot process " + arg //NOI18N + " as a float"); //NOI18N return f; } return value; } public float tryArg(int k, float f) { float value; try { value = processArg(theArgs[k], f); } catch (ArrayIndexOutOfBoundsException e) { if (optErr) System.err.println("tryArg: no theArgs[" + k + "]"); //NOI18N return f; } return value; } public boolean processArg(String arg, boolean b) { // `true' in any case mixture is true; anything else is false return Boolean.valueOf(arg).booleanValue(); } public boolean tryArg(int k, boolean b) { boolean value; try { value = processArg(theArgs[k], b); } catch (ArrayIndexOutOfBoundsException e) { if (optErr) System.err.println("tryArg: no theArgs[" + k + "]"); //NOI18N return b; } return value; } public String tryArg(int k, String s) { String value; try { value = theArgs[k]; } catch (ArrayIndexOutOfBoundsException e) { if (optErr) System.err.println("tryArg: no theArgs[" + k + "]"); //NOI18N return s; } return value; } private static void writeError(String msg, char ch) { System.err.println("GetOpt: " + msg + " -- " + ch); //NOI18N } public static final int optEOF = -1; private int optIndex = 0; public int optIndexGet() { return optIndex; } public void optIndexSet(int i) { optIndex = i; } private String optArg = null; public String optArgGet() { return optArg; } private int optPosition = 1; public int getopt() { optArg = null; if (theArgs == null || optString == null) return optEOF; if (optIndex < 0 || optIndex >= argCount) return optEOF; String thisArg = theArgs[optIndex]; int argLength = thisArg.length(); // handle special cases if (argLength <= 1 || thisArg.charAt(0) != '-') { // e.g., "", "a", "abc", or just "-" return optEOF; } else if (thisArg.equals("--")) {//NOI18N // end of non-option args optIndex++; return optEOF; } // get next "letter" from option argument char ch = thisArg.charAt(optPosition); // find this option in optString int pos = optString.indexOf(ch); if (pos == -1 || ch == ':') { if (optErr) { writeError("illegal option", ch); //NOI18N } ch = '?'; } else { // handle colon, if present if (pos < optString.length() - 1 && optString.charAt(pos + 1) == ':') { if (optPosition != argLength - 1) { // take rest of current arg as optArg optArg = thisArg.substring(optPosition + 1); optPosition = argLength - 1; // force advance to next arg below } else { // take next arg as optArg optIndex++; if (optIndex < argCount && (theArgs[optIndex].charAt(0) != '-' || theArgs[optIndex].length() >= 2 && (optString.indexOf(theArgs[optIndex].charAt(1)) == -1 || theArgs[optIndex].charAt(1) == ':'))) { optArg = theArgs[optIndex]; } else { if (optErr) { writeError("option requires an argument", ch); //NOI18N } optArg = null; ch = ':'; // Linux man page for getopt(3) says : not ? } } } } // advance to next option argument, // which might be in thisArg or next arg optPosition++; if (optPosition >= argLength) { optIndex++; optPosition = 1; } return ch; } public static void main(String[] args) { // test the class GetOpt go = new GetOpt(args, "Uab:f:h:w:"); go.optErr = true; int ch = -1; // process options in command line arguments boolean usagePrint = false; // set int aflg = 0; // default boolean bflg = false; // values String filename = "out"; // of int width = 80; // options double height = 1; // here while ((ch = go.getopt()) != go.optEOF) { if ((char)ch == 'U') usagePrint = true; else if ((char)ch == 'a') aflg++; else if ((char)ch == 'b') bflg = go.processArg(go.optArgGet(), bflg); else if ((char)ch == 'f') filename = go.optArgGet(); else if ((char)ch == 'h') height = go.processArg(go.optArgGet(), height); else if ((char)ch == 'w') width = go.processArg(go.optArgGet(), width); else System.exit(1); // undefined option } // getopt() returns '?' if (usagePrint) { System.out.println("Usage: -a -b bool -f file -h height -w width"); //NOI18N System.exit(0); } System.out.println("These are all the command line arguments " + //NOI18N "before processing with GetOpt:"); //NOI18N for (int i = 0; i < args.length; i++) { System.out.print(" " + args[i]); //NOI18N } System.out.println(); System.out.println("-U " + usagePrint); //NOI18N System.out.println("-a " + aflg); //NOI18N System.out.println("-b " + bflg); //NOI18N System.out.println("-f " + filename); //NOI18N System.out.println("-h " + height); //NOI18N System.out.println("-w " + width); //NOI18N // process non-option command line arguments for (int k = go.optIndexGet(); k < args.length; k++) { System.out.println("normal argument " + k + " is " + args[k]); //NOI18N } } } /* ............... Example compile and run(s) D:\>javac GetOpt.java D:\>java GetOpt -aaa -b true -f theFile -w -80 -h3.33 arg1 arg2 These are all the command line arguments before processing with GetOpt: -aaa -b true -f theFile -w -80 -h3.33 arg1 arg2 -U false -a 3 -b true -f theFile -h 3.33 -w -80 normal argument 8 is arg1 normal argument 9 is arg2 D:\>java GetOpt -aaa -x -w90 GetOpt: illegal option -- x D:\>java GetOpt -af theFile -w -b true GetOpt: option requires an argument -- w ... end of example run(s) */ netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/ListenerProvider.java0000644000175300001440000000527211175407001030432 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Milos Kleint. * Portions created by Milos Kleint are Copyright (C) 2003. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Milos Kleint. *****************************************************************************/ package org.netbeans.lib.cvsclient.commandLine; import java.io.PrintStream; import org.netbeans.lib.cvsclient.event.CVSListener; /** * for commands created in commandLine.command, that don't want to have the BasicListener * attached to the created command, but rather a custom one. * @author milos */ public interface ListenerProvider { /** * */ CVSListener createCVSListener(PrintStream stdout, PrintStream stderr); } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/command/0000755000175300001440000000000011175434236025711 5ustar ludousers././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/command/AbstractCommandProvider.javanetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/command/AbstractCommandProvider.ja0000644000175300001440000000713311175407001032774 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.commandLine.command; import java.io.PrintStream; import java.text.MessageFormat; import java.util.ResourceBundle; import org.netbeans.lib.cvsclient.command.Command; /** * The provider of CVS commands. * The implementation of this interface knows how to create a CVS command * from an array of arguments. * * @author Martin Entlicher */ abstract class AbstractCommandProvider implements CommandProvider { /** * Get the name of this command. * The default implementation returns the name of the implementing class. */ public String getName() { String className = getClass().getName(); int dot = className.lastIndexOf('.'); if (dot > 0) { return className.substring(dot + 1); } else { return className; } } public String getUsage() { return ResourceBundle.getBundle(CommandProvider.class.getPackage().getName()+".Bundle").getString(getName()+".usage"); // NOI18N } public void printShortDescription(PrintStream out) { String msg = ResourceBundle.getBundle(CommandProvider.class.getPackage().getName()+".Bundle").getString(getName()+".shortDescription"); // NOI18N out.print(msg); } public void printLongDescription(PrintStream out) { String msg = ResourceBundle.getBundle(CommandProvider.class.getPackage().getName()+".Bundle").getString(getName()+".longDescription"); // NOI18N out.println(MessageFormat.format(msg, new Object[] { getUsage() })); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/command/Bundle.properties0000644000175300001440000003126711175407001031237 0ustar ludousers# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # # Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. # # The contents of this file are subject to the terms of either the GNU # General Public License Version 2 only ("GPL") or the Common # Development and Distribution License("CDDL") (collectively, the # "License"). You may not use this file except in compliance with the # License. You can obtain a copy of the License at # http://www.netbeans.org/cddl-gplv2.html # or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the # specific language governing permissions and limitations under the # License. When distributing the software, include this License Header # Notice in each file and include the License file at # nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this # particular file as subject to the "Classpath" exception as provided # by Sun in the GPL Version 2 section of the License file that # accompanied this code. If applicable, add the following below the # License Header, with the fields enclosed by brackets [] replaced by # your own identifying information: # "Portions Copyrighted [year] [name of copyright owner]" # # Contributor(s): # # The Original Software is NetBeans. The Initial Developer of the Original # Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun # Microsystems, Inc. All Rights Reserved. # # If you wish your version of this file to be governed by only the CDDL # or only the GPL Version 2, indicate your decision by adding # "[Contributor] elects to include this software in this distribution # under the [CDDL or GPL Version 2] license." If you do not indicate a # single choice of license, a recipient has the option to distribute # your version of this file under either the CDDL, the GPL Version 2 or # to extend the choice of license to its licensees as provided above. # However, if you add GPL Version 2 code and therefore, elected the GPL # Version 2 license, then the option applies only if the new code is # made subject to such option by the copyright holder. #-------------------------------------------------------------------- # ResourceBundle properties file add.usage=add [-k rcs-kflag] [-m message] files... add.shortDescription=Add a new file/directory to the repository. add.longDescription=Usage: {0}\n\ \ -k Use "rcs-kflag" to add the file with the specified kflag.\n\ \ -m Use "message" for the creation log. annotate.usage=annotate [-lRf] [-r rev|-D date] [files...] annotate.shortDescription=Show the last revision where each source line was modified. annotate.longDescription=Usage: {0}\n\ \ -l Local directory only, no recursion.\ \ -R Process directories recursively.\ \ -f Use head revision if tag/date not found.\ \ -r rev Annotate file as of specified revision/tag.\ \ -D date Annotate file as of specified date. checkout.usage=checkout [-ANPRcflnps] [-r rev | -D date] [-d dir] [-j rev1] [-j rev2] [-k kopt] modules... checkout.shortDescription=Check out the sources from repository to local working directory. checkout.longDescription=Usage: {0}\n\ \ -A Reset any sticky tags/date/kopts.\n\ \ -N Don't shorten module paths if -d specified.\n\ \ -P Prune empty directories.\n\ \ -R Process directories recursively.\n\ \ -c "cat" the module database.\n\ \ -f Force a head revision match if tag/date not found.\n\ \ -l Local directory only, not recursive\n\ \ -n Do not run module program (if any).\n\ \ -p Check out files to standard output (avoids stickiness).\n\ \ -s Like -c, but include module status.\n\ \ -r rev Check out revision or tag. (implies -P) (is sticky)\n\ \ -D date Check out revisions as of date. (implies -P) (is sticky)\n\ \ -d dir Check out into dir instead of module name.\n\ \ -k kopt Use RCS kopt -k option on checkout.\n\ \ -j rev Merge in changes made between current revision and rev. commit.usage=commit [-nRlf] [-m msg | -F logfile] [-r rev] files... commit.shortDescription=Check files into the repository. commit.longDescription=Usage: {0}\n\ \ -n Do not run the module program (if any).\n\ \ -R Process directories recursively.\n\ \ -l Local directory only (not recursive).\n\ \ -f Force the file to be committed; disables recursion.\n\ \ -F file Read the log message from file.\n\ \ -m msg Log message.\n\ \ -r rev Commit to this branch or trunk revision. commit.messageNotSpecified=The message was not specified. Please use -m or -F options. diff.usage=diff [-lNR] [rcsdiff-options] [[-r rev1 | -D date1] [-r rev2 | -D date2]] [files...] diff.shortDescription=Show differences between local file and a revision, or between two revisions. diff.longDescription=Usage: {0}\n\ \ -l Local directory only, not recursive\n\ \ -R Process directories recursively.\n\ \ -D d1 Diff revision for date against working file.\n\ \ -D d2 Diff rev1/date1 against date2.\n\ \ -N include diffs for added and removed files.\n\ \ -r rev1 Diff revision for rev1 against working file.\n\ \ -r rev2 Diff rev1/date1 against rev2.\n\ \ --ifdef=arg Output diffs in ifdef format.\n\ (consult the documentation for the CVS server diff program for rcsdiff-options.\n\ The most popular is -c for context diffs but there are many more). export.usage=export [-NPRfln] [-r rev | -D date] [-d dir] [-k kopt] module... export.shortDescription=Export sources from CVS, without administrative files. export.longDescription=Usage: {0}\n\ \ -N Don't shorten module paths if -d specified.\n\ \ -f Force a head revision match if tag/date not found.\n\ \ -l Local directory only, not recursive.\n\ \ -R Process directories recursively (default).\n\ \ -P Prune empty directories.\n\ \ -n Do not run module program (if any).\n\ \ -r rev Export revision or tag.\n\ \ -D date Export revisions as of date.\n\ \ -d dir Export into dir instead of module name.\n\ \ -k kopt Use RCS kopt -k option on checkout.\n export.Msg_NeedTagOrDate=must specify a tag or date import.usage=import [-d] [-k subst] [-I ign] [-m msg] [-b branch] [-W spec] repository vendor-tag release-tags... import.shortDescription=Import sources into CVS repository, using a vendor branch. import.longDescription=Usage: {0}\n\ \ -d Use the file's modification time as the time of import.\n\ \ -k sub Set default RCS keyword substitution mode.\n\ \ -I ign More files to ignore (! to reset).\n\ \ -b bra Vendor branch id.\n\ \ -m msg Log message.\n\ \ -W spec Wrappers specification line. locbundlecheck.usage=locbundlecheck -i [] [files...] locbundlecheck.shortDescription=Detect what bundle keys need to be updated in localized resource bundles. locbundlecheck.longDescription=Usage: {0}\n\ \ -i locale The locale to check\n\ (all switches that can be applied to annotate can be specified here as well). locbundlecheck.no_file_spec=no files specified locbundlecheck.illegal_state=illegal state locbundlecheck.noLocalizedFile=File {0} doesn't have a localized counterpart. locbundlecheck.File=File {0} locbundlecheck.propMissing=\ \ \ Property \"{0}\" doesn't exist in localized file. locbundlecheck.prop_updated=\ \ \ Property \"{0}\" was updated in the original file. locbundlecheck.prop_removed=\ \ \ Property \"{0}\" was removed from original file. log.usage=log [-lRbhtN] [-d ] [-r ] [-s ] [-w[logins]] [files...] log.shortDescription=Print out history information for files log.longDescription=Usage: {0}\n\ \ -l Local directory only, no recursion.\n\ \ -R Only print name of RCS file.\n\ \ -h Only print header.\n\ \ -t Only print header and descriptive text.\n\ \ -N Do not list tags.\n\ \ -b Only list revisions on the default branch.\n\ \ -r[revisions] Specify revision(s)s to list.\n\ \ -d dates Specify dates (D1] [-r ] [-s ] [-w[logins]] files... rlog.shortDescription=Print out history information for files rlog.longDescription=Usage: {0}\n\ Like log, but acts directly on files in repository, does not operate on check out sources.\ \ -l Local directory only, no recursion.\n\ \ -R Only print name of RCS file.\n\ \ -h Only print header.\n\ \ -t Only print header and descriptive text.\n\ \ -N Do not list tags.\n\ \ -b Only list revisions on the default branch.\n\ \ -r[revisions] Specify revision(s)s to list.\n\ \ -d dates Specify dates (D1 0) { // Get the template file from the first argument template = new File(args[0].getParentFile(), "CVS" + File.separator + "Template"); if (template.exists()) { templateReader = new BufferedReader( new FileReader(template)); String line = null; while ((line = templateReader.readLine()) != null) { writer.write(line); writer.newLine(); } } } writer.write("CVS: ----------------------------------------------------------------------"); writer.newLine(); writer.write("CVS: Enter Log. Lines beginning with `CVS:' are removed automatically"); writer.newLine(); writer.write("CVS: "); writer.newLine(); // TODO: fix this bit writer.write("CVS: Committing in ."); writer.newLine(); writer.write("CVS: "); writer.newLine(); writer.write("CVS: Modified Files:"); writer.newLine(); if (args != null) { for (int i = 0; i < args.length; i++) { // TODO: don't write out the full path of files writer.write("CVS: " + args[i].getPath()); } } writer.write("CVS: ----------------------------------------------------------------------"); writer.newLine(); return tempFile; } finally { if (templateReader != null) { templateReader.close(); } if (writer != null) { writer.close(); } } } private static String createMessage(File[] args, GlobalOptions gopt) { File temp = null; BufferedReader reader = null; try { temp = createTempFile(args, gopt.getTempDir()); // we now have a temp file with the appropriate text in it. Just // get the appropriate process to edit it. // TODO maybe make this more sophisticated, e.g. the cvs.editor // property allows certain fields to specify arguments, where the // actual filename goes etc. String editorProcess = getEditorProcess(gopt.getEditor()); if (editorProcess == null) return null; final Process proc = Runtime.getRuntime(). exec(new String[] { editorProcess, temp.getPath() }); int returnCode = -1; try { returnCode = proc.waitFor(); } catch (InterruptedException e) { // So somebody else interrupted us. } if (returnCode != 0) { return null; } else { // TODO: need to add the bit that tests whether the file // has been changed so that we can bring up the abort etc. // message just like real CVS. reader = new BufferedReader(new FileReader(temp)); String line; StringBuffer message = new StringBuffer((int)temp.length()); while ((line = reader.readLine()) != null) { if (!line.startsWith("CVS:")) { message.append(line); message.append('\n'); } } return message.toString(); } } catch (IOException e) { // OK something went wrong so just don't bother returning a // message System.err.println("Error: " + e); e.printStackTrace(); return null; } finally { try { if (reader != null) { reader.close(); } if (temp != null) { temp.delete(); } } catch (Exception e) { // we're clearly in real trouble so just dump the // exception to standard err and get out of here System.err.println("Fatal error: " + e); e.printStackTrace(); } } } public Command createCommand(String[] args, int index, GlobalOptions gopt, String workDir) { CommitCommand command = new CommitCommand(); command.setBuilder(null); final String getOptString = command.getOptString(); GetOpt go = new GetOpt(args, getOptString); int ch = -1; go.optIndexSet(index); boolean usagePrint = false; while ((ch = go.getopt()) != go.optEOF) { boolean ok = command.setCVSCommand((char)ch, go.optArgGet()); if (!ok) { usagePrint = true; } } if (usagePrint) { throw new IllegalArgumentException(getUsage()); } int fileArgsIndex = go.optIndexGet(); File[] fileArgs = null; // test if we have been passed any file arguments if (fileArgsIndex < args.length) { fileArgs = new File[args.length - fileArgsIndex]; // send the arguments as absolute paths if (workDir == null) { workDir = System.getProperty("user.dir"); } File workingDir = new File(workDir); for (int i = fileArgsIndex; i < args.length; i++) { fileArgs[i - fileArgsIndex] = new File(workingDir, args[i]); } command.setFiles(fileArgs); } // now only bring up the editor if the message has not been set using // the -m option if (command.getMessage() == null && command.getLogMessageFromFile() == null) { String message = createMessage(fileArgs, gopt); if (message == null) { throw new IllegalArgumentException(java.util.ResourceBundle.getBundle(commit.class.getPackage().getName()+".Bundle").getString("commit.messageNotSpecified")); } command.setMessage(message); } return command; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/command/diff.java0000644000175300001440000000772411175407001027464 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.commandLine.command; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.command.diff.*; import org.netbeans.lib.cvsclient.commandLine.*; /** * The log command * @author Robert Greig */ public class diff extends AbstractCommandProvider { public String[] getSynonyms() { return new String[] { "di", "dif" }; } public Command createCommand(String[] args, int index, GlobalOptions gopt, String workDir) { DiffCommand command = new DiffCommand(); final String getOptString = command.getOptString(); GetOpt go = new GetOpt(args, getOptString); int ch = -1; go.optIndexSet(index); boolean usagePrint = false; String arg; while ((ch = go.getopt()) != go.optEOF) { boolean ok = command.setCVSCommand((char)ch, go.optArgGet()); if (!ok) { usagePrint = true; } } if (usagePrint) { throw new IllegalArgumentException(getUsage()); } int fileArgsIndex = go.optIndexGet(); // test if we have been passed any file arguments if (fileArgsIndex < args.length) { File[] fileArgs = new File[args.length - fileArgsIndex]; // send the arguments as absolute paths if (workDir == null) { workDir = System.getProperty("user.dir"); } File workingDir = new File(workDir); for (int i = fileArgsIndex; i < args.length; i++) { fileArgs[i - fileArgsIndex] = new File(workingDir, args[i]); } command.setFiles(fileArgs); } return command; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/command/export.java0000644000175300001440000001014211175407001030061 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.commandLine.command; import java.io.File; import java.util.ResourceBundle; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.command.export.*; import org.netbeans.lib.cvsclient.commandLine.*; /** * Export sources from CVS repository. * * @author Martin Entlicher */ public class export extends AbstractCommandProvider { public String getName() { return "export"; // NOI18N } public String[] getSynonyms() { return new String[] { "ex", "exp" }; // NOI18N } public Command createCommand(String[] args, int index, GlobalOptions gopt, String workDir) { ExportCommand command = new ExportCommand(); command.setBuilder(null); final String getOptString = command.getOptString(); GetOpt go = new GetOpt(args, getOptString); int ch = -1; go.optIndexSet(index); boolean usagePrint = false; String arg; while ((ch = go.getopt()) != go.optEOF) { boolean ok = command.setCVSCommand((char)ch, go.optArgGet()); if (!ok) { usagePrint = true; } } if (usagePrint) { throw new IllegalArgumentException(getUsage()); } if (command.getExportByDate() == null && command.getExportByRevision() == null) { throw new IllegalArgumentException("cvs [export]: "+ResourceBundle.getBundle(export.class.getPackage().getName()+".Bundle").getString("export.Msg_NeedTagOrDate")); // NOI18N) } int modulesArgsIndex = go.optIndexGet(); // test if we have been passed any module arguments if (modulesArgsIndex < args.length) { String[] modulesArgs = new String[args.length - modulesArgsIndex]; // send the arguments as absolute paths for (int i = modulesArgsIndex; i < args.length; i++) { modulesArgs[i - modulesArgsIndex] = args[i]; } command.setModules(modulesArgs); } return command; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/command/locbundlecheck.java0000644000175300001440000003412311175407001031512 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Milos Kleint. * Portions created by Milos Kleint are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Milos Kleint. *****************************************************************************/ package org.netbeans.lib.cvsclient.commandLine.command; import java.io.*; import java.io.PrintStream; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.ResourceBundle; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.command.FileInfoContainer; import org.netbeans.lib.cvsclient.command.annotate.*; import org.netbeans.lib.cvsclient.commandLine.*; import org.netbeans.lib.cvsclient.commandLine.ListenerProvider; import org.netbeans.lib.cvsclient.event.CVSAdapter; import org.netbeans.lib.cvsclient.event.CVSListener; /** * The locbundlecheck command * @author Milos Kleint */ public class locbundlecheck extends CVSAdapter implements CommandProvider { /** * A constructor that is used to create the CommandProvider. */ public locbundlecheck() { } public String getName() { return "locbundlecheck"; // NOI18N } public String[] getSynonyms() { return new String[] { "lbch", "lbcheck" }; // NOI18N } public String getUsage() { return ResourceBundle.getBundle(CommandProvider.class.getPackage().getName()+".Bundle").getString("locbundlecheck.usage"); // NOI18N } public void printShortDescription(PrintStream out) { String msg = ResourceBundle.getBundle(CommandProvider.class.getPackage().getName()+".Bundle").getString("locbundlecheck.shortDescription"); // NOI18N out.print(msg); } public void printLongDescription(PrintStream out) { String msg = ResourceBundle.getBundle(CommandProvider.class.getPackage().getName()+".Bundle").getString("locbundlecheck.longDescription"); // NOI18N out.println(msg); } public Command createCommand(String[] args, int index, GlobalOptions gopt, String workDir) { LocBundleAnnotateCommand command = new LocBundleAnnotateCommand(); final String getOptString = command.getOptString(); GetOpt go = new GetOpt(args, getOptString + "i:"); int ch = -1; go.optIndexSet(index); boolean usagePrint = false; String arg; String localization = null; while ((ch = go.getopt()) != go.optEOF) { if (ch == 'i') { localization = go.optArgGet(); command.setLocalization(localization); } else { boolean ok = command.setCVSCommand((char)ch, go.optArgGet()); if (!ok) { usagePrint = true; } } } if (usagePrint || localization == null) { throw new IllegalArgumentException(getUsage()); } int fileArgsIndex = go.optIndexGet(); // test if we have been passed any file arguments if (fileArgsIndex < args.length) { Collection fls = new ArrayList(); // send the arguments as absolute paths if (workDir == null) { workDir = System.getProperty("user.dir"); } command.setWorkDir(workDir); File workingDir = new File(workDir); for (int i = fileArgsIndex; i < args.length; i++) { File fl = new File(workingDir, args[i]); // System.out.println("file=" + fl); if (fl.exists() && fl.isDirectory()) { addFilesInDir(fls, fl, localization); } else if (fl.exists() && fl.getName().endsWith(".properties")) { addFiles(fls, fl, localization); } else { throw new IllegalArgumentException(); } } if (fls.size() > 0) { File[] fileArgs = new File[fls.size()]; fileArgs = (File[])fls.toArray(fileArgs); command.setFiles(fileArgs); } else { throw new IllegalArgumentException(ResourceBundle.getBundle("org/netbeans/lib/cvsclient/commandLine/command/Bundle").getString("locbundlecheck.no_file_spec")); } } return command; } private static void addFiles(Collection fileList, File origFile, String localization) { String origPath = origFile.getAbsolutePath(); String enarg = origPath.substring(0, origPath.length() - ".properties".length()) + "_" + localization + ".properties"; //System.out.println("enarg=" + enarg); File addfl = new File(enarg); fileList.add(origFile); if (addfl.exists()) { fileList.add(addfl); } else { //TODO } } private static void addFilesInDir(Collection fileList, File origFile, String localization) { File[] files = origFile.listFiles(); if (files != null && files.length > 0) { for (int i = 0; i < files.length; i++) { if (files[i].exists() && files[i].isDirectory()) { addFilesInDir(fileList, files[i], localization); } else if (files[i].exists() && "Bundle.properties".equals(files[i].getName())) { addFiles(fileList, files[i], localization); } } } } private PrintStream out; private PrintStream err; private int realEnd = 0; private HashMap originalBundles; private HashMap localizedBundles; private String local; private String workDir; /** * A constructor that is used to create the CVSAdapter. */ locbundlecheck(PrintStream stdout, PrintStream stderr, String localization, String workDir) { out = stdout; err = stderr; originalBundles = new HashMap(); localizedBundles = new HashMap(); local = localization; this.workDir = workDir; } public void fileInfoGenerated(org.netbeans.lib.cvsclient.event.FileInfoEvent e) { // out.println("annotated " + e.getInfoContainer().getFile()); FileInfoContainer cont = e.getInfoContainer(); if (cont.getFile().getName().indexOf("_" + local) >= 0) { localizedBundles.put(cont.getFile().getAbsolutePath(), cont); } else { originalBundles.put(cont.getFile().getAbsolutePath(), cont); } // out.println("orig size=" + originalBundles.keySet().size() + " loc size=" + localizedBundles.keySet().size()); if (realEnd == 2) { // generate output. // out.println("generating output...."); generateOutput(); } } public void commandTerminated(org.netbeans.lib.cvsclient.event.TerminationEvent e) { if (realEnd == 0) { // now the event is triggered because of the validresponses request realEnd = 1; return; } realEnd = 2; // the second time it's the real end. waiting for the last info object to be received. // out.println("finish=" + e.isError()); } private void generateOutput() { Iterator it = originalBundles.keySet().iterator(); while (it.hasNext()) { String origPath = (String)it.next(); int dotIndex = origPath.lastIndexOf("."); if (dotIndex < 0) { throw new IllegalStateException(ResourceBundle.getBundle("org/netbeans/lib/cvsclient/commandLine/command/Bundle").getString("locbundlecheck.illegal_state")); } String locPath = origPath.substring(0, dotIndex) + "_" + local + origPath.substring(dotIndex); // System.out.println("locpath=" + locPath); AnnotateInformation origInfo = (AnnotateInformation)originalBundles.get(origPath); AnnotateInformation locInfo = (AnnotateInformation)localizedBundles.get(locPath); if (locInfo == null) { out.println(MessageFormat.format(ResourceBundle.getBundle("org/netbeans/lib/cvsclient/commandLine/command/Bundle").getString("locbundlecheck.noLocalizedFile"), new Object[] {origPath})); continue; } // remove from locl bundles to figure out what was removed in the original.. localizedBundles.remove(locPath); HashMap origPropMap = createPropMap(origInfo); HashMap locPropMap = createPropMap(locInfo); String printFile = origPath; if (origPath.startsWith(workDir)) { printFile = origPath.substring(workDir.length()); if (printFile.startsWith("/") || printFile.startsWith("\\") ) { printFile = printFile.substring(1); } } out.println(MessageFormat.format(ResourceBundle.getBundle("org/netbeans/lib/cvsclient/commandLine/command/Bundle").getString("locbundlecheck.File"), new Object[] {printFile})); Iterator propIt = origPropMap.keySet().iterator(); while (propIt.hasNext()) { String prop = (String)propIt.next(); AnnotateLine origLine = (AnnotateLine)origPropMap.get(prop); AnnotateLine locLine = (AnnotateLine)locPropMap.get(prop); if (locLine == null) { out.println(MessageFormat.format(ResourceBundle.getBundle("org/netbeans/lib/cvsclient/commandLine/command/Bundle").getString("locbundlecheck.propMissing"), new Object[] {prop})); continue; } // System.out.println("prop=" + prop); // System.out.println("orig date:" + origLine.getDate()); // System.out.println("loc date:" + locLine.getDate()); if (origLine.getDate().compareTo(locLine.getDate()) > 0) { out.println(MessageFormat.format(ResourceBundle.getBundle("org/netbeans/lib/cvsclient/commandLine/command/Bundle").getString("locbundlecheck.prop_updated"), new Object[] {prop})); } } } if (localizedBundles.size() > 0) { Iterator locIt = localizedBundles.keySet().iterator(); while (locIt.hasNext()) { String prop = (String)locIt.next(); out.println(MessageFormat.format(ResourceBundle.getBundle("org/netbeans/lib/cvsclient/commandLine/command/Bundle").getString("locbundlecheck.prop_removed"), new Object[] {prop})); } } } private HashMap createPropMap(AnnotateInformation info) { HashMap propMap = new HashMap(); AnnotateLine line = info.getFirstLine(); while (line != null) { String content = line.getContent(); if (content.startsWith("#")) { // ignore commented lines. line = info.getNextLine(); continue; } int index = content.indexOf('='); if (index > 0) { String key = content.substring(0, index); propMap.put(key, line); } else { //TODO.. for properties that span across multiple lines, one should take all lines into account } line = info.getNextLine(); } return propMap; } private static class LocBundleAnnotateCommand extends AnnotateCommand implements ListenerProvider { private String loc; private String workDir; public CVSListener createCVSListener(PrintStream stdout, PrintStream stderr) { return new locbundlecheck(stdout, stderr, loc, workDir); } public void setLocalization(String loc) { this.loc = loc; } public void setWorkDir(String dir) { workDir = dir; } } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/command/log.java0000644000175300001440000001001211175407001027315 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.commandLine.command; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.command.log.*; import org.netbeans.lib.cvsclient.commandLine.*; /** * The log command * @author Robert Greig */ public class log extends AbstractCommandProvider { public String[] getSynonyms() { // Not "rlog"! We have a special rlog command. return new String[] { "lo" }; // NOI18N } public Command createCommand(String[] args, int index, GlobalOptions gopt, String workDir) { LogCommand command = new LogCommand(); final String getOptString = command.getOptString(); GetOpt go = new GetOpt(args, getOptString); int ch = -1; go.optIndexSet(index); boolean usagePrint = false; String arg; while ((ch = go.getopt()) != go.optEOF) { boolean ok = command.setCVSCommand((char)ch, go.optArgGet()); if (!ok) { usagePrint = true; } } if (usagePrint) { throw new IllegalArgumentException(getUsage()); } int fileArgsIndex = go.optIndexGet(); // test if we have been passed any file arguments if (fileArgsIndex < args.length) { File[] fileArgs = new File[args.length - fileArgsIndex]; // send the arguments as absolute paths if (workDir == null) { workDir = System.getProperty("user.dir"); } File workingDir = new File(workDir); for (int i = fileArgsIndex; i < args.length; i++) { fileArgs[i - fileArgsIndex] = new File(workingDir, args[i]); } command.setFiles(fileArgs); } return command; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/command/rannotate.java0000644000175300001440000000753111175407001030543 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.commandLine.command; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.command.annotate.*; import org.netbeans.lib.cvsclient.commandLine.*; /** * The rlog command * @author Milos Kleint */ public class rannotate extends AbstractCommandProvider { public String[] getSynonyms() { return new String[] { "rann" }; // NOI18N } public Command createCommand(String[] args, int index, GlobalOptions gopt, String workDir) { RannotateCommand command = new RannotateCommand(); final String getOptString = command.getOptString(); GetOpt go = new GetOpt(args, getOptString); int ch = -1; go.optIndexSet(index); boolean usagePrint = false; String arg; while ((ch = go.getopt()) != go.optEOF) { boolean ok = command.setCVSCommand((char)ch, go.optArgGet()); if (!ok) { usagePrint = true; } } if (usagePrint) { throw new IllegalArgumentException(getUsage()); } int modulesArgsIndex = go.optIndexGet(); // test if we have been passed any file arguments if (modulesArgsIndex < args.length) { String[] modulesArgs = new String[args.length - modulesArgsIndex]; // send the arguments as absolute paths for (int i = modulesArgsIndex; i < args.length; i++) { modulesArgs[i - modulesArgsIndex] = args[i]; } command.setModules(modulesArgs); } return command; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/command/remove.java0000644000175300001440000001005211175407002030036 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.commandLine.command; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.command.remove.*; import org.netbeans.lib.cvsclient.commandLine.*; /** * The command to remove a file or directory from the repository. * @author Robert Greig */ public class remove extends AbstractCommandProvider { public String[] getSynonyms() { return new String[] { "rm", "delete" }; // NOI18N } public Command createCommand(String[] args, int index, GlobalOptions gopt, String workDir) { RemoveCommand command = new RemoveCommand(); command.setBuilder(null); final String getOptString = command.getOptString(); GetOpt go = new GetOpt(args, getOptString); int ch = -1; go.optIndexSet(index); boolean usagePrint = false; while ((ch = go.getopt()) != go.optEOF) { boolean ok = command.setCVSCommand((char)ch, go.optArgGet()); if (!ok) { usagePrint = true; } } if (usagePrint) { throw new IllegalArgumentException(getUsage()); } int fileArgsIndex = go.optIndexGet(); // test if we have been passed any file arguments if (fileArgsIndex < args.length) { File[] fileArgs = new File[args.length - fileArgsIndex]; // send the arguments as absolute paths if (workDir == null) { workDir = System.getProperty("user.dir"); } File workingDir = new File(workDir); for (int i = fileArgsIndex; i < args.length; i++) { fileArgs[i - fileArgsIndex] = new File(workingDir, args[i]); } command.setFiles(fileArgs); } return command; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/command/rlog.java0000644000175300001440000000750411175407002027514 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.commandLine.command; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.command.log.*; import org.netbeans.lib.cvsclient.commandLine.*; /** * The rlog command * @author Milos Kleint */ public class rlog extends AbstractCommandProvider { public String[] getSynonyms() { return new String[] { "rlo" }; // NOI18N } public Command createCommand(String[] args, int index, GlobalOptions gopt, String workDir) { RlogCommand command = new RlogCommand(); final String getOptString = command.getOptString(); GetOpt go = new GetOpt(args, getOptString); int ch = -1; go.optIndexSet(index); boolean usagePrint = false; String arg; while ((ch = go.getopt()) != go.optEOF) { boolean ok = command.setCVSCommand((char)ch, go.optArgGet()); if (!ok) { usagePrint = true; } } if (usagePrint) { throw new IllegalArgumentException(getUsage()); } int modulesArgsIndex = go.optIndexGet(); // test if we have been passed any file arguments if (modulesArgsIndex < args.length) { String[] modulesArgs = new String[args.length - modulesArgsIndex]; // send the arguments as absolute paths for (int i = modulesArgsIndex; i < args.length; i++) { modulesArgs[i - modulesArgsIndex] = args[i]; } command.setModules(modulesArgs); } return command; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/command/rtag.java0000644000175300001440000001000011175407002027467 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.commandLine.command; import java.io.File; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.command.tag.*; import org.netbeans.lib.cvsclient.commandLine.*; /** * Tag repository files. * * @author Martin Entlicher */ public class rtag extends AbstractCommandProvider { public String getName() { return "rtag"; // NOI18N } public String[] getSynonyms() { return new String[] { "rt" }; // NOI18N } public Command createCommand(String[] args, int index, GlobalOptions gopt, String workDir) { RtagCommand command = new RtagCommand(); command.setBuilder(null); final String getOptString = command.getOptString(); GetOpt go = new GetOpt(args, getOptString); int ch = -1; go.optIndexSet(index); boolean usagePrint = false; String arg; while ((ch = go.getopt()) != go.optEOF) { boolean ok = command.setCVSCommand((char)ch, go.optArgGet()); if (!ok) { usagePrint = true; } } if (usagePrint) { throw new IllegalArgumentException(getUsage()); } int argIndex = go.optIndexGet(); // test if we have been passed the tag name if (argIndex < args.length) { command.setTag(args[argIndex]); } else { throw new IllegalArgumentException(getUsage()); } int modulesArgsIndex = argIndex + 1; // test if we have been passed any module arguments if (modulesArgsIndex < args.length) { String[] modulesArgs = new String[args.length - modulesArgsIndex]; // send the arguments as absolute paths for (int i = modulesArgsIndex; i < args.length; i++) { modulesArgs[i - modulesArgsIndex] = args[i]; } command.setModules(modulesArgs); } return command; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/command/status.java0000644000175300001440000001034211175407002030066 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.commandLine.command; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.command.status.*; import org.netbeans.lib.cvsclient.commandLine.*; /** * The status command * @author Robert Greig */ public class status extends AbstractCommandProvider { public String[] getSynonyms() { return new String[] { "st", "stat" }; // NOI18N } public Command createCommand(String[] args, int index, GlobalOptions gopt, String workDir) { StatusCommand command = new StatusCommand(); final String getOptString = command.getOptString(); GetOpt go = new GetOpt(args, getOptString); int ch = -1; go.optIndexSet(index); boolean usagePrint = false; while ((ch = go.getopt()) != go.optEOF) { boolean ok = command.setCVSCommand((char)ch, go.optArgGet()); /* if ((char)ch == 'R') command.setRecursive(true); else if ((char)ch == 'l') command.setRecursive(false); else if ((char)ch == 'v') command.setIncludeTags(true); else */ if (!ok) { usagePrint = true; } } if (usagePrint) { throw new IllegalArgumentException(getUsage()); } int fileArgsIndex = go.optIndexGet(); // test if we have been passed any file arguments if (fileArgsIndex < args.length) { File[] fileArgs = new File[args.length - fileArgsIndex]; // send the arguments as absolute paths if (workDir == null) { workDir = System.getProperty("user.dir"); } File workingDir = new File(workDir); for (int i = fileArgsIndex; i < args.length; i++) { fileArgs[i - fileArgsIndex] = new File(workingDir, args[i]); } command.setFiles(fileArgs); } return command; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/command/tag.java0000644000175300001440000001021711175407002027317 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.commandLine.command; import java.io.File; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.command.tag.*; import org.netbeans.lib.cvsclient.commandLine.*; /** * Tag checked out files. * * @author Martin Entlicher */ public class tag extends AbstractCommandProvider { public String getName() { return "tag"; // NOI18N } public String[] getSynonyms() { return new String[] { "ta" }; // NOI18N } public Command createCommand(String[] args, int index, GlobalOptions gopt, String workDir) { TagCommand command = new TagCommand(); command.setBuilder(null); final String getOptString = command.getOptString(); GetOpt go = new GetOpt(args, getOptString); int ch = -1; go.optIndexSet(index); boolean usagePrint = false; String arg; while ((ch = go.getopt()) != go.optEOF) { boolean ok = command.setCVSCommand((char)ch, go.optArgGet()); if (!ok) { usagePrint = true; } } if (usagePrint) { throw new IllegalArgumentException(getUsage()); } int argIndex = go.optIndexGet(); // test if we have been passed the tag name if (argIndex < args.length) { command.setTag(args[argIndex]); } else { throw new IllegalArgumentException(getUsage()); } int fileArgsIndex = argIndex + 1; // test if we have been passed any file arguments if (fileArgsIndex < args.length) { File[] fileArgs = new File[args.length - fileArgsIndex]; // send the arguments as absolute paths if (workDir == null) { workDir = System.getProperty("user.dir"); } File workingDir = new File(workDir); for (int i = fileArgsIndex; i < args.length; i++) { fileArgs[i - fileArgsIndex] = new File(workingDir, args[i]); } command.setFiles(fileArgs); } return command; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/commandLine/command/update.java0000644000175300001440000001062111175407002030025 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.commandLine.command; import java.io.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.command.update.*; import org.netbeans.lib.cvsclient.commandLine.*; /** * A factory class for creating and configuring an update command * @author Robert Greig */ public class update extends AbstractCommandProvider { public String[] getSynonyms() { return new String[] { "up", "upd" }; // NOI18N } public Command createCommand(String[] args, int index, GlobalOptions gopt, String workDir) { UpdateCommand command = new UpdateCommand(); command.setBuilder(null); final String getOptString = command.getOptString(); GetOpt go = new GetOpt(args, getOptString); int ch = -1; go.optIndexSet(index); boolean usagePrint = false; while ((ch = go.getopt()) != go.optEOF) { boolean ok = command.setCVSCommand((char)ch, go.optArgGet()); /* if ((char)ch == 'R') command.setRecursive(true); else if ((char)ch == 'l') command.setRecursive(false); else if ((char)ch == 'd') command.setBuildDirectories(true); else if ((char)ch == 'P') command.setPruneDirectories(true); else */ if (!ok) { usagePrint = true; } } if (usagePrint) { throw new IllegalArgumentException(getUsage()); } int fileArgsIndex = go.optIndexGet(); // test if we have been passed any file arguments if (fileArgsIndex < args.length) { File[] fileArgs = new File[args.length - fileArgsIndex]; // send the arguments as absolute paths if (workDir == null) { workDir = System.getProperty("user.dir"); } File workingDir = new File(workDir); for (int i = fileArgsIndex; i < args.length; i++) { fileArgs[i - fileArgsIndex] = new File(workingDir, args[i]); } command.setFiles(fileArgs); } return command; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/connection/0000755000175300001440000000000011175434236024204 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/connection/AbstractConnection.java0000644000175300001440000001341511175407002030625 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.connection; import java.io.IOException; import org.netbeans.lib.cvsclient.util.*; import org.netbeans.lib.cvsclient.request.*; /** * This class abstracts the common features and functionality that all connection protocols to CVS * share * * @author Sriram Seshan */ public abstract class AbstractConnection implements Connection { /** * The name of the repository this connection is made to */ private String repository = null; /** * The socket's input stream. */ private LoggedDataInputStream inputStream; /** * The socket's output stream. */ private LoggedDataOutputStream outputStream; /** Creates a new instance of AbstractConnection */ public AbstractConnection() { } /** * Get an input stream for receiving data from the server. * @return a data input stream */ public LoggedDataInputStream getInputStream() { return inputStream; } /** * Set an input stream for receiving data from the server. * The old stream (if any) is closed. * @param inputStream The data input stream */ protected final void setInputStream(LoggedDataInputStream inputStream) { if (this.inputStream == inputStream) return ; if (this.inputStream != null) { try { this.inputStream.close(); } catch (IOException ioex) {/*Ignore*/} } this.inputStream = inputStream; } /** * Get an output stream for sending data to the server. * @return an output stream */ public LoggedDataOutputStream getOutputStream() { return outputStream; } /** * Set an output stream for sending data to the server. * The old stream (if any) is closed. * @param outputStream The data output stream */ protected final void setOutputStream(LoggedDataOutputStream outputStream) { if (this.outputStream == outputStream) return ; if (this.outputStream != null) { try { this.outputStream.close(); } catch (IOException ioex) {/*Ignore*/} } this.outputStream = outputStream; } /** * Get the repository path. * @return the repository path, e.g. /home/banana/foo/cvs */ public String getRepository() { return repository; } /** * Set the repository path. * @param repository the repository */ public void setRepository(String repository) { this.repository = repository; } /** * Verifies that this open connection is a connetion to a working CVS server. * Clients should close this connection after verifying. */ protected void verifyProtocol() throws IOException { try { outputStream.writeBytes(new RootRequest(repository).getRequestString(), "US-ASCII"); outputStream.writeBytes(new UseUnchangedRequest().getRequestString(), "US-ASCII"); outputStream.writeBytes(new ValidRequestsRequest().getRequestString(), "US-ASCII"); outputStream.writeBytes("noop \n", "US-ASCII"); } catch (UnconfiguredRequestException e) { throw new RuntimeException("Internal error verifying CVS protocol: " + e.getMessage()); } outputStream.flush(); StringBuffer responseNameBuffer = new StringBuffer(); int c; while ((c = inputStream.read()) != -1) { responseNameBuffer.append((char)c); if (c == '\n') break; } String response = responseNameBuffer.toString(); if (!response.startsWith("Valid-requests")) { throw new IOException("Unexpected server response: " + response); } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/connection/AuthenticationException.java0000644000175300001440000001173411175407002031702 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.connection; import java.util.*; import org.netbeans.lib.cvsclient.util.*; /** * This exception is thrown when a connection with the server cannot be made, * for whatever reason. * It may be that the username and/or password are incorrect or it could be * that the port number is incorrect. Note that authentication is not * restricted here to mean security. * @author Robert Greig */ public class AuthenticationException extends Exception { /** * The underlying cause of this exception, if any. */ private Throwable underlyingThrowable; private String message; private String localizedMessage; /** * Construct an AuthenticationException with a message giving more details * of what went wrong. * @param message the message describing the error **/ public AuthenticationException(String message, String localizedMessage) { super(message); this.message = message; this.localizedMessage = localizedMessage; } /** * Construct an AuthenticationException with a message and an * underlying exception. * @param message the message describing what went wrong * @param e the underlying exception */ public AuthenticationException(String message, Throwable underlyingThrowable, String localizedMessage) { this(message, localizedMessage); initCause(underlyingThrowable); } /** * Construct an AuthenticationException with an underlying * exception. * @param t the underlying throwable that caused this exception */ public AuthenticationException(Throwable underlyingThrowable, String localizedMessage) { this.localizedMessage = localizedMessage; initCause(underlyingThrowable); } /** * Get the underlying throwable that is responsible for this exception. * @return the underlying throwable, if any (may be null). */ public Throwable getUnderlyingThrowable() { return getCause(); } public String getLocalizedMessage() { if (localizedMessage == null) { return message; } return localizedMessage; } public String getMessage() { return message; } protected static String getBundleString(String key) { String value = null; try { ResourceBundle bundle = BundleUtilities.getResourceBundle(AuthenticationException.class, "Bundle"); //NOI18N if (bundle != null) { value = bundle.getString(key); } } catch (MissingResourceException exc) { } return value; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/connection/Bundle.properties0000644000175300001440000000551111175407002027524 0ustar ludousers# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # # Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. # # The contents of this file are subject to the terms of either the GNU # General Public License Version 2 only ("GPL") or the Common # Development and Distribution License("CDDL") (collectively, the # "License"). You may not use this file except in compliance with the # License. You can obtain a copy of the License at # http://www.netbeans.org/cddl-gplv2.html # or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the # specific language governing permissions and limitations under the # License. When distributing the software, include this License Header # Notice in each file and include the License file at # nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this # particular file as subject to the "Classpath" exception as provided # by Sun in the GPL Version 2 section of the License file that # accompanied this code. If applicable, add the following below the # License Header, with the fields enclosed by brackets [] replaced by # your own identifying information: # "Portions Copyrighted [year] [name of copyright owner]" # # Contributor(s): # # The Original Software is NetBeans. The Initial Developer of the Original # Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun # Microsystems, Inc. All Rights Reserved. # # If you wish your version of this file to be governed by only the CDDL # or only the GPL Version 2, indicate your decision by adding # "[Contributor] elects to include this software in this distribution # under the [CDDL or GPL Version 2] license." If you do not indicate a # single choice of license, a recipient has the option to distribute # your version of this file under either the CDDL, the GPL Version 2 or # to extend the choice of license to its licensees as provided above. # However, if you add GPL Version 2 code and therefore, elected the GPL # Version 2 license, then the option applies only if the new code is # made subject to such option by the copyright holder. #-------------------------------------------------------------------- # ResourceBundle properties file AuthenticationException.UnknownHostException=Unknown host {0}. AuthenticationException.IOException=I/O error while connecting to host {0}. AuthenticationException.NoRouteToHostException=No route to host {0}. AuthenticationException.ConnectException=Cannot connect to host {0}:{1}. AuthenticationException.Throwable=General error during authentication with host. AuthenticationException.HostIsNull=Host name must not be null. AuthenticationException.AuthenticationFailed=Authentication failed. Response from server was: "{0}". AuthenticationException.ServerVerification=Cannot verify server connection. AuthenticationException.ServerConnection=Cannot open server connection. AuthenticationException.badPassword=Wrong Password. netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/connection/Connection.java0000644000175300001440000001171411175407002027141 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.connection; import java.io.*; import org.netbeans.lib.cvsclient.command.CommandAbortedException; import org.netbeans.lib.cvsclient.util.*; /** * Provides a method for accessing a connection, in order to be able to * communicate using the CVS Protocol. Instances of this interface are used * by the Client class to communicate with the server without being too * concerned with how the communication is taking place or how it was * set up. * @see org.netbeans.lib.cvsclient.Client * @author Robert Greig */ public interface Connection { /** * Get a data inputstream for reading data * @return an input stream **/ LoggedDataInputStream getInputStream(); /** * Get an output stream for sending data to the server * @return an output stream **/ LoggedDataOutputStream getOutputStream(); /** * Open a connection with the server. Until this method is called, no * communication with the server can take place. This Client will * call this method before interacting with the server. It is up to * implementing classes to ensure that they are configured to * talk to the server (e.g. port number etc.) * @throws AutenticationException if the connection with the server * cannot be established **/ void open() throws AuthenticationException, CommandAbortedException; /** * Verify a cnnection with the server. Simply verifies that a connection * could be made, for example that the user name and password are both * acceptable. Does not create input and output stream. For that, use * the open() method. */ void verify() throws AuthenticationException; /** * Close the connection with the server */ void close() throws IOException; /** * Returns true to indicate that the connection was successfully established. */ boolean isOpen(); /** * Get the repository */ String getRepository(); /** * Get the port number, which this connection is actually using. * @return The port number or zero, when the port number does not have sense. */ int getPort(); /** * Modify the underlying inputstream * @param modifier the connection modifier that performs the modifications * @throws IOException if an error occurs modifying the streams */ void modifyInputStream(ConnectionModifier modifier) throws IOException; /** * Modify the underlying outputstream * @param modifier the connection modifier that performs the modifications * @throws IOException if an error occurs modifying the streams */ void modifyOutputStream(ConnectionModifier modifier) throws IOException; } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/connection/ConnectionFactory.java0000644000175300001440000001150011175407002030462 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Gerrit Riessen. * Portions created by Gerrit Riessen are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Gerrit Riessen. *****************************************************************************/ package org.netbeans.lib.cvsclient.connection; import org.netbeans.lib.cvsclient.CVSRoot; /** Simple class for managing the mapping from CVSROOT specifications to Connection classes. @author Gerrit Riessen, OAR Development AG @author Rami Ojares, Elisa Internet Oy */ public class ConnectionFactory { /** Protected Constructor */ protected ConnectionFactory() {} /** * Returns a Connection object to handle the specific CVSRoot * specification. This returns null if not suitable connection * was found. * * If the return value is an instance of the PServerConnection class, * then the encoded password needs to be set if not defined in the CVSRoot. * This is left up to the client to set. */ public static Connection getConnection(String cvsRoot) throws IllegalArgumentException { CVSRoot root = CVSRoot.parse(cvsRoot); return getConnection(root); } /** * Returns a Connection object to handle the specific CVSRoot * specification. This returns null if not suitable connection * was found. * * If the return value is an instance of the PServerConnection class, * then the encoded password needs to be set if not defined in the CVSRoot. * This is left up to the client to set. */ public static Connection getConnection(CVSRoot root) throws IllegalArgumentException { // LOCAL CONNECTIONS (no-method, local & fork) if (root.isLocal()) { LocalConnection con = new LocalConnection(); con.setRepository(root.getRepository()); return con; } String method = root.getMethod(); // SSH2Connection (server, ext) /* SSH2Connection is TBD if ( method == null || CVSRoot.METHOD_SERVER == method || CVSRoot.METHOD_EXT == method ) { // NOTE: If you want to implement your own authenticator you have to construct SSH2Connection yourself SSH2Connection con = new SSH2Connection( root, new ConsoleAuthenticator() ); return con; } */ // PServerConnection (pserver) if (CVSRoot.METHOD_PSERVER == method) { PServerConnection con = new PServerConnection(root); return con; } throw new IllegalArgumentException("Unrecognized CVS Root: " + root); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/connection/ConnectionModifier.java0000644000175300001440000000524411175407002030621 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.connection; import java.io.*; import org.netbeans.lib.cvsclient.util.*; /** * Provides a way to modify the communication channel between client and * server. * @author Robert Greig */ public interface ConnectionModifier { void modifyInputStream(LoggedDataInputStream ldis) throws IOException; void modifyOutputStream(LoggedDataOutputStream ldos) throws IOException; } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/connection/ExtConnection.java0000644000175300001440000001051111175407002027614 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.connection; import org.netbeans.lib.cvsclient.command.CommandAbortedException; import org.netbeans.lib.cvsclient.util.LoggedDataInputStream; import org.netbeans.lib.cvsclient.util.LoggedDataOutputStream; import java.io.IOException; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; /** * Provides support for the :ext: connection method. * * @author Maros Sandor */ public class ExtConnection extends AbstractConnection { private final String command; private Process process; /** * Creates new EXT connection method support class. Given command will be used for getting I/O * streams to CVS server. * * @param command command to execute */ public ExtConnection(String command) { this.command = command; } public void open() throws AuthenticationException, CommandAbortedException { try { process = Runtime.getRuntime().exec(command); setInputStream(new LoggedDataInputStream(new BufferedInputStream(process.getInputStream()))); setOutputStream(new LoggedDataOutputStream(new BufferedOutputStream(process.getOutputStream()))); } catch (IOException e) { throw new AuthenticationException(e, "Failed to execute: " + command); } } public void verify() throws AuthenticationException { try { open(); verifyProtocol(); process.destroy(); } catch (Exception e) { throw new AuthenticationException(e, "Failed to execute: " + command); } } public void close() throws IOException { if (isOpen()) { process.destroy(); } } public boolean isOpen() { if (process == null) return false; try { process.exitValue(); return false; } catch (IllegalThreadStateException e) { return true; } } public int getPort() { return 0; } public void modifyInputStream(ConnectionModifier modifier) throws IOException { modifier.modifyInputStream(getInputStream()); } public void modifyOutputStream(ConnectionModifier modifier) throws IOException { modifier.modifyOutputStream(getOutputStream()); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/connection/GzipModifier.java0000644000175300001440000000656511175407002027442 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.connection; import java.io.*; import java.util.zip.*; import org.netbeans.lib.cvsclient.util.*; /** * This class modifies a connection by gzipping all client/server communication * @author Robert Greig */ public class GzipModifier extends Object implements ConnectionModifier { /** * Creates new GzipModifier */ public GzipModifier() { } public void modifyInputStream(LoggedDataInputStream ldis) throws IOException { // System.err.println("Setting the underlying stream for the IS"); GZIPInputStream gzis = new GZIPInputStream(ldis. getUnderlyingStream()); // System.err.println("Finished constructing the gzipinputstream"); ldis.setUnderlyingStream(gzis); } public void modifyOutputStream(LoggedDataOutputStream ldos) throws IOException { // System.err.println("Setting the underlying stream for the OS"); ldos.setUnderlyingStream(new GZIPOutputStream(ldos. getUnderlyingStream())); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/connection/LocalConnection.java0000644000175300001440000001564611175407002030124 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.connection; import java.io.*; import org.netbeans.lib.cvsclient.util.*; // import org.openide.util.RequestProcessor; /** * Implements a connection to a local server. See the cvs documents for more * information about different connection methods. Local is popular where * the CVS repository exists on the machine where the client library is * running.

* Because this library implements just the client part, it can not operate * directly on the repository. It needs a server to talk to. Therefore * it needs to execute the server process on the local machine. * * @author Robert Greig */ public class LocalConnection extends AbstractConnection { private static final String CVS_EXE_COMMAND = System.getenv("CVS_EXE") != null? System.getenv("CVS_EXE") + " server": "cvs server"; // NOI18N /** * The CVS process that is being run. */ protected Process process; /** * Creates a instance of ServerConnection. */ public LocalConnection() { reset(); } /** * Authenticate a connection with the server. * * @throws AuthenticationException if an error occurred */ private void openConnection() throws AuthenticationException { try { process = Runtime.getRuntime().exec(CVS_EXE_COMMAND); setOutputStream(new LoggedDataOutputStream(process. getOutputStream())); setInputStream(new LoggedDataInputStream(process.getInputStream())); } catch (IOException t) { reset(); String locMessage = AuthenticationException.getBundleString( "AuthenticationException.ServerConnection"); //NOI18N throw new AuthenticationException("Connection error", t, locMessage); //NOI18N } } private void reset() { process = null; setInputStream(null); setOutputStream(null); } /** * Authenticate with the server. Closes the connection immediately. * Clients can use this method to ensure that they are capable of * authenticating with the server. If no exception is thrown, you can * assume that authentication was successful * * @throws AuthenticationException if the connection with the server * cannot be established */ public void verify() throws AuthenticationException { try { openConnection(); verifyProtocol(); process.destroy(); } catch (Exception e) { String locMessage = AuthenticationException.getBundleString( "AuthenticationException.ServerVerification"); //NOI18N throw new AuthenticationException("Verification error", e, locMessage); //NOI18N } finally { reset(); } } /** * Authenticate with the server and open a channel of communication * with the server. This Client will * call this method before interacting with the server. It is up to * implementing classes to ensure that they are configured to * talk to the server (e.g. port number etc.) * @throws AuthenticationException if the connection with the server * cannot be established */ public void open() throws AuthenticationException { openConnection(); } /** * Returns true to indicate that the connection was successfully established. */ public boolean isOpen() { return process != null; } /** * Close the connection with the server. */ public void close() throws IOException { try { if (process != null) { process.destroy(); } } finally { reset(); } } /** * @return 0, no port is used by the local connection. */ public int getPort() { return 0; // No port } /** * Modify the underlying inputstream. * @param modifier the connection modifier that performs the modifications * @throws IOException if an error occurs modifying the streams */ public void modifyInputStream(ConnectionModifier modifier) throws IOException { modifier.modifyInputStream(getInputStream()); } /** * Modify the underlying outputstream. * @param modifier the connection modifier that performs the modifications * @throws IOException if an error occurs modifying the streams */ public void modifyOutputStream(ConnectionModifier modifier) throws IOException { modifier.modifyOutputStream(getOutputStream()); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/connection/PServerConnection.java0000644000175300001440000004135611175407002030455 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.connection; import java.io.*; import java.net.*; import java.text.*; import java.util.Map; import java.util.HashMap; import org.netbeans.lib.cvsclient.CVSRoot; import org.netbeans.lib.cvsclient.request.*; import org.netbeans.lib.cvsclient.command.CommandAbortedException; import org.netbeans.lib.cvsclient.command.CommandException; import org.netbeans.lib.cvsclient.util.*; import javax.net.SocketFactory; /** * Implements a connection to a pserver. See the cvs documents for more * information about different connection methods. PServer is popular where * security is not an issue. For secure connections, consider using a * kserver (Kerberos) or the GSSAPI. * * @author Robert Greig */ public class PServerConnection extends AbstractConnection { /** * The string that is sent at the beginning of the request to open * a connection. */ protected static final String OPEN_PREAMBLE = "BEGIN AUTH REQUEST\n"; //NOI18N /** * The string that is sent at the end of the request to open a connection. */ protected static final String OPEN_POSTAMBLE = "END AUTH REQUEST\n"; //NOI18N /** * The string that is sent at the beginning of the request to * verify a connection. * Note the difference between opening a connection and simply verifying. */ protected static final String VERIFY_PREAMBLE = "BEGIN VERIFICATION REQUEST\n"; //NOI18N /** * The string that is sent at the end of a verify request. */ protected static final String VERIFY_POSTAMBLE = "END VERIFICATION REQUEST\n"; //NOI18N /** * A response indicating that authorisation has succeeded. */ protected static final String AUTHENTICATION_SUCCEEDED_RESPONSE = "I LOVE YOU"; //NOI18N private static final String AUTHENTICATION_SUCCEEDED_RESPONSE_RAW = "I LOVE YOU\n"; //NOI18N /** * A response indicating that the authorisation has failed. */ protected static final String AUTHENTICATION_FAILED_RESPONSE = "I HATE YOU"; //NOI18N private static final String AUTHENTICATION_FAILED_RESPONSE_RAW = "I HATE YOU\n"; //NOI18N /** * The user name to use. */ protected String userName; /** * The password, encoded appropriately. */ protected String encodedPassword; /** * The default port number to use. */ public static final int DEFAULT_PORT = 2401; /** * The port number to use. */ protected int port = DEFAULT_PORT; /** * The host to use. */ protected String hostName; /** * The socket used for the connection. */ protected Socket socket; /** * The socket factory that will be used to create sockets. */ protected SocketFactory socketFactory; /** * Create an uninitialized PServerConnection. All properties needs to be set * explicitly by appropriate setters before this connection can be opened. */ public PServerConnection() { } /** * Create PServerConnection and setup it's properties from the supplied * CVSRoot object. * @throws IllegalArgumentException if the cvsRoot does not represent pserver * connection type. */ public PServerConnection(CVSRoot cvsRoot) { this(cvsRoot, null); } /** * Create PServerConnection and setup it's properties from the supplied * CVSRoot object. * @throws IllegalArgumentException if the cvsRoot does not represent pserver * connection type. */ public PServerConnection(CVSRoot cvsRoot, SocketFactory factory) { if (!CVSRoot.METHOD_PSERVER.equals(cvsRoot.getMethod())) { throw new IllegalArgumentException("CVS Root '"+cvsRoot+"' does not represent :pserver: connection type."); } socketFactory = factory; String userName = cvsRoot.getUserName(); if (userName == null) { userName = System.getProperty("user.name"); } setUserName(userName); String password = cvsRoot.getPassword(); if (password != null) { setEncodedPassword(StandardScrambler.getInstance().scramble(password)); } setHostName(cvsRoot.getHostName()); setRepository(cvsRoot.getRepository()); int port = cvsRoot.getPort(); if (port == 0) { port = 2401; // The default pserver port } setPort(port); } /** * Authenticate a connection with the server, using the specified * postamble and preamble. * * @param preamble the preamble to use * @param postamble the postamble to use * * @throws AuthenticationException if an error occurred * @return the socket used to make the connection. The socket is * guaranteed to be open if an exception has not been thrown */ private void openConnection(String preamble, String postamble) throws AuthenticationException, CommandAbortedException { if (hostName == null) { String locMessage = AuthenticationException.getBundleString( "AuthenticationException.HostIsNull"); //NOI18N throw new AuthenticationException("HostIsNull", locMessage); //NOI18N } try { SocketFactory sf = (socketFactory != null) ? socketFactory : SocketFactory.getDefault(); socket = sf.createSocket(hostName, port); BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream(), 32768); LoggedDataOutputStream outputStream = new LoggedDataOutputStream(bos); setOutputStream(outputStream); BufferedInputStream bis = new BufferedInputStream(socket.getInputStream(), 32768); LoggedDataInputStream inputStream = new LoggedDataInputStream(bis); setInputStream(inputStream); outputStream.writeBytes(preamble, "US-ASCII"); outputStream.writeBytes(getRepository() + "\n"); //NOI18N outputStream.writeBytes(userName + "\n"); //NOI18N outputStream.writeBytes(getEncodedPasswordNotNull() + "\n", "US-ASCII"); //NOI18N outputStream.writeBytes(postamble, "US-ASCII"); outputStream.flush(); if (Thread.interrupted()) { reset(); String localMsg = CommandException.getLocalMessage("Client.connectionAborted", null); //NOI18N throw new CommandAbortedException("Aborted during connecting to the server.", localMsg); // NOI18N } // read first 11 bytes only (AUTHENTICATION_SUCCEEDED_RESPONSE\n) // I observed lock caused by missing '\n' in reponse // this method then blocks forever byte rawResponse[] = inputStream.readBytes(AUTHENTICATION_SUCCEEDED_RESPONSE_RAW.length()); String response = new String(rawResponse, "utf8"); // NOI18N if (Thread.interrupted()) { reset(); String localMsg = CommandException.getLocalMessage("Client.connectionAborted", null); //NOI18N throw new CommandAbortedException("Aborted during connecting to the server.", localMsg); // NOI18N } if (AUTHENTICATION_SUCCEEDED_RESPONSE_RAW.equals(response)) { return; } if (AUTHENTICATION_FAILED_RESPONSE_RAW.equals(response)) { String localizedMsg = getLocalMessage("AuthenticationException.badPassword", null); throw new AuthenticationException("AuthenticationFailed", //NOI18N localizedMsg); } if (response == null) response = ""; // NOI18N String locMessage = getLocalMessage("AuthenticationException.AuthenticationFailed", //NOI18N new Object[]{ response }); throw new AuthenticationException("AuthenticationFailed", //NOI18N locMessage); } catch (AuthenticationException ex) { reset(); throw ex; } catch (ConnectException ex) { reset(); String locMessage = getLocalMessage("AuthenticationException.ConnectException", //NOI18N new Object[]{hostName, Integer.toString(port)}); throw new AuthenticationException("ConnectException", ex, //NOI18N locMessage); } catch (NoRouteToHostException ex) { reset(); String locMessage = getLocalMessage("AuthenticationException.NoRouteToHostException", //NOI18N new Object[]{hostName}); throw new AuthenticationException("NoRouteToHostException", ex, //NOI18N locMessage); } catch (IOException ex) { reset(); String locMessage = getLocalMessage("AuthenticationException.IOException", //NOI18N new Object[]{hostName}); throw new AuthenticationException("IOException", ex, locMessage); //NOI18N } /* catch (Throwable t) { reset(); String locMessage = AuthenticationException.getBundleString( "AuthenticationException.Throwable"); //NOI18N throw new AuthenticationException("General error", t, locMessage); //NOI18N } */ } private void reset() { socket = null; setInputStream(null); setOutputStream(null); } /** * Authenticate with the server. * Closes the connection immediately. Clients can use this method to ensure * that they are capable of authenticating with the server. If no exception * is thrown, you can assume that authentication was successful. * * @throws AuthenticationException if the connection with the server * cannot be established */ public void verify() throws AuthenticationException { try { openConnection(VERIFY_PREAMBLE, VERIFY_POSTAMBLE); } catch (CommandAbortedException caex) { // Ignore, follow the next steps } if (socket == null) { return; } try { socket.close(); } catch (IOException exc) { String locMessage = AuthenticationException.getBundleString( "AuthenticationException.Throwable"); //NOI18N throw new AuthenticationException("General error", exc, locMessage); //NOI18N } finally { reset(); } } /** * Authenticate with the server and open a channel of communication with * the server. * This Client will call this method before interacting with the server. It * is up to implementing classes to ensure that they are configured to talk * to the server (e.g. port number etc.). * * @throws AutenticationException if the connection with the server * cannot be established */ public void open() throws AuthenticationException, CommandAbortedException { openConnection(OPEN_PREAMBLE, OPEN_POSTAMBLE); } /** * Get the username. */ public String getUserName() { return userName; } /** * Set the userName. * @param name the userName */ public void setUserName(String userName) { this.userName = userName; } /** * Get the encoded password. * @return the encoded password */ public String getEncodedPassword() { return encodedPassword; } private String getEncodedPasswordNotNull() { if (encodedPassword == null) { return StandardScrambler.getInstance().scramble(""); } return encodedPassword; } /** * Set the encoded password. * @param password the encoded password to use for authentication */ public void setEncodedPassword(String encodedPassword) { this.encodedPassword = encodedPassword; } /** * Get the port number to use. * @return the port number */ public int getPort() { return port; } /** * Set the port number to use. * @param thePort the port number to use. If you do not set this, 2401 * is used by default for pserver. */ public void setPort(int port) { this.port = port; } /** * Get the host name to use. * @return the host name of the server to connect to. If you do not set * this, localhost is used by default for pserver. */ public String getHostName() { return hostName; } /** * Get the host name to use. * @param theHostName the host name of the server to connect to. If you * do not set this, localhost is used by default for pserver. */ public void setHostName(String hostName) { this.hostName = hostName; } /** * Close the connection with the server. */ public void close() throws IOException { if (!isOpen()) { return; } try { socket.close(); } finally { reset(); } } /** * Modify the underlying inputstream. * @param modifier the connection modifier that performs the modifications * @throws IOException if an error occurs modifying the streams */ public void modifyInputStream(ConnectionModifier modifier) throws IOException { modifier.modifyInputStream(getInputStream()); } /** * Modify the underlying outputstream. * @param modifier the connection modifier that performs the modifications * @throws IOException if an error occurs modifying the streams */ public void modifyOutputStream(ConnectionModifier modifier) throws IOException { modifier.modifyOutputStream(getOutputStream()); } private String getLocalMessage(String key, Object[] arguments) { String locMessage = AuthenticationException.getBundleString(key); if (locMessage == null) { return null; } locMessage = MessageFormat.format(locMessage, arguments); return locMessage; } /** * Returns true to indicate that the connection was successfully established. */ public boolean isOpen() { return socket != null; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/connection/PasswordsFile.java0000644000175300001440000001637711175407002027641 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.connection; import org.netbeans.lib.cvsclient.file.FileUtils; import java.io.*; import java.util.*; /** * Represents .cvspass passwords file. * * @author Petr Kuzel */ public final class PasswordsFile { /** * Locates scrambled password for given CVS Root. * * @param cvsRootString identifies repository session [:method:][[user][:password]@][hostname[:[port]]]/path/to/repository * @return scrambled password or null */ public static String findPassword(String cvsRootString) { File passFile = new File(System.getProperty("cvs.passfile", System.getProperty("user.home") + "/.cvspass")); BufferedReader reader = null; String password = null; try { reader = new BufferedReader(new FileReader(passFile)); String line; while ((line = reader.readLine()) != null) { line = normalize(line); if (line.startsWith(cvsRootString+" ")) { password = line.substring(cvsRootString.length() + 1); break; } } } catch (IOException e) { return null; } finally { if (reader != null) { try { reader.close(); } catch (IOException e) {} } } return password; } /** * List roots matching given prefix e.g. ":pserver:". */ public static Collection listRoots(String prefix) { List roots = new ArrayList(); File passFile = new File(System.getProperty("cvs.passfile", System.getProperty("user.home") + "/.cvspass")); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(passFile)); String line; while ((line = reader.readLine()) != null) { line = normalize(line); String elements[] = line.split(" "); // NOI18N if (elements[0].startsWith(prefix)) { roots.add(elements[0]); } } } catch (IOException e) { return Collections.EMPTY_SET; } finally { if (reader != null) { try { reader.close(); } catch (IOException e) {} } } return roots; } /** * Writes scrambled password for given CVS root. * Eliminates all previous values and possible duplicities. * * @param cvsRootString identifies repository session [:method:][[user][:password]@][hostname[:[port]]]/path/to/repository * @param encodedPassword * @throws IOException on write failure */ public static void storePassword(String cvsRootString, String encodedPassword) throws IOException { File passFile = new File(System.getProperty("cvs.passfile", System.getProperty("user.home") + File.separatorChar + ".cvspass")); BufferedWriter writer = null; BufferedReader reader = null; try { final String LF = System.getProperty("line.separator"); // NOI18N if (passFile.createNewFile()) { writer = new BufferedWriter(new FileWriter(passFile)); writer.write(cvsRootString + " " + encodedPassword + LF); writer.close(); } else { File tempFile = File.createTempFile("cvs", "tmp"); reader = new BufferedReader(new FileReader(passFile)); writer = new BufferedWriter(new FileWriter(tempFile)); String line; boolean stored = false; while ((line = reader.readLine()) != null) { if (normalize(line).startsWith(cvsRootString + " ")) { if (stored == false) { writer.write(cvsRootString + " " + encodedPassword + LF); stored = true; } } else { writer.write(line + LF); } } if (stored == false) { writer.write(cvsRootString + " " + encodedPassword + LF); } reader.close(); writer.flush(); writer.close(); // copyFile needs less permissions than File.renameTo FileUtils.copyFile(tempFile, passFile); tempFile.delete(); } } finally { try { if (writer != null) { writer.close(); } if (reader != null) { reader.close(); } } catch (Exception e) { // ignore } } } /** * Normalizes several possible line formats into * 'normal' one that allows to apply dumb string operations. */ private static String normalize(String line) { if (line.startsWith("/1 ")) { // NOI18N line = line.substring("/1 ".length()); // NOI18N } return line; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/connection/Scrambler.java0000644000175300001440000000523111175407002026751 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.connection; /** * Provides methods used to scramble text. A concrete implementation will * use a particular encoding scheme to scramble the text. * @author Robert Greig */ public interface Scrambler { /** * Scramble text, turning it into a String of scrambled data * @return a String containing the scrambled data */ String scramble(String text); }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/connection/StandardScrambler.java0000644000175300001440000002320211175407002030430 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.connection; /** * Scrambles text (the password) using the standard scheme described in the * CVS protocol version 1.10. This encoding is trivial and should not be * used for security, but rather as a mechanism for avoiding inadvertant * compromise. * @author Robert Greig */ public class StandardScrambler implements Scrambler { /** * The mapping array */ private int[] shifts; /** * The single instance of this class (Singleton design pattern) */ public static StandardScrambler instance; /** * Do not instantiate the scrambler directly. Use the getInstance() method */ private StandardScrambler() { int i; shifts = new int[256]; for (i = 0; i < 32; ++i) { shifts[i] = i; } shifts[i++] = 114; shifts[i++] = 120; shifts[i++] = 53; shifts[i++] = 79; shifts[i++] = 96; shifts[i++] = 109; shifts[i++] = 72; shifts[i++] = 108; shifts[i++] = 70; shifts[i++] = 64; shifts[i++] = 76; shifts[i++] = 67; shifts[i++] = 116; shifts[i++] = 74; shifts[i++] = 68; shifts[i++] = 87; shifts[i++] = 111; shifts[i++] = 52; shifts[i++] = 75; shifts[i++] = 119; shifts[i++] = 49; shifts[i++] = 34; shifts[i++] = 82; shifts[i++] = 81; shifts[i++] = 95; shifts[i++] = 65; shifts[i++] = 112; shifts[i++] = 86; shifts[i++] = 118; shifts[i++] = 110; shifts[i++] = 122; shifts[i++] = 105; shifts[i++] = 41; shifts[i++] = 57; shifts[i++] = 83; shifts[i++] = 43; shifts[i++] = 46; shifts[i++] = 102; shifts[i++] = 40; shifts[i++] = 89; shifts[i++] = 38; shifts[i++] = 103; shifts[i++] = 45; shifts[i++] = 50; shifts[i++] = 42; shifts[i++] = 123; shifts[i++] = 91; shifts[i++] = 35; shifts[i++] = 125; shifts[i++] = 55; shifts[i++] = 54; shifts[i++] = 66; shifts[i++] = 124; shifts[i++] = 126; shifts[i++] = 59; shifts[i++] = 47; shifts[i++] = 92; shifts[i++] = 71; shifts[i++] = 115; shifts[i++] = 78; shifts[i++] = 88; shifts[i++] = 107; shifts[i++] = 106; shifts[i++] = 56; shifts[i++] = 36; shifts[i++] = 121; shifts[i++] = 117; shifts[i++] = 104; shifts[i++] = 101; shifts[i++] = 100; shifts[i++] = 69; shifts[i++] = 73; shifts[i++] = 99; shifts[i++] = 63; shifts[i++] = 94; shifts[i++] = 93; shifts[i++] = 39; shifts[i++] = 37; shifts[i++] = 61; shifts[i++] = 48; shifts[i++] = 58; shifts[i++] = 113; shifts[i++] = 32; shifts[i++] = 90; shifts[i++] = 44; shifts[i++] = 98; shifts[i++] = 60; shifts[i++] = 51; shifts[i++] = 33; shifts[i++] = 97; shifts[i++] = 62; shifts[i++] = 77; shifts[i++] = 84; shifts[i++] = 80; shifts[i++] = 85; shifts[i++] = 223; shifts[i++] = 225; shifts[i++] = 216; shifts[i++] = 187; shifts[i++] = 166; shifts[i++] = 229; shifts[i++] = 189; shifts[i++] = 222; shifts[i++] = 188; shifts[i++] = 141; shifts[i++] = 249; shifts[i++] = 148; shifts[i++] = 200; shifts[i++] = 184; shifts[i++] = 136; shifts[i++] = 248; shifts[i++] = 190; shifts[i++] = 199; shifts[i++] = 170; shifts[i++] = 181; shifts[i++] = 204; shifts[i++] = 138; shifts[i++] = 232; shifts[i++] = 218; shifts[i++] = 183; shifts[i++] = 255; shifts[i++] = 234; shifts[i++] = 220; shifts[i++] = 247; shifts[i++] = 213; shifts[i++] = 203; shifts[i++] = 226; shifts[i++] = 193; shifts[i++] = 174; shifts[i++] = 172; shifts[i++] = 228; shifts[i++] = 252; shifts[i++] = 217; shifts[i++] = 201; shifts[i++] = 131; shifts[i++] = 230; shifts[i++] = 197; shifts[i++] = 211; shifts[i++] = 145; shifts[i++] = 238; shifts[i++] = 161; shifts[i++] = 179; shifts[i++] = 160; shifts[i++] = 212; shifts[i++] = 207; shifts[i++] = 221; shifts[i++] = 254; shifts[i++] = 173; shifts[i++] = 202; shifts[i++] = 146; shifts[i++] = 224; shifts[i++] = 151; shifts[i++] = 140; shifts[i++] = 196; shifts[i++] = 205; shifts[i++] = 130; shifts[i++] = 135; shifts[i++] = 133; shifts[i++] = 143; shifts[i++] = 246; shifts[i++] = 192; shifts[i++] = 159; shifts[i++] = 244; shifts[i++] = 239; shifts[i++] = 185; shifts[i++] = 168; shifts[i++] = 215; shifts[i++] = 144; shifts[i++] = 139; shifts[i++] = 165; shifts[i++] = 180; shifts[i++] = 157; shifts[i++] = 147; shifts[i++] = 186; shifts[i++] = 214; shifts[i++] = 176; shifts[i++] = 227; shifts[i++] = 231; shifts[i++] = 219; shifts[i++] = 169; shifts[i++] = 175; shifts[i++] = 156; shifts[i++] = 206; shifts[i++] = 198; shifts[i++] = 129; shifts[i++] = 164; shifts[i++] = 150; shifts[i++] = 210; shifts[i++] = 154; shifts[i++] = 177; shifts[i++] = 134; shifts[i++] = 127; shifts[i++] = 182; shifts[i++] = 128; shifts[i++] = 158; shifts[i++] = 208; shifts[i++] = 162; shifts[i++] = 132; shifts[i++] = 167; shifts[i++] = 209; shifts[i++] = 149; shifts[i++] = 241; shifts[i++] = 153; shifts[i++] = 251; shifts[i++] = 237; shifts[i++] = 236; shifts[i++] = 171; shifts[i++] = 195; shifts[i++] = 243; shifts[i++] = 233; shifts[i++] = 253; shifts[i++] = 240; shifts[i++] = 194; shifts[i++] = 250; shifts[i++] = 191; shifts[i++] = 155; shifts[i++] = 142; shifts[i++] = 137; shifts[i++] = 245; shifts[i++] = 235; shifts[i++] = 163; shifts[i++] = 242; shifts[i++] = 178; shifts[i++] = 152; } /** * Get an instance of the standard scrambler */ public static Scrambler getInstance() { if (instance == null) { instance = new StandardScrambler(); } return instance; } /** * Scramble text, turning it into a String of scrambled data * @return a String of scrambled data */ public String scramble(String text) { StringBuffer buf = new StringBuffer("A"); //NOI18N if (text != null) { for (int i = 0; i < text.length(); ++i) { char ch = text.charAt(i); byte newCh = (byte)(shifts[(int)ch & 255] & 255); buf.append((char)newCh); } } return buf.toString(); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/event/0000755000175300001440000000000011175434236023166 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/event/BinaryMessageEvent.java0000644000175300001440000000670011175407002027556 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.event; /** * An event sent from the server to indicate that a binary message should be * displayed to the user. *

* One protocol reponse mey be splitted into several messages. * * @author Martin Entlicher */ public class BinaryMessageEvent extends CVSEvent { /** * Holds value of property message. */ private byte[] message; private int len; /** * Construct a MessageEvent * @param source the source of the event * @param message the message text */ public BinaryMessageEvent(Object source, byte[] message, int len) { super(source); this.message = message; this.len = len; } /** * Raw data buffer that holds binary data. * @return raw data buffer, its {@link #getMessageLength()} subset represents actual data */ public byte[] getMessage() { return message; } /** * Defines valid data length in raw data buffer. * @return number of valid bytes in message raw data buffer. */ public int getMessageLength() { return len; } /** * Fire the event to the event listener. Subclasses should call the * appropriate method on the listener to dispatch this event. * @param listener the event listener */ protected void fireEvent(CVSListener listener) { listener.messageSent(this); } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/event/CVSAdapter.java0000644000175300001440000001034711175407002025761 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.event; /** * A convenience class for implementing the CVSListener. This class provides * empty implementations of the CVSListener interface. Subclasses should * override the methods for the event in which they are interested. * @author Robert Greig */ public class CVSAdapter implements CVSListener { /** * Called when the server wants to send a message to be displayed to * the user. The message is only for information purposes and clients * can choose to ignore these messages if they wish. * @param e the event */ public void messageSent(MessageEvent e) { } /** * Called when the server wants to send a binary message to be displayed to * the user. The message is only for information purposes and clients * can choose to ignore these messages if they wish. * @param e the event */ public void messageSent(BinaryMessageEvent e) { } /** * Called when a file has been added. * @param e the event */ public void fileAdded(FileAddedEvent e) { } /** * Called when a file is going to be removed. * @param e the event */ public void fileToRemove(FileToRemoveEvent e) { } /** * Called when a file is removed. * @param e the event */ public void fileRemoved(FileRemovedEvent e) { } /** * Called when a file has been updated * @param e the event */ public void fileUpdated(FileUpdatedEvent e) { } /** * Called when file status information has been received */ public void fileInfoGenerated(FileInfoEvent e) { } /** * called when server responses with "ok" or "error", (when the command finishes) */ public void commandTerminated(TerminationEvent e) { } /** * Fire a module expansion event. This is called when the servers * has responded to an expand-modules request. */ public void moduleExpanded(ModuleExpansionEvent e) { } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/event/CVSEvent.java0000644000175300001440000000573311175407002025465 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.event; import java.util.*; /** * The base class of all events that are generated by the CVS library. * Specialisations of this class give more details about the event. * @author Robert Greig */ public abstract class CVSEvent extends EventObject { /** * Construct a CVS event. * @param source the object that is logically the source of the event */ public CVSEvent(Object source) { super(source); } /** * Fire the event to the event listener. Subclasses should call the * appropriate method on the listener to dispatch this event. * @param listener the event listener */ protected abstract void fireEvent(CVSListener listener); }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/event/CVSListener.java0000644000175300001440000000776111175407002026174 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.event; /** * This interface must be implemented by clients wishing to receive events * describing the results of commands. * @author Robert Greig */ public interface CVSListener { /** * Called when the server wants to send a message to be displayed to * the user. The message is only for information purposes and clients * can choose to ignore these messages if they wish. * @param e the event */ void messageSent(MessageEvent e); /** * Called when the server wants to send a binary message to be displayed to * the user. The message is only for information purposes and clients * can choose to ignore these messages if they wish. * @param e the event */ void messageSent(BinaryMessageEvent e); /** * Called when a file has been added. * @param e the event */ void fileAdded(FileAddedEvent e); /** * Called when a file is going to be removed. * @param e the event */ void fileToRemove(FileToRemoveEvent e); /** * Called when a file is removed. * @param e the event */ void fileRemoved(FileRemovedEvent e); /** * Called when a file has been updated * @param e the event */ void fileUpdated(FileUpdatedEvent e); /** * Called when file information has been received */ void fileInfoGenerated(FileInfoEvent e); /** * called when server responses with "ok" or "error", (when the command * finishes) */ void commandTerminated(TerminationEvent e); /** * Fire a module expansion event. This is called when the servers * has responded to an expand-modules request. */ void moduleExpanded(ModuleExpansionEvent e); }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/event/EnhancedMessageEvent.java0000644000175300001440000001060411175407003030036 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.event; /** * An event sent from the server to indicate that a message should be * displayed to the user * @author Milos Kleint */ public class EnhancedMessageEvent extends MessageEvent { /** * Sent by MergedResponse when 2 files were merged. * The value is a String instance that tells the full path to the file. */ public static final String MERGED_PATH = "Merged_Response_File_Path"; // NOI18N /** * Sent when a file was successfully sent to server. */ public static final String FILE_SENDING = "File_Sent_To_Server"; // NOI18N /** * Sent when a all requests were sent to server. * Value is a String with value of "ok". */ public static final String REQUESTS_SENT = "All_Requests_Were_Sent"; // NOI18N /** * Sent before all request are processed. * Value is an Integer object. */ public static final String REQUESTS_COUNT = "Requests_Count"; // NOI18N private String key; private Object value; /** * Construct a MessageEvent * @param source the source of the event * @param key identifier. Specifies what the value object is. * @param value. Some value passed to the listeners. The key parameter helps * the listeners to identify the value and handle it correctly. * for stderr rather than stdout), false otherwise */ public EnhancedMessageEvent(Object source, String key, Object value) { super(source, "", false); // NOI18N this.key = key; this.value = value; } /** Getter for property key. * @return Value of property key. */ public String getKey() { return key; } /** Setter for property key. * @param key New value of property key. */ public void setKey(String key) { this.key = key; } /** Getter for property value. * @return Value of property value. */ public Object getValue() { return value; } /** Setter for property value. * @param value New value of property value. */ public void setValue(Object value) { this.value = value; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/event/EventManager.java0000644000175300001440000001432111175407003026376 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.event; import org.netbeans.lib.cvsclient.ClientServices; import java.io.File; /** * This class is responsible for firing CVS events to registered listeners. * It can either fire events as they are generated or wait until a suitable * checkpoint and fire many events at once. This can prevent event storms * from degrading system performance. * @author Robert Greig */ public class EventManager { /** * Registered listeners for events. This is an array for performance when * firing events. We take the hit when adding or removing listeners - that * should be a relatively rare occurrence. */ private CVSListener[] listeners; /** * Holds value of property fireEnhancedEventSet. * If true, the library fires the EnhancedMessageEvents. * Default is true. Some builders might work badly, if set to false. */ private boolean fireEnhancedEventSet = true; private final ClientServices services; /** * Construct a new EventManager */ public EventManager(ClientServices services) { this.services = services; } /** * Returns Client services implementation tied to this event manager. * * @return a ClientServices implementation */ public ClientServices getClientServices() { return services; } /** * Add a listener to the list. * @param listener the listener to add */ public synchronized void addCVSListener(CVSListener listener) { if (listeners == null || listeners.length == 0) { listeners = new CVSListener[1]; } else { // allocate a new array and copy existing listeners CVSListener[] l = new CVSListener[listeners.length + 1]; for (int i = 0; i < listeners.length; i++) { l[i] = listeners[i]; } listeners = l; } listeners[listeners.length - 1] = listener; } /** * Remove a listeners from the list * @param listener the listener to remove */ public synchronized void removeCVSListener(CVSListener listener) { // TODO: test this method!! if (listeners.length == 1) { listeners = null; } else { CVSListener[] l = new CVSListener[listeners.length - 1]; int i = 0; while (i < l.length) { if (listeners[i] == listener) { for (int j = i + 1; j < listeners.length; j++) { l[j - 1] = listeners[j]; } break; } else { l[i] = listeners[i]; } i++; } listeners = l; } } /** * Fire a CVSEvent to all the listeners * @param e the event to send */ public void fireCVSEvent(CVSEvent e) { // if we have no listeners, then there is nothing to do if (listeners == null || listeners.length == 0) return; if (e instanceof FileInfoEvent) { File file = ((FileInfoEvent) e).getInfoContainer().getFile(); if (services.getGlobalOptions().isExcluded(file)) return; } CVSListener[] l = null; synchronized (listeners) { l = new CVSListener[listeners.length]; System.arraycopy(listeners, 0, l, 0, l.length); } for (int i = 0; i < l.length; i++) { e.fireEvent(l[i]); } } /** Getter for property fireEnhancedEventSet. * @return Value of property fireEnhancedEventSet. */ public boolean isFireEnhancedEventSet() { return fireEnhancedEventSet; } /** Setter for property fireEnhancedEventSet. * @param fireEnhancedEventSet New value of property fireEnhancedEventSet. */ public void setFireEnhancedEventSet(boolean fireEnhancedEventSet) { this.fireEnhancedEventSet = fireEnhancedEventSet; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/event/FileAddedEvent.java0000644000175300001440000000616011175407004026630 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.event; /** * Indicates that a file has been added. * @author Robert Greig */ public class FileAddedEvent extends CVSEvent { /** * The path of the file that has been added */ protected String path; /** * Construct a FileAddedEvent * @param source the source of the event */ public FileAddedEvent(Object source, String path) { super(source); this.path = path; } /** * Get the path of the file that has been added */ public String getFilePath() { return path; } /** * Fire the event to the event listener. Subclasses should call the * appropriate method on the listener to dispatch this event. * @param listener the event listener */ protected void fireEvent(CVSListener listener) { listener.fileAdded(this); } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/event/FileInfoEvent.java0000644000175300001440000000651311175407004026524 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.event; import org.netbeans.lib.cvsclient.command.*; /** * This event is created when file information is received from the * server. * @author Milos Kleint */ public class FileInfoEvent extends CVSEvent { /** * The information about the file. */ private final FileInfoContainer infoContainer; /** * Construct a FileInfoEvent * @param source the source of the event * @param message the message text * @param isError true if the message is an error message (i.e. intended * for stderr rather than stdout), false otherwise */ public FileInfoEvent(Object source, FileInfoContainer infoContainer) { super(source); this.infoContainer = infoContainer; } /** * Get the information in this event * @return the information object describing a file's info received from the server */ public FileInfoContainer getInfoContainer() { return infoContainer; } /** * Fire the event to the event listener. Subclasses should call the * appropriate method on the listener to dispatch this event. * @param listener the event listener */ protected void fireEvent(CVSListener listener) { listener.fileInfoGenerated(this); } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/event/FileRemovedEvent.java0000644000175300001440000000630011175407004027224 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.event; /** * Indicates that a file has been removed. * @author Robert Greig */ public class FileRemovedEvent extends CVSEvent { /** * The path of the file that has been removed. */ protected String path; /** * Construct a FileRemovedEvent * @param source the source of the event * @param path The path of the file that has been removed */ public FileRemovedEvent(Object source, String path) { super(source); this.path = path; } /** * Get the path of the file that has been removed. */ public String getFilePath() { return path; } /** * Fire the event to the event listener. Subclasses should call the * appropriate method on the listener to dispatch this event. * @param listener the event listener */ protected void fireEvent(CVSListener listener) { listener.fileRemoved(this); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/event/FileToRemoveEvent.java0000644000175300001440000000633011175407004027366 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.event; /** * Indicates that a file is to be removed. * @author Martin Entlicher */ public class FileToRemoveEvent extends CVSEvent { /** * The path of the file that is going to be removed. */ protected String path; /** * Construct a FileRemovedEvent * @param source the source of the event * @param path The path of the file that is going to be removed */ public FileToRemoveEvent(Object source, String path) { super(source); this.path = path; } /** * Get the path of the file that is going to be removed. */ public String getFilePath() { return path; } /** * Fire the event to the event listener. Subclasses should call the * appropriate method on the listener to dispatch this event. * @param listener the event listener */ protected void fireEvent(CVSListener listener) { listener.fileToRemove(this); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/event/FileUpdatedEvent.java0000644000175300001440000000617511175407004027223 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.event; /** * Indicates that an existing file has been updated. * @author Robert Greig */ public class FileUpdatedEvent extends CVSEvent { /** * The path of the file that has been added */ protected String path; /** * Construct a FileUpdatedEvent * @param source the event source */ public FileUpdatedEvent(Object source, String path) { super(source); this.path = path; } /** * Get the path of the file that has been added */ public String getFilePath() { return path; } /** * Fire the event to the event listener. Subclasses should call the * appropriate method on the listener to dispatch this event. * @param listener the event listener */ protected void fireEvent(CVSListener listener) { listener.fileUpdated(this); } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/event/MessageEvent.java0000644000175300001440000001335211175407004026414 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.event; /** * An event sent from the server to indicate that a message should be * displayed to the user * @author Robert Greig */ public class MessageEvent extends CVSEvent { /** * Holds value of property message. */ private String message; /** * Whether the message is an error message */ private boolean error; /** Holds value of property tagged. */ private boolean tagged; private final byte[] raw; public MessageEvent(Object source, String message, byte[] raw, boolean isError) { super(source); setMessage(message); setError(isError); setTagged(false); this.raw = raw; } /** * Construct a MessageEvent * @param source the source of the event * @param message the message text * @param isError true if the message is an error message (i.e. intended * for stderr rather than stdout), false otherwise */ public MessageEvent(Object source, String message, boolean isError) { this(source, message, null, isError); } /** * Construct a MessageEvent with no message text * @param source the source of the event */ public MessageEvent(Object source) { this(source, null, false); } /** * Getter for property message. * @return Value of property message. */ public String getMessage() { return message; } /** @return bytes from wire or null */ public byte[] getRawData() { return raw; } /** * Setter for property message. * @param message New value of property message. */ public void setMessage(String message) { this.message = message; } /** * Get whether the message should be displayed in stderr * @return true if the message should be sent to stderr, false otherwise */ public boolean isError() { return error; } /** * Set whether the message should go to stderr * @param error true if the message is an error message, false otherwise */ public void setError(boolean error) { this.error = error; } /** * Fire the event to the event listener. Subclasses should call the * appropriate method on the listener to dispatch this event. * @param listener the event listener */ protected void fireEvent(CVSListener listener) { listener.messageSent(this); } /** Getter for property tagged. * @return Value of property tagged. */ public boolean isTagged() { return tagged; } /** Setter for property tagged. * @param tagged New value of property tagged. */ public void setTagged(boolean tagged) { this.tagged = tagged; } /** * Parses the tagged message using the specified buffer. * @returns != null, if the line is finished and could be processed */ public static String parseTaggedMessage(StringBuffer taggedLineBufferNotNull, String taggedMessage) { String line = taggedMessage; if (line.charAt(0) == '+' || line.charAt(0) == '-') { return null; } String result = null; if (line.equals("newline")) {//NOI18N result = taggedLineBufferNotNull.toString(); taggedLineBufferNotNull.setLength(0); } int index = line.indexOf(' '); if (index > 0) { taggedLineBufferNotNull.append(line.substring(index + 1)); } return result; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/event/ModuleExpansionEvent.java0000644000175300001440000000663411175407004030147 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.event; /** * This event is really intended only for the use in the Checkout command. * During a checkout command, the client must ask the server to expand modules * to determine whether there are aliases defined for a particular module. * The client must then use the expansion to determine if a local directory * exists and if so, send appropriate Modified requests etc. * @author Robert Greig */ public class ModuleExpansionEvent extends CVSEvent { /** * The expanded module name */ private String module; /** * Creates new ModuleExpansionEvent. * @param source the source of the event * @param theModule the module name that the original request has been * "expanded" to. */ public ModuleExpansionEvent(Object source, String module) { super(source); this.module = module; } /** * Get the module name that the original module name has been expanded to. * @return the expanded name */ public String getModule() { return module; } /** * Fire the event to the event listener. Subclasses should call the * appropriate method on the listener to dispatch this event. * @param listener the event listener */ protected void fireEvent(CVSListener listener) { listener.moduleExpanded(this); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/event/TerminationEvent.java0000644000175300001440000000744311175407004027325 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.event; /** * An event sent from the server to indicate that a the output from the server * has ended for the current command * @author Milos Kleint */ public class TerminationEvent extends CVSEvent { /** * Whether the termination is an error or not */ private boolean error; /** * Construct a MessageEvent * @param source the source of the event * @param message the message text * @param isError true if the message is an error message (i.e. intended * for stderr rather than stdout), false otherwise */ public TerminationEvent(Object source, boolean isError) { super(source); setError(isError); } /** * Construct a MessageEvent with no message text * @param source the source of the event */ public TerminationEvent(Object source) { this(source, false); } /** * Get whether the command ended successfully or not * @return true if the successfull */ public boolean isError() { return error; } /** * Get whether the command ended successfully or not * @param error true if successfull */ public void setError(boolean error) { this.error = error; } /** * Fire the event to the event listener. Subclasses should call the * appropriate method on the listener to dispatch this event. * @param listener the event listener */ protected void fireEvent(CVSListener listener) { listener.commandTerminated(this); } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/file/0000755000175300001440000000000011175434236022764 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/file/DefaultFileHandler.java0000644000175300001440000005143211175407005027310 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.file; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.request.*; import org.netbeans.lib.cvsclient.util.*; /** * Provides a basic implementation of FileHandler, and does much of the * handling of reading and writing files and performing CRLF conversions. * @author Robert Greig */ public class DefaultFileHandler implements FileHandler { /** * Whether to emit debug information. */ private static final boolean DEBUG = false; /** * The size of chunks read from disk. */ private static final int CHUNK_SIZE = 32768; /** * The date the next file written should be marked as being modified on. */ private Date modifiedDate; private TransmitTextFilePreprocessor transmitTextFilePreprocessor; private WriteTextFilePreprocessor writeTextFilePreprocessor; private WriteTextFilePreprocessor writeRcsDiffFilePreprocessor; private GlobalOptions globalOptions; private final boolean ignoreModeFromServer = System.getProperty("netbeans.cvs.ignoreModeFromServer") != null; /** * Creates a DefaultFileHandler. */ public DefaultFileHandler() { setTransmitTextFilePreprocessor(new DefaultTransmitTextFilePreprocessor()); setWriteTextFilePreprocessor(new DefaultWriteTextFilePreprocessor()); setWriteRcsDiffFilePreprocessor(new WriteRcsDiffFilePreprocessor()); } /** * Returns the preprocessor for transmitting text files. */ public TransmitTextFilePreprocessor getTransmitTextFilePreprocessor() { return transmitTextFilePreprocessor; } /** * Sets the preprocessor for transmitting text files. * The default one changes all line endings to Unix-lineendings (cvs default). */ public void setTransmitTextFilePreprocessor(TransmitTextFilePreprocessor transmitTextFilePreprocessor) { this.transmitTextFilePreprocessor = transmitTextFilePreprocessor; } /** * Gets the preprocessor for writing text files after getting (and un-gzipping) from server. */ public WriteTextFilePreprocessor getWriteTextFilePreprocessor() { return writeTextFilePreprocessor; } /** * Sets the preprocessor for writing text files after getting (and un-gzipping) from server. */ public void setWriteTextFilePreprocessor(WriteTextFilePreprocessor writeTextFilePreprocessor) { this.writeTextFilePreprocessor = writeTextFilePreprocessor; } /** * Gets the preprocessor for merging text files after getting * (and un-gzipping) the diff received from server. */ public WriteTextFilePreprocessor getWriteRcsDiffFilePreprocessor() { return writeRcsDiffFilePreprocessor; } /** * Sets the preprocessor for merging text files after getting * (and un-gzipping) the diff received from server. */ public void setWriteRcsDiffFilePreprocessor(WriteTextFilePreprocessor writeRcsDiffFilePreprocessor) { this.writeRcsDiffFilePreprocessor = writeRcsDiffFilePreprocessor; } /** * Get the string to transmit containing the file transmission length. * * @return a String to transmit to the server (including carriage return) * @param length the amount of data that will be sent */ protected String getLengthString(long length) { return String.valueOf(length) + "\n"; //NOI18N } protected Reader getProcessedReader(File f) throws IOException { return new FileReader(f); } protected InputStream getProcessedInputStream(File file) throws IOException { return new FileInputStream(file); } /** * Get any requests that must be sent before commands are sent, to init * this file handler. * * @return an array of Requests that must be sent */ public Request[] getInitialisationRequests() { return null; } /** * Transmit a text file to the server, using the standard CVS protocol * conventions. CR/LFs are converted to the Unix format. * * @param file the file to transmit * @param dos the data outputstream on which to transmit the file */ public void transmitTextFile(File file, LoggedDataOutputStream dos) throws IOException { if (file == null || !file.exists()) { throw new IllegalArgumentException("File is either null or " + "does not exist. Cannot transmit."); } File fileToSend = file; final TransmitTextFilePreprocessor transmitTextFilePreprocessor = getTransmitTextFilePreprocessor(); if (transmitTextFilePreprocessor != null) { fileToSend = transmitTextFilePreprocessor.getPreprocessedTextFile(file); } BufferedInputStream bis = null; try { // first write the length of the file long length = fileToSend.length(); dos.writeBytes(getLengthString(length), "US-ASCII"); bis = new BufferedInputStream(new FileInputStream(fileToSend)); // now transmit the file itself byte[] chunk = new byte[CHUNK_SIZE]; while (length > 0) { int bytesToRead = (length >= CHUNK_SIZE) ? CHUNK_SIZE : (int)length; int count = bis.read(chunk, 0, bytesToRead); if (count == -1) { throw new IOException("Unexpected end of stream from "+fileToSend+"."); } length -= count; dos.write(chunk, 0, count); } dos.flush(); } finally { if (bis != null) { try { bis.close(); } catch (IOException ex) { // ignore } } if (transmitTextFilePreprocessor != null) { transmitTextFilePreprocessor.cleanup(fileToSend); } } } /** * Transmit a binary file to the server, using the standard CVS protocol * conventions. * @param file the file to transmit * @param dos the data outputstream on which to transmit the file */ public void transmitBinaryFile(File file, LoggedDataOutputStream dos) throws IOException { if (file == null || !file.exists()) { throw new IllegalArgumentException("File is either null or " + "does not exist. Cannot transmit."); } BufferedInputStream bis = null; try { bis = new BufferedInputStream(new FileInputStream(file)); // first write the length of the file long length = file.length(); dos.writeBytes(getLengthString(length), "US-ASCII"); // now transmit the file itself byte[] chunk = new byte[CHUNK_SIZE]; while (length > 0) { int bytesToRead = (length >= CHUNK_SIZE) ? CHUNK_SIZE : (int)length; int count = bis.read(chunk, 0, bytesToRead); if (count == -1) { throw new IOException("Unexpected end of stream from "+file+"."); } length -= count; dos.write(chunk, 0, count); } dos.flush(); } finally { if (bis != null) { try { bis.close(); } catch (IOException ex) { ex.printStackTrace(); } } } } /** * Write (either create or replace) a file on the local machine with * one read from the server. * @param path the absolute path of the file, (including the file name). * @param mode the mode of the file * @param dis the stream to read the file from, as bytes * @param length the number of bytes to read */ public void writeTextFile(String path, String mode, LoggedDataInputStream dis, int length) throws IOException { writeAndPostProcessTextFile(path, mode, dis, length, getWriteTextFilePreprocessor()); } /** * Merge a text file on the local machine with * the diff from the server. (it uses the RcsDiff response format * - see cvsclient.ps for details) * @param path the absolute path of the file, (including the file name). * @param mode the mode of the file * @param dis the stream to read the file from, as bytes * @param length the number of bytes to read */ public void writeRcsDiffFile(String path, String mode, LoggedDataInputStream dis, int length) throws IOException { writeAndPostProcessTextFile(path, mode, dis, length, getWriteRcsDiffFilePreprocessor()); } /** * Common code for writeTextFile() and writeRcsDiffFile() methods. * Differs only in the passed file processor. */ private void writeAndPostProcessTextFile(String path, String mode, LoggedDataInputStream dis, int length, WriteTextFilePreprocessor processor) throws IOException { if (DEBUG) { System.err.println("[writeTextFile] writing: " + path); //NOI18N System.err.println("[writeTextFile] length: " + length); //NOI18N System.err.println("Reader object is: " + dis.hashCode()); //NOI18N } File file = new File(path); boolean readOnly = resetReadOnly(file, mode); createNewFile(file); // For CRLF conversion, we have to read the file // into a temp file, then do the conversion. This is because we cannot // perform a sequence of readLines() until we've read the file from // the server - the file transmission is not followed by a newline. // Bah. File tempFile = File.createTempFile("cvsCRLF", "tmp"); //NOI18N try { OutputStream os = null; try { os = new BufferedOutputStream(new FileOutputStream(tempFile)); byte[] chunk = new byte[CHUNK_SIZE]; while (length > 0) { int count = (length >= CHUNK_SIZE) ? CHUNK_SIZE :length; count = dis.read(chunk, 0, count); if (count == -1) { throw new IOException("Unexpected end of stream: " + path + "\nMissing " + length + " bytes. Probably network communication failure.\nPlease try again."); // NOI18N } length -= count; if (DEBUG) { System.err.println("Still got: " + length + " to read"); //NOI18N } os.write(chunk, 0, count); } } finally { if (os != null) { try { os.close(); } catch (IOException ex) { // ignore } } } // Here we read the temp file in again, doing any processing required // (for example, unzipping). We must not convert bytes to characters // because it would break characters that are not in the current encoding InputStream tempInput = getProcessedInputStream(tempFile); try { //BUGLOG - assert the processor is not null.. processor.copyTextFileToLocation(tempInput, file, new StreamProvider(file)); } finally { tempInput.close(); } if (modifiedDate != null) { file.setLastModified(modifiedDate.getTime()); modifiedDate = null; } } finally { tempFile.delete(); } if (readOnly) { FileUtils.setFileReadOnly(file, true); } } /** * Write (either create or replace) a binary file on the local machine with * one read from the server. * @param path the absolute path of the file, (including the file name). * @param mode the mode of the file * @param dis the stream to read the file from, as bytes * @param length the number of bytes to read */ public void writeBinaryFile(String path, String mode, LoggedDataInputStream dis, int length) throws IOException { if (DEBUG) { System.err.println("[writeBinaryFile] writing: " + path); //NOI18N System.err.println("[writeBinaryFile] length: " + length); //NOI18N System.err.println("Reader object is: " + dis.hashCode()); //NOI18N } File file = new File(path); boolean readOnly = resetReadOnly(file, mode); createNewFile(file); // FUTURE: optimisation possible - no need to use a temp file if there // is no post processing required (e.g. unzipping). So perhaps enhance // the interface to allow this stage to be optional File cvsDir = new File(file.getParentFile(), "CVS"); cvsDir.mkdir(); File tempFile = File.createTempFile("cvsPostConversion", "tmp", cvsDir); //NOI18N try { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tempFile)); byte[] chunk = new byte[CHUNK_SIZE]; try { while (length > 0) { int bytesToRead = (length >= CHUNK_SIZE) ? CHUNK_SIZE : (int)length; int count = dis.read(chunk, 0, bytesToRead); if (count == -1) { throw new IOException("Unexpected end of stream: " + path + "\nMissing " + length + " bytes. Probably network communication failure.\nPlease try again."); // NOI18N } if (count < 0) { break; } length -= count; if (DEBUG) { System.err.println("Still got: " + length + " to read"); //NOI18N } bos.write(chunk, 0, count); } } finally { bos.close(); } // Here we read the temp file in, taking the opportunity to process // the file, e.g. unzip the data BufferedInputStream tempIS = new BufferedInputStream(getProcessedInputStream(tempFile)); bos = new BufferedOutputStream(createOutputStream(file)); try { for (int count = tempIS.read(chunk, 0, CHUNK_SIZE); count > 0; count = tempIS.read(chunk, 0, CHUNK_SIZE)) { bos.write(chunk, 0, count); } } finally { bos.close(); tempIS.close(); } // now we need to modifiy the timestamp on the file, if specified if (modifiedDate != null) { file.setLastModified(modifiedDate.getTime()); modifiedDate = null; } } finally { tempFile.delete(); } if (readOnly) { FileUtils.setFileReadOnly(file, true); } } /** Extension point allowing subclasses to change file creation logic.*/ protected boolean createNewFile(File file) throws IOException { file.getParentFile().mkdirs(); return file.createNewFile(); } /** * Extension point allowing subclasses to change file write logic. * The stream is close()d after usage. */ protected OutputStream createOutputStream(File file) throws IOException { return new FileOutputStream(file); } private class StreamProvider implements OutputStreamProvider { private final File file; public StreamProvider(File file) { this.file = file; } public OutputStream createOutputStream() throws IOException { return DefaultFileHandler.this.createOutputStream(file); } } private boolean resetReadOnly(File file, String cvsMode) throws java.io.IOException { boolean isReadOnly = file.exists() && !file.canWrite(); if (isReadOnly) { FileUtils.setFileReadOnly(file, false); } boolean readOnlyFromClient = globalOptions != null && globalOptions.isCheckedOutFilesReadOnly(); boolean readOnlyFromServer = false; if (!ignoreModeFromServer && cvsMode != null) { // u=rw,g=rw,o=rw int idx1 = cvsMode.indexOf('='); int idx2 = cvsMode.indexOf(','); readOnlyFromServer = idx2 > idx1 && cvsMode.substring(idx1 + 1, idx2).indexOf('w') == -1; } return readOnlyFromClient || readOnlyFromServer; } /** * Remove the specified file from the local disk. * * @param pathname the full path to the file to remove * @throws IOException if an IO error occurs while removing the file */ public void removeLocalFile(String pathname) throws IOException { File fileToDelete = new File(pathname); if (fileToDelete.exists() && !fileToDelete.delete()) { System.err.println("Could not delete file " + fileToDelete.getAbsolutePath()); } } public void copyLocalFile(String pathname, String newName) throws IOException { File sourceFile = new File(pathname); File destinationFile = new File(sourceFile.getParentFile(), newName); FileUtils.copyFile(sourceFile, destinationFile); } /** * Set the modified date of the next file to be written. * The next call to writeFile will use this date. * * @param modifiedDate the date the file should be marked as modified */ public void setNextFileDate(Date modifiedDate) { this.modifiedDate = modifiedDate; } /** * Sets the global options. * This can be useful to detect, whether local files should be made read-only. */ public void setGlobalOptions(GlobalOptions globalOptions) { BugLog.getInstance().assertNotNull(globalOptions); this.globalOptions = globalOptions; transmitTextFilePreprocessor.setTempDir(globalOptions.getTempDir()); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/file/DefaultTransmitTextFilePreprocessor.java0000644000175300001440000001310611175407006033005 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.file; import java.io.*; /** * @author Thomas Singer * @version Sep 26, 2001 */ public class DefaultTransmitTextFilePreprocessor implements TransmitTextFilePreprocessor { private static final int CHUNK_SIZE = 32768; private File tempDir; public void setTempDir(File tempDir) { this.tempDir = tempDir; } public File getPreprocessedTextFile(File originalTextFile) throws IOException { // must write file to temp location first because size might change // due to CR/LF changes File preprocessedTextFile = File.createTempFile("cvs", null, tempDir); // NOI18N byte[] newLine = System.getProperty("line.separator").getBytes(); boolean doConversion = newLine.length != 1 || newLine[0] != '\n'; OutputStream out = null; InputStream in = null; try { in = new BufferedInputStream(new FileInputStream(originalTextFile)); out = new BufferedOutputStream(new FileOutputStream(preprocessedTextFile)); byte[] fileChunk = new byte[CHUNK_SIZE]; byte[] fileWriteChunk = new byte[CHUNK_SIZE]; for (int readLength = in.read(fileChunk); readLength > 0; readLength = in.read(fileChunk)) { if (doConversion) { int writeLength = 0; for (int i = 0; i < readLength; ) { int pos = findIndexOf(fileChunk, newLine, i); if (pos >= i && pos < readLength) { System.arraycopy(fileChunk, i, fileWriteChunk, writeLength, pos - i); writeLength += pos - i; i = pos + newLine.length; fileWriteChunk[writeLength++] = '\n'; } else { System.arraycopy(fileChunk, i, fileWriteChunk, writeLength, readLength - i); writeLength += readLength - i; i = readLength; } } out.write(fileWriteChunk, 0, writeLength); } else { out.write(fileChunk, 0, readLength); } } return preprocessedTextFile; } catch (IOException ex) { if (preprocessedTextFile != null) { cleanup(preprocessedTextFile); } throw ex; } finally { if (in != null) { try { in.close(); } catch (IOException ex) { // ignore } } if (out != null) { try { out.close(); } catch (IOException ex) { // ignore } } } } private static int findIndexOf(byte[] array, byte[] pattern, int start) { int subPosition = 0; for (int i = start; i < array.length; i++) { if (array[i] == pattern[subPosition]) { if (++subPosition == pattern.length) { return i - subPosition + 1; } } else { subPosition = 0; } } return -1; } public void cleanup(File preprocessedTextFile) { if (preprocessedTextFile != null) { preprocessedTextFile.delete(); } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/file/DefaultWriteTextFilePreprocessor.java0000644000175300001440000001053211175407006032276 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.file; import java.io.*; /** * @author Thomas Singer * @version Sep 26, 2001 */ public class DefaultWriteTextFilePreprocessor implements WriteTextFilePreprocessor { private static final int CHUNK_SIZE = 32768; public void copyTextFileToLocation(InputStream processedInputStream, File fileToWrite, OutputStreamProvider customOutput) throws IOException { // Here we read the temp file in again, doing any processing required // (for example, unzipping). We must not convert the bytes to characters // because the file may not be written in the current encoding. // We would corrupt it's content when characters would be written! InputStream tempInput = null; OutputStream out = null; byte[] newLine = System.getProperty("line.separator").getBytes(); try { tempInput = new BufferedInputStream(processedInputStream); out = new BufferedOutputStream(customOutput.createOutputStream()); // this chunk is directly read from the temp file byte[] cchunk = new byte[CHUNK_SIZE]; for (int readLength = tempInput.read(cchunk); readLength > 0; readLength = tempInput.read(cchunk)) { // we must perform our own newline conversion. The file will // definitely have unix style CRLF conventions, so if we have // a \n this code will write out a \n or \r\n as appropriate for // the platform we are running on for (int i = 0; i < readLength; i++) { if (cchunk[i] == '\n') { out.write(newLine); } else { out.write(cchunk[i]); } } } } finally { if (tempInput != null) { try { tempInput.close(); } catch (IOException ex) { // ignore } } if (out != null) { try { out.close(); } catch (IOException ex) { // ignore } } } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/file/FileDetails.java0000644000175300001440000000614011175407006026010 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.file; import java.io.*; /** * A wrapper class that describes a file. * @author Robert Greig */ public class FileDetails { /** * The file */ private File file; /** * Whether the file is binary */ private boolean isBinary; /** * Construct a FileDetails object * @param theFile the file * @param binary true if the file is binary, false if it is text */ public FileDetails(File file, boolean isBinary) { this.file = file; this.isBinary = isBinary; } /** * Return the file. * @return the file */ public File getFile() { return file; } /** * Return the file type. * @return true if the file is binary, false if it is text */ public boolean isBinary() { return isBinary; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/file/FileHandler.java0000644000175300001440000001435711175407006026011 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.file; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.request.*; import org.netbeans.lib.cvsclient.util.*; /** * Handles the reading and writing of files to and from the server. Different * implementations of this interface can use different formats for sending or * receiving the files, for example gzipped format. * @author Robert Greig */ public interface FileHandler { /** * Transmit a text file to the server, using the standard CVS protocol * conventions. CR/LFs are converted to the Unix format. * @param file the file to transmit * @param dos the data outputstream on which to transmit the file */ void transmitTextFile(File file, LoggedDataOutputStream dos) throws IOException; /** * Transmit a binary file to the server, using the standard CVS protocol * conventions. * @param file the file to transmit * @param dos the data outputstream on which to transmit the file */ void transmitBinaryFile(File file, LoggedDataOutputStream dos) throws IOException; /** * Write (either create or replace) a text file on the local machine with * one read from the server. * @param path the absolute path of the file, (including the file name). * @param mode the mode of the file * @param dis the stream to read the file from, as bytes * @param length the number of bytes to read */ void writeTextFile(String path, String mode, LoggedDataInputStream dis, int length) throws IOException; /** * Merge a text file on the local machine with * the diff from the server. (it uses the RcsDiff response format * - see cvsclient.ps for details) * @param path the absolute path of the file, (including the file name). * @param mode the mode of the file * @param dis the stream to read the file from, as bytes * @param length the number of bytes to read */ void writeRcsDiffFile(String path, String mode, LoggedDataInputStream dis, int length) throws IOException; /** * Write (either create or replace) a text file on the local machine with * one read from the server. * @param path the absolute path of the file, (including the file name). * @param mode the mode of the file * @param dis the stream to read the file from, as bytes * @param length the number of bytes to read */ void writeBinaryFile(String path, String mode, LoggedDataInputStream dis, int length) throws IOException; /** * Remove the specified file from the local disk. * If the file does not exist, the operation does nothing. * @param pathname the full path to the file to remove * @throws IOException if an IO error occurs while removing the file */ void removeLocalFile(String pathname) throws IOException; /** * Copy a local file to new destination. * If the destination file exists, the file is overwritten. * * @param pathname the full path to the file to copy * @param newName the new name of the file's copy (not the full path) * @throws IOException if an IO error occurs while copying the file */ void copyLocalFile(String pathname, String newName) throws IOException; /** * Set the modified date of the next file to be written. The next call * to writeFile will use this date. * @param modifiedDate the date the file should be marked as modified */ void setNextFileDate(Date modifiedDate); /** * Get any requests that must be sent before commands are sent, to init * this file handler. * @return an array of Requests that must be sent */ Request[] getInitialisationRequests(); /** * Sets the global options. * This can be useful to detect, whether local files should be made read-only. */ void setGlobalOptions(GlobalOptions globalOptions); } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/file/FileMode.java0000644000175300001440000000545011175407006025312 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.file; import java.io.*; /** * Implements the CVS concept of File Modes (permissions). * @author Robert Greig */ public class FileMode { /** * The underlying file */ private File file; /** * Construct a new file mode from a file. */ public FileMode(File file) { this.file = file; } /** * Returns a CVS-compatible file mode string */ public String toString() { // TODO: really implement this! return "u=rw,g=r,o=r"; //NOI18N } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/file/FileReadOnlyHandler.java0000644000175300001440000000471711175407006027446 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.file; import java.io.*; /** * @author Thomas Singer * @version Nov 17, 2001 */ public interface FileReadOnlyHandler { /** * Makes the specified file read-only or writable, depending on the specified * readOnly flag. * @throws IOException if something gone wrong */ void setFileReadOnly(File file, boolean readOnly) throws IOException; } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/file/FileStatus.java0000644000175300001440000001501011175407006025702 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.file; /** * This class provides constants for file statuses. * @author Robert Greig */ public class FileStatus { /** * Returns the corresponding FileStatus constant for the specified String. */ public static FileStatus getStatusForString(String statusString) { if (statusString == null) { return null; } if (statusString.equals(ADDED.toString())) { return ADDED; } if (statusString.equals(REMOVED.toString())) { return REMOVED; } if (statusString.equals(MODIFIED.toString())) { return MODIFIED; } if (statusString.equals(UP_TO_DATE.toString())) { return UP_TO_DATE; } if (statusString.equals(NEEDS_CHECKOUT.toString())) { return NEEDS_CHECKOUT; } if (statusString.equals(NEEDS_MERGE.toString())) { return NEEDS_MERGE; } if (statusString.equals(NEEDS_PATCH.toString())) { return NEEDS_PATCH; } if (statusString.equals(HAS_CONFLICTS.toString())) { return HAS_CONFLICTS; } if (statusString.equals(UNRESOLVED_CONFLICT.toString())) { return UNRESOLVED_CONFLICT; } if (statusString.equals(UNKNOWN.toString())) { return UNKNOWN; } if (statusString.equals(INVALID.toString())) { return INVALID; } return null; } /** * The Added status, i.e. the file has been added to the repository * but not committed yet. */ public static final FileStatus ADDED = new FileStatus("Locally Added"); //NOI18N /** * The Removed status, i.e. the file has been removed from the repository * but not committed yet */ public static final FileStatus REMOVED = new FileStatus("Locally Removed"); //NOI18N /** * The locally modified status, i.e. the file has been modified locally * and is out of sync with the repository */ public static final FileStatus MODIFIED = new FileStatus("Locally Modified"); //NOI18N /** * The up-to-date status, i.e. the file is in sync with the repository */ public static final FileStatus UP_TO_DATE = new FileStatus("Up-to-date"); //NOI18N /** * The "needs checkout" status, i.e. the file is out of sync with the * repository and needs to be updated */ public static final FileStatus NEEDS_CHECKOUT = new FileStatus("Needs Checkout"); //NOI18N /** * The "needs patch" status, i.e. the file is out of sync with the * repository and needs to be patched */ public static final FileStatus NEEDS_PATCH = new FileStatus("Needs Patch"); //NOI18N /** * The "needs merge" status, i.e. the file is locally modified and * the file in the repository has been modified too */ public static final FileStatus NEEDS_MERGE = new FileStatus("Needs Merge"); //NOI18N /** * The "conflicts" status, i.e. the file has been merged and now * has conflicts that need resolved before it can be checked-in */ public static final FileStatus HAS_CONFLICTS = new FileStatus("File had conflicts on merge"); //NOI18N /** * A file with the same name as this new file has been added to the * repository from a second workspace. This file will need to be moved out * of the way to allow an update to complete. */ public static final FileStatus UNRESOLVED_CONFLICT = new FileStatus("Unresolved Conflict"); // NOI18N /** * The unknown status, i.e. the file is not known to the CVS repository. */ public static final FileStatus UNKNOWN = new FileStatus("Unknown"); //NOI18N /** * The entry is invalid, appropriate file in CVS repository can not be found. */ public static final FileStatus INVALID = new FileStatus("Entry Invalid"); // NOI18N private final String statusString; /** * Do not construct a FileStatus object youself, but use one of the static * constants. */ private FileStatus(String statusString) { this.statusString = statusString; } /** * Returns the String representation for thiz. */ public String toString() { return statusString; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/file/FileUtils.java0000644000175300001440000001460411175407006025527 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.file; import java.io.*; /** * A utility class for file based operations. * * @author Thomas Singer * @version Nov 23, 2001 */ public class FileUtils { private static FileReadOnlyHandler fileReadOnlyHandler; /** * Returns the current FileReadOnlyHandler used by setFileReadOnly(). */ public static FileReadOnlyHandler getFileReadOnlyHandler() { return fileReadOnlyHandler; } /** * Sets the specified fileReadOnlyHandler to be used with setFileReadOnly(). */ public static void setFileReadOnlyHandler(FileReadOnlyHandler fileReadOnlyHandler) { FileUtils.fileReadOnlyHandler = fileReadOnlyHandler; } /** * Sets the specified file read-only (readOnly == true) or writable (readOnly == false). * If no fileReadOnlyHandler is set, nothing happens. * * @throws IOException if the operation failed */ public static void setFileReadOnly(File file, boolean readOnly) throws IOException { if (getFileReadOnlyHandler() == null) { return; } getFileReadOnlyHandler().setFileReadOnly(file, readOnly); } /** * Copies the specified sourceFile to the specified targetFile. */ public static void copyFile(File sourceFile, File targetFile) throws IOException { if (sourceFile == null || targetFile == null) { throw new NullPointerException("sourceFile and targetFile must not be null"); // NOI18N } // ensure existing parent directories File directory = targetFile.getParentFile(); if (!directory.exists() && !directory.mkdirs()) { throw new IOException("Could not create directory '" + directory + "'"); // NOI18N } InputStream inputStream = null; OutputStream outputStream = null; try { inputStream = new BufferedInputStream(new FileInputStream(sourceFile)); outputStream = new BufferedOutputStream(new FileOutputStream(targetFile)); try { byte[] buffer = new byte[32768]; for (int readBytes = inputStream.read(buffer); readBytes > 0; readBytes = inputStream.read(buffer)) { outputStream.write(buffer, 0, readBytes); } } catch (IOException ex) { targetFile.delete(); throw ex; } } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException ex) { // ignore } } if (outputStream != null) { try { outputStream.close(); } catch (IOException ex) { // ignore } } } } /** * Do the best to rename the file. * @param orig regular file * @param dest regular file (if exists it's rewritten) */ public static void renameFile(File orig, File dest) throws IOException { boolean destExists = dest.exists(); if (destExists) { for (int i = 0; i<3; i++) { if (dest.delete()) { destExists = false; break; } try { Thread.sleep(71); } catch (InterruptedException e) { } } } if (destExists == false) { for (int i = 0; i<3; i++) { if (orig.renameTo(dest)) { return; } try { Thread.sleep(71); } catch (InterruptedException e) { } } } // requires less permisions than renameTo FileUtils.copyFile(orig, dest); for (int i = 0; i<3; i++) { if (orig.delete()) { return; } try { Thread.sleep(71); } catch (InterruptedException e) { } } throw new IOException("Can not delete: " + orig.getAbsolutePath()); // NOI18N } /** * This utility class needs not to be instantiated anywhere. */ private FileUtils() { } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/file/GzippedFileHandler.java0000644000175300001440000000502711175407006027326 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * * Contributor(s): Robert Greig, Milos Kleint. *****************************************************************************/ package org.netbeans.lib.cvsclient.file; import java.io.*; import java.util.zip.*; import org.netbeans.lib.cvsclient.request.*; /** * Handles the reading and writing of Compressed files to and from the * server. * @author Milos Kleint */ public class GzippedFileHandler extends DefaultFileHandler { /** * Indicates whether the file is actually compressed */ private boolean isCompressed; /** * Get any requests that must be sent before commands are sent, to init * this file handler. * @return an array of Requests that must be sent */ public Request[] getInitialisationRequests() { return new Request[]{ new GzipStreamRequest() }; } protected Reader getProcessedReader(File f) throws IOException { return new InputStreamReader(new GZIPInputStream(new FileInputStream(f))); } protected InputStream getProcessedInputStream(File f) throws IOException { return new GZIPInputStream(new FileInputStream(f)); } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/file/OutputStreamProvider.java0000644000175300001440000000450311175407006030013 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.file; import java.io.OutputStream; import java.io.IOException; /** * Custom output stream factory. * * @author Petr Kuzel */ public interface OutputStreamProvider { OutputStream createOutputStream() throws IOException; } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/file/TransmitTextFilePreprocessor.java0000644000175300001440000000560011175407006031500 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Thomas Singer. * Portions created by Thomas Singer are Copyright (C) 2001. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Thomas Singer. *****************************************************************************/ package org.netbeans.lib.cvsclient.file; import java.io.*; /** * Preprocesses the text file before transmitting to the server. * @author Thomas Singer */ public interface TransmitTextFilePreprocessor { /** * Generates the preprocessed text file from the original text file. */ File getPreprocessedTextFile(File originalTextFile) throws IOException; /** * Cleans up the preprocessed text file after sending it. */ void cleanup(File preprocessedTextFile); /** * Set the temporary directory that is to be used to create temporary files. */ void setTempDir(File tempDir); } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/file/WindowsFileReadOnlyHandler.java0000644000175300001440000000624111175407006031013 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.file; import java.io.*; import org.netbeans.lib.cvsclient.util.*; /** * @author Thomas Singer * @version Nov 17, 2001 */ public class WindowsFileReadOnlyHandler implements FileReadOnlyHandler { // Implemented ============================================================ /** * Makes the specified file read-only or writable, depending on the specified * readOnly flag. * @throws IOException if something gone wrong */ public void setFileReadOnly(File file, boolean readOnly) throws IOException { if (file == null) { throw new IllegalArgumentException("file must not be null"); // NOI18N } try { String[] arguments = { "attrib", // NOI18N readOnly ? "+r": "-r", // NOI18N file.getName() }; Process process = Runtime.getRuntime().exec(arguments, null, file.getParentFile()); process.waitFor(); } catch (InterruptedException ex) { BugLog.getInstance().showException(ex); } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/file/WriteRcsDiffFilePreprocessor.java0000644000175300001440000003655211175407006031377 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.file; import java.io.*; import org.netbeans.lib.cvsclient.util.*; /** * File Processor that handles processing of rcs-diff response. * (aka diff -n format) The original file is read and a merge is created. * At the same time the correct line-ending is processed. * It's possible to set the processor the preffered line-ending. * The default is dependant on the platform. * * @author Milos Kleint */ public class WriteRcsDiffFilePreprocessor implements WriteTextFilePreprocessor { private static final int CHUNK_SIZE = 32768; private static final int READ_REMAINING = -2; /** * line ending that will be used when writing the final result file. */ private String lineEnding = System.getProperty("line.separator"); public WriteRcsDiffFilePreprocessor() { } /** * Gets the value of lineending used when writing the resulting file. * @return Value of property lineEnding. */ public String getLineEnding() { return lineEnding; } /** * Setter for lineEnding used to write the file. * @param lineEnding New value of property lineEnding. */ public void setLineEnding(String lineEnding) { this.lineEnding = lineEnding; } /** * Processes the diff and merges it with the original file. * @param processedInput the stored diff. * @param fileToWrite the resulting file and * the original that is merged as the same time. * @param customOutput * @throws IOException if any IO operation fails. * The original file is replaced by the merge only if no excpetion is thrown. */ public void copyTextFileToLocation(InputStream processedInput, File fileToWrite, OutputStreamProvider customOutput) throws IOException { // Here we read the temp file in again, doing any processing required // (for example, unzipping). We must not convert the bytes to characters // because this would corrupt files, that were written in an encoding // different from the current encoding. ReadInfo tempFileReader = null; OutputStream out = null; ReadInfo tempDiffReader = null; File tempFile = null; // BUGLOG.. assert the fileToWrite Exists.. otherwise it has no sense. try { tempDiffReader = new ReadInfo(new BufferedInputStream(processedInput)); tempFileReader = new ReadInfo(new BufferedInputStream(new FileInputStream(fileToWrite))); tempFile = File.createTempFile(".#merg", "cvs"); //NOI18N out = new BufferedOutputStream(new FileOutputStream(tempFile)); int fileStart = 0; int diffCount = 0; byte[] diff = tempDiffReader.readLine(); while (diff != null && diff.length > 0) { // System.out.println("diffline=" + diff); if (diff[0] == 'd') { // now do delete.. int startLine = getStart(diff); int count = getLength(diff); // System.out.println("deleting. start =" + startLine + " count=" + count); if (startLine >= 0 && count > 0) { // read from file only if deletion is not some // from the beginning.. readToLine(startLine - 1, tempFileReader, out); readToLine(startLine - 1 + count, tempFileReader, null); // null skips the lines.. } else { // BugLog.. BugLog.getInstance().bug("wrong parsing.." + new String(diff)); throw new IOException(); // Interrupt the merging process so that the file is not corrupted. } } else if (diff[0] == 'a') { // now add lines from the diff.. int startLine = getStart(diff); int count = getLength(diff); // System.out.println("adding.. start =" + startLine + " count=" + count); if (startLine >= 0 && count > 0) { readToLine(startLine, tempFileReader, out); tempDiffReader.setLineNumber(0); readToLine(count, tempDiffReader, out); } else { // BugLog.. BugLog.getInstance().bug("wrong parsing.." + new String(diff)); throw new IOException(); // Interrupt the merging process so that the file is not corrupted. } } // now process next difference. diff = tempDiffReader.readLine(); } // read what's remaining.. readToLine(READ_REMAINING, tempFileReader, out); if (tempFile != null) { tempFileReader.close(); out.close(); InputStream in = null; OutputStream customOutputStream = customOutput.createOutputStream(); try { in = new BufferedInputStream(new FileInputStream(tempFile)); while (true) { int ch = in.read(); if (ch == -1) { break; } customOutputStream.write(ch); } } finally { if (in != null) { try { in.close(); } catch (IOException ex) { } } try { customOutputStream.close(); } catch (IOException ex) { } } } } catch (Exception exc) { BugLog.getInstance().showException(exc); } finally { if (tempDiffReader != null) { try { tempDiffReader.close(); } catch (IOException ex) { // ignore } } if (tempFileReader != null) { try { tempFileReader.close(); } catch (IOException ex) { // ignore } } if (out != null) { try { out.close(); } catch (IOException ex) { // ignore } } if (tempFile != null) { tempFile.delete(); } } } /** * Reads lines from the reader until the specified line number is reached. * Writes the lines to the writer * @param finalLine the last line to read/write. Special value -2 reads * all that is remaining in the reader. * @param reader - does not accept null. * @param writer the writer that the read lines are written to. Accepts null. * In such a case the read lines are discarded. */ private void readToLine(int finalLine, final ReadInfo reader, final OutputStream out) throws IOException { byte[] line; while (reader.getLineNumber() < finalLine || finalLine == READ_REMAINING) { line = reader.readLine(); if (line == null) { // end of file.. return; } if (out != null) { out.write(line); out.write(getLineEnding().getBytes()); } } } private static int indexOf(byte[] bytes, byte b) { return indexOf(bytes, b, 0); } private static int indexOf(byte[] bytes, byte b, int start) { int index = -1; for (int i = start; i < bytes.length; i++) { if (bytes[i] == b) { index = i; break; } } return index; } /** * Extracts the line where the diff starts. */ private static int getStart(byte[] diffLine) { int spacePos = indexOf(diffLine, (byte) ' '); if (spacePos > 0) { String number = new String(diffLine, 1, spacePos - 1); try { int toReturn = Integer.parseInt(number); return toReturn; } catch (NumberFormatException exc) { // System.out.println("diffLine=" + diffLine); return -1; } } // System.out.println("no space in diffline=" + diffLine); return -1; } /** * Extracts the length of the diff. * For "delete" it means how many lines to delete from original. * For "add" it means how many lines are added from the diff to original file. */ private static int getLength(byte[] diffLine) { //String trimmed = diffLine.trim(); int spacePos = indexOf(diffLine, (byte) ' '); if (spacePos > 0) { int end = indexOf(diffLine, (byte) ' ', spacePos + 1); if (end < 0) end = diffLine.length; String number = new String(diffLine, spacePos + 1, end - spacePos - 1); try { int toReturn = Integer.parseInt(number); return toReturn; } catch (NumberFormatException exc) { // System.out.println("numformat exception..=" + diffLine); return -1; } } // System.out.println("no space in diffline=" + diffLine); return -1; } private static class ReadInfo { private static final boolean crLines = "\r".equals(System.getProperty("line.separator")); private PushbackInputStream in; private int readLength; private int startIndex; private int lineNumber; private ByteArray line; public ReadInfo(InputStream in) { this.in = new PushbackInputStream(in, 1); readLength = -1; startIndex = 0; lineNumber = 0; line = new ByteArray(); } public int getLineNumber() { return lineNumber; } public void setLineNumber(int lineNumber) { this.lineNumber = lineNumber; } /** * Reads a line. The line-termination bytes are not added. * @return null When the end of the stream is reached. */ public byte[] readLine() throws IOException { line.reset(); boolean end = false; do { int b = in.read(); if (b == -1) { end = true; break; } if (b == '\n') { lineNumber++; break; } if (b == '\r') { int next = in.read(); if (next == '\n') { lineNumber++; break; } in.unread(next); if (crLines) { lineNumber++; break; } } line.add((byte) b); } while (true); byte[] bytes = line.getBytes(); if (end && bytes.length == 0) { bytes = null; } return bytes; /* StringBuffer toReturn = new StringBuffer(); while (true) { if (startIndex > readLength) { // System.out.println("reading.."); readLength = reader.read(cchunk); // System.out.println("read=" + readLength); startIndex = 0; } if (startIndex >= readLength) { readLength = -1; if (toReturn.length() == 0) { return null; } else { lineNumber = lineNumber + 1; return toReturn.toString(); } } // System.out.println("startindex = " + startIndex + " length=" + readLength); for (int i = startIndex; i < readLength; i++) { if (cchunk[i] == '\n') { toReturn.append(WriteRcsDiffFilePreprocessor.this.getLineEnding()); startIndex = i + 1; lineNumber = lineNumber + 1; // System.out.println("linenum=" + lineNumber); // System.out.println("line=" + toReturn.toString() + "--"); return toReturn.toString(); } else { // could be maybe made faster by appending the whole array when // read all or encountering the newline.. toReturn.append(cchunk[i]); } } startIndex = readLength; } */ } public void close() throws IOException { if (in != null) { in.close(); } } } // end of inner class.. } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/file/WriteTextFilePreprocessor.java0000644000175300001440000000512711175407006030775 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Thomas Singer. * Portions created by Thomas Singer are Copyright (C) 2001. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Thomas Singer. *****************************************************************************/ package org.netbeans.lib.cvsclient.file; import java.io.*; /** * Preprocesses the text file after getting from server. * @author Thomas Singer */ public interface WriteTextFilePreprocessor { void copyTextFileToLocation(InputStream processedInputStream, File fileToWrite, OutputStreamProvider customOutput) throws IOException; } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/0000755000175300001440000000000011175434236023535 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/ArgumentRequest.java0000644000175300001440000000754211175407006027536 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.request; /** * The Argument request. The server saves the specified argument for use in * a future argument-using command * @author Robert Greig */ public class ArgumentRequest extends Request { /** * The argument to pass in */ private final String argument; private final boolean escapeLeadingDash; /** * Create a new request * @param theArgument the argument to use */ public ArgumentRequest(String argument) { this(argument, false); } /** * Create a new request * @param theArgument the argument to use * @param escapeLeadingDash true to escape leasding dash in the argument with another "--" Argument request, false otherwise */ public ArgumentRequest(String argument, boolean escapeLeadingDash) { this.escapeLeadingDash = escapeLeadingDash; if (argument == null) { throw new IllegalArgumentException("argument must not be null!"); // NOI18N } this.argument = argument; } /** * Get the request String that will be passed to the server * @return the request String */ public String getRequestString() { if (escapeLeadingDash && argument.startsWith("-")) { return "Argument --\nArgument " + argument + "\n"; //NOI18N } return "Argument " + argument + "\n"; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return false; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/ArgumentxRequest.java0000644000175300001440000000670411175407006027725 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.request; /** * Appends \n followed by the text specified in the request to the previous * argument sent. * @author Robert Greig */ public class ArgumentxRequest extends Request { /** * The argument to pass in */ private String argument; /** * Create a new request * @param theArgument the argument to use */ public ArgumentxRequest(String theArgument) { argument = theArgument; } /** * Set the argument */ public void setArgument(String theArgument) { argument = theArgument; } /** * Get the request String that will be passed to the server * @return the request String */ public String getRequestString() throws UnconfiguredRequestException { if (argument == null) { throw new UnconfiguredRequestException( "Argument has not been set"); } return "Argumentx " + argument + "\n"; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return false; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/CaseRequest.java0000644000175300001440000000576411175407006026633 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.request; /** * Tells the server that filenames should be matched in a case-insensitive * fashion. * @author Robert Greig */ public class CaseRequest extends Request { /** * Get the request String that will be passed to the server * @return the request String * @throws UnconfiguredRequestException if the request has not been * properly configured */ public String getRequestString() throws UnconfiguredRequestException { return "Case \n"; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return false; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/CommandRequest.java0000644000175300001440000001124311175407006027323 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.request; /** * The request for a command. * Always a response is expected. * * @author Thomas Singer */ public class CommandRequest extends Request { public static final CommandRequest ADD = new CommandRequest("add\n"); //NOI18N public static final CommandRequest ANNOTATE = new CommandRequest("annotate\n"); //NOI18N public static final CommandRequest CHECKOUT = new CommandRequest("co\n"); //NOI18N public static final CommandRequest COMMIT = new CommandRequest("ci\n"); //NOI18N public static final CommandRequest DIFF = new CommandRequest("diff\n"); //NOI18N public static final CommandRequest EDITORS = new CommandRequest("editors\n"); //NOI18N public static final CommandRequest EXPORT = new CommandRequest("export\n"); //NOI18N public static final CommandRequest HISTORY = new CommandRequest("history\n"); //NOI18N public static final CommandRequest IMPORT = new CommandRequest("import\n"); //NOI18N public static final CommandRequest LOG = new CommandRequest("log\n"); //NOI18N public static final CommandRequest NOOP = new CommandRequest("noop\n"); //NOI18N public static final CommandRequest RANNOTATE = new CommandRequest("rannotate\n"); //NOI18N public static final CommandRequest REMOVE = new CommandRequest("remove\n"); //NOI18N public static final CommandRequest RLOG = new CommandRequest("rlog\n"); //NOI18N public static final CommandRequest RTAG = new CommandRequest("rtag\n"); //NOI18N public static final CommandRequest STATUS = new CommandRequest("status\n"); //NOI18N public static final CommandRequest TAG = new CommandRequest("tag\n"); //NOI18N public static final CommandRequest UPDATE = new CommandRequest("update\n"); //NOI18N public static final CommandRequest WATCH_ADD = new CommandRequest("watch-add\n"); //NOI18N public static final CommandRequest WATCH_ON = new CommandRequest("watch-on\n"); //NOI18N public static final CommandRequest WATCH_OFF = new CommandRequest("watch-off\n"); //NOI18N public static final CommandRequest WATCH_REMOVE = new CommandRequest("watch-remove\n"); //NOI18N public static final CommandRequest WATCHERS = new CommandRequest("watchers\n"); //NOI18N private final String request; private CommandRequest(String request) { this.request = request; } /** * Get the request String that will be passed to the server. */ public String getRequestString() { return request; } /** * Returns true if a response from the server is expected. */ public boolean isResponseExpected() { return true; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/DirectoryRequest.java0000644000175300001440000000757411175407006027725 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.request; /** * The directory request. Tell the server which directory to use. * @author Robert Greig */ public final class DirectoryRequest extends Request { /** * The local directory. Used as the first argument */ private final String localDirectory; /** * The repository. The second argument */ private final String repository; /** * Create a new DirectoryRequest * @param theLocalDirectory the local directory argument * @param theRepository the repository argument */ public DirectoryRequest(String localDirectory, String repository) { if (localDirectory == null || repository == null) { throw new IllegalArgumentException("Both, directory and repository, must not be null!"); } this.localDirectory = localDirectory; this.repository = repository; } /** * Returns the value of used local directory. */ public String getLocalDirectory() { return localDirectory; } /** * Returns the value of used repository directory. */ public String getRepository() { return repository; } /** * Get the request String that will be passed to the server * @return the request String */ public String getRequestString() { return "Directory " + localDirectory + "\n" + repository + "\n"; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/EntryRequest.java0000644000175300001440000001023511175407006027046 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.request; import org.netbeans.lib.cvsclient.admin.*; /** * Sends an entry to the server, to tell the server which version of a file * is on the local machine. The filename is relative to the most recent * Directory request. Note that if an

Entry
request is sent * without
Modified
,
Is-Modified
or
Unchanged
* it means that the file is lost. Also note that if
Modified
, *
Is-Modified
or Unchanged is sent with
Entry
 * 
then Entry must be sent first. * @author Robert Greig * @see org.netbeans.lib.cvsclient.request.DirectoryRequest * @see org.netbeans.lib.cvsclient.request.ModifiedRequest * @see org.netbeans.lib.cvsclient.request.ModifiedRequest * @see org.netbeans.lib.cvsclient.request.UnchangedRequest */ public class EntryRequest extends Request { /** * The Entry sent by this request */ private Entry entry; /** * Create an EntryRequest * @param theEntry the Entry to send */ public EntryRequest(Entry theEntry) { if (theEntry == null) throw new IllegalArgumentException("EntryRequest: Entry must not " + "be null"); entry = theEntry; } /** * Get the request String that will be passed to the server * @return the request String * @throws UnconfiguredRequestException if the request has not been * properly configured */ public String getRequestString() throws UnconfiguredRequestException { return "Entry " + entry.toString() + "\n"; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return false; } public Entry getEntry() { return entry; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/ExpandModulesRequest.java0000644000175300001440000000670411175407006030523 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.request; /** * Sends the expand-modules request. This request expands the modules which * have been specified in previous argument requests. The server can assume * this is a checkout or export.
* Expand is not the best word for what this request does. It does not * expand a module in any meaningful way. What it does is ask the server * to tell you which working directories the server needs to know about in * order to handle a checkout of a specific module. This is important where * you have aliased modules. If you alias module foo as bar, then you need * to know when you do a checkout of foo that bar on disk is an existing * checkout of the module. * @author Robert Greig * @see org.netbeans.lib.cvsclient.response.ModuleExpansionResponse */ public class ExpandModulesRequest extends Request { /** * Get the request String that will be passed to the server * @return the request String * @throws UnconfiguredRequestException if the request has not been * properly configured */ public String getRequestString() throws UnconfiguredRequestException { return "expand-modules \n"; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return true; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/GlobalOptionRequest.java0000644000175300001440000000616411175407007030345 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.request; /** * The global options request. * Sends global switch to the server. * * @author Milos Kleint */ public class GlobalOptionRequest extends Request { /** * The option to pass in. */ private final String option; /** * Create a new request * @param theOption the option to use */ public GlobalOptionRequest(String option) { this.option = option; } /** * Get the request String that will be passed to the server. * @return the request String */ public String getRequestString() throws UnconfiguredRequestException { if (option == null) { throw new UnconfiguredRequestException( "Global option has not been set"); } return "Global_option " + option + "\n"; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return false; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/GzipFileContentsRequest.java0000644000175300001440000000673011175407007031202 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.request; /** * Sends the request that instructs the server to gzip all file transfers * @author Robert Greig */ public class GzipFileContentsRequest extends Request { private int compressionLevel; /** * Creates new GzipFileContentsRequest. * Compression level '6' is used by default. */ public GzipFileContentsRequest() { this(6); } /** * Creates new GzipFileContentsRequest. * @param compressionLevel The desired compression level. */ public GzipFileContentsRequest(int compressionLevel) { this.compressionLevel = compressionLevel; } /** * Get the request String that will be passed to the server * @return the request String * @throws UnconfiguredRequestException if the request has not been * properly configured */ public String getRequestString() throws UnconfiguredRequestException { return "gzip-file-contents "+compressionLevel+" \n"; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/GzipStreamRequest.java0000644000175300001440000001016511175407007030035 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.request; import java.io.*; import org.netbeans.lib.cvsclient.connection.*; /** * This class implements the Gzip-Stream request that is used to indicate that * all further communication with the server is to be gzipped. * @author Robert Greig */ public class GzipStreamRequest extends Request { /** * The level of gzipping to specify */ private int level = 6; /** * Creates new GzipStreamRequest with gzip level 6 */ public GzipStreamRequest() { } /** * Creates new GzipStreamRequest * @param level the level of zipping to use (between 1 and 9) */ public GzipStreamRequest(int level) { this.level = level; } /** * Get the request String that will be passed to the server * @return the request String * @throws UnconfiguredRequestException if the request has not been * properly configured */ public String getRequestString() throws UnconfiguredRequestException { return "Gzip-stream " + level + "\n"; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return false; } /** * Modify streams on the connection if necessary */ public void modifyOutputStream(Connection connection) throws IOException { connection.modifyOutputStream(new GzipModifier()); } /** * Modify streams on the connection if necessary */ public void modifyInputStream(Connection connection) throws IOException { connection.modifyInputStream(new GzipModifier()); } /** * Does this request modify the input stream? * @return true if it does, false otherwise */ public boolean modifiesInputStream() { return true; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/IsModifiedRequest.java0000644000175300001440000000522011175407007027760 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.request; import java.io.File; /** * Represents Is-modified filename \n request. * It's faster alternative to Modified but must be used with * care see protocol specs. * * @author Petr Kuzel */ public final class IsModifiedRequest extends Request { private final String fileName; public IsModifiedRequest(File file) { fileName = file.getName(); } public String getRequestString() { return "Is-modified " + fileName + "\n"; // NOI18N } public boolean isResponseExpected() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/KoptRequest.java0000644000175300001440000000517011175407007026665 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.request; /** * Represents Kopt option\n request. * * @author Petr Kuzel */ public class KoptRequest extends Request { private final String option; /** * @param option >i>option terminal from C/S protol specification. */ public KoptRequest(String option) { this.option = option; } public String getRequestString() throws UnconfiguredRequestException { return "Kopt " + option + "\n"; // NOI!8N } public boolean isResponseExpected() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/ModifiedRequest.java0000644000175300001440000001015311175407007027465 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.request; import java.io.*; import org.netbeans.lib.cvsclient.file.*; /** * Sends the server a copy of a locally modified file. * @author Robert Greig */ public class ModifiedRequest extends Request { /** * The file details */ private FileDetails fileDetails; /** * Construct a new modified request. * @param theFile the file that has been modified */ public ModifiedRequest(File file, boolean isBinary) { fileDetails = new FileDetails(file, isBinary); } /** * Get the request String that will be passed to the server * @return the request String * @throws UnconfiguredRequestException if the request has not been * properly configured */ public String getRequestString() throws UnconfiguredRequestException { if (fileDetails == null) { throw new UnconfiguredRequestException("FileDetails is null in " + "ModifiedRequest"); } final FileMode mode = new FileMode(fileDetails.getFile()); return "Modified " + fileDetails.getFile().getName() + "\n" + //NOI18N mode.toString() + "\n"; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return false; } /** * If a file transmission is required, get the file object representing * the file to transmit after the request string. The default * implementation returns null, indicating no file is to be transmitted * @return the file details object, if one should be transmitted, or null * if no file object is to be transmitted. */ public FileDetails getFileForTransmission() { return fileDetails; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/NotifyRequest.java0000644000175300001440000001024611175407007027220 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.request; import java.io.*; import java.net.*; import java.text.*; import java.util.*; /** * Notify Entry.java * E Sun Nov 11 10:25:40 2001 GMT worker E:\test\admin EUC * * @author Thomas Singer * @version Nov 14, 2001 */ public class NotifyRequest extends Request { // Constants ============================================================== private static final DateFormat DATE_FORMAT; private static final String HOST_NAME; static { DATE_FORMAT = new SimpleDateFormat("EEE MMM dd hh:mm:ss yyyy z", Locale.US); // detect host name String hostName = ""; try { hostName = InetAddress.getLocalHost().getHostName(); } catch (Exception ex) { ex.printStackTrace(); } HOST_NAME = hostName; } // Fields ================================================================= private final String request; // Setup ================================================================== /** * Creates an NotifyRequest for the specified file. * If the specified file is null, a IllegalArgumentException is thrown. */ public NotifyRequest(File file, String command, String parameters) { if (file == null) { throw new IllegalArgumentException("File must not be null!"); } StringBuffer buffer = new StringBuffer(); buffer.append("Notify "); // NOI18N buffer.append(file.getName()); buffer.append('\n'); buffer.append(command); buffer.append('\t'); buffer.append(DATE_FORMAT.format(new Date())); buffer.append('\t'); buffer.append(HOST_NAME); buffer.append('\t'); buffer.append(file.getParent()); buffer.append('\t'); buffer.append(parameters); buffer.append('\n'); this.request = buffer.toString(); } // Implemented ============================================================ public String getRequestString() { return request; } public boolean isResponseExpected() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/QuestionableRequest.java0000644000175300001440000000661311175407007030406 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.request; /** * The questionable request. Tell the server which directory to use. * @author Milos Kleint */ public final class QuestionableRequest extends Request { /** * name of file that is questionable */ private String questionFile; /** * Create a new QuestionableRequest * @param fileName name of the file that is questionable. */ public QuestionableRequest(String questionFile) { this.questionFile = questionFile; } /** * Get the request String that will be passed to the server * @return the request String */ public String getRequestString() throws UnconfiguredRequestException { if (questionFile == null) { throw new UnconfiguredRequestException( "Questionable request has not been configured"); } return "Questionable " + questionFile + "\n"; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/Request.java0000644000175300001440000000773011175407007026033 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.request; import java.io.*; import org.netbeans.lib.cvsclient.connection.*; import org.netbeans.lib.cvsclient.file.*; /** * The superclass of all requests made to the CVS server * @author Robert Greig */ public abstract class Request { /** * Get the request String that will be passed to the server * @return the request String * @throws UnconfiguredRequestException if the request has not been * properly configured */ public abstract String getRequestString() throws UnconfiguredRequestException; /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public abstract boolean isResponseExpected(); /** * If a file transmission is required, get the file object representing * the file to transmit after the request string. The default * implementation returns null, indicating no file is to be transmitted * @return the file object, if one should be transmitted, or null if * no file object is to be transmitted. */ public FileDetails getFileForTransmission() { return null; } /** * Modify streams on the connection if necessary */ public void modifyOutputStream(Connection connection) throws IOException { // DO NOTHING } /** * Modify streams on the connection if necessary */ public void modifyInputStream(Connection connection) throws IOException { // DO NOTHING } /** * Does this request modify the input stream? * @return true if it does, false otherwise */ public boolean modifiesInputStream() { return false; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/RootRequest.java0000644000175300001440000000641711175407007026700 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.request; /** * Implements the Root request * @author Robert Greig */ public final class RootRequest extends Request { /** * The CVS root to send. */ private final String cvsRoot; /** * Construct a new Root request * @param cvsRoot the CVS root to use as an argument in the request */ public RootRequest(String cvsRoot) { if (cvsRoot == null) { throw new IllegalArgumentException("cvsRoot must not be null!"); // NOI18N } this.cvsRoot = cvsRoot; } /** * Get the request String that will be passed to the server * @return the request String */ public String getRequestString() throws UnconfiguredRequestException { return "Root " + cvsRoot + "\n"; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return false; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/SetRequest.java0000644000175300001440000000631611175407007026506 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.request; import org.netbeans.lib.cvsclient.util.*; /** * Tells the server about the eviroment variables to set for CVSROOT/*info executions. * @author Milos Kleint */ public class SetRequest extends Request { private String keyValue; /** * Creates a new SetResponse with the key-value pair for one enviroment variable. */ public SetRequest(String keyValue) { BugLog.getInstance().assertTrue(keyValue.indexOf('=') > 0, "Wrong SetRequest=" + keyValue); this.keyValue = keyValue; } /** * Get the request String that will be passed to the server * @return the request String * @throws UnconfiguredRequestException if the request has not been * properly configured */ public String getRequestString() throws UnconfiguredRequestException { String toReturn = "Set " + keyValue + "\n"; //NOI18N return toReturn; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return false; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/StickyRequest.java0000644000175300001440000000626211175407007027221 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.request; /** * Implements the Sticky request * @author Milos Kleint */ public final class StickyRequest extends Request { /** * The sticky tag/date to send */ private String sticky; /** * Construct a new Sticky request * @param theStickyTag the sticky tag to use as an argument in the request */ public StickyRequest(String theStickyTag) { sticky = theStickyTag; } /** * Get the request String that will be passed to the server * @return the request String */ public String getRequestString() throws UnconfiguredRequestException { if (sticky == null) { throw new UnconfiguredRequestException( "Sticky tag has not been set"); } return "Sticky " + sticky + "\n"; //NOI18N } public void setStickyTag(String tag) { sticky = tag; } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return false; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/UnchangedRequest.java0000644000175300001440000000715411175407007027650 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.request; import java.io.*; /** * Tells the server that a particular filename has not been modified in the * checked-out directory. * @author Robert Greig */ public class UnchangedRequest extends Request { /** * The filename of the file that is unchanged */ private String filename; /** * Construct an Unchanged request * @param theFilename the unchanged file's name */ public UnchangedRequest(String theFilename) { filename = theFilename; } /** * Construct an Unchanged request * @param file the unchanged file */ public UnchangedRequest(File file) { filename = file.getName(); } /** * Get the request String that will be passed to the server * @return the request String * @throws UnconfiguredRequestException if the request has not been * properly configured */ public String getRequestString() throws UnconfiguredRequestException { if (filename == null) throw new UnconfiguredRequestException("Filename must be set"); return "Unchanged " + filename + "\n"; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return false; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/UnconfiguredRequestException.java0000644000175300001440000000523311175407007032257 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.request; /** * This exception indicates that a request has not been properly configured * hence cannot be sent to the server for processing * @author Robert Greig */ public class UnconfiguredRequestException extends Exception { public UnconfiguredRequestException() { super(); } public UnconfiguredRequestException(String s) { super(s); } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/UseUnchangedRequest.java0000644000175300001440000000570011175407007030320 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.request; /** * Issues the UseUnchanged request, which tells servers that the client * is using version 1.10 of the CVS protocol. * @author Robert Greig */ public class UseUnchangedRequest extends Request { /** * Get the request String that will be passed to the server * @return the request String */ public String getRequestString() throws UnconfiguredRequestException { return "UseUnchanged \n"; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return false; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/ValidRequestsRequest.java0000644000175300001440000000605311175407007030544 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.request; /** * Asks the server to send back a Valid-requests response * @author Robert Greig * @see org.netbeans.lib.cvsclient.response.ValidRequestsResponse */ public class ValidRequestsRequest extends Request { /** * Get the request String that will be passed to the server * @return the request String * @throws UnconfiguredRequestException if the request has not been * properly configured */ public String getRequestString() throws UnconfiguredRequestException { return "valid-requests \n"; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return true; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/ValidResponsesRequest.java0000644000175300001440000000673611175407007030722 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.request; /** * Sends a request telling the server which responses this client understands. * This request should be sent before any commands are executed. This is done * automatically by the Client class. * @see org.netbeans.lib.cvsclient.Client * @author Robert Greig */ public class ValidResponsesRequest extends Request { /** * Get the request String that will be passed to the server * @return the request String * @throws UnconfiguredRequestException if the request has not been * properly configured */ public String getRequestString() throws UnconfiguredRequestException { return "Valid-responses E M MT Mbinary Updated Created Update-existing Rcs-diff Checked-in ok error " + //NOI18N "Clear-static-directory Valid-requests Merged Removed " + //NOI18N "Copy-file Mod-time Template Set-static-directory " + //NOI18N "Module-expansion Clear-sticky Set-sticky New-entry\n"; //NOI18N } /** * Is a response expected from the server? * @return true if a response is expected, false if no response if * expected */ public boolean isResponseExpected() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/request/WrapperSendRequest.java0000644000175300001440000000565711175407007030214 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.request; /** * This class encapsulates the wrapper-sendme-rcsOptions request in the * CVS client-server protocol. This request is used by the client to get * the wrapper settings on the server. * @author Sriram Seshan */ public class WrapperSendRequest extends Request { /** Get the request String that will be passed to the server * @return the request String * @throws UnconfiguredRequestException if the request has not been * properly configured * */ public String getRequestString() throws UnconfiguredRequestException { return "wrapper-sendme-rcsOptions \n"; } /** Is a response expected from the server? * @return true if a response is expected, false if no response if * expected * */ public boolean isResponseExpected() { return true; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/0000755000175300001440000000000011175434236023703 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/Bundle.properties0000644000175300001440000000057711175407007027237 0ustar ludousersBK0001=Received unknown response from server\:\

{0}\

Check your setup please\:\

    \
  • Are you connecting to supported CVS server?\
  • Is not misconfigured CVS_SERVER{1} environment variable?\
  • For \:local\: repositories\:
    \ What cvs binary is executed?
    \ It is defined by CVS_EXE{2} environment variable.\
netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/CheckedInResponse.java0000644000175300001440000001241211175407007030076 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.io.*; import java.util.*; import java.text.*; import org.netbeans.lib.cvsclient.admin.*; import org.netbeans.lib.cvsclient.util.*; /** * Indicates that a file has been successfully operated on, e.g. checked in, * added etc. * @author Robert Greig */ class CheckedInResponse implements Response { /** * The date Formatter used to parse and format dates. * Format is: "EEE MMM dd HH:mm:ss yyyy" */ private DateFormat dateFormatter; /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { String localPath = dis.readLine(); //System.err.println("Pathname is: " + localPath); String repositoryPath = dis.readLine(); //System.err.println("Repository path is: " + repositoryPath); String entriesLine = dis.readLine(); //System.err.println("New entries line is: " + entriesLine); String absPath = services.convertPathname(localPath, repositoryPath); if (services.getGlobalOptions().isExcluded(new File(absPath))) { return; } // we set the date the file was last modified in the Entry line // so that we can easily determine whether the file has been // untouched final File theFile = new File(absPath); final Date date = new Date(theFile.lastModified()); final Entry entry = new Entry(entriesLine); entry.setConflict(getDateFormatter().format(date)); // for added and removed entries set the conflict to Dummy timestamp. if (entry.isNewUserFile() || entry.isUserFileToBeRemoved()) { entry.setConflict(Entry.DUMMY_TIMESTAMP); } services.setEntry(theFile, entry); } catch (IOException e) { throw new ResponseException((Exception)e.fillInStackTrace(), e.getLocalizedMessage()); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } /** * Returns the DateFormatter instance that parses and formats date Strings. * The exact format matches the one in Entry.getLastModifiedDateFormatter() method. * */ protected DateFormat getDateFormatter() { if (dateFormatter == null) { dateFormatter = Entry.getLastModifiedDateFormatter(); } return dateFormatter; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/ClearStaticDirectoryResponse.java0000644000175300001440000001031711175407007032346 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.util.*; /** * Handles the Clear-static-directory response. * @author Robert Greig */ class ClearStaticDirectoryResponse implements Response { /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { final String localPath = dis.readLine(); final String repositoryPath = dis.readLine(); final String absPath = services.convertPathname(localPath, repositoryPath); if (services.getGlobalOptions().isExcluded(new File(absPath))) { return; } //System.err.println("Repository path is: " + repositoryPath); // It looks like it's not necessary to call updateAdminData(), // because all it does is that it creates CVS/ folder with empty // Entries if there is not one. This cause problems like issue #42267. // However, the removal of this has caused issue #52296. Added back: services.updateAdminData(localPath, repositoryPath, null); File absFile = new File(absPath, "CVS/Entries.Static"); //NOI18N if (absFile.exists()) { absFile.delete(); } } catch (IOException e) { throw new ResponseException(e); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/ClearStickyResponse.java0000644000175300001440000000743311175407007030505 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.util.*; /** * Handles the Clear-sticky response. * @author Milos Kleint */ class ClearStickyResponse implements Response { /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { final String localPath = dis.readLine(); final String repositoryPath = dis.readLine(); //System.err.println("Repository path is: " + repositoryPath); final String absPath = services.convertPathname(localPath, repositoryPath); if (services.getGlobalOptions().isExcluded(new File(absPath))) { return; } services.updateAdminData(localPath, repositoryPath, null); // TODO: remove the Entries.static file (check user manual for // file name first) File absFile = new File(absPath, "CVS/Tag"); //NOI18N if (absFile.exists()) { absFile.delete(); } } catch (IOException e) { throw new ResponseException(e); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/CopyFileResponse.java0000644000175300001440000001064711175407007030003 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.util.*; /** * This means that the server wants the local machine to copy a file in the * local file space. This is usually requested after a conflict (to allow the * user to keep the original file unaltered). * @author Robert Greig */ class CopyFileResponse implements Response { /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { // System.err.println("Got copy file response."); String localPath = dis.readLine(); // System.err.println("LocalPath is: " + localPath); String repositoryPath = dis.readLine(); // System.err.println("Repository path is: " + repositoryPath); String newname = dis.readLine(); // System.err.println("New name is: " + newname); final String absPath = services.convertPathname(localPath, repositoryPath); if (services.getGlobalOptions().isExcluded(new File(absPath))) { return; } if (!services.getGlobalOptions().isDoNoChanges()) { services.removeLocalFile(new File(new File(absPath).getParentFile(), newname).getAbsolutePath()); services.copyLocalFile(absPath, newname); } } catch (EOFException ex) { throw new ResponseException(ex, ResponseException.getLocalMessage("CommandException.EndOfFile", null)); //NOI18N } catch (IOException ex) { throw new ResponseException(ex); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/CreatedResponse.java0000644000175300001440000000462611175407007027640 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.response; /** * Acts just like the Updated response but refuses to overwrite existing files. Server uses either only the * Updated response or Created/Update-existing responses, depending on responses supported by client. * * @author Maros Sandor */ public class CreatedResponse extends UpdatedResponse { } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/ErrorMessageResponse.java0000644000175300001440000001053311175407007030661 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.util.*; /** * Handles a message that the server requests is sent to stderr. Note that * this does not mean that an error occurred, only that the message is * to be sent to stderr. * @author Robert Greig * @see org.netbeans.lib.cvsclient.response.ErrorResponse */ public final class ErrorMessageResponse implements Response { private boolean terminating; private String message; /** * Process the data for the response. * @param r the buffered reader allowing the client to read the server's * response. Note that the actual response name has already been read * and the reader is positioned just before the first argument, if any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { final String line = dis.readLine(); terminating |= line.endsWith(SpecialResponses.SERVER_ABORTED); terminating |= line.endsWith(SpecialResponses.SERVER_ABORTED_2); terminating |= line.endsWith(SpecialResponses.SERVER_ABORTED_3); terminating &= dis.available() == 0; // heuristics to relax SpecialResponses in commit messages... message = line; MessageEvent event = new MessageEvent(this, line, true); services.getEventManager().fireCVSEvent(event); } catch (EOFException ex) { throw new ResponseException(ex, ResponseException.getLocalMessage("CommandException.EndOfFile", null)); //NOI18N } catch (IOException ex) { throw new ResponseException(ex); } } /** Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return terminating; } /** * Get the error message. */ public String getMessage() { return message; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/ErrorResponse.java0000644000175300001440000000736311175407010027355 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.util.*; /** * Indicates that the command completed with an error. * @author Robert Greig */ public class ErrorResponse implements Response { /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { MessageEvent event = new MessageEvent(this, dis.readLine(), true); services.getEventManager().fireCVSEvent(event); TerminationEvent termEvent = new TerminationEvent(this, true); services.getEventManager().fireCVSEvent(termEvent); } catch (EOFException ex) { throw new ResponseException(ex, ResponseException.getLocalMessage("CommandException.EndOfFile", null)); //NOI18N } catch (IOException ex) { throw new ResponseException(ex); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return true; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/MergedResponse.java0000644000175300001440000001026311175407010027460 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.util.*; import org.netbeans.lib.cvsclient.admin.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.util.*; /** * This response is very similar to an UpdatedResponse except that it backs * up the file being merged, and the file in question will still not be * up-to-date after the merge. * @author Robert Greig * @see org.netbeans.lib.cvsclient.response.UpdatedResponse */ class MergedResponse extends UpdatedResponse { /** * Process the data for the response. * @param r the buffered reader allowing the client to read the server's * response. Note that the actual response name has already been read * and the reader is positioned just before the first argument, if any. * @param services various services that are useful to response handlers * @throws ResponseException if something goes wrong handling this response */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { super.process(dis, services); EventManager manager = services.getEventManager(); if (manager.isFireEnhancedEventSet()) { manager.fireCVSEvent(new EnhancedMessageEvent(this, EnhancedMessageEvent.MERGED_PATH, localFile)); } } /** * Returns the Conflict field for the file's entry. * Can be overriden by subclasses. * (For example the MergedResponse that sets the "result of merge" there.) * @param date the date to put in * @param hadConflicts if there were conflicts (e.g after merge) * @return the conflict field */ protected String getEntryConflict(Date date, boolean hadConflicts) { if (!hadConflicts) { return "Result of merge"; //NOI18N } else { return "Result of merge+" + //NOI18N getDateFormatter().format(date); } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/MessageBinaryResponse.java0000644000175300001440000001050111175407010031001 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.util.*; /** * Handles binary message responses. Translate dthe reponse into * BinaryMessageEvents. * * @author Martin Entlicher */ class MessageBinaryResponse implements Response { private static final int CHUNK_SIZE = 1024 * 256; // 256Kb public MessageBinaryResponse() { // do nothing } /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the inputstream is positioned just before the first argument, if any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { String numBytesStr = dis.readLine(); int numBytes; try { numBytes = Integer.parseInt(numBytesStr); } catch (NumberFormatException nfex) { throw new ResponseException(nfex); } int chunk = Math.min(numBytes, CHUNK_SIZE); byte[] bytes = new byte[chunk]; while (numBytes > 0) { int len = dis.read(bytes, 0, chunk); if (len == -1) { throw new ResponseException("EOF", ResponseException.getLocalMessage("CommandException.EndOfFile", null)); // NOI18N } numBytes -= len; chunk = Math.min(numBytes, CHUNK_SIZE); BinaryMessageEvent event = new BinaryMessageEvent(this, bytes, len); services.getEventManager().fireCVSEvent(event); } } catch (EOFException ex) { throw new ResponseException(ex, ResponseException.getLocalMessage("CommandException.EndOfFile", null)); //NOI18N } catch (IOException ex) { throw new ResponseException(ex); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/MessageResponse.java0000644000175300001440000001064111175407010027641 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.util.*; /** * Handles standard message responses * @author Robert Greig */ class MessageResponse implements Response { private boolean terminating = false; private String firstWord; public MessageResponse() { // do nothing } public MessageResponse(String initialWord) { firstWord = initialWord; } /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the inputstream is positioned just before the first argument, if any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { ByteArray bytes = dis.readLineBytes(); String line = bytes.getStringFromBytes(); if (firstWord != null) { line = firstWord + " " + line; //NOI18N } terminating |= line.endsWith(SpecialResponses.SERVER_ABORTED); terminating |= line.endsWith(SpecialResponses.SERVER_ABORTED_2); terminating |= line.endsWith(SpecialResponses.SERVER_ABORTED_3); terminating &= dis.available() == 0; // heuristics to relax SpecialResponses in commit messages... MessageEvent event = new MessageEvent(this, line, bytes.getBytes(), false); services.getEventManager().fireCVSEvent(event); } catch (EOFException ex) { throw new ResponseException(ex, ResponseException.getLocalMessage("CommandException.EndOfFile", null)); //NOI18N } catch (IOException ex) { throw new ResponseException(ex); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response *

* @see SpecialResponses.SERVER_ABORTED */ public boolean isTerminalResponse() { return terminating; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/MessageTaggedResponse.java0000644000175300001440000000723411175407010030761 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.util.*; /** * Handles standard message responses * @author Milos Kleint */ class MessageTaggedResponse implements Response { /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the inputstream is positioned just before the first argument, if any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { final String text = dis.readLine(); MessageEvent event = new MessageEvent(this, text, false); event.setTagged(true); services.getEventManager().fireCVSEvent(event); } catch (EOFException ex) { throw new ResponseException(ex, ResponseException.getLocalMessage("CommandException.EndOfFile", null)); //NOI18N } catch (IOException ex) { throw new ResponseException(ex); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/ModTimeResponse.java0000644000175300001440000001264611175407010027622 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.text.*; import java.util.*; import org.netbeans.lib.cvsclient.admin.*; import org.netbeans.lib.cvsclient.util.*; /** * Sets the modification time of the next file sent to a specified time. * @author Robert Greig */ class ModTimeResponse implements Response { /** * The formatter responsible for converting server dates to our own dates */ protected static final SimpleDateFormat dateFormatter; /** * The way the server formats dates */ protected static final String SERVER_DATE_FORMAT = "dd MMM yyyy HH:mm:ss"; //NOI18N static { dateFormatter = new SimpleDateFormat(SERVER_DATE_FORMAT, Locale.US); dateFormatter.setTimeZone(Entry.getTimeZone()); } /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { String dateString = dis.readLine(); // we assume the date is in GMT, this appears to be the case // We remove the ending because SimpleDateFormat does not parse // +xxxx, only GMT+xxxx and this avoid us having to do String // concat Date date = dateFormatter.parse( dateString.substring(0, dateString.length() - 6)); if (date.getTime() < 0) { // now we're in trouble - see #18232 issue. // we need to adjust the modified time.. // so that the resulting date.getTime() is not negative. // The problem occurs when the sent year has only 2 digits. // this happens with old versions of cvs. if (date.getYear() < 100 && date.getYear() >= 70) { date.setYear(date.getYear() + 1900); } else if (date.getYear() >= 0 && date.getYear() < 70) { date.setYear(date.getYear() + 2000); } else { date.setYear(2000 + date.getYear()); // for values less than zero let's assume // that we need to substract the value from 2000 /* throw new ResponseException( "Cannot adjust negative time value (" + dateString + ")", //NOI18N ResponseException.getLocalMessage("ModTimeResponse.badDate", //NOI18N new Object[] {dateString})); */ } } services.setNextFileDate(date); } catch (Exception e) { throw new ResponseException(e); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/ModuleExpansionResponse.java0000644000175300001440000000715111175407010031371 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.util.*; /** * Return a file or directory which is included in a particular module. * @author Robert Greig */ class ModuleExpansionResponse implements Response { /** * Creates new ModuleExpansionResponse */ public ModuleExpansionResponse() { } /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { final String localPath = dis.readLine(); EventManager em = services.getEventManager(); em.fireCVSEvent(new ModuleExpansionEvent(this, localPath)); } catch (IOException e) { throw new ResponseException(e); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/NewEntryResponse.java0000644000175300001440000001074311175407010030033 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.admin.*; import org.netbeans.lib.cvsclient.util.*; /** * Indicates that a file has been successfully operated on, e.g. checked in, * added etc. is the same as Checked-in but operates on modified files.. * @author Milos Kleint */ class NewEntryResponse implements Response { /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { String localPath = dis.readLine(); //System.err.println("Pathname is: " + localPath); String repositoryPath = dis.readLine(); //System.err.println("Repository path is: " + repositoryPath); String entriesLine = dis.readLine(); //System.err.println("New entries line is: " + entriesLine); String absPath = services.convertPathname(localPath, repositoryPath); if (services.getGlobalOptions().isExcluded(new File(absPath))) { return; } // we set the date the file was last modified in the Entry line // so that we can easily determine whether the file has been // untouched final File theFile = new File(absPath); // final Date d = new Date(theFile.lastModified()); final Entry entry = new Entry(entriesLine); entry.setConflict(Entry.DUMMY_TIMESTAMP); services.setEntry(theFile, entry); } catch (IOException e) { throw new ResponseException((Exception)e.fillInStackTrace(), e.getLocalizedMessage()); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/NotifiedResponse.java0000644000175300001440000000655311175407010030025 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.util.*; /** * @author Thomas Singer * @version Nov 14, 2001 */ class NotifiedResponse implements Response { /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ public void process(LoggedDataInputStream dataInputStream, ResponseServices services) throws ResponseException { try { /* String relativeLocalDirectory =*/ dataInputStream.readLine(); /* String repositoryFilePath =*/ dataInputStream.readLine(); } catch (EOFException ex) { throw new ResponseException(ex, ResponseException.getLocalMessage("CommandException.EndOfFile", null)); //NOI18N } catch (IOException ex) { throw new ResponseException(ex); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/OKResponse.java0000644000175300001440000000655611175407010026600 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.util.*; /** * Handles the OK response * @author Robert Greig */ class OKResponse implements Response { /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. * @return true if processing should continue, false if processing should * now stop */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { TerminationEvent termEvent = new TerminationEvent(this, false); services.getEventManager().fireCVSEvent(termEvent); } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return true; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/RcsDiffResponse.java0000644000175300001440000002135211175407010027576 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.io.*; import java.util.*; import java.text.*; import org.netbeans.lib.cvsclient.admin.*; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.file.*; import org.netbeans.lib.cvsclient.util.*; /** * Sends a diff of a particular file, indicating that the file currently * checked-out needs to be updated by the patch sent with this response. * @author Milos Kleint */ class RcsDiffResponse implements Response { private static final boolean DEBUG = false; /** * The local path of the new file. */ private String localPath; /** * The full repository path of the file. */ private String repositoryPath; /** * The entry line. */ private String entryLine; /** * The file mode. */ private String mode; /** * fullpath to the file being processed. */ protected String localFile; /** * The date Formatter used to parse and format dates. * Format is: "EEE MMM dd HH:mm:ss yyyy" */ private DateFormat dateFormatter; /** * Process the data for the response. * @param r the buffered reader allowing the client to read the server's * response. Note that the actual response name has already been read * and the reader is positioned just before the first argument, if any. * @param services various services that are useful to response handlers * @throws ResponseException if something goes wrong handling this response */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { localPath = dis.readLine(); repositoryPath = dis.readLine(); entryLine = dis.readLine(); mode = dis.readLine(); String nextLine = dis.readLine(); boolean useGzip = (nextLine.charAt(0) == 'z'); int length = Integer.parseInt(useGzip ? nextLine.substring(1) : nextLine); if (DEBUG) { System.err.println("Got update response."); //NOI18N System.err.println("LocalPath is : " + localPath); //NOI18N System.err.println("Repository path is : " + repositoryPath); //NOI18N System.err.println("Entries line is : " + entryLine); //NOI18N System.err.println("Mode is : " + mode); //NOI18N System.err.println("Next line (length) is : " + nextLine); //NOI18N System.err.println("File length is : " + length); //NOI18N } // now read in the file final String filePath = services.convertPathname(localPath, repositoryPath); final File newFile = new File(filePath); if (services.getGlobalOptions().isExcluded(newFile)) { while (length > 0) { length -= dis.skip(length); } return; } localFile = newFile.getAbsolutePath(); final Entry entry = new Entry(entryLine); FileHandler fileHandler = useGzip ? services.getGzipFileHandler() : services.getUncompressedFileHandler(); // FileHandler fileHandler = useGzip ? getGzippedFileHandler() // : getUncompressedFileHandler(); fileHandler.setNextFileDate(services.getNextFileDate()); // check if the file is binary if (entry.isBinary()) { // should actually not happen. it's possible to send pathces for text files only.. //TODO add BugLog print here } else { fileHandler.writeRcsDiffFile(filePath, mode, dis, length); } // we set the date the file was last modified in the Entry line // so that we can easily determine whether the file has been // untouched // for files with conflicts skip the setting of the conflict field. //NOT SURE THIS IS NESSESARY HERE.. String conflictString = null; if ((entry.getConflict() != null) && (entry.getConflict().charAt(0) == Entry.HAD_CONFLICTS)) { if (entry.getConflict().charAt(1) == Entry.TIMESTAMP_MATCHES_FILE) { final Date d = new Date(newFile.lastModified()); conflictString = getEntryConflict(d, true); } else { conflictString = entry.getConflict().substring(1); } } else { final Date d = new Date(newFile.lastModified()); conflictString = getEntryConflict(d, false); } entry.setConflict(conflictString); // update the admin files (i.e. within the CVS directory) services.updateAdminData(localPath, repositoryPath, entry); FileUpdatedEvent e = new FileUpdatedEvent(this, filePath); services.getEventManager().fireCVSEvent(e); //System.err.println("Finished writing file"); } catch (IOException e) { throw new ResponseException(e); } } /** * Returns the Conflict field for the file's entry. * Can be overriden by subclasses. * (For example the MergedResponse that sets the "result of merge" there.) * @param date the date to put in * @param hadConflicts if there were conflicts (e.g after merge) * @return the conflict field */ protected String getEntryConflict(Date date, boolean hadConflicts) { return getDateFormatter().format(date); } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } /** * Returns the DateFormatter instance that parses and formats date Strings. * The exact format matches the one in Entry.getLastModifiedDateFormatter() method. * */ protected DateFormat getDateFormatter() { if (dateFormatter == null) { dateFormatter = Entry.getLastModifiedDateFormatter(); } return dateFormatter; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/RemoveEntryResponse.java0000644000175300001440000000750611175407010030542 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.util.*; /** * Tells the client to remove an entry from the Entries file * @author Robert Greig */ class RemoveEntryResponse implements Response { /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { final String localPath = dis.readLine(); //System.err.println("LocalPath is: " + localPath); final String repositoryPath = dis.readLine(); //System.err.println("Repository path is: " + repositoryPath); String filePath = services.convertPathname(localPath, repositoryPath); File toRemove = new File(filePath); if (services.getGlobalOptions().isExcluded(toRemove)) { return; } services.removeEntry(toRemove); } catch (Exception e) { throw new ResponseException(e); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/RemovedResponse.java0000644000175300001440000001110711175407010027654 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.event.FileRemovedEvent; import org.netbeans.lib.cvsclient.event.FileToRemoveEvent; import org.netbeans.lib.cvsclient.util.*; /** * Indicates that a file has been removed from the repository. * @author Robert Greig */ class RemovedResponse implements Response { /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { String localPath = dis.readLine(); String repositoryPath = dis.readLine(); String filePath = services.convertPathname(localPath, repositoryPath); filePath = new File(filePath).getAbsolutePath(); if (services.getGlobalOptions().isExcluded(new File(filePath))) { return; } FileToRemoveEvent e1 = new FileToRemoveEvent(this, filePath); FileRemovedEvent e2 = new FileRemovedEvent(this, filePath); //Fire the event before removing the local file. This is done //so that event listeners have a chance to access the file one //last time before the file is removed. services.getEventManager().fireCVSEvent(e1); services.removeLocalFile(localPath, repositoryPath); services.getEventManager().fireCVSEvent(e2); } catch (EOFException ex) { throw new ResponseException(ex, ResponseException.getLocalMessage( "CommandException.EndOfFile", // NOI18N null)); } catch (IOException ex) { throw new ResponseException(ex); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/Response.java0000644000175300001440000000606211175407010026336 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import org.netbeans.lib.cvsclient.util.*; /** * Handles responses from the CVS server * @author Robert Greig */ public interface Response { /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException; /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ boolean isTerminalResponse(); }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/ResponseException.java0000644000175300001440000000551611175407010030220 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import org.netbeans.lib.cvsclient.command.*; /** * This exception is thrown when an error occurs while processing the * server's responses. * @author Robert Greig */ public class ResponseException extends CommandException { public ResponseException(Exception e) { super(e, e.getLocalizedMessage()); } public ResponseException(Exception e, String locMessage) { super(e, locMessage); } public ResponseException(String message, String localizedMessage) { super(message, localizedMessage); } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/ResponseFactory.java0000644000175300001440000001506411175407010027670 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.util.*; import java.text.MessageFormat; /** * Create response objects appropriate for handling different types of response * @author Robert Greig */ public class ResponseFactory { private final Map responseInstancesMap; private String previousResponse = null; public ResponseFactory() { responseInstancesMap = new HashMap(); responseInstancesMap.put("E", new ErrorMessageResponse()); //NOI18N responseInstancesMap.put("M", new MessageResponse()); //NOI18N responseInstancesMap.put("Mbinary", new MessageBinaryResponse()); //NOI18N responseInstancesMap.put("MT", new MessageTaggedResponse()); //NOI18N responseInstancesMap.put("Updated", new UpdatedResponse()); //NOI18N responseInstancesMap.put("Update-existing", new UpdatedResponse()); //NOI18N responseInstancesMap.put("Created", new CreatedResponse()); //NOI18N responseInstancesMap.put("Rcs-diff", new RcsDiffResponse()); //NOI18N responseInstancesMap.put("Checked-in", new CheckedInResponse()); //NOI18N responseInstancesMap.put("New-entry", new NewEntryResponse()); //NOI18N responseInstancesMap.put("ok", new OKResponse()); //NOI18N responseInstancesMap.put("error", new ErrorResponse()); //NOI18N responseInstancesMap.put("Set-static-directory", new SetStaticDirectoryResponse()); //NOI18N responseInstancesMap.put("Clear-static-directory", new ClearStaticDirectoryResponse()); //NOI18N responseInstancesMap.put("Set-sticky", new SetStickyResponse()); //NOI18N responseInstancesMap.put("Clear-sticky", new ClearStickyResponse()); //NOI18N responseInstancesMap.put("Valid-requests", new ValidRequestsResponse()); //NOI18N responseInstancesMap.put("Merged", new MergedResponse()); //NOI18N responseInstancesMap.put("Notified", new NotifiedResponse()); //NOI18N responseInstancesMap.put("Removed", new RemovedResponse()); //NOI18N responseInstancesMap.put("Remove-entry", new RemoveEntryResponse()); //NOI18N responseInstancesMap.put("Copy-file", new CopyFileResponse()); //NOI18N responseInstancesMap.put("Mod-time", new ModTimeResponse()); //NOI18N responseInstancesMap.put("Template", new TemplateResponse()); //NOI18N responseInstancesMap.put("Module-expansion", new ModuleExpansionResponse()); //NOI18N responseInstancesMap.put("Wrapper-rcsOption", new WrapperSendResponse()); //NOI18N } public Response createResponse(String responseName) { Response response = (Response)responseInstancesMap.get(responseName); if (response != null) { previousResponse = responseName; return response; } if (previousResponse != null && previousResponse.equals("M")) { //NOI18N return new MessageResponse(responseName); } previousResponse = null; IllegalArgumentException2 ex = new IllegalArgumentException2("Unhandled response: " + //NOI18N responseName + "."); //NOI18N // assemble reasonable localized message String cvsServer = System.getenv("CVS_SERVER"); // NOI18N if (cvsServer == null) { cvsServer = ""; // NOI18N } else { cvsServer = "=" + cvsServer; // NOI18N } String cvsExe = System.getenv("CVS_EXE"); // NOI18N if (cvsExe == null) { cvsExe = ""; // NOI18N } else { cvsExe = "=" + cvsExe; // NOI18N } ResourceBundle bundle = ResourceBundle.getBundle("org.netbeans.lib.cvsclient.response.Bundle"); //NOI18N String msg = bundle.getString("BK0001"); msg = MessageFormat.format(msg, new Object[] {responseName, cvsServer, cvsExe}); ex.setLocalizedMessage(msg); throw ex; } private static class IllegalArgumentException2 extends IllegalArgumentException { private String localizedMessage; public IllegalArgumentException2(String s) { super(s); } public String getLocalizedMessage() { return localizedMessage; } private void setLocalizedMessage(String localizedMessage) { this.localizedMessage = localizedMessage; } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/ResponseServices.java0000644000175300001440000001643211175407010030044 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.admin.*; import org.netbeans.lib.cvsclient.command.GlobalOptions; import org.netbeans.lib.cvsclient.event.*; import org.netbeans.lib.cvsclient.file.*; import org.netbeans.lib.cvsclient.util.StringPattern; import org.netbeans.lib.cvsclient.command.KeywordSubstitutionOptions; /** * Services that are provided to response handlers. * @author Robert Greig */ public interface ResponseServices { /** * Set the modified date of the next file to be written. The next call * to writeFile will use this date. * @param modifiedDate the date the file should be marked as modified */ void setNextFileDate(Date modifiedDate); /** * Get the modified date of the next file to be written. This will also * null any stored date so that future calls will not retrieve a date * that was meant for a previous file. * @return the date the next file should be marked as having been modified * on. */ Date getNextFileDate(); /** * Convert a pathname in the CVS sense (see 5.10 in the protocol * document) into a local pathname for the file * @param localDirectory the name of the local directory, relative to the * directory in which the command was given * @param repository the full repository name for the file */ String convertPathname(String localDirectory, String repository); /** * Create or update the administration files for a particular file * This will create the CVS directory if necessary, and the * Root and Repository files if necessary. It will also update * the Entries file with the new entry * @param localDirectory the local directory, relative to the directory * in which the command was given, where the file in question lives * @param entry the entry object for that file * @throws IOException if there is an error writing the files */ void updateAdminData(String localDirectory, String repositoryPath, Entry entry) throws IOException; /** * Set the Entry for the specified file * @param f the file * @param e the new entry * @throws IOException if an error occurs writing the details */ void setEntry(File f, Entry e) throws IOException; /** * Remove the Entry for the specified file * @param f the file whose entry is to be removed * @throws IOException if an error occurs writing the Entries file */ void removeEntry(File f) throws IOException; /** * Remove the specified file from the local disk * If the file does not exist, the operation does nothing. * * @param pathname the full path to the file to remove * @throws IOException if an IO error occurs while removing the file */ void removeLocalFile(String pathname) throws IOException; /** * Remove the specified file from the local disk. * @throws IOException if an IO error occurs while removing the file */ void removeLocalFile(String localPath, String repositoryFileName) throws IOException; /** * Copy the local file * @param pathname the full path to the file to coyp * @param newname the new name of the file (not the full path) * @throws IOException if an IO error occurs while copying the file */ void copyLocalFile(String pathname, String newname) throws IOException; /** * Get the CVS event manager. This is generally called by response handlers * that want to fire events. * @return the eventManager */ EventManager getEventManager(); /** * Obtain from the underlying implementation the file handler for * handling uncompressed data. * @return file handler for uncompressed data. */ FileHandler getUncompressedFileHandler(); /** * Obtain the file handler for Gzip compressed data. * @return file handler for Gzip compressed data. */ FileHandler getGzipFileHandler(); /** * ReSet the filehandler for Gzip compressed data. Makes sure the * requests for sending gzipped data are not sent.. */ void dontUseGzipFileHandler(); /** * This method is called when a response for the ValidRequests request * is received. * @param requests A List of requests that is valid for this CVS server * separated by spaces. */ void setValidRequests(String requests); /** * This method is called by WrapperSendResponse for each wrapper setting sent * back by the CVS server * @param pattern A StringPattern indicating the pattern for which the * wrapper applies * @param option A KeywordSubstituionOption corresponding to the setting */ void addWrapper(StringPattern pattern, KeywordSubstitutionOptions option); /** * Get the global options that are set to this client. * Individual commands can get the global options via this method. */ GlobalOptions getGlobalOptions(); } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/SetStaticDirectoryResponse.java0000644000175300001440000000772011175407010032051 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.util.*; /** * Handles the Set-static-directory response. * @author Robert Greig */ class SetStaticDirectoryResponse implements Response { /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { String localPath = dis.readLine(); String repositoryPath = dis.readLine(); //System.err.println("Repository path is: " + repositoryPath); services.updateAdminData(localPath, repositoryPath, null); String absPath = services.convertPathname(localPath, repositoryPath); if (services.getGlobalOptions().isExcluded(new File(absPath))) { return; } absPath = absPath + "/CVS"; //NOI18N File absFile = new File(absPath); if (absFile.exists()) { File staticFile = new File(absPath, "Entries.Static"); //NOI18N staticFile.createNewFile(); } } catch (IOException e) { throw new ResponseException(e); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/SetStickyResponse.java0000644000175300001440000001034711175407010030202 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.util.*; /** * Handles the Set-sticky response. * @author Milos Kleint */ class SetStickyResponse implements Response { /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { PrintWriter w = null; try { String localPath = dis.readLine(); String repositoryPath = dis.readLine(); String tag = dis.readLine(); //System.err.println("Repository path is: " + repositoryPath); // services.updateAdminData(localPath, repositoryPath, null); String absPath = services.convertPathname(localPath, repositoryPath); if (services.getGlobalOptions().isExcluded(new File(absPath))) { return; } absPath = absPath + "/CVS"; //NOI18N File absFile = new File(absPath); if (absFile.exists()) { File tagFile = new File(absPath, "Tag"); //NOI18N if ("THEAD".equals(tag) | "NHEAD".equals(tag) ) { //NOI18N tagFile.delete(); } else { w = new PrintWriter( new BufferedWriter(new FileWriter(tagFile))); // we write out the sticky tag/date w.println(tag); } } } catch (IOException e) { throw new ResponseException(e); } finally { if (w != null) { w.close(); } } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/SpecialResponses.java0000644000175300001440000000745311175407010030027 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.response; /** * Defines few hacks needed to support special and error cases. * * @author Petr Kuzel */ final class SpecialResponses { /** * Sometimes server aborts without sending error terminating * response. It sends just message reponse ending with following text. *

* It could terminate prematurely, ignoring error that should * be probably the next response. AFAIK it's harmless. *

* #56552 * */ public static final String SERVER_ABORTED = " [server aborted]: received termination signal"; // NOI18N /** * Sometimes server aborts without sending error terminating * response. It sends just message reponse ending with following text. *

* It could terminate prematurely, ignoring error that should * be probably the next response. AFAIK it's harmless. *

* #56552 * */ public static final String SERVER_ABORTED_2 = " [server aborted]: received broken pipe signal"; // NOI18N /** * Sometimes server aborts without sending error terminating * response. It sends just message reponse ending with following text. *

* It could terminate prematurely, ignoring error that should * be probably the next response. AFAIK it's harmless. *

* #63376 * */ public static final String SERVER_ABORTED_3 = " [checkout aborted]: end of file from server (consult above messages if any)"; // NOI18N } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/TemplateResponse.java0000644000175300001440000001357311175407010030037 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.util.*; /** * This Template response allows the server to send a template file that is * used when committing changes. The client tools can read the Template file * which is stored in CVS/Template and display it to the user to be used as a * prompt for commit comments. * @author Robert Greig */ class TemplateResponse implements Response { /** * A reference to an uncompressed file handler */ /* // TODO: Should this be taken from ResponseServices??? protected static FileHandler uncompressedFileHandler; */ /** * The local path of the new file */ protected String localPath; /** * The full repository path of the file */ protected String repositoryPath; /** * Creates new TemplateResponse */ public TemplateResponse() { } /* // TODO: replace this with a call to ResponseSerivices::getUncompr....ler? protected static FileHandler getUncompressedFileHandler() { if (uncompressedFileHandler == null) { uncompressedFileHandler = new DefaultFileHandler(); } return uncompressedFileHandler; } */ /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { localPath = dis.readLine(); repositoryPath = dis.readLine(); int length = Integer.parseInt(dis.readLine()); // now read in the file final String filePath = services.convertPathname(localPath, repositoryPath) + "CVS/Template"; //NOI18N // #69639 write metadata directly // XXX possibly add a method to AdminHandler OutputStream out = null; File file = new File(filePath); file.getParentFile().mkdirs(); try { out = new FileOutputStream(file); out = new BufferedOutputStream(out); byte[] lineSeparator = System.getProperty("line.separator").getBytes(); // NOI18N byte[] data = dis.readBytes(length); for (int i = 0; i 0) { length -= dis.skip(length); } } /** * Returns the Conflict field for the file's entry. * Can be overriden by subclasses. * (For example the MergedResponse that sets the "result of merge" there.) * @param date the date to put in * @param hadConflicts if there were conflicts (e.g after merge) * @return the conflict field */ protected String getEntryConflict(Date date, boolean hadConflicts) { return getDateFormatter().format(date); } /** * Returns the DateFormatter instance that parses and formats date Strings. * The exact format matches the one in Entry.getLastModifiedDateFormatter() method. * */ protected DateFormat getDateFormatter() { if (dateFormatter == null) { dateFormatter = Entry.getLastModifiedDateFormatter(); } return dateFormatter; } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/ValidRequestsResponse.java0000644000175300001440000000742711175407010031060 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.response; import java.io.*; import org.netbeans.lib.cvsclient.util.*; /** * Tells the client what requests the server will accept. Also returns * whether the server supports sending patches, which is not really * anything to do with requests! * @author Robert Greig */ class ValidRequestsResponse implements Response { /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { String validRequests = dis.readLine(); services.setValidRequests(validRequests); if (validRequests.indexOf("gzip-file-contents") < 0) { services.dontUseGzipFileHandler(); } } catch (EOFException ex) { throw new ResponseException(ex, ResponseException.getLocalMessage("CommandException.EndOfFile", null)); //NOI18N } catch (IOException ex) { throw new ResponseException(ex); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/response/WrapperSendResponse.java0000644000175300001440000001301411175407010030504 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.response; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.util.*; import org.netbeans.lib.cvsclient.util.SimpleStringPattern; import org.netbeans.lib.cvsclient.command.KeywordSubstitutionOptions; /** * This class handles the response from the server to a wrapper-sendme-rcsOptions * request * @author Sriram Seshan */ public class WrapperSendResponse implements Response { public static Map parseWrappers(String line) { StringTokenizer tokenizer = new StringTokenizer(line); // the first token is the pattern SimpleStringPattern pattern = new SimpleStringPattern(tokenizer.nextToken()); // it is followed by option value pairs String option, value; Map wrappersMap = null; while (tokenizer.hasMoreTokens()) { option = tokenizer.nextToken(); value = tokenizer.nextToken(); // do not bother with the -m Options now if (option.equals("-k")) { //NOI18N // This is a keyword substitution option // strip the quotes int first = value.indexOf('\''); int last = value.lastIndexOf('\''); if (first >=0 && last >= 0) { value = value.substring(first+1, last); } KeywordSubstitutionOptions keywordOption = KeywordSubstitutionOptions.findKeywordSubstOption(value); if (wrappersMap == null) { if (!tokenizer.hasMoreTokens()) { wrappersMap = Collections.singletonMap(pattern, keywordOption); } else { wrappersMap = new LinkedHashMap(); wrappersMap.put(pattern, keywordOption); } } else { wrappersMap.put(pattern, keywordOption); } } } return wrappersMap; } /** * Process the data for the response. * @param dis the data inputstream allowing the client to read the server's * response. Note that the actual response name has already been read * and the input stream is positioned just before the first argument, if * any. */ public void process(LoggedDataInputStream dis, ResponseServices services) throws ResponseException { try { String wrapperSettings = dis.readLine(); Map wrappers = parseWrappers(wrapperSettings); for (Iterator it = wrappers.keySet().iterator(); it.hasNext(); ) { StringPattern pattern = (StringPattern) it.next(); KeywordSubstitutionOptions keywordOption = (KeywordSubstitutionOptions) wrappers.get(pattern); services.addWrapper(pattern, keywordOption); } } catch (EOFException ex) { throw new ResponseException(ex, ResponseException.getLocalMessage("CommandException.EndOfFile", null)); //NOI18N } catch (IOException ex) { throw new ResponseException(ex); } catch (NoSuchElementException nse) { throw new ResponseException(nse); } } /** * Is this a terminal response, i.e. should reading of responses stop * after this response. This is true for responses such as OK or * an error response */ public boolean isTerminalResponse() { return false; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/util/0000755000175300001440000000000011175434236023022 5ustar ludousersnetbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/util/BugLog.java0000644000175300001440000000625111175407010025036 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.util; /** * Assertion tool class. * @author Thomas Singer */ public class BugLog { private static BugLog instance; public synchronized static BugLog getInstance() { if (instance == null) { instance = new BugLog(); } return instance; } public synchronized static void setInstance(BugLog instance) { BugLog.instance = instance; } public BugLog() { } public void showException(Exception ex) { ex.printStackTrace(); } public void assertTrue(boolean value, String message) { if (value) { return; } throw new BugException(message); } public void assertNotNull(Object obj) { if (obj != null) { return; } throw new BugException("Value must not be null!"); // NOI18N } public void bug(String message) { new Exception(message).printStackTrace(); } public static class BugException extends RuntimeException { public BugException(String message) { super(message); } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/util/BundleUtilities.java0000644000175300001440000000710111175407010026757 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Thomas Singer. * Portions created by Thomas Singer are Copyright (C) 2001. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Thomas Singer. *****************************************************************************/ package org.netbeans.lib.cvsclient.util; import java.util.*; /** * @author Thomas Singer * @version Sep 26, 2001 */ public class BundleUtilities { /** * Returns the package name of the specified class. * An empty String is returned, if the class is in the default package. */ public static String getPackageName(Class clazz) { String fullClassName = clazz.getName(); int lastDotIndex = fullClassName.lastIndexOf('.'); if (lastDotIndex < 0) { return ""; // NOI18N } return fullClassName.substring(0, lastDotIndex); } /** * Returns the resourcename for the resource' shortName relative to the classInSamePackage. */ public static String getResourceName(Class classInSamePackage, String shortName) { String packageName = getPackageName(classInSamePackage); String resourceName = packageName.replace('.', '/') + '/' + shortName; return resourceName; } /** * Returns the resource bundle for the specified resource' shortName relative to classInSamePackage. */ public static ResourceBundle getResourceBundle(Class classInSamePackage, String shortName) { String resourceName = getResourceName(classInSamePackage, shortName); return ResourceBundle.getBundle(resourceName); } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/util/ByteArray.java0000644000175300001440000000655211175407010025565 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.util; /** * The growable array of bytes. * This class in not thread safe. * * @author Martin Entlicher */ public class ByteArray extends Object { private byte[] bytesBuffer; private int length; /** Creates a new instance of ByteArray */ public ByteArray() { bytesBuffer = new byte[50]; length = 0; } /** * Add a byte to the byte array. */ public void add(byte b) { if (bytesBuffer.length <= length) { byte[] newBytesBuffer = new byte[length + length/2]; System.arraycopy(bytesBuffer, 0, newBytesBuffer, 0, bytesBuffer.length); bytesBuffer = newBytesBuffer; } bytesBuffer[length++] = b; } /** * Get the array of bytes. */ public byte[] getBytes() { byte[] bytes = new byte[length]; System.arraycopy(bytesBuffer, 0, bytes, 0, length); return bytes; } /** * Get the String representation of bytes in this array. The bytes are * decoded using the platform's default charset. */ public String getStringFromBytes() { return new String(bytesBuffer, 0, length); } /** * Reset the byte array to zero length. */ public void reset() { length = 0; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/util/DefaultIgnoreFileFilter.java0000644000175300001440000001616011175407010030355 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.util; import java.io.*; import java.util.*; /** * @author Milos Kleint, Thomas Singer */ public class DefaultIgnoreFileFilter implements IgnoreFileFilter { private final List patterns = new LinkedList(); private final List localPatterns = new LinkedList(); private boolean processGlobalPatterns = true; private boolean processLocalPatterns = false; private File lastDirectory = null; public DefaultIgnoreFileFilter() { } /** * Creates new DefaultIgnoreFileFilter and fills in patterns. * @param patternList - list of objects, patterns are retrieved * via the Object.toString() method. */ public DefaultIgnoreFileFilter(List patternList) { for (Iterator it = patternList.iterator(); it.hasNext();) { String patternString = it.next().toString(); SimpleStringPattern pattern = new SimpleStringPattern(patternString); addPattern(pattern); } } /** * Adds a StringPattern to the list of ignore file patters. */ public void addPattern(StringPattern pattern) { if (pattern.toString().equals("!")) { //NOI18N clearPatterns(); } else { patterns.add(pattern); } } /** * Adds a string to the list of ignore file patters using the SimpleStringPattern. */ public void addPattern(String pattern) { if (pattern.equals("!")) { //NOI18N clearPatterns(); } else { patterns.add(new SimpleStringPattern(pattern)); } } /** * Clears the list of patters. * To be used when the "!" character is used in any of the .cvsignore lists. */ public void clearPatterns() { patterns.clear(); } /** * A file is checked against the patterns in the filter. * If any of these matches, the file should be ignored. A file will also * be ignored, if its name matches any local .cvsignore file * entry. * @param directory is a file object that refers to the directory the file resides in. * @param noneCvsFile is the name of the file to be checked. */ public boolean shouldBeIgnored(File directory, String noneCvsFile) { // current implementation ignores the directory parameter. // in future or different implementations can add the directory dependant .cvsignore lists if (lastDirectory != directory) { lastDirectory = directory; processGlobalPatterns = true; processLocalPatterns = false; localPatterns.clear(); String filename = directory.getPath() + File.separator + ".cvsignore"; //NOI18N File cvsIgnoreFile = new File(filename); if (cvsIgnoreFile.exists()) { try { List list = parseCvsIgnoreFile(cvsIgnoreFile); for (Iterator it = list.iterator(); it.hasNext();) { String s = it.next().toString(); if (s.equals("!")) { //NOI18N processGlobalPatterns = false; localPatterns.clear(); } else { localPatterns.add(new SimpleStringPattern(s)); } } } catch (IOException ex) { // ignore exception } } processLocalPatterns = localPatterns.size() > 0; } if (processGlobalPatterns) { for (Iterator it = patterns.iterator(); it.hasNext();) { StringPattern pattern = (StringPattern)it.next(); if (pattern.doesMatch(noneCvsFile)) { return true; } } } if (processLocalPatterns) { for (Iterator it = localPatterns.iterator(); it.hasNext();) { StringPattern pattern = (StringPattern)it.next(); if (pattern.doesMatch(noneCvsFile)) { return true; } } } return false; } /** * Utility method that reads the .cvsignore file and returns a list of Strings. * These strings represent the patterns read from the file. */ public static List parseCvsIgnoreFile(File cvsIgnoreFile) throws IOException, FileNotFoundException { BufferedReader reader = null; List toReturn = new LinkedList(); try { reader = new BufferedReader(new FileReader(cvsIgnoreFile)); String line; while ((line = reader.readLine()) != null) { StringTokenizer token = new StringTokenizer(line, " ", false); //NOI18N while (token.hasMoreTokens()) { String tok = token.nextToken(); toReturn.add(tok); } } } finally { if (reader != null) { reader.close(); } } return toReturn; } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/util/IgnoreFileFilter.java0000644000175300001440000000525311175407010027051 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.util; import java.io.*; /** * interface for recognizing if the local files are to be ignored. * Implements the functionality of the .cvsignore files.. * * @author Milos Kleint */ public interface IgnoreFileFilter { /** * A file is checked against the patterns in the filter. * If any of these matches, the file should be ignored. * * @param directory is a file object that refers to the directory the file resides in. * @param noneCvsFile is the name of the file to be checked. */ boolean shouldBeIgnored(File directory, String noneCvsFile); } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/util/LoggedDataInputStream.java0000644000175300001440000001650711175407010030053 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.util; import java.io.*; /** * This input stream worked exactly like the normal DataInputStream except that * it logs anything read to a file * @author Robert Greig */ public class LoggedDataInputStream extends FilterInputStream { private long counter; /** * Construct a logged stream using the specified underlying stream * @param in the stream */ public LoggedDataInputStream(InputStream in) { super(in); } /** * Read a line (up to the newline character) from the stream, logging * it too. * * @deprecated It converts input data to string using {@link ByteArray#getStringFromBytes} * that works only for ASCII without 0. Use byte access methods instead. */ public String readLine() throws IOException { return readLineBytes().getStringFromBytes(); } /** * * @return * @throws IOException * @throws EOFException at stream end */ public ByteArray readLineBytes() throws IOException { int ch; boolean throwEOF = true; ByteArray byteArray = new ByteArray(); loop: while (true) { if (Thread.interrupted()) { Thread.currentThread().interrupt(); break; } if (in.available() == 0) { try { Thread.sleep(100); } catch (InterruptedException iex) { Thread.currentThread().interrupt(); break loop; } continue; } ch = in.read(); counter++; switch (ch) { case -1: if (throwEOF) { throw new EOFException(); } case '\n': break loop; default: byteArray.add((byte) ch); } throwEOF = false; } byte[] bytes = byteArray.getBytes(); Logger.logInput(bytes); Logger.logInput('\n'); //NOI18N return byteArray; } /** * Synchronously reads fixed chunk from the stream, logging it too. * * @param len blocks until specifid number of bytes is read. */ public byte[] readBytes(int len) throws IOException { int ch; ByteArray byteArray = new ByteArray(); loop: while (len != 0) { if (Thread.interrupted()) { Thread.currentThread().interrupt(); break; } if (in.available() == 0) { try { Thread.sleep(100); } catch (InterruptedException iex) { Thread.currentThread().interrupt(); break loop; } continue; } ch = in.read(); counter++; switch (ch) { case -1: break loop; default: byteArray.add((byte) ch); len--; } } byte[] bytes = byteArray.getBytes(); Logger.logInput(bytes); return bytes; } /** * Closes this input stream and releases any system resources associated * with the stream. */ public void close() throws IOException { in.close(); } /** * Reads up to byte.length bytes of data from this input stream into an * array of bytes. */ public int read(byte[] b) throws IOException { int read = in.read(b); if (read != -1) { Logger.logInput(b, 0, read); counter += read; } return read; } /** * Reads up to len bytes of data from this input stream into an array of * bytes */ public int read(byte[] b, int off, int len) throws IOException { int read = in.read(b, off, len); if (read != -1) { Logger.logInput(b, off, read); counter += read; } return read; } public long skip(long n) throws IOException { long skip = super.skip(n); if (skip > 0) { Logger.logInput(new String("").getBytes("utf8")); // NOI18N counter += skip; } return skip; } /** * Interruptible read. * @throws InterruptedIOException on thread interrupt */ public int read() throws IOException { while (in.available() == 0) { try { Thread.sleep(100); } catch (InterruptedException iex) { Thread.currentThread().interrupt(); throw new InterruptedIOException(); } } int i = super.read(); if (i != -1) { Logger.logInput((char) i); counter++; } return i; } public InputStream getUnderlyingStream() { return in; } public void setUnderlyingStream(InputStream is) { in = is; } public long getCounter() { return counter; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/util/LoggedDataOutputStream.java0000644000175300001440000001073711175407010030253 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.util; import java.io.*; /** * A data output stream that also logs everything sent to a Writer (via the * logger). * @author Robert Greig */ public class LoggedDataOutputStream extends FilterOutputStream { private long counter; /** * Construct a logged stream using the specified underlying stream * @param out the stream */ public LoggedDataOutputStream(OutputStream out) { super(out); } /** * Write a line to the stream, logging it too. For compatibility reasons * only. Does exactly the same what writeBytes() does. * * @deprecated Line to to bytes conversion is host specifics. * Use raw byte access methods insted. * */ public void writeChars(String line) throws IOException { writeBytes(line); } /** * Write a line to the stream, logging it too. * * Line to to bytes conversion is host specifics. Use {@link #writeBytes(String, String)} if possible. */ public void writeBytes(String line) throws IOException { byte[] bytes = line.getBytes(); out.write(bytes); Logger.logOutput(bytes); counter += bytes.length; } /** * Write a line to the stream, logging it too. */ public void writeBytes(String line, String encoding) throws IOException { byte[] bytes = line.getBytes(encoding); out.write(bytes); Logger.logOutput(bytes); counter += bytes.length; } public void write(int b) throws IOException { super.write(b); counter++; } public void write(byte b[]) throws IOException { super.write(b); counter += b.length; } public void write(byte b[], int off, int len) throws IOException { super.write(b, off, len); counter += len; } /** * Closes this input stream and releases any system resources associated * with the stream. */ public void close() throws IOException { out.close(); } public OutputStream getUnderlyingStream() { return out; } public void setUnderlyingStream(OutputStream os) { out = os; } public long getCounter() { return counter; } }netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/util/Logger.java0000644000175300001440000001475711175407010025110 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Robert Greig. * Portions created by Robert Greig are Copyright (C) 2000. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Robert Greig. *****************************************************************************/ package org.netbeans.lib.cvsclient.util; import java.io.*; /** * Handles the logging of communication to and from the server * * @author Robert Greig * @author Petr Kuzel rewriten to streams */ public final class Logger { /** * The output stream to use to write communication sent to the server */ private static OutputStream outLogStream; /** * The output stream to use to write communication received from the server */ private static OutputStream inLogStream; /** * The log files path. If the property is set to the constant "system" * then it uses System.err, otherwise it tries to create a file at the * specified path */ private static final String LOG_PROPERTY = "cvsClientLog"; // NOI18N /** * Whether we are logging or not */ private static boolean logging; static { setLogging(System.getProperty(LOG_PROPERTY)); } public static void setLogging(String logPath) { logging = (logPath != null); try { if (logging) { if (logPath.equals("system")) { // NOI18N outLogStream = System.err; inLogStream = System.err; } else { outLogStream = new BufferedOutputStream(new FileOutputStream(logPath + ".out")); // NOI18N inLogStream = new BufferedOutputStream(new FileOutputStream(logPath + ".in")); // NOI18N } } } catch (IOException e) { System.err.println("Unable to create log files: " + e); // NOI18N System.err.println("Logging DISABLED"); // NOI18N logging = false; try { if (outLogStream != null) { outLogStream.close(); } } catch (IOException ex2) { // ignore, if we get one here we really are screwed } try { if (inLogStream != null) { inLogStream.close(); } } catch (IOException ex2) { // ignore, if we get one here we really are screwed } } } /** * Log a message received from the server. The message is logged if * logging is enabled * @param received the data received from the server */ public static void logInput(byte[] received) { logInput(received, 0 , received.length); } /** * Log a message received from the server. The message is logged if * logging is enabled * @param received the data received from the server */ public static void logInput(byte[] received, int offset, int len) { if (!logging) { return; } try { inLogStream.write(received, offset, len); inLogStream.flush(); } catch (IOException ex) { System.err.println("Could not write to log file: " + ex); // NOI18N System.err.println("Logging DISABLED."); // NOI18N logging = false; } } /** * Log a character received from the server. The message is logged if * logging is enabled * @param received the data received from the server */ public static void logInput(char received) { if (!logging) { return; } try { inLogStream.write(received); inLogStream.flush(); } catch (IOException ex) { System.err.println("Could not write to log file: " + ex); // NOI18N System.err.println("Logging DISABLED."); // NOI18N logging = false; } } /** * Log a message sent to the server. The message is logged if * logging is enabled * @param sent the data sent to the server */ public static void logOutput(byte[] sent) { if (!logging) { return; } try { outLogStream.write(sent); outLogStream.flush(); } catch (IOException ex) { System.err.println("Could not write to log file: " + ex); // NOI18N System.err.println("Logging DISABLED."); // NOI18N logging = false; } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/util/SimpleStringPattern.java0000644000175300001440000002422611175407010027637 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Thomas Singer. * Portions created by Thomas Singer Copyright (C) 2001. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Thomas Singer, Milos Kleint *****************************************************************************/ package org.netbeans.lib.cvsclient.util; import java.util.*; /** * @author Thomas Singer */ public class SimpleStringPattern implements StringPattern { private static final char MATCH_EACH = '*'; private static final char MATCH_ONE = '?'; private final List subPatterns = new LinkedList(); /** * Creates a SimpleStringPattern for the specified definition. * The definition might contain two special characters ('*' and '?'). */ public SimpleStringPattern(String definition) { splitInSubPattern(definition); } /** * Returns whether the specified string matches thiz pattern. */ public boolean doesMatch(String string) { int index = 0; SubPattern subPattern = null; for (Iterator it = subPatterns.iterator(); it.hasNext();) { subPattern = (SubPattern)it.next(); index = subPattern.doesMatch(string, index); if (index < 0) { return false; } } if (index == string.length()) { return true; } if (subPattern == null) { return false; } return subPattern.checkEnding(string, index); } private void splitInSubPattern(String definition) { char prevSubPattern = ' '; int prevIndex = 0; for (int index = 0; index >= 0;) { prevIndex = index; index = definition.indexOf(MATCH_EACH, prevIndex); if (index >= 0) { String match = definition.substring(prevIndex, index); addSubPattern(match, prevSubPattern); prevSubPattern = MATCH_EACH; index++; continue; } index = definition.indexOf(MATCH_ONE, prevIndex); if (index >= 0) { String match = definition.substring(prevIndex, index); addSubPattern(match, prevSubPattern); prevSubPattern = MATCH_ONE; index++; continue; } } String match = definition.substring(prevIndex); addSubPattern(match, prevSubPattern); } private void addSubPattern(String match, char subPatternMode) { SubPattern subPattern = null; switch (subPatternMode) { case MATCH_EACH: subPattern = new MatchEachCharPattern(match); break; case MATCH_ONE: subPattern = new MatchOneCharPattern(match); break; default: subPattern = new MatchExactSubPattern(match); break; } subPatterns.add(subPattern); } public String toString() { StringBuffer buffer = new StringBuffer(); for (Iterator it = subPatterns.iterator(); it.hasNext();) { SubPattern subPattern = (SubPattern)it.next(); buffer.append(subPattern.toString()); } return buffer.toString(); } public boolean equals(Object obj) { if (!(obj instanceof SimpleStringPattern)) return false; return subPatterns.equals(((SimpleStringPattern) obj).subPatterns); } public int hashCode() { return -subPatterns.hashCode(); } public static void main(String[] arguments) { StringPattern sp = new SimpleStringPattern("a*b"); //NOI18N test(sp, "ab", true); //NOI18N test(sp, "aab", true); //NOI18N test(sp, "ba", false); //NOI18N test(sp, "abc", false); //NOI18N sp = new SimpleStringPattern("*.txt"); //NOI18N test(sp, "datei.txt", true); //NOI18N test(sp, ".txt", true); //NOI18N test(sp, "datei.tx", false); //NOI18N test(sp, "datei.txt.txt", true); //NOI18N sp = new SimpleStringPattern("datei*1*"); //NOI18N test(sp, "datei0.txt", false); //NOI18N test(sp, "datei1.txt", true); //NOI18N test(sp, "datei.tx", false); //NOI18N test(sp, "datei1.txt.txt", true); //NOI18N sp = new SimpleStringPattern("Makefile"); //NOI18N test(sp, "Makefile", true); //NOI18N test(sp, "Makefile.mak", false); //NOI18N test(sp, "Makefile1", false); //NOI18N test(sp, ".Makefile", false); //NOI18N test(sp, ".Makefile.", false); //NOI18N sp = new SimpleStringPattern("*~"); //NOI18N test(sp, "datei~", true); //NOI18N test(sp, "datei~1", false); //NOI18N test(sp, "datei~1~", true); //NOI18N // Equality: SimpleStringPattern pattern1 = new SimpleStringPattern("*.class"); SimpleStringPattern pattern2 = new SimpleStringPattern("*.class"); System.err.println(pattern1+".equals("+pattern2+") = "+pattern1.equals(pattern2)); pattern1 = new SimpleStringPattern("?.class"); pattern2 = new SimpleStringPattern("*.class"); System.err.println(pattern1+".equals("+pattern2+") = "+pattern1.equals(pattern2)); pattern1 = new SimpleStringPattern("*.clazz"); pattern2 = new SimpleStringPattern("*.class"); System.err.println(pattern1+".equals("+pattern2+") = "+pattern1.equals(pattern2)); } private static void test(StringPattern sp, String testString, boolean shouldResult) { System.err.print('"' + sp.toString() + '"' + ": " + testString + " " + shouldResult); //NOI18N boolean doesMatch = sp.doesMatch(testString); if (doesMatch == shouldResult) { System.err.println(" proved"); //NOI18N } else { System.err.println(" **denied**"); //NOI18N } } private static abstract class SubPattern { protected final String match; protected SubPattern(String match) { this.match = match; } /** * @parameter string ... the whole string to test for matching * @parameter index ... the index in string where this' test should begin * @returns ... if successful the next test-position, if not -1 */ public abstract int doesMatch(String string, int index); public boolean checkEnding(String string, int index) { return false; } public boolean equals(Object obj) { if (!(this.getClass().isInstance(obj))) return false; return match.equals(((SubPattern) obj).match); } public int hashCode() { return -match.hashCode(); } } private static class MatchExactSubPattern extends SubPattern { public MatchExactSubPattern(String match) { super(match); } public int doesMatch(String string, int index) { if (!string.startsWith(match, index)) { return -1; } return index + match.length(); } public String toString() { return match; } } private static class MatchEachCharPattern extends SubPattern { public MatchEachCharPattern(String match) { super(match); } public int doesMatch(String string, int index) { int matchIndex = string.indexOf(match, index); if (matchIndex < 0) { return -1; } return matchIndex + match.length(); } public boolean checkEnding(String string, int index) { return string.endsWith(match); } public String toString() { return MATCH_EACH + match; } } private static class MatchOneCharPattern extends MatchExactSubPattern { public MatchOneCharPattern(String match) { super(match); } public int doesMatch(String string, int index) { index++; if (string.length() < index) { return -1; } return super.doesMatch(string, index); } public String toString() { return MATCH_ONE + match; } } } netbeans-cvsclient_6.5/src/org/netbeans/lib/cvsclient/util/StringPattern.java0000644000175300001440000000476511175407010026473 0ustar ludousers/***************************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is the CVS Client Library. * The Initial Developer of the Original Software is Thomas Singer. * Portions created by Thomas Singer Copyright (C) 2001. * All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. * * Contributor(s): Thomas Singer, Milos Kleint *****************************************************************************/ package org.netbeans.lib.cvsclient.util; /** * @author Thomas Singer */ public interface StringPattern { /** * Returns whether the specified string matches thiz pattern. */ boolean doesMatch(String string); } netbeans-cvsclient_6.5/test/0000755000175300001440000000000011175434236015107 5ustar ludousersnetbeans-cvsclient_6.5/test/build-qa-functional.xml0000644000175300001440000002746411175407010021472 0ustar ludousers netbeans-cvsclient_6.5/test/build.xml0000644000175300001440000001252311175407010016721 0ustar ludousers netbeans-cvsclient_6.5/test/cfg-qa-functional-DISABLED.xml0000644000175300001440000000572411175407010022272 0ustar ludousers netbeans-cvsclient_6.5/test/data/0000755000175300001440000000000011175434236016020 5ustar ludousersnetbeans-cvsclient_6.5/test/data/iz50229.zip0000644000175300001440000000071311175407010017557 0ustar ludousersPKPc7uXo linux.srcUT 0XG0XGUxsK,THIUH,IMQH+U+P(,/-Q(.HMLKWNRHILqS(I- s]ݸPKPc7 +bYp windows.srcUT 0XG0XGUxsK,THIUH,IMQH+UK//V(,/-Q(.HMLKWNRHILqS(I-GqPKPc7uXo $linux.srcUT0XGUxPKPc7 +bYp $windows.srcUT0XGUxPK+netbeans-cvsclient_6.5/test/data/iz50963/0000755000175300001440000000000011175434236017051 5ustar ludousersnetbeans-cvsclient_6.5/test/data/iz50963/about.txt0000644000175300001440000000115211175407010020711 0ustar ludousers1. Create a file and commit it to CVS. 2. Now remove this file from CVS. It now only exists in the "Attic" and is not displayed in the explorer. 3. Create a local copy of this file again. The status displayed will be "Local". 4. Do a "cvs refresh" on this file. That status will change to "Up-to-date, No". To get this file into CVS again, have to do a "cvs add" first. But this option is now not available in the context menu and is dimmed in the task bar. Well, "cvs status" for that file says that it's "Up-to-date"! This seems to be a bug in javacvs library, because cvs binary says that it's "Unknown". netbeans-cvsclient_6.5/test/data/iz56710/0000755000175300001440000000000011175434236017045 5ustar ludousersnetbeans-cvsclient_6.5/test/data/iz56710/binary.out0000644000175300001440000000040011175407010021042 0ustar ludousers  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~netbeans-cvsclient_6.5/test/qa-functional/0000755000175300001440000000000011175434236017650 5ustar ludousersnetbeans-cvsclient_6.5/test/qa-functional/src/0000755000175300001440000000000011175434236020437 5ustar ludousersnetbeans-cvsclient_6.5/test/qa-functional/src/complete/0000755000175300001440000000000011175434236022247 5ustar ludousersnetbeans-cvsclient_6.5/test/qa-functional/src/complete/AdditionalCommands.java0000644000175300001440000007536311175407010026650 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package complete; import org.netbeans.jellytools.EditorOperator; import org.netbeans.jellytools.NbDialogOperator; import org.netbeans.jellytools.NewWizardOperator; import org.netbeans.jellytools.TopComponentOperator; import org.netbeans.jellytools.actions.OpenAction; import org.netbeans.jellytools.modules.javacvs.output.AnnotateOutputOperator; import org.netbeans.jellytools.modules.javacvs.output.LogOutputOperator; import org.netbeans.jellytools.modules.javacvs.output.StatusOutputOperator; import org.netbeans.jellytools.modules.vcscore.VCSCommandsOutputOperator; import org.netbeans.jellytools.nodes.FilesystemNode; import org.netbeans.jellytools.nodes.Node; import org.netbeans.jellytools.util.StringFilter; import org.netbeans.jemmy.operators.JTextFieldOperator; import org.netbeans.test.oo.gui.jelly.javacvs.AnnotateDialog; import org.netbeans.test.oo.gui.jelly.javacvs.CommitDialog; import org.netbeans.test.oo.gui.jelly.javacvs.DiffDialog; import org.netbeans.test.oo.gui.jelly.javacvs.LogDialog; import org.netbeans.test.oo.gui.jelly.javacvs.RemoveDialog; import org.netbeans.test.oo.gui.jelly.javacvs.StatusDialog; import org.netbeans.test.oo.gui.jelly.vcscore.OutputOfVCSCommandsFrame; public class AdditionalCommands extends JCVSStub { public AdditionalCommands(String testName) { super(testName); } public static junit.framework.Test suite() { // DEBUG = true; junit.framework.TestSuite suite = new org.netbeans.junit.NbTestSuite(); suite.addTest(new AdditionalCommands("configure")); suite.addTest(new AdditionalCommands("testStatusRefresh")); suite.addTest(new AdditionalCommands("testRemove")); // suite.addTest(new AdditionalCommands("testRemoveRecursively")); // !!! do it suite.addTest(new AdditionalCommands("testLogInit")); suite.addTest(new AdditionalCommands("testLogFileFull")); suite.addTest(new AdditionalCommands("testLogFileStrict")); suite.addTest(new AdditionalCommands("testLogDirectory")); suite.addTest(new AdditionalCommands("testLogDirectoryRecursive")); suite.addTest(new AdditionalCommands("testLogRestrictions")); suite.addTest(new AdditionalCommands("testStatusInit")); suite.addTest(new AdditionalCommands("testStatusFile")); suite.addTest(new AdditionalCommands("testStatusFileIncludeTags")); suite.addTest(new AdditionalCommands("testStatusDirectory")); suite.addTest(new AdditionalCommands("testStatusDirectoryRecursive")); suite.addTest(new AdditionalCommands("testAnnotateInit")); suite.addTest(new AdditionalCommands("testAnnotateFileFull")); suite.addTest(new AdditionalCommands("testAnnotateFileStrict")); suite.addTest(new AdditionalCommands("testAnnotateDirectory")); suite.addTest(new AdditionalCommands("testAnnotateDirectoryRecursive")); suite.addTest(new AdditionalCommands("testAnnotateInvalid")); suite.addTest(new AdditionalCommands("testAnnotateForce")); suite.addTest(new AdditionalCommands("testDiffInit")); suite.addTest(new AdditionalCommands("testDiffFile1Revision")); suite.addTest(new AdditionalCommands("testDiffFile2Revisions")); suite.addTest(new AdditionalCommands("testDiffFileIgnore")); suite.addTest(new AdditionalCommands("testDiffFileFormat")); // suite.addTest(new AdditionalCommands("testDiffDirectory")); // graphical diff not work - used textual diff - but textual is broken too - always fail due to bug #29769 suite.addTest(new AdditionalCommands("testUnmount")); return suite; } public static void main(java.lang.String[] args) { junit.textui.TestRunner.run(suite()); } GenericNode pac1, subpac1; GenericNode aa1; GenericNode log1, log2; GenericNode pac2, subpac2; GenericNode status1, status2; GenericNode pac3, subpac3; GenericNode anno1, anno2; GenericNode pac4, subpac4; GenericNode diff1, diff2; protected void createStructure() { pac1 = new GenericNode (root, "pac1"); subpac1 = new GenericNode (pac1, "subpac1"); aa1 = new GenericNode (subpac1, "Aa1", ".java"); log1 = new GenericNode (subpac1, "log1", ".java"); log2 = new GenericNode (subpac1, "log2", ".java"); pac2 = new GenericNode (root, "pac2"); subpac2 = new GenericNode (pac2, "subpac2"); status1 = new GenericNode (subpac2, "status1", ".java"); status2 = new GenericNode (subpac2, "status2", ".java"); pac3 = new GenericNode (root, "pac3"); subpac3 = new GenericNode (pac3, "subpac3"); anno1 = new GenericNode (pac3, "anno1"); anno2 = new GenericNode (subpac3, "anno2"); pac4 = new GenericNode (root, "pac4"); subpac4 = new GenericNode (pac4, "subpac4"); diff1 = new GenericNode (subpac4, "diff1"); diff2 = new GenericNode (subpac4, "diff2"); } public void configure () { super.configure (); if (!DEBUG) { createStructure (); subpac1.mkdirs (); refresh (root); pac1.waitStatus ("Local"); addDirectory(pac1); refresh (pac1); subpac1.waitStatus ("Local"); addDirectory(subpac1); subpac2.mkdirs (); refresh (root); pac2.waitStatus ("Local"); addDirectory(pac2); refresh (pac2); subpac2.waitStatus ("Local"); addDirectory(subpac2); createAddCommitFile (aa1, "Java Classes|Main"); } } public void testStatusRefresh () { aa1.waitStatus ("Up-to-date; 1.1"); String file = loadFile(aa1.file ()); try { new OpenAction ().perform(aa1.jcvsNode ()); EditorOperator eo = new EditorOperator (aa1.name () + " [Up-to-date; 1.1]"); eo.txtEditorPane().typeText("// inserted line\n", 0); eo.waitModified(true); eo.save (); eo.waitModified (false); aa1.waitStatus ("LMod; 1.1"); eo.deleteLine(1); eo.waitModified (true); eo.save (); eo.waitModified (false); // eo.close(); // workaround for unreported bug refresh (pac1); aa1.waitStatus ("LMod; 1.1"); refresh (subpac1); aa1.waitStatus ("Up-to-date; 1.1"); } finally { saveToFile(getWorkFilePath() + "/modfile1", loadFile (aa1.file ())); aa1.save (file); } try { aa1.save ("Modify"); refresh (aa1); aa1.waitStatus ("LMod; 1.1"); } finally { saveToFile(getWorkFilePath() + "/modfile2", loadFile (aa1.file ())); aa1.save (file); } refresh (pac1); aa1.waitStatus ("LMod; 1.1"); refresh (subpac1); aa1.waitStatus ("Up-to-date; 1.1"); try { aa1.save ("Modify"); refresh (aa1); aa1.waitStatus ("LMod; 1.1"); } finally { saveToFile(getWorkFilePath() + "/modfile3", loadFile (aa1.file ())); aa1.save (file); } refreshRecursively(pac1); aa1.waitStatus ("Up-to-date; 1.1"); } public void testRemove () { GenericNode remfile = new GenericNode (subpac1, "remfile", ".java"); createAddCommitFile (remfile, "Java Classes|Main"); closeAllVCSWindows(); remfile.jcvsNode ().jCVSRemove (); RemoveDialog rem = new RemoveDialog (); rem.runCommand (); rem.waitClosed (); OutputOfVCSCommandsFrame output = new OutputOfVCSCommandsFrame (); dumpTable (output.tabJTable()); remfile.waitStatus ("Up-to-date; 1.1"); closeAllVCSWindows(); remfile.jcvsNode ().jCVSRemove (); rem = new RemoveDialog (); checkCheckBox (rem.cbDeleteBeforeRemove()); rem.runCommand (); rem.waitClosed (); output = new OutputOfVCSCommandsFrame (); dumpTable (output.tabJTable()); remfile.waitStatus ("LRemoved", false); remfile.jcvsNode().jCVSCommit (); CommitDialog com = new CommitDialog (); com.runCommand(); com.waitClosed (); remfile.waitHistoryShort ("commit -m \"\""); remfile.parent ().jcvsNode ().waitChildNotPresent(remfile.name ()); } public void testRemoveRecursively () { // !!! do it } public void testLogInit () { createAddCommitFile(log1, "Java Classes|Empty"); log1.waitStatus ("Up-to-date; 1.1"); createAddCommitFile(log2, "Java Classes|Empty"); log2.waitStatus ("Up-to-date; 1.1"); log1.save ("modify - log 1 - 1.2"); refresh (log1); log1.waitStatus ("LMod; 1.1"); commitFile(log1, null, "Desc - log 1 - 1.2"); log1.waitStatus ("Up-to-date; 1.2"); log2.save ("modify - log 2 - 1.2"); refresh (log2); log2.waitStatus ("LMod; 1.1"); commitFile(log2, null, "Desc - log 2 - 1.2"); log2.waitStatus ("Up-to-date; 1.2"); addTagFile (log1, "branchtag", true); log1.save ("modify - log 1 - branch - 1.2.1.1"); refresh (log1); log1.waitStatus ("LMod; 1.2"); commitFile (log1, "branchtag", "Desc - log 1 - branchtag - 1.2.2.1"); log1.waitStatus ("Up-to-date; 1.2.2.1"); log1.waitVersion("branchtag"); } public void testLogFileFull () { closeAllVCSWindows(); log1.jcvsNode ().jCVSLog (); LogDialog dia = new LogDialog (); dia.runCommand(); dia.waitClosed(); log1.waitHistoryShort ("log"); LogOutputOperator log = new LogOutputOperator (false, false, false); log.dumpFile(out, "/cvsroot/test/jcvs/" + roothistoryshort); compareReferenceFiles(); } public void testLogFileStrict () { closeAllVCSWindows(); log1.jcvsNode ().jCVSLog (); LogDialog dia = new LogDialog (); checkCheckBox (dia.cbNotRecursively()); checkCheckBox (dia.cbDefaultBranchOnly()); checkCheckBox (dia.cbNoTags()); checkCheckBox (dia.cbHeaderAndDescriptionOnly()); checkCheckBox (dia.cbHeaderOnly()); dia.runCommand(); dia.waitClosed(); log1.waitHistoryShort ("log -b -t -h -N -l"); LogOutputOperator log = new LogOutputOperator (false, true, true); log.dumpFile(out, "/cvsroot/test/jcvs/" + roothistoryshort); compareReferenceFiles(); } public void testLogDirectory () { closeAllVCSWindows(); pac1.jcvsNode ().jCVSLog (); LogDialog dia = new LogDialog (); checkCheckBox (dia.cbNotRecursively()); dia.runCommand(); dia.waitClosed(); pac1.waitHistoryShort ("log -l"); LogOutputOperator log = new LogOutputOperator (true, false, false); log.txtContains().clearText (); log.txtContains().enterText("Desc - log "); log.dumpAll(out, "/cvsroot/test/jcvs/" + roothistoryshort); compareReferenceFiles(); } public void testLogDirectoryRecursive () { closeAllVCSWindows(); pac1.jcvsNode ().jCVSLog (); LogDialog dia = new LogDialog (); dia.runCommand(); dia.waitClosed(); pac1.waitHistoryShort ("log"); LogOutputOperator log = new LogOutputOperator (true, false, false); log.txtContains().clearText (); log.txtContains().enterText("Desc - log "); log.dumpAll(out, "/cvsroot/test/jcvs/" + roothistoryshort); compareReferenceFiles(); } public void testLogRestrictions () { pac1.jcvsNode ().jCVSLog (); LogDialog dia = new LogDialog (); checkCheckBox (dia.cbNotRecursively()); checkCheckBox (dia.cbDefaultBranchOnly()); checkCheckBox (dia.cbNoTags()); checkCheckBox (dia.cbHeaderAndDescriptionOnly()); checkCheckBox (dia.cbHeaderOnly()); checkCheckBox (dia.cbState()); dia.txtState().clearText (); dia.txtState().typeText ("STATE"); checkCheckBox (dia.cbRevision()); dia.txtRevision().clearText (); dia.txtRevision().typeText ("REVISION"); checkCheckBox (dia.cbDate()); dia.txtDate().clearText (); dia.txtDate().typeText ("DATE"); checkCheckBox (dia.cbUser()); dia.txtUser().clearText (); dia.txtUser().typeText ("USER"); JTextFieldOperator cvsSwitches = new JTextFieldOperator (dia, "log "); assertEquals ("CVS Command String", "log -b -t -h -N -l -wUSER -rREVISION -sSTATE -dDATE ", cvsSwitches.getText ()); dia.cancel(); dia.waitClosed(); } public void testStatusInit () { createAddCommitFile(status1, "Java Classes|Empty"); status1.waitStatus ("Up-to-date; 1.1"); createAddCommitFile(status2, "Java Classes|Empty"); status2.waitStatus ("Up-to-date; 1.1"); status1.save ("modify - status 1 - 1.2"); refresh (status1); status1.waitStatus ("LMod; 1.1"); commitFile(status1, null, "Desc - status 1 - 1.2"); status1.waitStatus ("Up-to-date; 1.2"); status2.save ("modify - status 2 - 1.2"); refresh (status2); status2.waitStatus ("LMod; 1.1"); commitFile(status2, null, "Desc - status 2 - 1.2"); status2.waitStatus ("Up-to-date; 1.2"); addTagFile (status1, "branchtag", true); status1.save ("modify - status 1 - branch - 1.2.1.1"); refresh (status1); status1.waitStatus ("LMod; 1.2"); commitFile (status1, "branchtag", "Desc - status 1 - branchtag - 1.2.2.1"); status1.waitStatus ("Up-to-date; 1.2.2.1"); status1.waitVersion("branchtag"); } public void testStatusFile () { closeAllVCSWindows(); status1.jcvsNode ().jCVSStatus (); StatusDialog dia = new StatusDialog (); dia.runCommand(); dia.waitClosed(); status1.waitHistoryShort ("status"); StatusOutputOperator status = new StatusOutputOperator (false); status.dumpFile(out, "/cvsroot/test/jcvs/" + roothistoryshort); status.btGetTags().push (); waitNoEmpty (status.tabExistingTags()); status.dumpExistingTags(out); compareReferenceFiles(); } public void testStatusFileIncludeTags () { closeAllVCSWindows(); status1.jcvsNode ().jCVSStatus (); StatusDialog dia = new StatusDialog (); checkCheckBox (dia.cbIncludeTagInfo()); dia.runCommand(); dia.waitClosed(); status1.waitHistoryShort ("status -v"); StatusOutputOperator status = new StatusOutputOperator (false); status.dumpFile(out, "/cvsroot/test/jcvs/" + roothistoryshort); compareReferenceFiles(); } public void testStatusDirectory () { closeAllVCSWindows(); pac2.jcvsNode ().jCVSStatus (); StatusDialog dia = new StatusDialog (); checkCheckBox (dia.cbIncludeTagInfo()); checkCheckBox (dia.cbNotRecursively()); dia.runCommand(); dia.waitClosed(); pac2.waitHistoryShort ("status -v -l"); StatusOutputOperator status = new StatusOutputOperator (true); status.dumpAll(out, "/cvsroot/test/jcvs/" + roothistoryshort); compareReferenceFiles(); } public void testStatusDirectoryRecursive () { closeAllVCSWindows(); pac2.jcvsNode ().jCVSStatus (); StatusDialog dia = new StatusDialog (); checkCheckBox (dia.cbIncludeTagInfo()); dia.runCommand(); dia.waitClosed(); pac2.waitHistoryShort ("status -v"); StatusOutputOperator status = new StatusOutputOperator (true); status.dumpAll(out, "/cvsroot/test/jcvs/" + roothistoryshort); compareReferenceFiles(); } public void testAnnotateInit () { subpac3.mkdirs (); refresh (root); pac3.waitStatus ("Local"); addDirectory(pac3); refresh (pac3); subpac3.waitStatus ("Local"); addDirectory(subpac3); anno1.save ("Commit-1.1"); refresh (anno1.parent ()); anno1.jcvsNode(); addFile(anno1, "Add-Desc-1.1"); commitFile(anno1, null, "Commit-Desc-1.1"); anno1.waitStatus ("Up-to-date; 1.1"); addTagFile(anno1, "TagName", true); anno1.save ("Commit-TagName"); refresh (anno1.parent ()); anno1.waitStatus ("LMod; 1.1"); commitFile(anno1, "TagName", "Commit-Desc-TagName"); anno1.waitStatus ("Up-to-date; 1.1.2.1"); anno1.waitVersion ("TagName"); anno2.save ("Commit-1.1 - Line1\nCommit-1.1 - Line2\nCommit-1.1 - Line4\nCommit-1.1 - Line5\n"); refresh(anno2.parent ()); anno2.jcvsNode(); addFile (anno2, "InitialState"); commitFile (anno2, null, "Commit_1.1"); anno2.waitStatus ("Up-to-date; 1.1"); anno2.save ("Commit-1.1 - Line1\nCommit-1.1 - Line2 - Modified-1.2\nCommit-1.2 - Line3 - Added-1.2\nCommit-1.1 - Line4\nCommit-1.1 - Line5 - Modified-1.2\n"); commitFile (anno2, null, "Commit_1.2"); anno2.waitStatus ("Up-to-date; 1.2"); anno2.save ("Commit-1.3 - Line0 - Added-1.3\nCommit-1.1 - Line1\nCommit-1.1 - Line2 - Modified-1.2 - Modified-1.3\nCommit-1.2 - Line3 - Added-1.2\nCommit-1.1 - Line4\nCommit-1.1 - Line5 - Modified-1.2\n"); commitFile (anno2, null, "Commit_1.3"); anno2.waitStatus ("Up-to-date; 1.3"); } public void testAnnotateFileFull () { closeAllVCSWindows (); anno2.jcvsNode().jCVSAnnotate(); AnnotateDialog dia = new AnnotateDialog (); dia.runCommand(); dia.waitClosed(); anno2.waitHistoryShort ("annotate"); AnnotateOutputOperator aoo = new AnnotateOutputOperator (false); aoo.dumpFile (out, roothistoryshort); compareReferenceFiles(); } public void testAnnotateFileStrict () { AnnotateDialog dia; AnnotateOutputOperator aoo; closeAllVCSWindows (); anno1.jcvsNode().jCVSAnnotate(); dia = new AnnotateDialog (); checkCheckBox(dia.cbDate()); checkCheckBox(dia.cbRevisionTag()); dia.txtRevisionTag().typeText ("TagName"); checkCheckBox(dia.cbForceHead()); dia.runCommand(); dia.waitClosed(); dia = null; anno1.waitHistoryShort ("annotate -r TagName -D -f"); aoo = new AnnotateOutputOperator (false); aoo.dumpFile (out, roothistoryshort); aoo = null; compareReferenceFiles(); } public void testAnnotateDirectory () { closeAllVCSWindows (); pac3.jcvsNode().jCVSAnnotate(); AnnotateDialog dia = new AnnotateDialog (); checkCheckBox(dia.cbNotRecursively()); dia.runCommand(); dia.waitClosed(); pac3.waitHistoryShort ("annotate -l"); AnnotateOutputOperator aoo = new AnnotateOutputOperator (true); aoo.dumpAll (out, roothistoryshort); compareReferenceFiles(); } public void testAnnotateDirectoryRecursive () { closeAllVCSWindows (); pac3.jcvsNode().jCVSAnnotate(); AnnotateDialog dia = new AnnotateDialog (); dia.runCommand(); dia.waitClosed(); pac3.waitHistoryShort ("annotate"); AnnotateOutputOperator aoo = new AnnotateOutputOperator (true); aoo.dumpAll (out, roothistoryshort); compareReferenceFiles(); } public void testAnnotateInvalid () { closeAllVCSWindows (); anno1.jcvsNode().jCVSAnnotate(); AnnotateDialog dia = new AnnotateDialog (); checkCheckBox(dia.cbDate()); checkCheckBox(dia.cbRevisionTag()); dia.txtRevisionTag().typeText ("InvalidTagName"); checkCheckBox(dia.cbForceHead()); dia.runCommand(); dia.waitClosed(); NbDialogOperator d = new NbDialogOperator ("CVS Error"); d.close(); d.waitClosed (); } public void testAnnotateForce () { AnnotateDialog dia; AnnotateOutputOperator aoo; addTagFile (pac3, "NewTag", true); GenericNode anno3 = new GenericNode (pac3, "anno3", ".java"); createAddCommitFile(anno3, "Java Classes|Empty"); out.println ("+=== No Force ===+"); closeAllVCSWindows (); pac3.jcvsNode().jCVSAnnotate(); dia = new AnnotateDialog (); checkCheckBox(dia.cbRevisionTag()); dia.txtRevisionTag().typeText ("NewTag"); checkCheckBox(dia.cbForceHead()); dia.runCommand(); dia.waitClosed(); pac3.waitHistoryShort ("annotate -r NewTag -f"); aoo = new AnnotateOutputOperator (true); aoo.dumpAll (out, roothistoryshort); out.println ("+=== Force HEAD ===+"); closeAllVCSWindows (); pac3.jcvsNode().jCVSAnnotate(); dia = new AnnotateDialog (); checkCheckBox(dia.cbRevisionTag()); dia.txtRevisionTag().typeText ("NewTag"); dia.runCommand(); dia.waitClosed(); pac3.waitHistoryShort ("annotate -r NewTag"); aoo = new AnnotateOutputOperator (true); aoo.dumpAll (out, roothistoryshort); compareReferenceFiles(); } public void testDiffInit () { subpac4.mkdirs (); refresh (root); pac4.waitStatus ("Local"); addDirectory(pac4); refresh (pac4); subpac4.waitStatus ("Local"); addDirectory(subpac4); diff1.save ("Commit-1.1\nWhitespace Check\nSpace Changes Check\nCase-sensitive Check\nNewLines Check\nEnd of NewLines Check\n"); refresh (diff1.parent ()); diff1.jcvsNode(); addFile(diff1, "Add-Desc-1.1"); commitFile(diff1, null, "Commit-Desc-1.1"); diff1.waitStatus ("Up-to-date; 1.1"); diff1.save ("Commit-1.1\n Whitespace Check \nSpace Changes Check\ncASE-SENsitive Check\nNewLines Check\n\n\n\nEnd of NewLines Check\n"); refresh (diff1.parent ()); diff1.waitStatus ("LMod; 1.1"); diff2.save ("Commit-1.1 - Line1\nCommit-1.1 - Line2\nCommit-1.1 - Line4\nCommit-1.1 - Line5\n"); refresh(diff2.parent ()); diff2.jcvsNode(); addFile (diff2, "InitialState"); commitFile (diff2, null, "Commit_1.1"); diff2.waitStatus ("Up-to-date; 1.1"); diff2.save ("Commit-1.1 - Line1\nCommit-1.1 - Line2 - Modified-1.2\nCommit-1.2 - Line3 - Added-1.2\nCommit-1.1 - Line4\nCommit-1.1 - Line5 - Modified-1.2\n"); commitFile (diff2, null, "Commit_1.2"); diff2.waitStatus ("Up-to-date; 1.2"); diff2.save ("Commit-1.3 - Line0 - Added-1.3\nCommit-1.1 - Line1\nCommit-1.1 - Line2 - Modified-1.2 - Modified-1.3\nCommit-1.2 - Line3 - Added-1.2\nCommit-1.1 - Line4\nCommit-1.1 - Line5 - Modified-1.2\n"); commitFile (diff2, null, "Commit_1.3"); diff2.waitStatus ("Up-to-date; 1.3"); } public void dumpDiffGraphical (GenericNode node) { TopComponentOperator tco = new TopComponentOperator ("Diff " + node.filename(0)); out.println ("==== Diff: " + node.filename(0)); try { dumpDiffGraphical (tco); } finally { tco.close(); waitIsShowing(tco.getSource()); } } public void dumpDiffTextual (GenericNode node, String command) { VCSCommandsOutputOperator coo = new VCSCommandsOutputOperator ("Diff"); out.println ("==== Diff: " + node.filename(0)); waitNoEmpty(coo.txtStandardOutput()); String txt = coo.txtStandardOutput ().getText (); info.println ("==== Diff: " + node.filename(0)); info.println (txt); StringFilter sf = new StringFilter (); sf.addReplaceAllFilter("/cvsroot/test/jcvs/" + roothistoryshort, ""); sf.addReplaceFilter("*** " + node.history (), "", "*** " + node.history () + ""); sf.addReplaceFilter("--- " + node.history (), "", "--- " + node.history () + ""); sf.addReplaceFilter("+++ " + node.history (), "", "+++ " + node.history () + ""); printFiltered(txt, sf); } public void testDiffFile1Revision () { DiffDialog dia; diff2.jcvsNode ().jCVSDiff(); dia = new DiffDialog (); dia.txtRevision1().typeText ("1.1"); dia.runCommand(); dia.waitClosed (); dia = null; diff2.waitHistoryShort ("diff -r 1.1"); out.println ("==== 1 revision ===="); dumpDiffGraphical (diff2); compareReferenceFiles(); } public void testDiffFile2Revisions () { DiffDialog dia; diff2.jcvsNode ().jCVSDiff(); dia = new DiffDialog (); dia.txtRevision1().typeText ("1.1"); dia.txtRevision2().typeText ("1.2"); dia.runCommand(); dia.waitClosed (); dia = null; diff2.waitHistoryShort ("diff -r 1.1 -r 1.2"); out.println ("==== 2 revisions ===="); dumpDiffGraphical (diff2); compareReferenceFiles(); } public void testDiffFileIgnore () { DiffDialog dia; diff1.jcvsNode ().jCVSDiff(); dia = new DiffDialog (); checkCheckBox (dia.cbIgnoreAllWhitespace()); dia.runCommand(); dia.waitClosed (); dia = null; diff1.waitHistoryShort ("diff -w"); out.println ("==== cbIgnoneAllWhitespace ===="); dumpDiffGraphical (diff1); diff1.jcvsNode ().jCVSDiff(); dia = new DiffDialog (); checkCheckBox (dia.cbIgnoreBlankLines()); dia.runCommand(); dia.waitClosed (); dia = null; diff1.waitHistoryShort ("diff -B"); out.println ("==== cbIgnoreBlankLines ===="); dumpDiffGraphical (diff1); diff1.jcvsNode ().jCVSDiff(); dia = new DiffDialog (); checkCheckBox (dia.cbIgnoreCase()); dia.runCommand(); dia.waitClosed (); dia = null; diff1.waitHistoryShort ("diff -i"); out.println ("==== cbIgnoreCase ===="); dumpDiffGraphical (diff1); diff1.jcvsNode ().jCVSDiff(); dia = new DiffDialog (); checkCheckBox (dia.cbIgnoreSpaceChanges()); dia.runCommand(); dia.waitClosed (); dia = null; diff1.waitHistoryShort ("diff -b"); out.println ("==== cbIgnoreSpaceChanges ===="); dumpDiffGraphical (diff1); diff1.jcvsNode ().jCVSDiff(); dia = new DiffDialog (); checkCheckBox (dia.cbIgnoreAllWhitespace()); checkCheckBox (dia.cbIgnoreBlankLines()); checkCheckBox (dia.cbIgnoreCase()); checkCheckBox (dia.cbIgnoreSpaceChanges()); dia.runCommand(); dia.waitClosed (); dia = null; out.println ("==== Ignore All ===="); assertInformationDialog("Diff showed no difference on the following file:"); diff1.waitHistoryShort ("diff -w -B -i -b"); compareReferenceFiles(); } public void testDiffFileFormat () { DiffDialog dia; closeAllVCSWindows(); diff1.jcvsNode ().jCVSDiff(); dia = new DiffDialog (); checkCheckBox (dia.cbContextOutput()); dia.runCommand(); dia.waitClosed (); dia = null; out.println ("==== cbContextOutput ===="); dumpDiffTextual (diff1, "diff -c"); closeAllVCSWindows(); diff1.jcvsNode ().jCVSDiff(); dia = new DiffDialog (); checkCheckBox (dia.cbUnifiedOutput()); dia.runCommand(); dia.waitClosed (); dia = null; out.println ("==== cbUnifiedOutput ===="); dumpDiffTextual (diff1, "diff -u"); compareReferenceFiles(); } public void testDiffDirectory () { DiffDialog dia; closeAllVCSWindows(); pac4.jcvsNode ().jCVSDiff(); dia = new DiffDialog (); dia.runCommand(); dia.waitClosed (); dia = null; out.println ("==== Recursively ===="); dumpDiffTextual (pac4, "diff"); closeAllVCSWindows(); pac4.jcvsNode ().jCVSDiff(); dia = new DiffDialog (); checkCheckBox (dia.cbNotRecursively()); dia.runCommand(); dia.waitClosed (); dia = null; out.println ("==== NOT Recursively ===="); dumpDiffTextual (pac4, "diff -l"); compareReferenceFiles(); } public void testUnmount() { new FilesystemNode(exp.repositoryTab().tree(), root.node ()).unmount(); new Node (exp.repositoryTab ().tree (), "").waitChildNotPresent(root.node ()); } } netbeans-cvsclient_6.5/test/qa-functional/src/complete/BasicCommands.java0000644000175300001440000003311211175407010025603 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package complete; import org.netbeans.jellytools.EditorOperator; import org.netbeans.jellytools.NbDialogOperator; import org.netbeans.jellytools.NewWizardOperator; import org.netbeans.jellytools.TopComponentOperator; import org.netbeans.jellytools.actions.OpenAction; import org.netbeans.jellytools.modules.javacvs.output.AnnotateOutputOperator; import org.netbeans.jellytools.modules.javacvs.output.LogOutputOperator; import org.netbeans.jellytools.modules.javacvs.output.StatusOutputOperator; import org.netbeans.jellytools.modules.vcscore.VCSCommandsOutputOperator; import org.netbeans.jellytools.nodes.FilesystemNode; import org.netbeans.jellytools.nodes.Node; import org.netbeans.jellytools.util.StringFilter; import org.netbeans.jemmy.operators.JTextFieldOperator; import org.netbeans.test.oo.gui.jelly.javacvs.AddDialog; import org.netbeans.test.oo.gui.jelly.javacvs.AnnotateDialog; import org.netbeans.test.oo.gui.jelly.javacvs.CommitDialog; import org.netbeans.test.oo.gui.jelly.javacvs.DiffDialog; import org.netbeans.test.oo.gui.jelly.javacvs.LogDialog; import org.netbeans.test.oo.gui.jelly.javacvs.RemoveDialog; import org.netbeans.test.oo.gui.jelly.javacvs.StatusDialog; import org.netbeans.test.oo.gui.jelly.javacvs.TagDialog; import org.netbeans.test.oo.gui.jelly.vcscore.OutputOfVCSCommandsFrame; public class BasicCommands extends JCVSStub { public BasicCommands(String testName) { super(testName); } public static junit.framework.Test suite() { // DEBUG = true; junit.framework.TestSuite suite = new org.netbeans.junit.NbTestSuite(); suite.addTest(new BasicCommands("configure")); suite.addTest(new BasicCommands("testAddDirectoryRecursive")); suite.addTest(new BasicCommands("testAddNoKeywordSubstitution")); suite.addTest(new BasicCommands("testAddKeywordSubstitution")); suite.addTest(new BasicCommands("testTagInit")); suite.addTest(new BasicCommands("testTagDirectory")); suite.addTest(new BasicCommands("testTagAdd")); suite.addTest(new BasicCommands("testTagModified")); suite.addTest(new BasicCommands("testTagByRevision")); suite.addTest(new BasicCommands("testTagForce")); suite.addTest(new BasicCommands("testTagDelete")); suite.addTest(new BasicCommands("testUnmount")); return suite; } public static void main(java.lang.String[] args) { junit.textui.TestRunner.run(suite()); } GenericNode pac1, subpac1; GenericNode add1, add2, add3; GenericNode pac2, subpac2, subpac22; GenericNode tag1, tag2, tag3, tag4, tag51, tag52, tag6; protected void createStructure() { pac1 = new GenericNode (root, "pac1"); subpac1 = new GenericNode (pac1, "subpac1"); add1 = new GenericNode (subpac1, "add1"); add2 = new GenericNode (pac1, "add2"); add3 = new GenericNode (pac1, "add3"); pac2 = new GenericNode (root, "pac2"); subpac2 = new GenericNode (pac2, "subpac2"); tag1 = new GenericNode (subpac2, "tag1", ".java"); tag2 = new GenericNode (pac2, "tag2", ".java"); tag3 = new GenericNode (pac2, "tag3", ".java"); tag4 = new GenericNode (pac2, "tag4", ".java"); subpac22 = new GenericNode (pac2, "subpa22"); tag51 = new GenericNode (subpac22, "tag51"); tag52 = new GenericNode (subpac22, "tag52"); tag6 = new GenericNode (pac2, "tag6",".java"); } public void configure () { super.configure (); } public void dumpStatus (GenericNode node, boolean directory) { closeAllVCSWindows (); node.jcvsNode ().jCVSStatus (); StatusDialog stat = new StatusDialog (); checkCheckBox (stat.cbIncludeTagInfo()); stat.runCommand(); stat.waitClosed (); node.waitHistoryShort ("status -v"); StatusOutputOperator soo = new StatusOutputOperator (directory); if (directory) soo.dumpAll(out, "/cvsroot/test/jcvs/" + roothistoryshort); else soo.dumpFile(out, "/cvsroot/test/jcvs/" + roothistoryshort); } public void testAddDirectoryRecursive () { subpac1.mkdirs (); add1.save ("Adding 1"); refresh(root); pac1.jcvsNode ().jCVSAdd (); AddDialog add = new AddDialog (); add.txtMessage().setText ("Adding Desc 1"); checkCheckBox(add.cbRecursively()); add.runCommand(); add.waitClosed (); pac1.waitHistoryShort("add -m \"Addin...\""); add1.waitStatus ("LAdded; New", true); dumpStatus (add1, false); compareReferenceFiles (); } public void assertKeywordSubstitution (AddDialog add, String value, String switches) { switches = "add " + ((switches != null) ? (switches + " ") : ""); add.cboSubstitution().selectItem (value); add.compareSwitches(switches); JTextFieldOperator tfo = new JTextFieldOperator (add, switches); assertEquals ("Keyword Substitution assertion failed", switches, tfo.getText ()); } public void testAddNoKeywordSubstitution () { add2.save ("$Revision$\n"); refresh (pac1); add2.jcvsNode ().jCVSAdd (); AddDialog add = new AddDialog (); assertKeywordSubstitution (add, "Reuse Old Value (-ko)", "-ko"); add.txtMessage().setText ("Adding Desc 2"); add.runCommand(); add.waitClosed (); add2.waitHistoryShort("add -m \"Addin...\" -ko"); add2.waitStatus ("LAdded; New", true); commitFile (add2, null, null); add2.waitStatus ("Up-to-date; 1.1", true); out.println ("Corrected file:"); out.println (loadFile(add2.file ())); compareReferenceFiles (); } public void testAddKeywordSubstitution () { add3.save ("$Revision$\n"); refresh (pac1); add3.jcvsNode ().jCVSAdd (); AddDialog add = new AddDialog (); assertKeywordSubstitution (add, "", null); assertKeywordSubstitution (add, "Binary (-kb)", "-kb"); assertKeywordSubstitution (add, "Keyword and Value (-kkv)", "-kkv"); assertKeywordSubstitution (add, "Keyword, Value, Locker (-kkvl)", "-kkvl"); assertKeywordSubstitution (add, "Keyword Only (-kk)", "-kk"); assertKeywordSubstitution (add, "Value Only (-kv)", "-kv"); assertKeywordSubstitution (add, "Reuse Old Value (-ko)", "-ko"); assertKeywordSubstitution (add, "Keyword and Value (-kkv)", "-kkv"); add.txtMessage().setText ("Adding Desc 3"); add.runCommand(); add.waitClosed (); add3.waitHistoryShort("add -m \"Addin...\" -kkv"); add3.waitStatus ("LAdded; New", true); commitFile (add3, null, null); add3.waitStatus ("Up-to-date; 1.1", true); out.println ("Corrected file:"); out.println (loadFile(add3.file ())); compareReferenceFiles (); } public void testTagInit () { subpac2.mkdirs (); refresh (root); addDirectory (pac2); refresh (pac2); addDirectory (subpac2); createAddCommitFile (tag1, "Java Classes|Empty"); createAddCommitFile (tag2, "Java Classes|Empty"); } public void testTagDirectory () { TagDialog tag; pac2.jcvsNode ().jCVSTag (); tag = new TagDialog (); tag.txtTag().typeText ("DirectoryRecursiveTag"); checkCheckBox (tag.cbBranch()); tag.runCommand(); tag.waitClosed (); pac2.waitHistoryShort("tag -b DirectoryRecursiveTag"); pac2.jcvsNode ().jCVSTag (); tag = new TagDialog (); tag.txtTag().typeText ("DirectoryTag"); checkCheckBox (tag.cbNotRecursively()); tag.runCommand(); tag.waitClosed (); pac2.waitHistoryShort("tag -l DirectoryTag"); dumpStatus (pac2, true); compareReferenceFiles (); } public void testTagAdd () { createAddCommitFile(tag3, "Java Classes|Empty"); TagDialog tag; tag3.jcvsNode ().jCVSTag (); tag = new TagDialog (); tag.txtTag().typeText ("AddTagName"); tag.runCommand (); tag.waitClosed (); tag3.waitHistoryShort ("tag AddTagName"); tag3.jcvsNode ().jCVSTag (); tag = new TagDialog (); tag.txtTag().typeText ("AddBranchTagName"); checkCheckBox (tag.cbBranch()); tag.runCommand (); tag.waitClosed (); tag3.waitHistoryShort ("tag -b AddBranchTagName"); dumpStatus (tag3, false); compareReferenceFiles(); } public void testTagModified () { createAddCommitFile(tag4, "Java Classes|Empty"); tag4.save (""); refresh (tag4.parent ()); closeAllVCSWindows (); tag4.jcvsNode ().jCVSTag (); TagDialog tag = new TagDialog (); tag.txtTag().typeText ("ModifiedAddTagName"); checkCheckBox (tag.cbCheckModifiedFiles()); tag.runCommand (); tag.waitClosed (); assertCVSErrorDialog (); } public void testTagByRevision () { commitFile (tag4, null, "Desc 1.2"); tag4.waitStatus ("Up-to-date; 1.2"); closeAllVCSWindows (); tag4.jcvsNode ().jCVSTag (); TagDialog tag = new TagDialog (); tag.txtTag().typeText ("AddTagToRevisionName"); checkCheckBox (tag.cbByRevision()); tag.txtByRevision().typeText ("1.1"); tag.runCommand (); tag.waitClosed (); dumpStatus (tag4, false); compareReferenceFiles(); } public void testTagForce () { subpac22.mkdirs (); refresh (subpac22.parent ()); addDirectory(subpac22); tag51.save ("Tag51"); tag52.save ("Tag52"); refresh (subpac22); addFile(tag51, null); commitFile(tag51, null, null); tag51.waitStatus ("Up-to-date; 1.1"); addTagFile(tag51, "NoForceTag", false); tag51.save ("Tag51a"); commitFile(tag51, null, null); tag51.waitStatus ("Up-to-date; 1.2"); addFile(tag52, null); commitFile(tag52, null, null); tag52.waitStatus ("Up-to-date; 1.1"); addTagFile(tag52, "ForceTag", false); tag52.save ("Tag52a"); commitFile(tag52, null, null); tag52.waitStatus ("Up-to-date; 1.2"); dumpStatus(subpac22, true); subpac22.jcvsNode ().jCVSTag(); TagDialog tag = new TagDialog (); tag.txtTag().typeText ("ForceTag"); checkCheckBox (tag.cbForceReassignement()); tag.runCommand(); tag.waitClosed (); subpac22.waitHistoryShort("tag -F ForceTag"); dumpStatus(subpac22, true); compareReferenceFiles (); } public void testTagDelete () { createAddCommitFile(tag6, "Java Classes|Empty"); addTagFile(tag6, "TagToDelete", false); dumpStatus (tag6, false); tag6.jcvsNode ().jCVSTag (); TagDialog tag = new TagDialog (); tag.txtTag().typeText ("TagToDelete"); checkCheckBox(tag.cbDelete()); tag.runCommand (); tag.waitClosed (); tag6.waitHistoryShort("tag -d TagToDelete"); dumpStatus(tag6, false); compareReferenceFiles (); } public void testUnmount() { new FilesystemNode(exp.repositoryTab().tree(), root.node ()).unmount(); new Node (exp.repositoryTab ().tree (), "").waitChildNotPresent(root.node ()); } } netbeans-cvsclient_6.5/test/qa-functional/src/complete/JCVSStub.java0000644000175300001440000003402511175407010024507 0ustar ludousers /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package complete; import complete.GenericStub.GenericNode; import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Enumeration; import junit.framework.AssertionFailedError; import org.netbeans.jellytools.NbDialogOperator; import org.netbeans.jellytools.NewWizardOperator; import org.netbeans.jellytools.actions.Action; import org.netbeans.jellytools.actions.CustomizeAction; import org.netbeans.jellytools.modules.javacvs.CVSClientCustomizerDialogOperator; import org.netbeans.jellytools.modules.javacvs.actions.JCVSMountAction; import org.netbeans.jellytools.modules.javacvs.wizard.*; import org.netbeans.jellytools.nodes.Node; import org.netbeans.jellytools.properties.ComboBoxProperty; import org.netbeans.jellytools.properties.PropertySheetOperator; import org.netbeans.jemmy.operators.JCheckBoxOperator; import org.netbeans.jemmy.operators.JTableOperator; import org.netbeans.test.oo.gui.jelly.javacvs.AddDialog; import org.netbeans.test.oo.gui.jelly.javacvs.CheckoutDialog; import org.netbeans.test.oo.gui.jelly.javacvs.CommitDialog; import org.netbeans.test.oo.gui.jelly.javacvs.TagDialog; import org.openide.filesystems.FileSystem; import org.openide.filesystems.Repository; import util.History; public abstract class JCVSStub extends GenericStub { public JCVSStub(String testName) { super(testName); nRootPrefix = "CVS "; } static FileSystem sfs = null; protected FileSystem getFileSystem () { return sfs; } protected void setFileSystem (FileSystem fs) { sfs = fs; } protected void prepareServer (String dir) { } protected static String roothistoryshort = null; protected void setUp() throws Exception { super.setUp (); if (!"configure".equals (getName ())) { history.switchToJCVS(); history.setTimeout(30); root.setHistoryShort(roothistoryshort); } } protected void findFS () { if (!GenericStub.DEBUG) { super.findFS (); return; } String normalizedClient = (nRootPrefix + clientDirectory.replace ('\\', '/')).toLowerCase (); Enumeration e = Repository.getDefault().getFileSystems(); while (e.hasMoreElements()) { FileSystem f = (FileSystem) e.nextElement(); info.println("Is it?: " + f.getDisplayName()); String path = f.getDisplayName ().replace ('\\', '/').toLowerCase(); if (path.indexOf (normalizedClient) >= 0) { info.println("Yes"); setFileSystem(f); roothistoryshort = f.getDisplayName ().substring(f.getDisplayName ().lastIndexOf ('/') + 1); return; } } new AssertionFailedError ("Filesystem not found: Filesystem: " + normalizedClient); } protected void mountVCSFileSystem () { new Action ("Versioning|Mount Version Control", null).performMenu (); // workaround for issue #31026 new Action ("Tools", null).performMenu (); // workaround for issue #31026 sleep (10000); new Action ("Versioning|Mount Version Control", null).performMenu (); // workaround for issue #31026 new Action ("Tools", null).performMenu (); // workaround for issue #31026 new JCVSMountAction().perform(); WorkingDirectoryStepOperator wdso = new WorkingDirectoryStepOperator (); wdso.verify (); txtSetTypeText (wdso.cboWorkingDirectory().getTextField(), clientDirectory); wdso.next (); CVSConnectionMethodStepOperator ccmsto = new CVSConnectionMethodStepOperator (); ccmsto.verify (); ccmsto.passwordServer(); // ccmsto.setServerName("qa-w2k-s1"); // ccmsto.setUserName("test"); // txtSetTypeText (ccmsto.txtRepository(), "d:\\apps\\vcs\\cvs\\repository"); // ccmsto.txtCVSROOT().waitText(":pserver:test@qa-w2k-s1:d:\\apps\\vcs\\cvs\\repository"); ccmsto.setServerName("mercury"); ccmsto.setUserName("test"); txtSetTypeText (ccmsto.txtRepository(), "/cvsroot"); ccmsto.txtCVSROOT().waitText(":pserver:test@mercury:/cvsroot"); ccmsto.next (); CVSClientStepOperator ccso = new CVSClientStepOperator (); ccso.verify (); ccso.useBuiltInCVSClient(); ccso.next (); CVSLoginStepOperator clso = new CVSLoginStepOperator (); clso.verify (); clso.txtPassword().clearText (); clso.txtPassword().typeText ("test"); clso.login(); clso.txtLogin().waitText ("Login successful."); clso.next (); InitialCheckoutStepOperator icso = new InitialCheckoutStepOperator (); icso.checkCheckOutACopyOfTheRepositoryFilesToYourWorkingDirectory (false); icso.finish (); } protected void prepareClient () { history = new History (getFileSystem(), info); history.switchToJCVS(); history.setTimeout(30); root.setHistoryShort ("client"); closeAllVCSWindows(); closeAllProperties(); root.jcvsNode().properties(); PropertySheetOperator pso = new PropertySheetOperator (root.node ()); ComboBoxProperty cbp = new ComboBoxProperty (pso, "User Interface Mode"); cbp.setValue("GUI Style"); sleep (1000); info.println ("User Interface Mode property value 1: " + cbp.getValue ()); closeAllProperties(); // stabilization root.jcvsNode().properties(); pso = new PropertySheetOperator (root.node ()); cbp = new ComboBoxProperty (pso, "User Interface Mode"); info.println ("User Interface Mode property value 2: " + cbp.getValue ()); cbp.setValue("GUI Style"); sleep (1000); info.println ("User Interface Mode property value 3: " + cbp.getValue ()); closeAllProperties(); history.setTimeout(120); checkout(root, "test/jcvs"); history.setTimeout(30); GenericNode test = new GenericNode (root, "test"); GenericNode jcvs = new GenericNode (test, "jcvs"); jcvs.waitStatus (null); jcvs.jcvsNode().select (); roothistoryshort = new SimpleDateFormat ("yyMMddHHmmssSS").format (new Date (System.currentTimeMillis())); GenericNode cur = new GenericNode (jcvs, roothistoryshort); cur.mkdirs(); refresh (jcvs); cur.waitStatus("Local"); addDirectory (cur); new CustomizeAction ().performPopup(root.jcvsNode()); CVSClientCustomizerDialogOperator cus = new CVSClientCustomizerDialogOperator (); new Node (cus.treeSelectRelativeMountPoint(), "test|jcvs|" + roothistoryshort).select (); cus.txtRelativeMountPoint().waitText ("test" + File.separator + "jcvs" + File.separator + roothistoryshort); cus.ok (); cus.waitClosed(); closeAllVCSWindows(); for (int a = 0; a < 30; a ++) { if (getFileSystem().getDisplayName().endsWith(roothistoryshort)) { root = new GenericNode (null, getFileSystem ().getDisplayName ().substring(nRootPrefix.length())); root.setHistoryShort(roothistoryshort); root.jcvsNode ().select (); return; } sleep (1000); } throw new AssertionFailedError ("New root not found: Root: " + roothistoryshort); } protected void refresh (GenericNode node) { node.jcvsNode ().expand (); // workaround for issue #29598 node.jcvsNode().jCVSRefresh(); node.waitHistoryShort ("status -l"); } protected void refreshRecursively (GenericNode node) { node.jcvsNode ().expand (); // workaround for issue #29598 node.jcvsNode ().jCVSRefreshRecursively(); node.waitHistoryShort ("status"); } protected void addDirectory (GenericNode node) { node.jcvsNode ().expand (); // workaround for issue #29598 node.jcvsNode ().jCVSAdd(); AddDialog add = new AddDialog (); add.runCommand (); add.waitClosed(); node.waitHistoryShort ("add"); node.waitStatus (null); } protected void checkout (GenericNode node, String what) { node.jcvsNode ().expand (); // workaround for issue #29598 node.jcvsNode ().jCVSCheckOut(); CheckoutDialog cod = new CheckoutDialog (); cod.txtCheckout().clearText(); cod.txtCheckout().typeText(what); cod.runCommand(); cod.waitClosed(); node.waitHistoryShort ("checkout " + what); } protected void addFile (GenericNode node, String desc) { node.cvsNode ().cVSAdd(); AddDialog add = new AddDialog (); if (desc != null) { add.txtMessage().setCaretPosition(0); add.txtMessage().typeText(desc); } add.runCommand (); add.waitClosed(); if (desc != null) { if (desc.length () > 9) desc = desc.substring(0, 5) + "..."; node.waitHistoryShort("add -m \"" + desc + "\""); } else node.waitHistoryShort("add"); node.waitStatus ("LAdded; New"); } protected void commitFile (GenericNode node, String branch, String desc) { node.cvsNode ().cVSCommit(); CommitDialog com = new CommitDialog (); if (branch != null) { checkCheckBox (com.cbRevisionBranch()); com.txtRevisionBranch().clearText(); com.txtRevisionBranch().typeText(branch); } if (desc != null) { com.txtMessage().setCaretPosition(0); com.txtMessage().typeText(desc); } com.runCommand (); com.waitClosed(); String cmd = "commit"; if (branch != null) cmd += " -r " + branch; if (desc != null) { if (desc.length () > 9) desc = desc.substring (0, 5) + "..."; cmd += " -m \"" + desc + "\""; } else cmd += " -m \"\""; node.waitHistoryShort (cmd); node.jcvsNode().jCVSRefresh(); // workaround for unreported issue - sometimes file annotation is not updated after commit node.waitHistoryShort ("status -l"); // workaround for unreported issue - sometimes file annotation is not updated after commit node.waitStatus ("Up-to-date", false); } public void createAddCommitFile (GenericNode node, String template) { NewWizardOperator.create(template, node.parent ().node (), node.name ()); node.waitStatus ("Local"); addFile (node, "Initial"); commitFile (node, null, "Initial state"); node.waitStatus ("Up-to-date; 1.1"); } public void dumpTable (JTableOperator table) { out.println ("==== Table Dump ===="); int rows = table.getRowCount(); out.println ("Rows: " + rows); int columns = table.getColumnCount(); out.println ("Columns: " + columns); for (int a = 0; a < rows; a ++) { out.print ("" + (a + 1) + "."); for (int b = 0; b < columns; b ++) out.print (" - " + table.getValueAt(a, b)); out.println (); } } protected void addTagFile (GenericNode node, String name, boolean branch) { node.jcvsNode().jCVSTag(); TagDialog tag = new TagDialog (); checkCheckBox (tag.cbBranch(), branch); tag.txtTag().clearText (); tag.txtTag().typeText (name); tag.runCommand (); tag.waitClosed (); if (branch) node.waitHistoryShort("tag -b " + name); else node.waitHistoryShort("tag " + name); } protected void checkCheckBox (JCheckBoxOperator cb) { checkCheckBox (cb, true); } protected void checkCheckBox (JCheckBoxOperator cb, boolean state) { if (cb.isSelected() != state) cb.push (); } protected void assertCVSErrorDialog () { NbDialogOperator dia = new NbDialogOperator ("CVS Error"); dia.close(); dia.waitClosed (); } } netbeans-cvsclient_6.5/test/qa-functional/src/complete/data/0000755000175300001440000000000011175434236023160 5ustar ludousersnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/0000755000175300001440000000000011175434236025453 5ustar ludousersnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/0000755000175300001440000000000011175434236031205 5ustar ludousers././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testAnnotateDirectory.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testAnnot0000644000175300001440000000141411175407010033075 0ustar ludousersdumpAll: Rows: 1 dumpFile: /pac3/anno1 Line: 1 ---- 1 1.1 Commit-1.1 No Author selected: ---- Equals -- ---- Line: 1 ---- White ---- Equals -- 1.1 ---- Line: 1 ---- Green ---- Newer than -- ---- Line: 1 ---- White ---- Newer than -- 1.1 ---- Line: 1 ---- White ---- Older than -- ---- Line: 1 ---- White ---- Older than -- 1.1 ---- Line: 1 ---- White Author selected: ---- Equals -- ---- Line: 1 ---- Blue ---- Equals -- 1.1 ---- Line: 1 ---- Red ---- Newer than -- ---- Line: 1 ---- Blue ---- Newer than -- 1.1 ---- Line: 1 ---- Blue ---- Older than -- ---- Line: 1 ---- Blue ---- Older than -- 1.1 ---- Line: 1 ---- Blue ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testAnnotateDirectoryRecursive.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testAnnot0000644000175300001440000001072311175407010033100 0ustar ludousersdumpAll: Rows: 2 dumpFile: /pac3/anno1 Line: 1 ---- 1 1.1 Commit-1.1 No Author selected: ---- Equals -- ---- Line: 1 ---- White ---- Equals -- 1.1 ---- Line: 1 ---- Green ---- Newer than -- ---- Line: 1 ---- White ---- Newer than -- 1.1 ---- Line: 1 ---- White ---- Older than -- ---- Line: 1 ---- White ---- Older than -- 1.1 ---- Line: 1 ---- White Author selected: ---- Equals -- ---- Line: 1 ---- Blue ---- Equals -- 1.1 ---- Line: 1 ---- Red ---- Newer than -- ---- Line: 1 ---- Blue ---- Newer than -- 1.1 ---- Line: 1 ---- Blue ---- Older than -- ---- Line: 1 ---- Blue ---- Older than -- 1.1 ---- Line: 1 ---- Blue dumpFile: /pac3/subpac3/anno2 Line: 1 ---- 1 1.3 Commit-1.3 - Line0 - Added-1.3 Line: 2 ---- 2 1.1 Commit-1.1 - Line1 Line: 3 ---- 3 1.3 Commit-1.1 - Line2 - Modified-1.2 - Modified-1.3 Line: 4 ---- 4 1.2 Commit-1.2 - Line3 - Added-1.2 Line: 5 ---- 5 1.1 Commit-1.1 - Line4 Line: 6 ---- 6 1.2 Commit-1.1 - Line5 - Modified-1.2 No Author selected: ---- Equals -- ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Equals -- 1.1 ---- Line: 1 ---- White Line: 2 ---- Green Line: 3 ---- White Line: 4 ---- White Line: 5 ---- Green Line: 6 ---- White ---- Equals -- 1.2 ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- Green Line: 5 ---- White Line: 6 ---- Green ---- Equals -- 1.3 ---- Line: 1 ---- Green Line: 2 ---- White Line: 3 ---- Green Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Newer than -- ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Newer than -- 1.1 ---- Line: 1 ---- Green Line: 2 ---- White Line: 3 ---- Green Line: 4 ---- Green Line: 5 ---- White Line: 6 ---- Green ---- Newer than -- 1.2 ---- Line: 1 ---- Green Line: 2 ---- White Line: 3 ---- Green Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Newer than -- 1.3 ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Older than -- ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Older than -- 1.1 ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Older than -- 1.2 ---- Line: 1 ---- White Line: 2 ---- Green Line: 3 ---- White Line: 4 ---- White Line: 5 ---- Green Line: 6 ---- White ---- Older than -- 1.3 ---- Line: 1 ---- White Line: 2 ---- Green Line: 3 ---- White Line: 4 ---- Green Line: 5 ---- Green Line: 6 ---- Green Author selected: ---- Equals -- ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Equals -- 1.1 ---- Line: 1 ---- Blue Line: 2 ---- Red Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Red Line: 6 ---- Blue ---- Equals -- 1.2 ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Red Line: 5 ---- Blue Line: 6 ---- Red ---- Equals -- 1.3 ---- Line: 1 ---- Red Line: 2 ---- Blue Line: 3 ---- Red Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Newer than -- ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Newer than -- 1.1 ---- Line: 1 ---- Red Line: 2 ---- Blue Line: 3 ---- Red Line: 4 ---- Red Line: 5 ---- Blue Line: 6 ---- Red ---- Newer than -- 1.2 ---- Line: 1 ---- Red Line: 2 ---- Blue Line: 3 ---- Red Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Newer than -- 1.3 ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Older than -- ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Older than -- 1.1 ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Older than -- 1.2 ---- Line: 1 ---- Blue Line: 2 ---- Red Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Red Line: 6 ---- Blue ---- Older than -- 1.3 ---- Line: 1 ---- Blue Line: 2 ---- Red Line: 3 ---- Blue Line: 4 ---- Red Line: 5 ---- Red Line: 6 ---- Red ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testAnnotateFileFull.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testAnnot0000644000175300001440000000730711175407010033104 0ustar ludousersdumpFile: /pac3/subpac3/anno2 Line: 1 ---- 1 1.3 Commit-1.3 - Line0 - Added-1.3 Line: 2 ---- 2 1.1 Commit-1.1 - Line1 Line: 3 ---- 3 1.3 Commit-1.1 - Line2 - Modified-1.2 - Modified-1.3 Line: 4 ---- 4 1.2 Commit-1.2 - Line3 - Added-1.2 Line: 5 ---- 5 1.1 Commit-1.1 - Line4 Line: 6 ---- 6 1.2 Commit-1.1 - Line5 - Modified-1.2 No Author selected: ---- Equals -- ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Equals -- 1.1 ---- Line: 1 ---- White Line: 2 ---- Green Line: 3 ---- White Line: 4 ---- White Line: 5 ---- Green Line: 6 ---- White ---- Equals -- 1.2 ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- Green Line: 5 ---- White Line: 6 ---- Green ---- Equals -- 1.3 ---- Line: 1 ---- Green Line: 2 ---- White Line: 3 ---- Green Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Newer than -- ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Newer than -- 1.1 ---- Line: 1 ---- Green Line: 2 ---- White Line: 3 ---- Green Line: 4 ---- Green Line: 5 ---- White Line: 6 ---- Green ---- Newer than -- 1.2 ---- Line: 1 ---- Green Line: 2 ---- White Line: 3 ---- Green Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Newer than -- 1.3 ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Older than -- ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Older than -- 1.1 ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Older than -- 1.2 ---- Line: 1 ---- White Line: 2 ---- Green Line: 3 ---- White Line: 4 ---- White Line: 5 ---- Green Line: 6 ---- White ---- Older than -- 1.3 ---- Line: 1 ---- White Line: 2 ---- Green Line: 3 ---- White Line: 4 ---- Green Line: 5 ---- Green Line: 6 ---- Green Author selected: ---- Equals -- ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Equals -- 1.1 ---- Line: 1 ---- Blue Line: 2 ---- Red Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Red Line: 6 ---- Blue ---- Equals -- 1.2 ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Red Line: 5 ---- Blue Line: 6 ---- Red ---- Equals -- 1.3 ---- Line: 1 ---- Red Line: 2 ---- Blue Line: 3 ---- Red Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Newer than -- ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Newer than -- 1.1 ---- Line: 1 ---- Red Line: 2 ---- Blue Line: 3 ---- Red Line: 4 ---- Red Line: 5 ---- Blue Line: 6 ---- Red ---- Newer than -- 1.2 ---- Line: 1 ---- Red Line: 2 ---- Blue Line: 3 ---- Red Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Newer than -- 1.3 ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Older than -- ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Older than -- 1.1 ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Older than -- 1.2 ---- Line: 1 ---- Blue Line: 2 ---- Red Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Red Line: 6 ---- Blue ---- Older than -- 1.3 ---- Line: 1 ---- Blue Line: 2 ---- Red Line: 3 ---- Blue Line: 4 ---- Red Line: 5 ---- Red Line: 6 ---- Red ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testAnnotateFileStrict.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testAnnot0000644000175300001440000000143311175407010033076 0ustar ludousersdumpFile: /pac3/anno1 Line: 1 ---- 1 1.1.2.1 Commit-TagName No Author selected: ---- Equals -- ---- Line: 1 ---- White ---- Equals -- 1.1.2.1 ---- Line: 1 ---- Green ---- Newer than -- ---- Line: 1 ---- White ---- Newer than -- 1.1.2.1 ---- Line: 1 ---- White ---- Older than -- ---- Line: 1 ---- White ---- Older than -- 1.1.2.1 ---- Line: 1 ---- White Author selected: ---- Equals -- ---- Line: 1 ---- Blue ---- Equals -- 1.1.2.1 ---- Line: 1 ---- Red ---- Newer than -- ---- Line: 1 ---- Blue ---- Newer than -- 1.1.2.1 ---- Line: 1 ---- Blue ---- Older than -- ---- Line: 1 ---- Blue ---- Older than -- 1.1.2.1 ---- Line: 1 ---- Blue ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testAnnotateForce.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testAnnot0000644000175300001440000002436311175407010033105 0ustar ludousers+=== No Force ===+ dumpAll: Rows: 3 dumpFile: /pac3/anno1 Line: 1 ---- 1 1.1.2.1 Commit-TagName No Author selected: ---- Equals -- ---- Line: 1 ---- White ---- Equals -- 1.1.2.1 ---- Line: 1 ---- Green ---- Newer than -- ---- Line: 1 ---- White ---- Newer than -- 1.1.2.1 ---- Line: 1 ---- White ---- Older than -- ---- Line: 1 ---- White ---- Older than -- 1.1.2.1 ---- Line: 1 ---- White Author selected: ---- Equals -- ---- Line: 1 ---- Blue ---- Equals -- 1.1.2.1 ---- Line: 1 ---- Red ---- Newer than -- ---- Line: 1 ---- Blue ---- Newer than -- 1.1.2.1 ---- Line: 1 ---- Blue ---- Older than -- ---- Line: 1 ---- Blue ---- Older than -- 1.1.2.1 ---- Line: 1 ---- Blue dumpFile: /pac3/anno3.java Line: 1 ---- 1 1.1 package pac3; Line: 2 ---- 2 1.1 Line: 3 ---- 3 1.1 No Author selected: ---- Equals -- ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White ---- Equals -- 1.1 ---- Line: 1 ---- Green Line: 2 ---- Green Line: 3 ---- Green ---- Newer than -- ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White ---- Newer than -- 1.1 ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White ---- Older than -- ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White ---- Older than -- 1.1 ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Author selected: ---- Equals -- ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue ---- Equals -- 1.1 ---- Line: 1 ---- Red Line: 2 ---- Red Line: 3 ---- Red ---- Newer than -- ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue ---- Newer than -- 1.1 ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue ---- Older than -- ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue ---- Older than -- 1.1 ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue dumpFile: /pac3/subpac3/anno2 Line: 1 ---- 1 1.3 Commit-1.3 - Line0 - Added-1.3 Line: 2 ---- 2 1.1 Commit-1.1 - Line1 Line: 3 ---- 3 1.3 Commit-1.1 - Line2 - Modified-1.2 - Modified-1.3 Line: 4 ---- 4 1.2 Commit-1.2 - Line3 - Added-1.2 Line: 5 ---- 5 1.1 Commit-1.1 - Line4 Line: 6 ---- 6 1.2 Commit-1.1 - Line5 - Modified-1.2 No Author selected: ---- Equals -- ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Equals -- 1.1 ---- Line: 1 ---- White Line: 2 ---- Green Line: 3 ---- White Line: 4 ---- White Line: 5 ---- Green Line: 6 ---- White ---- Equals -- 1.2 ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- Green Line: 5 ---- White Line: 6 ---- Green ---- Equals -- 1.3 ---- Line: 1 ---- Green Line: 2 ---- White Line: 3 ---- Green Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Newer than -- ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Newer than -- 1.1 ---- Line: 1 ---- Green Line: 2 ---- White Line: 3 ---- Green Line: 4 ---- Green Line: 5 ---- White Line: 6 ---- Green ---- Newer than -- 1.2 ---- Line: 1 ---- Green Line: 2 ---- White Line: 3 ---- Green Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Newer than -- 1.3 ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Older than -- ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Older than -- 1.1 ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Older than -- 1.2 ---- Line: 1 ---- White Line: 2 ---- Green Line: 3 ---- White Line: 4 ---- White Line: 5 ---- Green Line: 6 ---- White ---- Older than -- 1.3 ---- Line: 1 ---- White Line: 2 ---- Green Line: 3 ---- White Line: 4 ---- Green Line: 5 ---- Green Line: 6 ---- Green Author selected: ---- Equals -- ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Equals -- 1.1 ---- Line: 1 ---- Blue Line: 2 ---- Red Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Red Line: 6 ---- Blue ---- Equals -- 1.2 ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Red Line: 5 ---- Blue Line: 6 ---- Red ---- Equals -- 1.3 ---- Line: 1 ---- Red Line: 2 ---- Blue Line: 3 ---- Red Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Newer than -- ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Newer than -- 1.1 ---- Line: 1 ---- Red Line: 2 ---- Blue Line: 3 ---- Red Line: 4 ---- Red Line: 5 ---- Blue Line: 6 ---- Red ---- Newer than -- 1.2 ---- Line: 1 ---- Red Line: 2 ---- Blue Line: 3 ---- Red Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Newer than -- 1.3 ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Older than -- ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Older than -- 1.1 ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Older than -- 1.2 ---- Line: 1 ---- Blue Line: 2 ---- Red Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Red Line: 6 ---- Blue ---- Older than -- 1.3 ---- Line: 1 ---- Blue Line: 2 ---- Red Line: 3 ---- Blue Line: 4 ---- Red Line: 5 ---- Red Line: 6 ---- Red +=== Force HEAD ===+ dumpAll: Rows: 2 dumpFile: /pac3/anno1 Line: 1 ---- 1 1.1.2.1 Commit-TagName No Author selected: ---- Equals -- ---- Line: 1 ---- White ---- Equals -- 1.1.2.1 ---- Line: 1 ---- Green ---- Newer than -- ---- Line: 1 ---- White ---- Newer than -- 1.1.2.1 ---- Line: 1 ---- White ---- Older than -- ---- Line: 1 ---- White ---- Older than -- 1.1.2.1 ---- Line: 1 ---- White Author selected: ---- Equals -- ---- Line: 1 ---- Blue ---- Equals -- 1.1.2.1 ---- Line: 1 ---- Red ---- Newer than -- ---- Line: 1 ---- Blue ---- Newer than -- 1.1.2.1 ---- Line: 1 ---- Blue ---- Older than -- ---- Line: 1 ---- Blue ---- Older than -- 1.1.2.1 ---- Line: 1 ---- Blue dumpFile: /pac3/subpac3/anno2 Line: 1 ---- 1 1.3 Commit-1.3 - Line0 - Added-1.3 Line: 2 ---- 2 1.1 Commit-1.1 - Line1 Line: 3 ---- 3 1.3 Commit-1.1 - Line2 - Modified-1.2 - Modified-1.3 Line: 4 ---- 4 1.2 Commit-1.2 - Line3 - Added-1.2 Line: 5 ---- 5 1.1 Commit-1.1 - Line4 Line: 6 ---- 6 1.2 Commit-1.1 - Line5 - Modified-1.2 No Author selected: ---- Equals -- ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Equals -- 1.1 ---- Line: 1 ---- White Line: 2 ---- Green Line: 3 ---- White Line: 4 ---- White Line: 5 ---- Green Line: 6 ---- White ---- Equals -- 1.2 ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- Green Line: 5 ---- White Line: 6 ---- Green ---- Equals -- 1.3 ---- Line: 1 ---- Green Line: 2 ---- White Line: 3 ---- Green Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Newer than -- ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Newer than -- 1.1 ---- Line: 1 ---- Green Line: 2 ---- White Line: 3 ---- Green Line: 4 ---- Green Line: 5 ---- White Line: 6 ---- Green ---- Newer than -- 1.2 ---- Line: 1 ---- Green Line: 2 ---- White Line: 3 ---- Green Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Newer than -- 1.3 ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Older than -- ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Older than -- 1.1 ---- Line: 1 ---- White Line: 2 ---- White Line: 3 ---- White Line: 4 ---- White Line: 5 ---- White Line: 6 ---- White ---- Older than -- 1.2 ---- Line: 1 ---- White Line: 2 ---- Green Line: 3 ---- White Line: 4 ---- White Line: 5 ---- Green Line: 6 ---- White ---- Older than -- 1.3 ---- Line: 1 ---- White Line: 2 ---- Green Line: 3 ---- White Line: 4 ---- Green Line: 5 ---- Green Line: 6 ---- Green Author selected: ---- Equals -- ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Equals -- 1.1 ---- Line: 1 ---- Blue Line: 2 ---- Red Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Red Line: 6 ---- Blue ---- Equals -- 1.2 ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Red Line: 5 ---- Blue Line: 6 ---- Red ---- Equals -- 1.3 ---- Line: 1 ---- Red Line: 2 ---- Blue Line: 3 ---- Red Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Newer than -- ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Newer than -- 1.1 ---- Line: 1 ---- Red Line: 2 ---- Blue Line: 3 ---- Red Line: 4 ---- Red Line: 5 ---- Blue Line: 6 ---- Red ---- Newer than -- 1.2 ---- Line: 1 ---- Red Line: 2 ---- Blue Line: 3 ---- Red Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Newer than -- 1.3 ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Older than -- ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Older than -- 1.1 ---- Line: 1 ---- Blue Line: 2 ---- Blue Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Blue Line: 6 ---- Blue ---- Older than -- 1.2 ---- Line: 1 ---- Blue Line: 2 ---- Red Line: 3 ---- Blue Line: 4 ---- Blue Line: 5 ---- Red Line: 6 ---- Blue ---- Older than -- 1.3 ---- Line: 1 ---- Blue Line: 2 ---- Red Line: 3 ---- Blue Line: 4 ---- Red Line: 5 ---- Red Line: 6 ---- Red ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testDiffDirectory.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testDiffD0000644000175300001440000000066411175407010033000 0ustar ludousers==== Recursively ==== ==== Diff: pac4 Index: pac4/subpac4/diff1 =================================================================== RCS file: /pac4/subpac4/diff1,v retrieving revision 1.1 diff -r1.1 diff1 2,4c2,4 < Whitespace Check < Space Changes Check < Case-sensitive Check --- > Whitespace Check > Space Changes Check > cASE-SENsitive Check 5a6,8 > > > ==== NOT Recursively ==== ==== Diff: pac4 ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testDiffFile1Revision.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testDiffF0000644000175300001440000000411211175407010032772 0ustar ludousers==== 1 revision ==== ==== Diff: diff2 ==== Text - Panel 1 ==== Commit-1.1 - Line1 Commit-1.1 - Line2 Commit-1.1 - Line4 Commit-1.1 - Line5 ==== Text - Panel 2 ==== Commit-1.3 - Line0 - Added-1.3 Commit-1.1 - Line1 Commit-1.1 - Line2 - Modified-1.2 - Modified-1.3 Commit-1.2 - Line3 - Added-1.2 Commit-1.1 - Line4 Commit-1.1 - Line5 - Modified-1.2 ==== Colors - Panel 1 ==== Pos: 20 ---- Blue Pos: 22 ---- Blue Pos: 24 ---- Blue Pos: 26 ---- Blue Pos: 28 ---- Blue Pos: 30 ---- Blue Pos: 32 ---- Blue Pos: 34 ---- Blue Pos: 36 ---- Blue Pos: 38 ---- Blue Pos: 59 ---- Blue Pos: 61 ---- Blue Pos: 63 ---- Blue Pos: 65 ---- Blue Pos: 67 ---- Blue Pos: 69 ---- Blue Pos: 71 ---- Blue Pos: 73 ---- Blue Pos: 75 ---- Blue Pos: 77 ---- Blue ==== Colors - Panel 2 ==== Pos: 0 ---- Green Pos: 2 ---- Green Pos: 4 ---- Green Pos: 6 ---- Green Pos: 8 ---- Green Pos: 10 ---- Green Pos: 12 ---- Green Pos: 14 ---- Green Pos: 16 ---- Green Pos: 18 ---- Green Pos: 20 ---- Green Pos: 22 ---- Green Pos: 24 ---- Green Pos: 26 ---- Green Pos: 28 ---- Green Pos: 30 ---- Green Pos: 50 ---- Blue Pos: 52 ---- Blue Pos: 54 ---- Blue Pos: 56 ---- Blue Pos: 58 ---- Blue Pos: 60 ---- Blue Pos: 62 ---- Blue Pos: 64 ---- Blue Pos: 66 ---- Blue Pos: 68 ---- Blue Pos: 70 ---- Blue Pos: 72 ---- Blue Pos: 74 ---- Blue Pos: 76 ---- Blue Pos: 78 ---- Blue Pos: 80 ---- Blue Pos: 82 ---- Blue Pos: 84 ---- Blue Pos: 86 ---- Blue Pos: 88 ---- Blue Pos: 90 ---- Blue Pos: 92 ---- Blue Pos: 94 ---- Blue Pos: 96 ---- Blue Pos: 98 ---- Blue Pos: 100 ---- Blue Pos: 102 ---- Blue Pos: 104 ---- Blue Pos: 106 ---- Blue Pos: 108 ---- Blue Pos: 110 ---- Blue Pos: 112 ---- Blue Pos: 114 ---- Blue Pos: 116 ---- Blue Pos: 118 ---- Blue Pos: 120 ---- Blue Pos: 122 ---- Blue Pos: 124 ---- Blue Pos: 126 ---- Blue Pos: 128 ---- Blue Pos: 149 ---- Blue Pos: 151 ---- Blue Pos: 153 ---- Blue Pos: 155 ---- Blue Pos: 157 ---- Blue Pos: 159 ---- Blue Pos: 161 ---- Blue Pos: 163 ---- Blue Pos: 165 ---- Blue Pos: 167 ---- Blue Pos: 169 ---- Blue Pos: 171 ---- Blue Pos: 173 ---- Blue Pos: 175 ---- Blue Pos: 177 ---- Blue Pos: 179 ---- Blue Pos: 181 ---- Blue ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testDiffFile2Revisions.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testDiffF0000644000175300001440000000314411175407010032776 0ustar ludousers==== 2 revisions ==== ==== Diff: diff2 ==== Text - Panel 1 ==== Commit-1.1 - Line1 Commit-1.1 - Line2 Commit-1.1 - Line4 Commit-1.1 - Line5 ==== Text - Panel 2 ==== Commit-1.1 - Line1 Commit-1.1 - Line2 - Modified-1.2 Commit-1.2 - Line3 - Added-1.2 Commit-1.1 - Line4 Commit-1.1 - Line5 - Modified-1.2 ==== Colors - Panel 1 ==== Pos: 19 ---- Blue Pos: 21 ---- Blue Pos: 23 ---- Blue Pos: 25 ---- Blue Pos: 27 ---- Blue Pos: 29 ---- Blue Pos: 31 ---- Blue Pos: 33 ---- Blue Pos: 35 ---- Blue Pos: 37 ---- Blue Pos: 58 ---- Blue Pos: 60 ---- Blue Pos: 62 ---- Blue Pos: 64 ---- Blue Pos: 66 ---- Blue Pos: 68 ---- Blue Pos: 70 ---- Blue Pos: 72 ---- Blue Pos: 74 ---- Blue Pos: 76 ---- Blue ==== Colors - Panel 2 ==== Pos: 19 ---- Blue Pos: 21 ---- Blue Pos: 23 ---- Blue Pos: 25 ---- Blue Pos: 27 ---- Blue Pos: 29 ---- Blue Pos: 31 ---- Blue Pos: 33 ---- Blue Pos: 35 ---- Blue Pos: 37 ---- Blue Pos: 39 ---- Blue Pos: 41 ---- Blue Pos: 43 ---- Blue Pos: 45 ---- Blue Pos: 47 ---- Blue Pos: 49 ---- Blue Pos: 51 ---- Blue Pos: 53 ---- Blue Pos: 55 ---- Blue Pos: 57 ---- Blue Pos: 59 ---- Blue Pos: 61 ---- Blue Pos: 63 ---- Blue Pos: 65 ---- Blue Pos: 67 ---- Blue Pos: 69 ---- Blue Pos: 71 ---- Blue Pos: 73 ---- Blue Pos: 75 ---- Blue Pos: 77 ---- Blue Pos: 79 ---- Blue Pos: 81 ---- Blue Pos: 83 ---- Blue Pos: 103 ---- Blue Pos: 105 ---- Blue Pos: 107 ---- Blue Pos: 109 ---- Blue Pos: 111 ---- Blue Pos: 113 ---- Blue Pos: 115 ---- Blue Pos: 117 ---- Blue Pos: 119 ---- Blue Pos: 121 ---- Blue Pos: 123 ---- Blue Pos: 125 ---- Blue Pos: 127 ---- Blue Pos: 129 ---- Blue Pos: 131 ---- Blue Pos: 133 ---- Blue Pos: 135 ---- Blue ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testDiffFileFormat.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testDiffF0000644000175300001440000000212411175407010032773 0ustar ludousers==== cbContextOutput ==== ==== Diff: diff1 Index: pac4/subpac4/diff1 =================================================================== RCS file: /pac4/subpac4/diff1,v retrieving revision 1.1 diff -c -r1.1 diff1 *** pac4/subpac4/diff1 --- pac4/subpac4/diff1 *************** *** 1,6 **** Commit-1.1 ! Whitespace Check ! Space Changes Check ! Case-sensitive Check NewLines Check End of NewLines Check --- 1,9 ---- Commit-1.1 ! Whitespace Check ! Space Changes Check ! cASE-SENsitive Check NewLines Check + + + End of NewLines Check ==== cbUnifiedOutput ==== ==== Diff: diff1 Index: pac4/subpac4/diff1 =================================================================== RCS file: /pac4/subpac4/diff1,v retrieving revision 1.1 diff -u -r1.1 diff1 --- pac4/subpac4/diff1 +++ pac4/subpac4/diff1 @@ -1,6 +1,9 @@ Commit-1.1 -Whitespace Check -Space Changes Check -Case-sensitive Check + Whitespace Check +Space Changes Check +cASE-SENsitive Check NewLines Check + + + End of NewLines Check ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testDiffFileIgnore.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testDiffF0000644000175300001440000001137411175407010033002 0ustar ludousers==== cbIgnoneAllWhitespace ==== ==== Diff: diff1 ==== Text - Panel 1 ==== Commit-1.1 Whitespace Check Space Changes Check Case-sensitive Check NewLines Check End of NewLines Check ==== Text - Panel 2 ==== Commit-1.1 Whitespace Check Space Changes Check cASE-SENsitive Check NewLines Check End of NewLines Check ==== Colors - Panel 1 ==== Pos: 48 ---- Blue Pos: 50 ---- Blue Pos: 52 ---- Blue Pos: 54 ---- Blue Pos: 56 ---- Blue Pos: 58 ---- Blue Pos: 60 ---- Blue Pos: 62 ---- Blue Pos: 64 ---- Blue Pos: 66 ---- Blue Pos: 68 ---- Blue ==== Colors - Panel 2 ==== Pos: 63 ---- Blue Pos: 65 ---- Blue Pos: 67 ---- Blue Pos: 69 ---- Blue Pos: 71 ---- Blue Pos: 73 ---- Blue Pos: 75 ---- Blue Pos: 77 ---- Blue Pos: 79 ---- Blue Pos: 81 ---- Blue Pos: 83 ---- Blue Pos: 99 ---- Green Pos: 101 ---- Green ==== cbIgnoreBlankLines ==== ==== Diff: diff1 ==== Text - Panel 1 ==== Commit-1.1 Whitespace Check Space Changes Check Case-sensitive Check NewLines Check End of NewLines Check ==== Text - Panel 2 ==== Commit-1.1 Whitespace Check Space Changes Check cASE-SENsitive Check NewLines Check End of NewLines Check ==== Colors - Panel 1 ==== Pos: 11 ---- Blue Pos: 13 ---- Blue Pos: 15 ---- Blue Pos: 17 ---- Blue Pos: 19 ---- Blue Pos: 21 ---- Blue Pos: 23 ---- Blue Pos: 25 ---- Blue Pos: 27 ---- Blue Pos: 29 ---- Blue Pos: 31 ---- Blue Pos: 33 ---- Blue Pos: 35 ---- Blue Pos: 37 ---- Blue Pos: 39 ---- Blue Pos: 41 ---- Blue Pos: 43 ---- Blue Pos: 45 ---- Blue Pos: 47 ---- Blue Pos: 49 ---- Blue Pos: 51 ---- Blue Pos: 53 ---- Blue Pos: 55 ---- Blue Pos: 57 ---- Blue Pos: 59 ---- Blue Pos: 61 ---- Blue Pos: 63 ---- Blue Pos: 65 ---- Blue Pos: 67 ---- Blue ==== Colors - Panel 2 ==== Pos: 11 ---- Blue Pos: 13 ---- Blue Pos: 15 ---- Blue Pos: 17 ---- Blue Pos: 19 ---- Blue Pos: 21 ---- Blue Pos: 23 ---- Blue Pos: 25 ---- Blue Pos: 27 ---- Blue Pos: 29 ---- Blue Pos: 31 ---- Blue Pos: 33 ---- Blue Pos: 35 ---- Blue Pos: 37 ---- Blue Pos: 39 ---- Blue Pos: 41 ---- Blue Pos: 43 ---- Blue Pos: 45 ---- Blue Pos: 47 ---- Blue Pos: 49 ---- Blue Pos: 51 ---- Blue Pos: 53 ---- Blue Pos: 55 ---- Blue Pos: 57 ---- Blue Pos: 59 ---- Blue Pos: 61 ---- Blue Pos: 63 ---- Blue Pos: 65 ---- Blue Pos: 67 ---- Blue Pos: 69 ---- Blue Pos: 71 ---- Blue Pos: 73 ---- Blue Pos: 75 ---- Blue Pos: 77 ---- Blue Pos: 79 ---- Blue Pos: 81 ---- Blue Pos: 83 ---- Blue ==== cbIgnoreCase ==== ==== Diff: diff1 ==== Text - Panel 1 ==== Commit-1.1 Whitespace Check Space Changes Check Case-sensitive Check NewLines Check End of NewLines Check ==== Text - Panel 2 ==== Commit-1.1 Whitespace Check Space Changes Check cASE-SENsitive Check NewLines Check End of NewLines Check ==== Colors - Panel 1 ==== Pos: 11 ---- Blue Pos: 13 ---- Blue Pos: 15 ---- Blue Pos: 17 ---- Blue Pos: 19 ---- Blue Pos: 21 ---- Blue Pos: 23 ---- Blue Pos: 25 ---- Blue Pos: 27 ---- Blue Pos: 29 ---- Blue Pos: 31 ---- Blue Pos: 33 ---- Blue Pos: 35 ---- Blue Pos: 37 ---- Blue Pos: 39 ---- Blue Pos: 41 ---- Blue Pos: 43 ---- Blue Pos: 45 ---- Blue Pos: 47 ---- Blue ==== Colors - Panel 2 ==== Pos: 11 ---- Blue Pos: 13 ---- Blue Pos: 15 ---- Blue Pos: 17 ---- Blue Pos: 19 ---- Blue Pos: 21 ---- Blue Pos: 23 ---- Blue Pos: 25 ---- Blue Pos: 27 ---- Blue Pos: 29 ---- Blue Pos: 31 ---- Blue Pos: 33 ---- Blue Pos: 35 ---- Blue Pos: 37 ---- Blue Pos: 39 ---- Blue Pos: 41 ---- Blue Pos: 43 ---- Blue Pos: 45 ---- Blue Pos: 47 ---- Blue Pos: 49 ---- Blue Pos: 51 ---- Blue Pos: 53 ---- Blue Pos: 55 ---- Blue Pos: 57 ---- Blue Pos: 59 ---- Blue Pos: 61 ---- Blue Pos: 99 ---- Green Pos: 101 ---- Green ==== cbIgnoreSpaceChanges ==== ==== Diff: diff1 ==== Text - Panel 1 ==== Commit-1.1 Whitespace Check Space Changes Check Case-sensitive Check NewLines Check End of NewLines Check ==== Text - Panel 2 ==== Commit-1.1 Whitespace Check Space Changes Check cASE-SENsitive Check NewLines Check End of NewLines Check ==== Colors - Panel 1 ==== Pos: 11 ---- Blue Pos: 13 ---- Blue Pos: 15 ---- Blue Pos: 17 ---- Blue Pos: 19 ---- Blue Pos: 21 ---- Blue Pos: 23 ---- Blue Pos: 25 ---- Blue Pos: 27 ---- Blue Pos: 48 ---- Blue Pos: 50 ---- Blue Pos: 52 ---- Blue Pos: 54 ---- Blue Pos: 56 ---- Blue Pos: 58 ---- Blue Pos: 60 ---- Blue Pos: 62 ---- Blue Pos: 64 ---- Blue Pos: 66 ---- Blue Pos: 68 ---- Blue ==== Colors - Panel 2 ==== Pos: 11 ---- Blue Pos: 13 ---- Blue Pos: 15 ---- Blue Pos: 17 ---- Blue Pos: 19 ---- Blue Pos: 21 ---- Blue Pos: 23 ---- Blue Pos: 25 ---- Blue Pos: 27 ---- Blue Pos: 29 ---- Blue Pos: 31 ---- Blue Pos: 33 ---- Blue Pos: 35 ---- Blue Pos: 37 ---- Blue Pos: 63 ---- Blue Pos: 65 ---- Blue Pos: 67 ---- Blue Pos: 69 ---- Blue Pos: 71 ---- Blue Pos: 73 ---- Blue Pos: 75 ---- Blue Pos: 77 ---- Blue Pos: 79 ---- Blue Pos: 81 ---- Blue Pos: 83 ---- Blue Pos: 99 ---- Green Pos: 101 ---- Green ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testLogDirectory.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testLogDi0000644000175300001440000000004311175407010033011 0ustar ludousersdumpAll: Desc - log Table Rows: 0 ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testLogDirectoryRecursive.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testLogDi0000644000175300001440000000125711175407010033021 0ustar ludousersdumpAll: Desc - log Table Rows: 2 dumpFile: log1.java strict /pac1/subpac1/log1.java,v 1.2 3 3 dumpSymbolicNamesList: 1,2 1. - branchtag - 1.2.0.2 dumpRevisionList: 3,6 1. - 1.1 - test - Initial state - Exp - null 2. - 1.2 - test - Desc - log 1 - 1.2 - Exp - +1 -3 3. - 1.2.2.1 - test - Desc - log 1 - branchtag - 1.2.2.1 - Exp - +1 -1 dumpLogMessage: 3 Initial state Desc - log 1 - 1.2 Desc - log 1 - branchtag - 1.2.2.1 dumpFile: log2.java strict /pac1/subpac1/log2.java,v 1.2 2 2 dumpSymbolicNamesList: 0,2 dumpRevisionList: 2,6 1. - 1.1 - test - Initial state - Exp - null 2. - 1.2 - test - Desc - log 2 - 1.2 - Exp - +1 -3 dumpLogMessage: 2 Initial state Desc - log 2 - 1.2 ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testLogFileFull.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testLogFi0000644000175300001440000000061011175407010033013 0ustar ludousersdumpFile: log1.java strict /pac1/subpac1/log1.java,v 1.2 3 3 dumpSymbolicNamesList: 1,2 1. - branchtag - 1.2.0.2 dumpRevisionList: 3,6 1. - 1.1 - test - Initial state - Exp - null 2. - 1.2 - test - Desc - log 1 - 1.2 - Exp - +1 -3 3. - 1.2.2.1 - test - Desc - log 1 - branchtag - 1.2.2.1 - Exp - +1 -1 dumpLogMessage: 3 Initial state Desc - log 1 - 1.2 Desc - log 1 - branchtag - 1.2.2.1 ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testLogFileStrict.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testLogFi0000644000175300001440000000014511175407010033016 0ustar ludousersdumpFile: log1.java strict /pac1/subpac1/log1.java,v 1.2 0 3 dumpRevisionList: 0,6 dumpLogMessage: 0 ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testStatusDirectory.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testStatu0000644000175300001440000000002311175407010033111 0ustar ludousersdumpAll Table Rows ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testStatusDirectoryRecursive.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testStatu0000644000175300001440000000044311175407010033117 0ustar ludousersdumpAll Table Rows dumpFile: status1.java Up-to-date /pac2/subpac2/status1.java,v 1.2.2.1 1.2.2.1 branchtag (branch: 1.2.2) (none) dumpExistingTags: 1,2 1. - branchtag - branch: 1.2.2 dumpFile: status2.java Up-to-date /pac2/subpac2/status2.java,v 1.2 1.2 (none) (none) dumpExistingTags: 0,2 ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testStatusFile.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testStatu0000644000175300001440000000027311175407010033120 0ustar ludousersdumpFile: status1.java Up-to-date /pac2/subpac2/status1.java,v 1.2.2.1 1.2.2.1 branchtag (branch: 1.2.2) (none) dumpExistingTags: 0,2 dumpExistingTags: 1,2 1. - branchtag - branch: 1.2.2 ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testStatusFileIncludeTags.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/AdditionalCommands/testStatu0000644000175300001440000000024511175407010033117 0ustar ludousersdumpFile: status1.java Up-to-date /pac2/subpac2/status1.java,v 1.2.2.1 1.2.2.1 branchtag (branch: 1.2.2) (none) dumpExistingTags: 1,2 1. - branchtag - branch: 1.2.2 netbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/0000755000175300001440000000000011175434236030156 5ustar ludousers././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/testAddDirectoryRecursive.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/testAddDirecto0000644000175300001440000000013611175407010032771 0ustar ludousersdumpFile: add1 LAdded New file! No revision control file (none) (none) dumpExistingTags: 0,2 ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/testAddKeywordSubstitution.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/testAddKeyword0000644000175300001440000000003411175407010033021 0ustar ludousersCorrected file: $Revision$ ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/testAddNoKeywordSubstitution.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/testAddNoKeywo0000644000175300001440000000003411175407010032770 0ustar ludousersCorrected file: $Revision$ ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/testTagAdd.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/testTagAdd.pas0000644000175300001440000000024311175407010032674 0ustar ludousersdumpFile: tag3.java Up-to-date /pac2/tag3.java,v 1.1 1.1 (none) (none) dumpExistingTags: 2,2 1. - AddBranchTagName - branch: 1.1.2 2. - AddTagName - revision: 1.1 ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/testTagByRevision.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/testTagByRevis0000644000175300001440000000020711175407010033005 0ustar ludousersdumpFile: tag4.java Up-to-date /pac2/tag4.java,v 1.2 1.2 (none) (none) dumpExistingTags: 1,2 1. - AddTagToRevisionName - revision: 1.1 ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/testTagDelete.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/testTagDelete.0000644000175300001440000000033311175407010032702 0ustar ludousersdumpFile: tag6.java Up-to-date /pac2/tag6.java,v 1.1 1.1 (none) (none) dumpExistingTags: 1,2 1. - TagToDelete - revision: 1.1 dumpFile: tag6.java Up-to-date /pac2/tag6.java,v 1.1 1.1 (none) (none) dumpExistingTags: 0,2 ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/testTagDirectory.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/testTagDirecto0000644000175300001440000000051511175407010033015 0ustar ludousersdumpAll Table Rows dumpFile: tag2.java Up-to-date /pac2/tag2.java,v 1.1 1.1 (none) (none) dumpExistingTags: 2,2 1. - DirectoryRecursiveTag - branch: 1.1.2 2. - DirectoryTag - revision: 1.1 dumpFile: tag1.java Up-to-date /pac2/subpac2/tag1.java,v 1.1 1.1 (none) (none) dumpExistingTags: 1,2 1. - DirectoryRecursiveTag - branch: 1.1.2 ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/testTagForce.passnetbeans-cvsclient_6.5/test/qa-functional/src/complete/data/goldenfiles/BasicCommands/testTagForce.p0000644000175300001440000000106411175407010032720 0ustar ludousersdumpAll Table Rows dumpFile: tag51 Up-to-date /pac2/subpa22/tag51,v 1.2 1.2 (none) (none) dumpExistingTags: 1,2 1. - NoForceTag - revision: 1.1 dumpFile: tag52 Up-to-date /pac2/subpa22/tag52,v 1.2 1.2 (none) (none) dumpExistingTags: 1,2 1. - ForceTag - revision: 1.1 dumpAll Table Rows dumpFile: tag51 Up-to-date /pac2/subpa22/tag51,v 1.2 1.2 (none) (none) dumpExistingTags: 2,2 1. - ForceTag - revision: 1.2 2. - NoForceTag - revision: 1.1 dumpFile: tag52 Up-to-date /pac2/subpa22/tag52,v 1.2 1.2 (none) (none) dumpExistingTags: 1,2 1. - ForceTag - revision: 1.2 netbeans-cvsclient_6.5/test/qa-functional/src/site-specific/0000755000175300001440000000000011175434236023166 5ustar ludousersnetbeans-cvsclient_6.5/test/qa-functional/src/site-specific/JavaCVSValidationTest.properties0000644000175300001440000000453411175407010031410 0ustar ludousers# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # # Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. # # The contents of this file are subject to the terms of either the GNU # General Public License Version 2 only ("GPL") or the Common # Development and Distribution License("CDDL") (collectively, the # "License"). You may not use this file except in compliance with the # License. You can obtain a copy of the License at # http://www.netbeans.org/cddl-gplv2.html # or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the # specific language governing permissions and limitations under the # License. When distributing the software, include this License Header # Notice in each file and include the License file at # nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this # particular file as subject to the "Classpath" exception as provided # by Sun in the GPL Version 2 section of the License file that # accompanied this code. If applicable, add the following below the # License Header, with the fields enclosed by brackets [] replaced by # your own identifying information: # "Portions Copyrighted [year] [name of copyright owner]" # # Contributor(s): # # The Original Software is NetBeans. The Initial Developer of the Original # Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun # Microsystems, Inc. All Rights Reserved. # # If you wish your version of this file to be governed by only the CDDL # or only the GPL Version 2, indicate your decision by adding # "[Contributor] elects to include this software in this distribution # under the [CDDL or GPL Version 2] license." If you do not indicate a # single choice of license, a recipient has the option to distribute # your version of this file under either the CDDL, the GPL Version 2 or # to extend the choice of license to its licensees as provided above. # However, if you add GPL Version 2 code and therefore, elected the GPL # Version 2 license, then the option applies only if the new code is # made subject to such option by the copyright holder. # Site specific properties # Sectinon for setting cvs connection xtest.userdata|SERVER=qa-w2k-s1.czech xtest.userdata|REPOSITORY=D:\\apps\\vcs\\cvs\\repository xtest.userdata|SERVERTYPE=pserver xtest.userdata|USER=test xtest.userdata|PASSWORD=test xtest.userdata|PORT=2401 xtest.userdata|MODULE=validation # Section for mounting FSs netbeans-cvsclient_6.5/test/qa-functional/src/site-specific/JavaCVSValidationTest_home.properties0000644000175300001440000000451211175407010032414 0ustar ludousers# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # # Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. # # The contents of this file are subject to the terms of either the GNU # General Public License Version 2 only ("GPL") or the Common # Development and Distribution License("CDDL") (collectively, the # "License"). You may not use this file except in compliance with the # License. You can obtain a copy of the License at # http://www.netbeans.org/cddl-gplv2.html # or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the # specific language governing permissions and limitations under the # License. When distributing the software, include this License Header # Notice in each file and include the License file at # nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this # particular file as subject to the "Classpath" exception as provided # by Sun in the GPL Version 2 section of the License file that # accompanied this code. If applicable, add the following below the # License Header, with the fields enclosed by brackets [] replaced by # your own identifying information: # "Portions Copyrighted [year] [name of copyright owner]" # # Contributor(s): # # The Original Software is NetBeans. The Initial Developer of the Original # Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun # Microsystems, Inc. All Rights Reserved. # # If you wish your version of this file to be governed by only the CDDL # or only the GPL Version 2, indicate your decision by adding # "[Contributor] elects to include this software in this distribution # under the [CDDL or GPL Version 2] license." If you do not indicate a # single choice of license, a recipient has the option to distribute # your version of this file under either the CDDL, the GPL Version 2 or # to extend the choice of license to its licensees as provided above. # However, if you add GPL Version 2 code and therefore, elected the GPL # Version 2 license, then the option applies only if the new code is # made subject to such option by the copyright holder. # Site specific properties # Sectinon for setting cvs connection xtest.userdata|SERVER=localhost xtest.userdata|REPOSITORY=/usr/local/CVSrepo xtest.userdata|SERVERTYPE=pserver xtest.userdata|USER=test xtest.userdata|PASSWORD=test xtest.userdata|PORT=2401 xtest.userdata|MODULE=validation # Section for mounting FSs netbeans-cvsclient_6.5/test/qa-functional/src/validation/0000755000175300001440000000000011175434236022571 5ustar ludousersnetbeans-cvsclient_6.5/test/qa-functional/src/validation/JavaCVSValidationTest.java0000644000175300001440000025361111175407010027542 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ /* * JavaCVSValidationTest.java * * Created on December 12, 2001, 11:09 AM * Last Update: $Date$ */ package validation; import java.awt.Color; import java.awt.Container; import java.lang.reflect.Method; import java.io.*; import java.util.Enumeration; import java.util.Properties; import java.util.Set; import javax.swing.text.Style; import javax.swing.text.StyledDocument; import javax.swing.text.StyleConstants.ColorConstants; import javax.swing.tree.TreePath; import junit.framework.*; //import org.netbeans.jemmy.*; import org.netbeans.jemmy.EventTool; import org.netbeans.jemmy.JemmyProperties; import org.netbeans.jemmy.TestOut; import org.netbeans.jemmy.JemmyException; import org.netbeans.jemmy.operators.*; import org.netbeans.jemmy.util.PNGEncoder; import org.netbeans.junit.*; // New Jelly2 lib import org.netbeans.jellytools.*; import org.netbeans.jellytools.actions.*; import org.netbeans.jellytools.nodes.*; import org.netbeans.jellytools.properties.*; import org.netbeans.jellytools.modules.javacvs.actions.*; import org.netbeans.jellytools.modules.javacvs.output.JCVSDiffOutputOperator; import org.netbeans.jellytools.modules.javacvs.output.LogOutputOperator; import org.netbeans.jellytools.modules.javacvs.output.StatusOutputOperator; import org.netbeans.jellytools.modules.vcscore.actions.*; import org.netbeans.jellytools.modules.vcscore.VCSGroupsFrameOperator; import org.netbeans.jellytools.modules.vcscore.VersioningFrameOperator; import org.netbeans.jellytools.modules.vcscore.GroupVerificationOperator; import org.netbeans.jemmy.Waitable; import org.netbeans.jemmy.Waiter; //import org.netbeans.jellytools.properties.editors.*; //import org.netbeans.jellytools.modules.javacvs.*; // Old Jelly lib //import org.netbeans.test.oo.gui.jam.*; //import org.netbeans.test.oo.gui.jello.*; //import org.netbeans.test.oo.gui.jelly.*; import org.netbeans.test.oo.gui.jelly.vcscore.*; //import org.netbeans.test.oo.gui.jelly.vcscore.wizard.*; import org.netbeans.test.oo.gui.jelly.javacvs.*; import org.openide.options.SystemOption; import org.netbeans.modules.cvsclient.JavaCvsSettings; import org.openide.filesystems.FileSystem; import org.openide.filesystems.Repository; /** XTest / JUnit test class performing validation of JavaCVS module * * @author Adam Sotona * @see #suite JavaCVS validation testsuite definition * @version 1.0 */ public class JavaCVSValidationTest extends JellyTestCase { static util.History his; static String path; static String repositoryprefix; static String CVSlbl = Bundle.getStringTrimmed("org.netbeans.modules.javacvs.Bundle", "JavaCvsFileSystem.validFilesystemLabel"); static String filesystem; static FileSystem testedJavaCVSFS; /* Site specific properties */ final String SERVER = System.getProperty("SERVER"); final String REPOSITORY = System.getProperty("REPOSITORY"); final String SERVERTYPE = System.getProperty("SERVERTYPE"); final String USER = System.getProperty("USER"); final String PASSWORD = System.getProperty("PASSWORD"); final String PORT = System.getProperty("PORT"); final String MODULE = System.getProperty("MODULE"); static final String WORKDIR = "JavaCVSwork"; static final String TESTDIR = "testdir"; static final String TESTFILE = "testfile"; static final String TESTFILEPROPERTY = "javacvs.validation.test.file"; static final String VERSIONINGMENU = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.actions.Bundle", "Menu/Versioning"); static final String MOUNTVCS = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.actions.Bundle", "CTL_MountActionName"); static String CVS = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.wizard.mountcvs.Bundle", "Templates/Mount/VCS/org-netbeans-modules-vcscore-wizard-mountcvs-CvsMountFS.settings"); static String strCmdAction; static File testFile = null; static MainWindowOperator.StatusTextTracer sbt = MainWindowOperator.getDefault().getStatusTextTracer(); static final boolean capture = true; PrintStream psRef; PrintStream ps; // PrintStream pstreams [] = {ps , psRef}; it's not neccessary anymore. See tearDown() APIController api; /** store previously used comparator */ Operator.StringComparator oldComparator = Operator.getDefaultStringComparator(); /** constructor required by JUnit * @param testName method name to be used as testcase */ public JavaCVSValidationTest(String testName) { super(testName); } /** method used for explicit testsuite definition
* JavaCVS validation suite is order-sensitive
* Contains also commented TRY-CATCH BLOCK * with set longer timeouts. This should be uncommented * on slower machines. * * * @return JavaCVS validation testsuite * @see #testConnectionManager 1.testConnectionManager * @see #testMount
2.testMount * @see #testHistory
3.testHistory * @see #testCreateFile
4.testCreateFile * @see #testAdd
5.testAdd * @see #testCommit
6.testCommit * @see #testDiff
7.testDiff * @see #testVCSGroups
8.testVCSGroups * @see #testVersioningExplorer
9.testVersioningExplorer * @see #testBranch
10.testBranch * @see #testUpdateBranch
11.testUpdateBranch * @see #testCommitToBranch
12.testCommitToBranch * @see #testMerge
13.testMerge * @see #testStatus
14.testStatus * @see #testLog
15.testLog * @see #testAnnotate
16.testAnnotate * @see #testUnmount
17.testUnmount * @see #testUndock
18.testUndock */ public static junit.framework.Test suite() { TestSuite suite = new NbTestSuite(); suite.addTest(new JavaCVSValidationTest("testConnectionManager")); suite.addTest(new JavaCVSValidationTest("testMount")); suite.addTest(new JavaCVSValidationTest("testHistory")); suite.addTest(new JavaCVSValidationTest("testCreateFile")); suite.addTest(new JavaCVSValidationTest("testAdd")); suite.addTest(new JavaCVSValidationTest("testCommit")); suite.addTest(new JavaCVSValidationTest("testDiff")); suite.addTest(new JavaCVSValidationTest("testVCSGroups")); suite.addTest(new JavaCVSValidationTest("testVersioningExplorer")); suite.addTest(new JavaCVSValidationTest("testBranch")); suite.addTest(new JavaCVSValidationTest("testUpdateBranch")); suite.addTest(new JavaCVSValidationTest("testCommitToBranch")); suite.addTest(new JavaCVSValidationTest("testMerge")); suite.addTest(new JavaCVSValidationTest("testStatus")); suite.addTest(new JavaCVSValidationTest("testLog")); suite.addTest(new JavaCVSValidationTest("testAnnotate")); suite.addTest(new JavaCVSValidationTest("testUnmount")); suite.addTest(new JavaCVSValidationTest("testUndock")); return suite; } /** Use for internal test execution inside IDE * @param args command line arguments */ public static void main(java.lang.String[] args) throws IOException { /* Execution Xtestu using ANT ant -Dxtest.userdata.propertyfile=/home.local/danielm/cvs/ide/javacvs/test/qa-functional/src/site-specific/JavaCVSValidationTest_home.properties */ /* Preparing xtest.userdate properties for internal usage */ InputStream inStream = JavaCVSValidationTest.class.getResourceAsStream("/site-specific/JavaCVSValidationTest_home.properties"); Properties pro = System.getProperties(); pro.load(inStream); Set set = pro.keySet(); String[] str = (String[]) set.toArray(new String[set.size ()]); if (str != null) for (int i = 0; i < str.length; i ++) if (str[i].startsWith ("xtest.userdata")) System.setProperty(str[i].substring (str[i].indexOf ('|') + 1), System.getProperty (str[i])); pro.list(System.out); junit.textui.TestRunner.run(suite()); } /** method called before each testcase
* sets long Jemmy WaitComponentTimeout and switches JavaCVS UI mode */ protected void setUp() { new EventTool().waitNoEvent(2000); System.out.println(getName()); ((JavaCvsSettings)SystemOption.findObject(JavaCvsSettings.class, true)).setUiMode(1); // JellyProperties.setJemmyDebugTimeouts(); JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout",20000); api = new APIController(); api.setOut (new PrintWriter (System.out, true)); //api.setOut (new PrintWriter (getLog(), true)); ps = getLog ("jemmy.log"); psRef = getRef(); // JellyProperties.setJemmyOutput(new PrintWriter(ps, true), new PrintWriter(ps, true)); JemmyProperties.getCurrentOutput().setAutoFlushMode(true); /* Seems that Robot dispatching is not safe on my linux (RedHat7.1, KDE2.1.1) * Test usualy fails at testMount() method when pushMenuNoBlock on Verisoning menu * and if it goes through the all test. My WindowMAnager is confused. I have to restart X-server :-( */ //JemmyProperties.setCurrentDispatchingModel(JemmyProperties.ROBOT_MODEL_MASK); // JemmyProperties.setCurrentDispatchingModel(JemmyProperties.QUEUE_MODEL_MASK); log("setUp(DispatchModel)="+JemmyProperties.getCurrentDispatchingModel()); /* Jemmy & Gnome workarround: * Usually happens on Linux and Gnome that just activated window doesn't have focus. * Calling this method : * ComponentOperator.setDefaultComponentVisualizer(new MouseVisualizer(MouseVisualizer.TOP, 0.5, 10, false); * or setting the following JellyProperty should help it: */ //JellyProperties.setLinuxWindowActivation(true); if (testedJavaCVSFS != null ) initHistory(testedJavaCVSFS); } /** method called after each testcase
* resets Jemmy WaitComponentTimeout */ protected void tearDown() { JemmyProperties.setCurrentOutput(TestOut.getNullOutput()); /* it is automaticaly flushed after returning into NbTestCase pstreams[0] = ps; pstreams[1] = psRef; for (int i=0 ; i < pstreams.length; i++) { pstreams[i].flush(); pstreams[i].close (); } */ // if ( ps != null ) ps.close(); // if ( psRef != null) ps.close(); } void fail(Exception e) { e.printStackTrace(getLog()); if (capture) { try { PNGEncoder.captureScreen(getWorkDirPath()+"/screen.png"); } catch (IOException ioe) {} } throw new AssertionFailedErrorException(e); } /** Method called in case of fail or error just after screen shot and XML dumps.
* Override this method when you need to be notified about test failures or errors * but avoid any exception to be throwed from this method.
* super.failNotify() does not need to be called because it is empty. * @param reason Throwable reason of current fail */ protected void failNotify(Throwable reason) { System.out.println("jsi v failNotify()"); sbt.printStatusTextHistory(ps); System.out.println(sbt.getStatusTextHistory().toString()); if (his != null) his.print (); } protected void dumpDiffGraphical (TopComponentOperator tco) { JEditorPaneOperator p1 = new JEditorPaneOperator (tco, 0); JEditorPaneOperator p2 = new JEditorPaneOperator (tco, 1); psRef.println ("==== Text - Panel 1 ===="); psRef.println (p1.getText ()); psRef.println ("==== Text - Panel 2 ===="); psRef.println (p2.getText ()); StyledDocument sd1 = (StyledDocument) p1.getDocument(); StyledDocument sd2 = (StyledDocument) p2.getDocument(); psRef.println ("==== Colors - Panel 1 ===="); dumpColors(sd1); psRef.println ("==== Colors - Panel 2 ===="); dumpColors(sd2); } protected static final Color annoWhite = new Color (254, 254, 254); protected static final Color annoGreen = new Color (180, 255, 180); protected static final Color annoBlue = new Color (160, 200, 255); protected static final Color annoRed = new Color (255, 160, 180); protected void dumpColors (StyledDocument sd) { int b = sd.getLength();// * 2; // psRef.println ("Len: " + b); for (int a = 0; a < b; a ++) { Style st = sd.getLogicalStyle(a); if (st == null) continue; Color col = (Color) st.getAttribute(ColorConstants.Background); String str; if (annoWhite.equals (col)) str = "White"; else if (annoGreen.equals (col)) str = "Green"; else if (annoBlue.equals (col)) str = "Blue"; else if (annoRed.equals (col)) str = "Red"; else str = col.toString (); psRef.println ("Pos: " + a + " ---- " + str); a ++; } } File getJavaCVSWork() throws IOException { return new File(getWorkDir().getParentFile(), WORKDIR); } File getTestFile() throws IOException { return (testFile==null)?new File(System.getProperty(TESTFILEPROPERTY)):testFile; } void setTestFile(File f) { testFile=f; System.setProperty(TESTFILEPROPERTY, f.getAbsolutePath()); } void setClassVariable() { try { path = getJavaCVSWork().getAbsolutePath(); } catch (IOException e) { e.printStackTrace(); } filesystem = CVSlbl + path; } FileSystem getTestedJavaCVSFS(String filesystem) { // setClassVariable(); Enumeration enFS = Repository.getDefault().getFileSystems(); FileSystem tmpFS; while(enFS.hasMoreElements()) { tmpFS = (FileSystem) enFS.nextElement(); if (tmpFS.getDisplayName().equals(filesystem)) { testedJavaCVSFS = tmpFS; return tmpFS; } } return null; } /** Inicializing of History object */ void initHistory(FileSystem testedJavaCVSFS) { his = new util.History(testedJavaCVSFS, getLog ()); his.setBreakpoint (null); his.switchToJCVS(); } /** invokes Connection Manager window from Versioning menu, adds new record and performs login * @throws Exception any unexpected exception thrown during test * @see #testMount next: testMount */ public void testConnectionManager() { this.clearTestStatus(); this.startTest(); /* Please, don't change the following line !!! * necessary for treating result of the test */ log("witchBRANCH", "This test suit was checkouted as the *release34*"); try { log("Trying to push Main Menu:\n"+VERSIONINGMENU+"|"+Bundle.getStringTrimmed("org.netbeans.modules.cvsclient.login.Bundle", "LoginManagerAction.dialogTitle")+"\n"); new JCVSConnectionManagerAction().perform(); log("Trying to invoke CVS Connection Manager dialog\n"); CVSConnectionDialog conn = new CVSConnectionDialog(); conn.activate(); log("Trying to find and click 'Add' button to open Login Manager Dialog\n"); CVSConnectionDialog.AddNewRootDialog add = conn.add(); log("Trying to fill-in the dialog:\n"+SERVERTYPE+","+ SERVER+","+ USER+","+ PORT+","+ REPOSITORY+"\n"); add.setAddNewRootOptions(SERVERTYPE, SERVER, USER, PORT, REPOSITORY); add.compareAddNewRootOptions(SERVERTYPE, SERVER, USER, PORT, REPOSITORY); add.verify(); log("Trying to find and click 'OK' button\n"); add.ok(); CVSConnectionDialog.LoginToPserverDialog login = new CVSConnectionDialog.LoginToPserverDialog(); log("Trying to write PASSWD in to the textfield: "+PASSWORD+"\n"); login.setJPasswordField(PASSWORD); login.verify(); log("Trying to find and click 'Login' button\n"); login.login(); int i=0; while ((i++<30)&&(login.isVisible())) { Thread.sleep(1000); } log("Trying to verify the login dialog\n"); conn.verify(); endTest(); log("Trying to find 'Close' button\n"); conn.close(); } catch (Exception e) { fail(e); } } /** invokes CVS Wizard from Versioning menu, sets workdir, connection settings and performs initial checkout of module * @throws Exception any unexpected exception thrown during test * @see #testConnectionManager depends on: testConnectionManager * @see #testHistory
next: testHistory */ public void testMount() { startTest(); try { log("JavaCVSWork dir is:\n"+getJavaCVSWork()+"\n"); File f = getJavaCVSWork(); assertTrue(f.mkdirs()); // log("Nasty workaround for bug #31026"); log("Trying to push MainMenu:\n"+VERSIONINGMENU+"|"+MOUNTVCS+"|"+CVS+"\n"); new JCVSMountAction().perform(); /* //---Hacking bug #31026--- //Checking if it was fixed or not new Action ("Versioning|Mount Version Control", null).performMenu (); //necessery for converting JmenuItem to Jmenu JMenuBarOperator jmbo = MainWindowOperator.getDefault().menuBar(); javax.swing.JMenu jm = ((javax.swing.JMenuBar)jmbo.getSource()).getMenu(6); //Should be Versioning log("MainMenu je ... |"+ jm.getText()+"|"); JMenuOperator jmo = new JMenuOperator(jm); log("jmo ma MenuItem? "+ jmo.getItemCount()); int ii = 0; for(int i = 0; i < jmo.getItemCount(); i++) { if(((javax.swing.JMenu)jmo.getSource()).getItem(i) != null) { log( i + " |"+ ((javax.swing.JMenu)jmo.getSource()).getItem(i).getText() +"|"); if ( ((javax.swing.JMenu)jmo.getSource()).getItem(i).getText().equals("Mount Version Control") ) ii = i; } } jmo = new JMenuOperator((javax.swing.JMenu) jmo.getItem(ii)); log("Menu je ("+ii+") ... |"+ jmo.getText()+"|"); log("jmo ma Item? "+ jmo.getItemCount()); for(int i = 0 ; i < jmo.getItemCount(); i++) { log(" ... " + i + "|" + jmo.getItem(i).getText()); } //End of check */ /* log("Trying to push MainMenu:\n"+VERSIONINGMENU+"|"+MOUNTVCS+"\n"); final String VERSIONING_MENU1 = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.actions.Bundle", "Menu/Versioning"); final String MOUNT_VERSIONING_CONTROL1 = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.actions.Bundle", "CTL_MountActionName"); final String CVS_TYPE1 = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.wizard.mountcvs.Bundle", "Templates/Mount/VCS/org-netbeans-modules-vcscore-wizard-mountcvs-CvsMountFS.settings"); new ActionNoBlock(VERSIONING_MENU1+"|"+MOUNT_VERSIONING_CONTROL1, null).perform(); new ActionNoBlock("Tools", null).perform(); org.netbeans.jemmy.Timeout tm = new org.netbeans.jemmy.Timeout("tmpTM", 10000); tm.sleep(); new JCVSMountAction().perform(); //---end of Hack--- */ NewWizardCVSDialog2 wizardPage1 = new NewWizardCVSDialog2(); log("Trying to fill-in the first Panel of Wizard\n"); wizardPage1.setWorkingDirectoryTxt(f.getAbsolutePath()); wizardPage1.verify(); wizardPage1.next(); log("Trying to fill-in the second Panel of Wizard\n"); NewWizardCVSDialog4 wizardPage2 = new NewWizardCVSDialog4(); wizardPage2.setServerName(SERVER); wizardPage2.setUserName(USER); wizardPage2.setRepository(REPOSITORY); wizardPage2.verify(); wizardPage2.next(); log("Trying to fill-in the third Panel of Wizard\n"); NewWizardCVSDialog5 wizardPage3 = new NewWizardCVSDialog5(); wizardPage3.verify(); wizardPage3.next(); log("Trying to fill-in the fourth Panel of Wizard\n"); NewWizardCVSDialog6 wizardPage4 = new NewWizardCVSDialog6(SERVER); wizardPage4.verify(); wizardPage4.next(); log("Trying to fill-in the fifth Panel of Wizard\n"); NewWizardCVSDialog6a wizardPage5 = new NewWizardCVSDialog6a(); log("Checking up Initial checkout!!!\n"); wizardPage5.checkCheckOutACopyOfTheRepositoryFilesToYourWorkingDirectory(true); wizardPage5.verify(); wizardPage5.finish(); log("now the Checkout dilaog should comes up...\n"); CheckoutDialog checkout=new CheckoutDialog(); log("DEADLOCK when invoking 'Select Module' dialog is fixed now,\n"+ "see issue #29464\nhttp://www.netbeans.org/issues/show_bug.cgi?id=29464 ,\n"+ "please if during automat test DEADLOCK occures again, please REOPEN this bug!"); log("Trying to open ModuleSelector dialog\n"); CheckoutDialog.ModuleChooserDialog chooser=checkout.selectModule(); log("Trying to find desired module: "+MODULE); int i=chooser.tabModulesTable().findCellRow(MODULE, new Operator.DefaultStringComparator (true, true)); log("Desired module on line "+i+" has been found...selecting it\n"); chooser.tabModulesTable().setRowSelectionInterval(i,i); chooser.verify(); chooser.ok(); // instead of it is used typing module into a text field /* checkout.txtCheckout().clearText(); checkout.txtCheckout().typeText(MODULE); */ checkout.verify(); log("The outpuWindow should open now...\n"); /* This piece of code is a workaround for problems with losted HierarchyEvent * There is an jemmy's issue http://www.netbeans.org/issues/show_bug.cgi?id=32466 * but later appeared as a JDK bug: http://developer.java.sun.com/developer/bugParade/bugs/4924516.html */ TabbedOutputOfVCSCommandsFrame out; try { EventTool.removeListeners(); log("Trying to find and click 'Run command' button\n"); checkout.runCommand(); out = new TabbedOutputOfVCSCommandsFrame(); } finally { EventTool.addListeners(); } // end of workaround issue #32466 endTest(); setClassVariable(); initHistory(getTestedJavaCVSFS(filesystem)); // just only for this TC. For the rest it is initialized in setUp() method out.verify(); // endTest(); log("Trying to find 'Close' button"); out.close(); log("Closed...\n"); } catch (Exception e) { fail(e); } } /** looks for CVS command checkout history record under Explorer's Runtime tab, opens record and tests if "Finished" info is present * @throws Exception any unexpected exception thrown during test * @see #testMount depends on: testMount * @see #testCreateFile
next: testCreateFile */ public void testHistory() { startTest(); String path; String filesystem; CVS = Bundle.getStringTrimmed("org.netbeans.modules.javacvs.Bundle", "JavaCvsFileSystem.validFilesystemLabel"); String cmdStatus = Bundle.getStringTrimmed("org.netbeans.modules.cvsclient.commands.Bundle", "CTL_Status_Done"); boolean isCommandSuccessed; String status; try { path = getJavaCVSWork().getAbsolutePath(); filesystem = CVS + path; /*Ask Milos How it's construct the command string which is in RunTime TAB * # RuntimeCommandNode: * # {0} .. Command's display name *The ResourceBundle is: org.netbeans.modules.vcscore.runtime.Bundle *The key is: RuntimeCommandNode.Description=VCS Command ''{0}'' *on the line no: 70 * *Property-Command name: Checkout *The ResourceBundle is: org.netbeans.modules.javacvs.commands.Bundle *The key is: CvsCheckout.name=Checkout *on the line no: 50 */ String command = "checkout " + MODULE; log("Trying to switch to RunTime TAB via API\n"); APICommandsHistory history = new APICommandsHistory(api); log("Creating RunTime TAB Jemmy handler\n"); CommandsHistory commandsHistory = new CommandsHistory(); log("Verifying if command succeded..."); isCommandSuccessed = history.isCommandSuccessed(filesystem, command, cmdStatus); log("Checkin' if command:\n |"+command+"|\non this filesystem:\n "+filesystem+ "\nsuccessed: "+isCommandSuccessed+"\n"); Thread.sleep(500L); assertTrue("\nError: cvs command:\n |"+command+ "|\nnode hasn't been found in RunTime TAB under the specified FS:\n " +filesystem+"|\n", isCommandSuccessed); log("Comparin' command status:\n |" +command+ "|\n |"+ cmdStatus +"|\non this filesystem:\n "+filesystem+"\n"); Thread.sleep(500L); assertTrue("\nError: Wrong status of\n|" + command + "|\ncommand.", commandsHistory.compareStatus(cmdStatus, filesystem, command)); log("Comparin' command name:\n |" +command+ "|\non this filesystem:\n "+filesystem+"\n"); Thread.sleep(500L); assertTrue("\nError: command name of\n|" + command + "|\ncommand.", commandsHistory.compareCommandName("Checkout", filesystem, command)); /* This piece of code is a workaround for problems with losted HierarchyEvent * There is an jemmy's issue http://www.netbeans.org/issues/show_bug.cgi?id=32466 * but later appeared as a JDK bug: http://developer.java.sun.com/developer/bugParade/bugs/4924516.html */ TabbedOutputOfVCSCommandsFrame out; try { EventTool.removeListeners(); log("Trying to open output of command..."); out = commandsHistory.viewOutput(filesystem, command); } finally { EventTool.addListeners(); } // end of workaround issue #32466 log("succeeded, OPENED :)\n"); status = Bundle.getString("org.netbeans.modules.vcscore.commands.Bundle", "CommandExitStatus.finished"); log("Comparin' statuses in the textfiled:\n |" +status+ "|\n"); Thread.sleep(500L); assertTrue("\nError: command status is different from expected value:\n " +status+"|\n", out.compareStatusTextFld(status)); out.verify(); log("Trying to find 'Close' button\n"); out.close(); endTest(); } catch (Exception e) { fail(e); } } String getTestFileObjectName() throws IOException { final String file=getTestFile().getName(); return file.substring(0,file.lastIndexOf(".")); } String getTestDirNodePath() throws IOException { return "CVS "+getJavaCVSWork().getAbsolutePath()+"|"+MODULE+"|"+getTestFile().getParentFile().getName(); } String getTestDirObjectName() throws IOException { return getTestFile().getParentFile().getName(); } /** creates new unique testdirectory under workdir, creates new testfile indside and verifies that both are present under Explorer's Filesystems tab with attribute [Local] * @throws Exception any unexpected exception thrown during test * @see #testHistory depends on: testHistory * @see #testAdd
next: testAdd */ public void testCreateFile() { clearTestStatus(); startTest(); try { // MainWindowOperator.StatusTextTracer sbt = MainWindowOperator.getDefault().getStatusTextTracer(); log("Trying to find(create) a unique dir/file on a disk: \n"+TESTDIR+", "+getJavaCVSWork()+", "+MODULE+"\n"); File f=File.createTempFile(TESTDIR, "", new File(getJavaCVSWork(), MODULE)); assertTrue(f.delete()); repositoryprefix = "/" + MODULE + "/" + f.getName(); log("Trying to make directory: \n"+f.toString()+"\n"); assertTrue(f.mkdir()); log("Trying to create testing file: "+f+" ,"+TESTFILE+".java\n"); setTestFile(new File(f, TESTFILE+".java")); FileOutputStream out = new FileOutputStream(getTestFile()); out.write(("class "+TESTFILE+" {}\n").getBytes()); log("Trying to close the FileOutputStream\n"); out.close(); log("Trying to open new Explorer and imediately locate and switch to FS TAB...\n"); Node rootNode = ExplorerOperator.invoke().repositoryTab().getRootNode();//selectPageFilesystems(); log("Creating a node on this filesystem:\n" + "CVS "+getJavaCVSWork().getAbsolutePath()+"\n"); Node node = new Node(rootNode, "CVS "+getJavaCVSWork().getAbsolutePath()); new JCVSRefreshAction().perform(node); log("Creating a node on this filesystem:\n" + "CVS "+getJavaCVSWork().getAbsolutePath()+"|"+MODULE+"\n"); node = new Node(rootNode, "CVS "+getJavaCVSWork().getAbsolutePath()+"|"+MODULE); log("The node is:\n "+ node.getParentPath()+"\n "+node.getPath()+"\n "+node.getText()+"\n "+node.toString()+"\n"); log("Trying to go to PopupMenu:\n"+"CVS|Refresh\non this filesystem:\n " + node.getPath() +"\n"); /* Operator.DefaultStringComparator comparator = new Operator.DefaultStringComparator(true, true); JMenuBarOperator // MainWindowOperator.getDefault().menuBar ().setDef // Operator.setDefaultStringComparator(comparator); Action ac = new Action(VERSIONINGMENU+"|"+CVS+"|Refresh", "CVS|Refresh"); ac.setComparator(comparator); ac.performMenu(node); Operator.setDefaultStringComparator(oldComparator); */ /* Operator.DefaultStringComparator comparator = new Operator.DefaultStringComparator(true, true); Action ac = new Action("Versioning|CVS|Refresh", null); ac.setComparator(comparator); ac.performMenu(node); */ sbt.start(); System.out.println("===BACHA!!! REFRESHIM ==="); new JCVSRefreshAction().perform(node); sbt.waitText("CVS Client Running Command: Refresh", true); sbt.waitText("Finished: Refresh", true); // exp.tree().callPopupOnPath("CVS|Refresh", "CVS "+getJavaCVSWork().getAbsolutePath()+"|"+MODULE); // exp.pushPopupMenu("CVS|Refresh", "CVS "+getJavaCVSWork().getAbsolutePath()+"|"+MODULE); log("Trying to select a node:\n "+rootNode.getPath() +"\n "+ getTestDirNodePath()+" [Local]|"+getTestFileObjectName()+" [Local]\n"); node = new Node(rootNode, getTestDirNodePath()+" [Local]|"+getTestFileObjectName()+" [Local]"); node.select(); // exp.selectNode(getTestDirNodePath()+" [Local]|"+getTestFileObjectName()+" [Local]"); endTest(); } catch (Exception e) { fail(e); } } /** invokes Add dialog from testdir's popup menu, runs add command recursively and verifies that testfile has now attributes [LAdded; New] under Explorer * @throws Exception any unexpected exception thrown during test * @see #testCreateFile depends on: testCreateFile * @see #testCommit
next: testCommit */ public void testAdd() { startTest(); try { // Explorer exp=new Explorer(); log("Explorer should be opened..\n switching to FS TAB\n"); // exp.switchToFilesystemsTab(); Node node = new Node(ExplorerOperator.invoke().repositoryTab().getRootNode(), getTestDirNodePath()+" [Local]"); log("Trying to push popup menu 'CVS|Add...' on the node: "+getTestDirNodePath()+" [Local]\n"); new JCVSAddAction().perform(node); log("Trying to open Add dialog\n"); AddDialog add=new AddDialog(); log("Checking up checkBox: 'Recursively'\n"); add.check(add.cbRecursively(), true); log("Verifiing the dialog\n"); add.verify(); log("Trying to push the 'Run Command=OK' buttonn\n"); add.runCommand(); OutputOfVCSCommandsFrame out=new OutputOfVCSCommandsFrame(); log("Verifying the OutputOfCommand dialog\n"); out.verify(); log("Trying to push the 'Close' button\n"); out.close(); log("TCs which are founding nodes using fileStatuses will probably fails\n"+ "BECAUSE OF P1 #25987 BUG IN OPENIDE, see http://www.netbeans.org/issues/show_bug.cgi?id=25987"); log("Trying to select a file node:\n "+getTestDirNodePath()+"|"+getTestFileObjectName()+" [LAdded; New]"); Thread.sleep(1000L); //Rather wait sometime to give ide a possibility to refresh its nodes... new Node((new RepositoryTabOperator()).getRootNode(), getTestDirNodePath()+"|"+getTestFileObjectName()+" [LAdded; New]").select(); // exp.selectNode(getTestDirNodePath()+"|"+getTestFileObjectName()+" [LAdded; New]"); log("Selected... :-)\n"); endTest(); } catch (Exception e) { fail(e); } } /** invokes Commit dialog from testfile's popup menu, runs commit command and verifies that testfile has now attributes [Up-to-date; 1.1] under Explorer * @throws Exception any unexpected exception thrown during test * @see #testAdd depends on: testAdd * @see #testDiff
next: testDiff */ public void testCommit() { startTest(); try { // Explorer exp=new Explorer(); log("Trying to switch to FS TAB\n"); Node node = new Node(ExplorerOperator.invoke().repositoryTab().getRootNode(), getTestDirNodePath()+"|"+getTestFileObjectName()+" [LAdded; New]"); // exp.switchToFilesystemsTab(); log("Trying to push popup menu 'CVS|Commit...' on the node: "+getTestDirNodePath()+"|"+getTestFileObjectName()+" [LAdded; New]\n"); new JCVSCommitAction().perform(node); CommitDialog commit=new CommitDialog(); log("verifiing Commit dialog\n"); commit.verify(); log("Trying to push 'Run Command' button\n"); commit.runCommand(); OutputOfVCSCommandsFrame out=new OutputOfVCSCommandsFrame(); log("verifiing the OutputOfCVSCommand dialog\n"); out.verify(); log("Trying to push 'Close' button\n"); out.close(); log("Trying to select a node:\n"+getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.1]"); new Node((new RepositoryTabOperator()).getRootNode(), getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.1]").select(); // exp.selectNode(getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.1]"); log("Selected... :-)\n"); endTest(); } catch (Exception e) { fail(e); } } /** changes testfile contents, invokes Refresh command, verifies that testfile has now attributes [LMod; 1.1] under Explorer, invokes diff command from testfile's popup menu and waits for Diff Output frame * @throws Exception any unexpected exception thrown during test * @see #testCommit depends on: testCommit * @see #testVCSGroups
next: testVCSGroups */ public void testDiff() { startTest(); String path; CVS = Bundle.getStringTrimmed("org.netbeans.modules.javacvs.Bundle", "JavaCvsFileSystem.validFilesystemLabel"); String filesystem; try { path = getJavaCVSWork().getAbsolutePath(); filesystem = CVS + path; // Explorer exp=new Explorer(); log("Trying to switch to FS TAB\n"); Node rootNode = ExplorerOperator.invoke().repositoryTab().getRootNode(); Node node = new Node(rootNode, getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.1]"); // exp.switchToFilesystemsTab(); log("Trying to select a node:\n"+getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.1]\n"); // exp.selectNode(getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.1]"); node.select(); log("Openning an FileOutputStream using this file:\n"+getTestFile()+"\n"); FileOutputStream file = new FileOutputStream(getTestFile()); log("Writing a text into it.\n"); file.write(("//comment\nclass "+TESTFILE+" {}\n").getBytes()); file.close(); log("Trying to open PopupMenu:\n'CVS|Refresh' on a node:\n" + getTestDirNodePath()+"\n"); node = new Node(rootNode, getTestDirNodePath()); // exp.pushPopupMenu("CVS|Refresh", getTestDirNodePath()); new JCVSRefreshAction().perform(node); MainWindowOperator.getDefault().waitStatusText("Finished: Refresh"); // Node rootNode1 = ExplorerOperator.invoke().runtimeTab().getRootNode(); // rootNode1.select(); /* The folowing block of code is there because I need wait for a node ... * It needs establish after refresh. And it's good for testing stability */ rootNode = ExplorerOperator.invoke().repositoryTab().getRootNode(); node = new Node(rootNode, getTestDirNodePath()+"|"+getTestFileObjectName()); node.select(); // log("Trying to open PopupMenu:\n'CVS|Diff...', "+ getTestDirNodePath()+"|"+getTestFileObjectName()+" [LMod; 1.1]\n"); // node = new Node(rootNode, getTestDirNodePath()+"|"+getTestFileObjectName()+" [LMod; 1.1]"); // node = new Node(node, " [LMod; 1.1]"); // exp.pushPopupMenu("CVS|Diff...", getTestDirNodePath()+"|"+getTestFileObjectName()+" [LMod; 1.1]"); log("node je...:\n"+node.getPath()); node.select(); new JCVSDiffAction().perform(node); log("Trying to open dialog for Diff command...\n"); DiffDialog diff=new DiffDialog(); diff.verify(); log("Trying to click on 'Run Command' button...\n"); diff.runCommand(); log("TCs which are test 'Output Of VCS command [' dialogs will probably fails\n"+ "BECAUSE OF P3 #26811 BUG IN CORE, see http://www.netbeans.org/issues/show_bug.cgi?id=26811"); log("Opening Diff output window...\n"); TopComponentOperator tco = new TopComponentOperator(new EditorWindowOperator (), "Diff testfile.java"); dumpDiffGraphical(tco); compareReferenceFiles(); tco.undockView(); JCVSDiffOutputOperator out = new JCVSDiffOutputOperator("Diff testfile.java", "1.1", "Working File"); log("Verifiing if everything is allright on the diff output\n"); out.verify(); log("Trying to push 'Close' button\n"); out.close(); endTest(); } catch (Exception e) { fail(e); } } void switchToTab(ExplorerOperator expO, String tab) throws Exception { expO.invoke().selectPage(tab); } /** adds testfile to default VCS group using popup menu, invokes VCS Groups frame from Versioning menu, docks it into Explorer, performs Verify, Commit and Delete commands on default group and verifies that testfile has now attributes [Up-to-date; 1.2] under Explorer * @throws Exception any unexpected exception thrown during test * @see #testDiff depends on: testDiff * @see #testVersioningExplorer
next: testVersioningExplorer */ public void testVCSGroups() { clearTestStatus(); startTest(); CVS = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.wizard.mountcvs.Bundle", "Templates/Mount/VCS/org-netbeans-modules-vcscore-wizard-mountcvs-CvsMountFS.settings"); String strCmdAction = Bundle.getStringTrimmed("org.netbeans.modules.cvsclient.actions.Bundle", "LBL_JCommitAction") + Bundle.getStringTrimmed("org.netbeans.modules.vcscore.actions.Bundle", "ClusteringAction.DialogDots"); final String DEFAULTGROUP = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.grouping.Bundle", "LBL_DefaultGroupName"); final String vcsgrpT = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.grouping.Bundle", "LBL_MODE.title"); final String vcsgrpM = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.grouping.Bundle", "LBL_VcsGroupMenuAction"); final String addTovcsGrp = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.actions.Bundle", "LBL_AddToGroupAction"); final String verify = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.grouping.Bundle", "LBL_VerifyGroupAction"); final String dialogTitle= Bundle.getStringTrimmed("org.openide.explorer.Bundle", "MSG_ConfirmDeleteObjectTitle"); try { log("Trying to get an instance of MainFrame\n"); // MainFrame main=MainFrame.getMainFrame(); MainWindowOperator main = MainWindowOperator.getDefault(); ExplorerOperator exp = new ExplorerOperator(); Node rootNode = exp.invoke().repositoryTab().getRootNode(); JTreeOperator jtro = null; log("Trying to invoke PopupMenu:\n" + addTovcsGrp +"|"+ DEFAULTGROUP +", on\n"+ getTestDirNodePath()+"|"+getTestFileObjectName()+" [LMod; 1.1]\n"); // exp.pushPopupMenu(addTovcsGrp+"|"+DEFAULTGROUP, getTestDirNodePath()+"|"+getTestFileObjectName()+" [LMod; 1.1]"); Node node = new Node(rootNode, getTestDirNodePath()+"|"+getTestFileObjectName()+" [LMod; 1.1]"); node.performPopupAction(addTovcsGrp +"|"+ DEFAULTGROUP); log("Trying to push MainMenu:\n"+VERSIONINGMENU+"|" +vcsgrpM+ "\n"); new VCSGroupsAction().perform(); try { // try is here because VCS Groups frame can be already docked under Explorer log("Realy trying to open VCSGroup Frame\n"); VCSGroupsFrameOperator groups = new VCSGroupsFrameOperator(); // VCSGroupsFrame groups = new VCSGroupsFrame(); log("Verifying the VCSGroup dialog...\n"); groups.makeComponentVisible(); groups.verify(); Thread.sleep(500); log("Trying to invoke MainMenu:\n'Window|Dock View Into|Explorer|Center'\n"); new DockingAction("Explorer|"+DockingAction.CENTER).perform(); // main.pushMenuNoExact("Window|Dock View Into|Explorer|Center"); } catch (JemmyException ex) {log("Seems that VCSGroup's been already docked in Exp");} log("Trying to switch to VCS Groups TAB\n"); //exp=new Explorer(); //This probably isn't needed and the construction below seems good enought /* for(int i = 0; i < exp.tbpExplorerTabPane().getTabCount(); i ++){ String sTitle = exp.tbpExplorerTabPane().getTitleAt(i); if(sTitle.indexOf(vcsgrpT) >= 0) { exp.selectPage(vcsgrpT); jtro = new JTreeOperator(JTreeOperator.waitJTree( (Container) exp.tbpExplorerTabPane().getComponent(i), null, false, false, 0)); } } */ exp.selectPage(vcsgrpT); jtro = new JTreeOperator(JTreeOperator.waitJTree( (Container) exp.tbpExplorerTabPane().getSource (), vcsgrpT, true, true, 0)); log("Trying to invoke PopupMenu:\n'Verify', "+" on the\n" + DEFAULTGROUP +"\n"); new VerifyGroupAction().perform(new Node(jtro, DEFAULTGROUP)); log("Trying to open GroupVerification Dialog....\n"); GroupVerificationOperator out = new GroupVerificationOperator(); log("Trying to verify the Group dialog...\n"); out.verify(false, false, false, false); log("Trying to click on 'Close' button\n"); out.close(); log("Invoking PopupMenu:\n'"+CVS+ "|" +strCmdAction+"', on "+DEFAULTGROUP+"\n"); new JCVSCommitAction().perform(new Node(jtro, DEFAULTGROUP)); // exp.pushPopupMenu("CVS|Commit...", DEFAULTGROUP); log("Commit dialog should appeare\n"); // No jelly2 CommitDialogOperator CommitDialog commit=new CommitDialog(); log("Verifying the Commit dialog...\n"); commit.verify(); log("Trying to click on 'Run Command' button\n"); commit.runCommand(); log("...an CommandOutputWindow should open NOW...\n"); // No jelly2 CommanOutputWondowOperator OutputOfVCSCommandsFrame out2=new OutputOfVCSCommandsFrame(); log("Verifying the Output dialog....\n"); out2.verify(); log("Trying to click on 'Close' button\n"); out2.close(); log("Trying to invoke PopupMenu:\n'Delete', "+ DEFAULTGROUP); strCmdAction = Bundle.getStringTrimmed("org.openide.actions.Bundle", "Delete"); new DeleteAction().perform(new Node(jtro, DEFAULTGROUP)); // exp.pushPopupMenu("Delete", DEFAULTGROUP); log("Answering YES! to the YesNoDialog 'Confirm Object Deletion'...\n"); new NbDialogOperator(dialogTitle).yes(); // new JelloYesNoDialog("Confirm Object Deletion").yes(); //exp=new Explorer(); log("...sleeping 1s...\n"); Thread.sleep(1000); log("Trying to switch to FS's TAB\n"); rootNode = exp.invoke().repositoryTab().getRootNode();//selectPageFilesystems(); log("Trying to select a node:\n"+getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.2]\n"); // exp.selectNode(getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.2]"); node = new Node(rootNode, getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.2]"); node.select(); endTest(); } catch (Exception e) { fail(e); } } /** invokes Versioning Explorer from testdir's popup menu, docks it into Explorer and looks for "1.1 no message" and "1.2 " nodes under testfile node inside Versioning Explorer * @throws Exception any unexpected exception thrown during test * @see #testVCSGroups depends on: testVCSGroups * @see #testBranch
next: testBranch */ public void testVersioningExplorer() { startTest(); String versioning = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.versioning.impl.Bundle", "versioningSystemName"); final String verExplorer= Bundle.getStringTrimmed("org.netbeans.modules.vcscore.actions.Bundle", "LBL_VersioningExplorer"); try { log("Trying to get MainFrame...\n"); MainWindowOperator main = MainWindowOperator.getDefault(); ExplorerOperator exp = new ExplorerOperator(); Node rootNode = exp.invoke().repositoryTab().getRootNode(); JTreeOperator jtro = null; log("Trying to switch to FS's TAB\n"); exp.selectPageFilesystems(); log("Invoking popup menu 'Versioning Explorer' on a node:\n"+getTestDirNodePath()+"\n"); new VersioningExplorerAction().perform(new Node(rootNode, getTestDirNodePath())); try { // try is here because Versioning Explorer can be already docked under Explorer new VersioningFrameOperator().verify(); log("Trying to dock the Explorer window into Explorer... pushing a MainMenu:\n'Window|Dock View Into|Explorer|Center'\n"); new DockingAction("Explorer|"+DockingAction.CENTER).perform(); } catch (JemmyException ex) {log("Seems that Versioning Expl.'s been already docked in Exp");} Thread.sleep(1000); log("Trying to switch to Versioning TAB\n"); switchToTab(exp, versioning); jtro = new JTreeOperator(JTreeOperator.waitJTree( (Container) exp.tbpExplorerTabPane().getSource (), versioning, true, true, 0)); log("Trying to select a node:\n" + getTestDirNodePath()+"\n"); Node node = new Node(jtro, getTestDirNodePath()); node.select(); // exp.selectNode(getTestDirNodePath()); log("Trying to select a node:\n" + getTestDirNodePath()+"|"+getTestFileObjectName()+".java [Up-to-date; 1.2]\n"); // exp.selectNode(getTestDirNodePath()+"|"+getTestFileObjectName()+".java [Up-to-date; 1.2]"); node = new Node(node, getTestFileObjectName()+".java [Up-to-date; 1.2]"); node.select(); node.expand(); /* Checking if there isn't unluckyly "Please wait..." node */ boolean isPlease = true; TreePath tp = jtro.findPath(getTestDirNodePath()+"|"+getTestFileObjectName()+".java", "|"); jtro.expandPath(tp); log("This is TreePath on VE node:\n"+tp+"\n"); while (isPlease) { for(int i = 0; i < jtro.getChildCount(tp); i++) { String please = jtro.getChildPath(tp, i).getLastPathComponent().toString().trim(); log("This is String node 'Please wait':\n"+please); if(please.equals("Please wait...") || please.indexOf("Please wait...")>-1){ log("There is still 'Please wait...' node.\nWe're waiting another second for refreshing nodes"); Thread.sleep(1000); } else { isPlease = false; } } } log("Trying to select a node:\n" + getTestDirNodePath()+"|"+getTestFileObjectName()+".java [Up-to-date; 1.2]|1.1 no message \n"); // exp.selectNode(getTestDirNodePath()+"|"+getTestFileObjectName()+".java [Up-to-date; 1.2]|1.1 no message "); Node tmpNode = node; node = new Node(node, "1.1 no message "); node.select(); // node.expand(); log("Trying to select a node:\n" + getTestDirNodePath()+"|"+getTestFileObjectName()+".java [Up-to-date; 1.2]|1.2 \n"); // exp.selectNode(getTestDirNodePath()+"|"+getTestFileObjectName()+".java [Up-to-date; 1.2]|1.2 "); node = new Node(tmpNode, "1.2 "); node.select(); endTest(); log("Switching into FS TAB\n"); // exp.switchToFilesystemsTab(); exp.selectPageFilesystems(); } catch (Exception e) { fail(e); } } /** invokes Tag dialog from testfile's popup menu, creates new branch "vetev2", invokes Refresh Revisions command under Versioning Explorer and looks for "1.2.2 (vetev2)" node inside Versioning Explorer * @throws Exception any unexpected exception thrown during test * @see #testVersioningExplorer depends on: testVersioningExplorer * @see #testUpdateBranch
next: testUpdateBranch */ public void testBranch() { startTest(); strCmdAction = Bundle.getStringTrimmed("org.netbeans.modules.cvsclient.actions.Bundle", "LBL_JTagAction") +"..."; String versioning = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.versioning.impl.Bundle", "versioningSystemName"); String refrRev = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.versioning.Bundle", "RefreshRevisionsAction_Name"); CVS = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.wizard.mountcvs.Bundle", "Templates/Mount/VCS/org-netbeans-modules-vcscore-wizard-mountcvs-CvsMountFS.settings"); try { // MainWindowOperator.StatusTextTracer sbt = MainWindowOperator.getDefault().getStatusTextTracer(); // MainWindowOperator main = MainWindowOperator.getDefault(); ExplorerOperator exp = new ExplorerOperator(); Node rootNode = exp.invoke().repositoryTab().getRootNode(); JTreeOperator jtro = null; log("Trying to switch to FS TAB in Explorer\n"); exp.selectPageFilesystems(); log("Trying to push PopupMe4nu:\n" + CVS +"|"+ strCmdAction +"\non this node:\n"+ getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.2]\n"); new JCVSTagAction(true).perform(new Node(rootNode, getTestDirNodePath()+"|"+ getTestFileObjectName()+" [Up-to-date; 1.2]")); log("Trying to open TAG dialog\n"); // No jelly2 TagDialogOperator TagDialog tag=new TagDialog(); log("Writing text 'vetev2' into tag textfield...\n"); tag.txtTag().setText("vetev2"); log("Checking up check box for branch tag...\n"); tag.check(tag.cbBranch(), true); /* Because of cvsrc file, there could be predefined various command switches * which we don't know. So we traying to find as much known substring as it is possible */ log("Trying to find known tag switches: '-b vetev2'\n"); assertTrue("Switches are different!", tag.compareSwitches("tag -")); assertTrue("Switches are different!", tag.compareSwitches(" -b vetev2")); log("Verification TAG dialog....\n"); tag.verify(); /* This component isn't used anymore now * Instead of it is used this one: * TabbedOutputOfVCSCommandsFrame */ // OutputOfVCSCommandsFrame out=new OutputOfVCSCommandsFrame(); /* This piece of code is a workaround for problems with losted HierarchyEvent * There is an jemmy's issue http://www.netbeans.org/issues/show_bug.cgi?id=32466 * but later appeared as a JDK bug: http://developer.java.sun.com/developer/bugParade/bugs/4924516.html */ TabbedOutputOfVCSCommandsFrame out; try { EventTool.removeListeners(); log("Trying ot execute command => clickin' on OK button\n"); tag.runCommand(); log("The Output Of VCS Command window should be opened now...\n"); out = new TabbedOutputOfVCSCommandsFrame(); } finally { EventTool.addListeners(); } // end of workaround issue #32466 log("Trying to verify the dialog\n"); //Nefunguje komponenta // pouzivej TabbedOutputOfVCSCommandsFrame out=new TabbedOutputOfVCSCommandsFrame(); out.verify(); log("Trying to close the dialog\n"); out.close(); //exp=new Explorer(); log("Trying to switch to 'Versioning' TAB in the Explorer\n"); switchToTab(exp, versioning); jtro = new JTreeOperator(JTreeOperator.waitJTree( (Container) exp.tbpExplorerTabPane().getSource (), versioning, true, true, 0)); //Starting listening to MainWindow's status line sbt.start(); log("Trying to push PopupMenu:\n"+"Refresh Revisions\non the node:\n"+ getTestDirNodePath()+"|"+getTestFileObjectName()+".java [Up-to-date; 1.2]\n"); new RefreshRevisionsAction().perform(new Node(jtro, getTestDirNodePath()+"|"+getTestFileObjectName()+".java [Up-to-date; 1.2]")); log("Trying to find this String 'Finished: Log' in the status line of the MainFrame...\n"); // Will expaire after 60s and throw an Exception if no matching String will be found. sbt.contains("Finished: Log", true); sbt.stop(); new EventTool().waitNoEvent(2000); log("Trying to select node in the Explorer:\n"+getTestDirNodePath()+"|"+getTestFileObjectName()+ ".java [Up-to-date; 1.2]|1.2 |1.2.2 (vetev2)\n"); (new Node(jtro, getTestDirNodePath()+"|"+getTestFileObjectName()+ ".java [Up-to-date; 1.2]|1.2 |1.2.2 (vetev2)")).select(); endTest(); log("Trying to switch to FS TAB\n"); exp.selectPageFilesystems(); } catch (Exception e) { fail(e); } } /** invokes Update dialog from testfile's popup menu, performs update using Tag "vetev2" and verifies that testfile has now attributes [Up-to-date; 1.2] (vetev2) under Filesystems tab * @throws Exception any unexpected exception thrown during test * @see #testBranch depends on: testBranch * @see #testCommitToBranch
next: testCommitToBranch */ public void testUpdateBranch() { startTest(); strCmdAction = Bundle.getStringTrimmed("org.netbeans.modules.cvsclient.actions.Bundle", "LBL_JUpdateAction") +"..."; CVS = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.wizard.mountcvs.Bundle", "Templates/Mount/VCS/org-netbeans-modules-vcscore-wizard-mountcvs-CvsMountFS.settings"); try { ExplorerOperator exp = new ExplorerOperator(); Node rootNode = exp.invoke().repositoryTab().getRootNode(); // JTreeOperator jtro = null; exp.selectPageFilesystems(); new Action(null, CVS +"|"+ strCmdAction).perform( new Node(rootNode,getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.2]")); // No jelly2 UpdateDialogOperator UpdateDialog update=new UpdateDialog(); update.check(update.cbRevisionTag(), true); update.txtRevisionTag().setText("vetev2"); update.check(update.cbRevisionTag(), false); update.check(update.cbRevisionTag(), true); /* Because of cvsrc file, there could be predefined various command switches * which we don't know. So we traying to find as much known substring as it is possible */ assertTrue("Switches are different!", update.compareSwitches("update -")); assertTrue("Switches are different!", update.compareSwitches(" -r vetev2")); update.verify(); update.runCommand(); // No jelly2 OutputOfVCSCommandsFrameOperator OutputOfVCSCommandsFrame out=new OutputOfVCSCommandsFrame(); out.verify(); out.close(); new Node(rootNode, getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.2] (vetev2)").select(); endTest(); } catch (Exception e) { fail(e); } } /** changes testfile contents again, invokes Refresh command, verifies that testfile has now attributes [LMod; 1.2] (vetev2), invokes Commit command from testfile's popup menu, verifies that testfile has now attributes [Up-to-date; 1.2.2.1] (vetev2), performs Refresh Revissions command under Revision Expplorer and looks for "1.2.2.1 no message" node inside * @throws Exception any unexpected exception thrown during test * @see #testUpdateBranch depends on: testUpdateBranch * @see #testMerge
next: testMerge */ public void testCommitToBranch() { startTest(); strCmdAction = Bundle.getStringTrimmed("org.netbeans.modules.cvsclient.actions.Bundle", "LBL_JRefreshAction"); String commitcmd= Bundle.getStringTrimmed("org.netbeans.modules.cvsclient.actions.Bundle", "LBL_JCommitAction") + "..."; String versioning = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.versioning.impl.Bundle", "versioningSystemName"); String refrRev = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.versioning.Bundle", "RefreshRevisionsAction_Name"); CVS = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.wizard.mountcvs.Bundle", "Templates/Mount/VCS/org-netbeans-modules-vcscore-wizard-mountcvs-CvsMountFS.settings"); try { ExplorerOperator exp = new ExplorerOperator(); Node rootNode = exp.invoke().repositoryTab().getRootNode(); // MainWindowOperator.StatusTextTracer sbt = MainWindowOperator.getDefault().getStatusTextTracer(); Node node = null; JTreeOperator jtro = null; log("Trying to switch to FS Tab\n"); exp.selectPageFilesystems(); log("Trying to select this node:\n"+ getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.2] (vetev2)"); new Node(rootNode, getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.2] (vetev2)").select(); FileOutputStream file = new FileOutputStream(getTestFile()); file.write(("//comment\nclass "+TESTFILE+" {\n//branch vetev2\n}\n").getBytes()); file.close(); log("Trying to push PopupMenu:\n"+ CVS +"|"+ strCmdAction +"\non the node:\n"+ getTestDirNodePath()+"\n"); new JCVSRefreshAction().perform(new Node(rootNode, getTestDirNodePath())); log("Trying to push PopupMenu:\n"+ CVS +"|"+ commitcmd +"\non the node:\n"+ getTestDirNodePath()+"|"+getTestFileObjectName()+" [LMod; 1.2] (vetev2)\n"); new JCVSCommitAction().perform( new Node(rootNode, getTestDirNodePath()+"|"+getTestFileObjectName()+" [LMod; 1.2] (vetev2)")); log("Opening the Commit dialog...\n"); // No jelly2 CommitDialogOperator CommitDialog commit=new CommitDialog(); log("Trying to verify the dialog...\b"); commit.verify(); log("Executing the command...\n"); commit.runCommand(); log("Opening the 'Output of VCS Commands [' dialog...\n"); OutputOfVCSCommandsFrame out=new OutputOfVCSCommandsFrame(); log("Verifying the dialog...\n"); out.verify(); log("Closing t dialog...\n"); out.close(); log("Trying to select a node:\n"+ getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.2.2.1] (vetev2)\n"); new Node(rootNode, getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.2.2.1] (vetev2)").select(); log("Trying to switch to Verifying TAB\n"); switchToTab(exp, versioning); jtro = new JTreeOperator(JTreeOperator.waitJTree( (Container) exp.tbpExplorerTabPane().getSource (), versioning, true, true, 0)); log("Selecting a node:\n" +getTestDirNodePath()); node = new Node(jtro, getTestDirNodePath()); node.select(); sbt.start(); log("Trying to push PopupMenu:\n" + refrRev + "\non the node:\n"+ getTestDirNodePath()+"|"+getTestFileObjectName()+".java [Up-to-date; 1.2.2.1] (vetev2)+\n"); node = new Node(node, getTestFileObjectName()+".java [Up-to-date; 1.2.2.1] (vetev2)"); new RefreshRevisionsAction().perform(node); log("Verifying status line in MainFrame...'Finished: Log'\n"); sbt.waitText("Finished: Log"); sbt.stop(); /* Waiting for creating node after LOG command in VE */ try { new Waiter(new Waitable() { public Object actionProduced(Object parent) { return new Node((Node)parent, "1.2|1.2.2 (vetev2)").isChildPresent("1.2.2.1") ? Boolean.TRUE: null; } public String getDescription() { return("Child '1.2.2 (vetev2)' present under parent '1.2 '"); } }).waitAction(node); } catch (InterruptedException e) { throw new JemmyException("Interrupted.", e); } log("Selecting node:\n"+ getTestDirNodePath()+"|"+getTestFileObjectName()+ ".java [Up-to-date; 1.2.2.1] (vetev2)|1.2 |1.2.2 (vetev2)|1.2.2.1 no message \n"); node = new Node(jtro, getTestDirNodePath()+"|"+getTestFileObjectName()+ ".java [Up-to-date; 1.2.2.1] (vetev2)|1.2 |1.2.2 (vetev2)|1.2.2.1 no message "); log("Selected node should be:\n"+node.getPath()); node.select(); endTest(); log("Trying to switch to FS TAB\n"); exp.selectPageFilesystems(); } catch (Exception e) { fail(e); } } /** performs update of testfile with Reset Sticky option, verifies that testfile has now [Up-to-date; 1.2] attributes, swithes to Revision Explorer, performs Merge With Revision command on "1.2.2 (vetev2)" node, verifies that testfile has now [LMod; 1.2] attributes, performs Commit command on testfile's node and verifies that testfile has now [Up-to-date; 1.3] attributes * @throws Exception any unexpected exception thrown during test * @see #testCommitToBranch depends on: testCommitToBranch * @see #testStatus
next: testStatus */ public void testMerge() { startTest(); strCmdAction = Bundle.getStringTrimmed("org.netbeans.modules.cvsclient.actions.Bundle", "LBL_JUpdateAction") +"..."; String versioning = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.versioning.impl.Bundle", "versioningSystemName"); String merge = Bundle.getStringTrimmed("org.netbeans.modules.cvsclient.versioning.Bundle", "JavaCvsVersioningAction.merge"); String commitCmd = Bundle.getStringTrimmed("org.netbeans.modules.cvsclient.actions.Bundle", "LBL_JCommitAction") + "..."; CVS = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.wizard.mountcvs.Bundle", "Templates/Mount/VCS/org-netbeans-modules-vcscore-wizard-mountcvs-CvsMountFS.settings"); try { ExplorerOperator exp = new ExplorerOperator(); Node rootNode = exp.invoke().repositoryTab().getRootNode(); // MainWindowOperator.StatusTextTracer sbt = MainWindowOperator.getDefault().getStatusTextTracer(); JTreeOperator jtro = null; log("Trying to switch to FS Tab\n"); exp.selectPageFilesystems(); log("Trying to push PopupMenu:\n" +CVS+ "|" +strCmdAction+ "\non the node:\n"+ getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.2.2.1] (vetev2)\n"); new JCVSUpdateAction().perform( new Node(rootNode, getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.2.2.1] (vetev2)")); log("Opening Update dialog...\n"); // No jelly2 UpdateDialogOperator UpdateDialog update=new UpdateDialog(); log("Trying to 'reset sticky tag'...\n"); update.check(update.cbResetSticky(), true); log("Trying to verify the dialog...\n"); update.verify(); log("Executing command....\n"); update.runCommand(); log("The 'Output of VCS Commands [' should be opened...\n"); // No jelly2 UpdateDialogOperator OutputOfVCSCommandsFrame out=new OutputOfVCSCommandsFrame(); log("Trying to verify the dialog\n"); out.verify(); log("Trying to close the dialog using 'Close' button\n"); out.close(); log("Trying to select node in the explorer:\n"+ getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.2]"); new Node(rootNode, getTestDirNodePath()+"|"+getTestFileObjectName()+" [Up-to-date; 1.2]").select(); //exp=new Explorer(); log("Trying to switch to Versioning TAB\n"); switchToTab(exp, versioning); jtro = new JTreeOperator(JTreeOperator.waitJTree( (Container) exp.tbpExplorerTabPane().getSource(), versioning, true, true, 0)); sbt.start(); log("Trying to push PopupMenu:\n" +merge+ "\non the node in VE:\n"+ getTestDirNodePath()+"|"+ getTestFileObjectName()+".java [Up-to-date; 1.2]|1.2 |1.2.2 (vetev2)"); new JCVSMergeWithRevisionAction().perform(new Node (jtro, getTestDirNodePath()+"|"+getTestFileObjectName()+ ".java [Up-to-date; 1.2]|1.2 |1.2.2 (vetev2)")); //Please correct text which is compaered in statusline after merge!!!! log("WARNING TO DEVELOPERS:\nPlease correct 'mergre' text in status line o MainWindow!!!"); System.out.println("Jaky je text v Main Window status Line?"); System.out.println(sbt.getStatusTextHistory().toString()); sbt.contains("Merge:finished...", true); sbt.stop(); log("Merge With Revision seems succeeded...\n"); log("Trying to push PopupMenu:\n"+ CVS +"|"+ commitCmd +"\non the node:\n"+ getTestDirNodePath()+"|"+getTestFileObjectName()+".java [LMod; 1.2]"); new JCVSCommitAction().perform(new Node (jtro, getTestDirNodePath()+"|"+getTestFileObjectName()+".java [LMod; 1.2]")); log("Invoking Commit dialog"); // No jelly2 CommitDialogOperator CommitDialog commit=new CommitDialog(); log("Typing a message:\nMerged with branch.\n"); commit.txtMessage().setText("Merged with branch."); log("Trying to verify the dialog\n"); commit.verify(); log("Trying to execute the command\n"); commit.runCommand(); log("Invoking the 'Ouptut of VCS Commands [' dialog\n"); out=new OutputOfVCSCommandsFrame(); log("Trying to verify the dialog\n"); out.verify(); log("Closing the dialog\n"); out.close(); log("Selecting a node:\n"+ getTestDirNodePath()+"|"+getTestFileObjectName()+".java [Up-to-date; 1.3]\n"); new Node(jtro, getTestDirNodePath()+"|"+getTestFileObjectName()+".java [Up-to-date; 1.3]").select(); endTest(); log("Trying to switch to FS Tab\n"); exp.selectPageFilesystems(); } catch (Exception e) { fail(e); } } /** performs Status command on testfile and looks for "Up-to-date" and "1.3" labels inside output frame * @throws Exception any unexpected exception thrown during test * @see #testMerge depends on: testMerge * @see #testLog
next: testLog */ public void testStatus() { startTest(); strCmdAction = Bundle.getStringTrimmed("org.netbeans.modules.cvsclient.actions.Bundle", "LBL_JStatusAction") +"..."; String versioning = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.versioning.impl.Bundle", "versioningSystemName"); CVS = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.wizard.mountcvs.Bundle", "Templates/Mount/VCS/org-netbeans-modules-vcscore-wizard-mountcvs-CvsMountFS.settings"); try { ExplorerOperator exp=new ExplorerOperator(); Node rootNode = exp.invoke().repositoryTab().getRootNode(); // MainWindowOperator.StatusTextTracer sbt = MainWindowOperator.getDefault().getStatusTextTracer(); Node node = null; JTreeOperator jtro = null; log("Trying to switch to Versioning TAB\n"); switchToTab(exp, versioning); log("Trying to push PopupMenu:\n"+ CVS +"|"+ strCmdAction +"\non the node:\n"+ getTestDirNodePath()+"|"+getTestFileObjectName()+".java [Up-to-date; 1.3]\n"); jtro = new JTreeOperator(JTreeOperator.waitJTree( (Container) exp.tbpExplorerTabPane().getSource(), versioning, true, true, 0)); new JCVSStatusAction().perform(new Node (jtro, getTestDirNodePath()+"|"+getTestFileObjectName()+".java [Up-to-date; 1.3]")); log("Invoking command dialog...\n"); // No jelly2 StatusDialogOperator StatusDialog dlg=new StatusDialog(); log("Verifying the dialog...\n"); dlg.verify(); log("Executing the command...\n"); dlg.runCommand(); log("Looking for 'CVS Output [Status - testfile.java]' dialog....\nbut sometimes it might happen"+ "that command name and file is ommited:-((((...In this case...\n test would fail\nsee P2 #26842 bug at: "+ "http://www.netbeans.org/issues/show_bug.cgi?id=26842\nand write your experiences in to it, please:\n"); StatusOutputOperator out=new StatusOutputOperator("testfile.java"); log("Status output dialog contains:"); log(out.getStatus()); log(out.getFilename()); log(out.getRepositoryFile()); log(out.getWorkingRevision()); log(out.getRepositoryRevision()); log(out.getStickyTag()); log(out.getStickyOptions()+"\n"); log("psRef="+psRef.toString()); log("repositoryprefix="+repositoryprefix); out.dumpFile(psRef, repositoryprefix); out.close(); compareReferenceFiles(); log("Trying to switch to FS Tab\n"); exp.selectPageFilesystems(); endTest(); } catch (Exception e) { fail(e); } } /** performs Log command on testfile and looks for "1.3" label inside output frame * @throws Exception any unexpected exception thrown during test * @see #testStatus depends on: testStatus * @see #testAnnotate
next: testAnnotate */ public void testLog() { clearTestStatus(); startTest(); strCmdAction = Bundle.getStringTrimmed("org.netbeans.modules.cvsclient.actions.Bundle", "LBL_JLogAction") +"..."; String versioning = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.versioning.impl.Bundle", "versioningSystemName"); CVS = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.wizard.mountcvs.Bundle", "Templates/Mount/VCS/org-netbeans-modules-vcscore-wizard-mountcvs-CvsMountFS.settings"); try { ExplorerOperator exp=new ExplorerOperator(); Node rootNode = exp.invoke().repositoryTab().getRootNode(); Node node = null; JTreeOperator jtro = null; log("Trying to switch to Verifying TAB\n"); switchToTab(exp, versioning); jtro = new JTreeOperator(JTreeOperator.waitJTree( (Container) exp.tbpExplorerTabPane().getSource (), versioning, true, true, 0)); node = new Node(jtro, getTestDirNodePath()+"|"+getTestFileObjectName()+".java [Up-to-date; 1.3]"); log("Trying to push PopupMenu:\n"+ CVS +"|"+ strCmdAction +"\non the node:\n" + node.getPath()); new JCVSLogAction().perform(node); log("Opening the input dialog for log command...\n"); // No jelly2 LogDialogOperator LogDialog dlg=new LogDialog(); log("Verifying the dialog...\n"); dlg.verify(); log("Exception the command...\n"); dlg.runCommand(); log("Looking for 'CVS Output [Log - testfile.java]' dialog....\nbut sometimes it might happen"+ "that command name and file is ommited:-((((...In this case...\n test would fail\nsee P2 bug at: "+ "http://www.netbeans.org/issues/show_bug.cgi?id=26842\nand write your experiences in to it, please:\n"); LogOutputOperator out=new LogOutputOperator("testfile.java", false, false); log("Log output dialog contains:"); log(out.getFilename()); log(out.getLocks()); log(out.getRepositoryFile()); log(out.getHeadRevision()); log(out.getSelectedRevisions()); log(out.getOutOf()); log(out.getLogMessage()+"\n"); log("psRef="+psRef.toString()); log("repositoryprefix="+repositoryprefix); out.dumpFile(psRef, repositoryprefix); compareReferenceFiles(); log("Closing the dialog...\n"); out.close(); endTest(); log("Trying to switch to FS TAB\n"); exp.selectPageFilesystems(); } catch (Exception e) { fail(e); } } /** performs Annotate command on testfile and looks for output * @throws Exception any unexpected exception thrown during test * @see #testLog depends on: testLog * @see #testUnmount
next: testUnmount */ public void testAnnotate() { clearTestStatus(); startTest(); strCmdAction = Bundle.getStringTrimmed("org.netbeans.modules.cvsclient.actions.Bundle", "LBL_JAnnotateAction") +"..."; String versioning = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.versioning.impl.Bundle", "versioningSystemName"); CVS = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.wizard.mountcvs.Bundle", "Templates/Mount/VCS/org-netbeans-modules-vcscore-wizard-mountcvs-CvsMountFS.settings"); try { ExplorerOperator exp=new ExplorerOperator(); Node rootNode = exp.invoke().repositoryTab().getRootNode(); Node node = null; JTreeOperator jtro = null; log("Trying to switch to Versioning TAB\n"); switchToTab(exp, versioning); log("Trying to push PopupMenu:\n"+ CVS +"|"+ strCmdAction +"\non the node:\n"+ getTestDirNodePath()+"|"+getTestFileObjectName()+".java [Up-to-date; 1.3]"); jtro = new JTreeOperator(JTreeOperator.waitJTree( (Container) exp.tbpExplorerTabPane().getSource (), versioning, true, true, 0)); new JCVSAnnotateAction().perform( new Node(jtro, getTestDirNodePath()+"|"+getTestFileObjectName()+".java [Up-to-date; 1.3]")); log("Opening the input command dialog...\n"); // No jelly2 AnnotateDialogOperator AnnotateDialog dlg=new AnnotateDialog(); log("Trying to verify the dialog...\n"); dlg.verify(); log("Explorer the log command...\n"); dlg.runCommand(); log("Looking for 'CVS Output [Annotate - testfile.java]' dialog.... and traying it to close,\nbut sometimes it might happen"+ "that command name and file is ommited:-((((...In this case...\n test would fail\nsee P2 bug at: "+ "http://www.netbeans.org/issues/show_bug.cgi?id=26842\nand write your experiences in to it, please:\n"); new FrameOperator("CVS Output [Annotate testfile.java]").close(); endTest(); log("Trying to switch to FS TAB\n"); exp.selectPageFilesystems(); } catch (Exception e) { fail(e); } } /** unmounts CVS filesystem using its popup menu * @throws Exception any unexpected exception thrown during test * @see #testAnnotate depends on: testAnnotate * @see #testUndock
next: testUndock */ public void testUnmount() { clearTestStatus(); startTest(); CVS = Bundle.getStringTrimmed("org.netbeans.modules.javacvs.Bundle", "JavaCvsFileSystem.validFilesystemLabel"); String umountFS = Bundle.getStringTrimmed("org.netbeans.core.actions.Bundle", "UnmountFS"); try { ExplorerOperator exp=new ExplorerOperator(); Node rootNode = exp.invoke().repositoryTab().getRootNode(); Node node = null; // JTreeOperator jtro = null; log("Trying to get focus to Explorer\n"); exp.getFocus(); // log("Trying to switch to FileSystems TAB"); // exp.selectPageFilesystems(); node = new Node(rootNode, CVS + getJavaCVSWork().getAbsolutePath()); log("Trying to push PopupMenu:\n"+umountFS+"\non the node:\n"+node+"\n"); new UnmountFSAction().perform(node); log("DONE:)"); endTest(); } catch (Exception e) { fail(e); } } /** undocks VCS Groups and Versioning frames from Explorer and closes them * @throws Exception any unexpected exception thrown during test * @see #testUnmount depends on: testUnmount */ public void testUndock() { clearTestStatus(); startTest(); String vcsGrpTAB = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.grouping.Bundle", "LBL_MODE.title"); String versTAB = Bundle.getStringTrimmed("org.netbeans.modules.vcscore.versioning.impl.Bundle", "versioningSystemName"); try { ExplorerOperator exp=new ExplorerOperator(); Node rootNode = exp.invoke().repositoryTab().getRootNode(); Node node = null; // JTreeOperator jtro = null; JFrameOperator jfo = null; log("Trying to activate the Explorer...\n"); exp.getFocus(); //Excersising with the Explorer to correctly undock VCS Groups TAB Thread.sleep(2500); log("Trying to switch to FS TAB\n"); exp.selectPageFilesystems(); //Excersising with the Explorer to correctly undock VCS Groups TAB Thread.sleep(2500); log("Trying to switch to '" +vcsGrpTAB+ "' TAB\n"); switchToTab(exp, vcsGrpTAB); log("Trying to push MainMenu:\"+ 'Window||Undock View'\n"); // MainWindowOperator.getDefault(); new UndockAction().perform(); log("...now the VCSGroupFrame should be undock....and we'return closing it...\n"); new VCSGroupsFrameOperator().close(); //exp=new Explorer(); log("Trying to activate the Explorer...\n"); // new JFrameOperator(exp.getJFrame()).activate(); exp.getFocus(); log("Trying to switch to '" +versTAB+ "' TAB\n"); switchToTab(exp, versTAB); // MainFrame.getMainFrame().pushMenu("Window|Undock View"); new UndockAction().perform(); new VersioningFrameOperator().close(); endTest(); } catch (Exception e) { fail(e); } } } netbeans-cvsclient_6.5/test/qa-functional/src/validation/ResBundlesInfo.txt0000644000175300001440000000537211175407010026211 0ustar ludousers#47 = org/netbeans/modules/cvsclient/actions/Bundle.properties CVS(47:38) ---------------------- Refresh(47:27), R Recursively(:28) Commit(:19) ...(51:59) Update(:20) Diff(:15) Status(:14) Log(:16) Annotate(:30) Checkout(:21) Impo(:22) Expo(:23) Add(:17) Remove(:18) Tag(:25) ListMod(26) ------------------------- #51 = org/netbeans/modules/vcscore/actions/Bundle.properties Versioning Explorer(51:49) IncludeInVCSGroup(51:55) #122 = org/netbeans/modules/vcscore/versioning/impl/Bundle.properties Versioning (dialog)(122:14) #42 = org/netbeans/modules/cvsclient/Bundle.properties RunCVS Cmd(42:102) #114 = org/netbeans/modules/cvsclient/login/Bundle.properties CVS ConnMan(114:13) CustomizeFS(51:30) #84 = org/netbeans/modules/vcscore/grouping/Bundle.properties VCS Group(84:22) #137 = org/netbeans/modules/cvsclient/commands/add/Bundle.propertie Commit ScheduledFiles(137:33) Dialogs ======= #45 = org/netbeans/modules/javacvs/commands/Bundle.properties Arguments for [xxx] (45:86) #5 = org/netbeans/core/windows/Bundle.properties Output of VCS Commands [xxx](45:84) ? CVS Output [xxx](5:23) #118 = org/netbeans/modules/cvsclient/commands/update/Bundle.properties Button->VievLog(118:30) #119 = org/netbeans/modules/cvsclient/commands/Bundle.properties Server Output Log(119:57) RunTimeTAB: =========== #123 = org/netbeans/modules/vcscore/runtime/Bundle.properties node VCS Cmds(123:14) popup menu->VievOut(123:37) #119 = org/netbeans/modules/cvsclient/commands/Bundle.properties popup menu->Open in Graph(119:74) #55 = org/openide/actions/Bundle.properties popup menu->Properties(55:41) VCSGrp: ======= #141 = org/netbeans/modules/cvsclient/commands/grouping/Bundle.properties Group Verification(141:22) CorrectGrop(141:20) No problems were found (141:21) #1xx = org/netbeans/modules/vcscore/grouping/Bundle.properties VCS Groups (Root node)(1xx:19) VCS Groups (Menu) (1xx:22) VCS Groups (Title) (1xx:27) #84 = org/netbeans/modules/vcscore/grouping/Bundle.properties popup menu->AddVCSGrp(84:14) popup menu->Remove VCSGRp(:14) popup menu->Verify(:15) popup menu->Proper(55:41) #51 = org/netbeans/modules/vcscore/actions/Bundle.properties popup menu->Move to VCS Grp(51:56) #94 = org/openide/actions/Bundle.properties popup menu->Delete (94:35) VersioningExp: ============== #75 = org/netbeans/modules/cvsclient/versioning/Bundle.properties Update(:31) Diff(:33) Merge with rev.(:32) Annotate(:36) #82 = org/netbeans/modules/vcscore/versioning/Bundle.properties Refresh Revision(:15) MainFrame...status.line: ======================== #42 = org/netbeans/modules/javacvs/commands/Bundle.properties #84 = org/netbeans/modules/cvsclient/commands/Bundle.properties Finished: Log(42:69) (84:14) DialogTitles: ============= #135 = org/openide/explorer/Bundle.properties Confirm Object Deletion(135:46) netbeans-cvsclient_6.5/test/qa-functional/src/validation/data/0000755000175300001440000000000011175434236023502 5ustar ludousersnetbeans-cvsclient_6.5/test/qa-functional/src/validation/data/goldenfiles/0000755000175300001440000000000011175434236025775 5ustar ludousersnetbeans-cvsclient_6.5/test/qa-functional/src/validation/data/goldenfiles/JavaCVSValidationTest/0000755000175300001440000000000011175434236032105 5ustar ludousers././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/validation/data/goldenfiles/JavaCVSValidationTest/testDiff.passnetbeans-cvsclient_6.5/test/qa-functional/src/validation/data/goldenfiles/JavaCVSValidationTest/test0000644000175300001440000000036311175407010032777 0ustar ludousers==== Text - Panel 1 ==== class testfile {} ==== Text - Panel 2 ==== //comment class testfile {} ==== Colors - Panel 1 ==== ==== Colors - Panel 2 ==== Pos: 0 ---- Green Pos: 2 ---- Green Pos: 4 ---- Green Pos: 6 ---- Green Pos: 8 ---- Green ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/validation/data/goldenfiles/JavaCVSValidationTest/testLog.passnetbeans-cvsclient_6.5/test/qa-functional/src/validation/data/goldenfiles/JavaCVSValidationTest/test0000644000175300001440000000061511175407010032777 0ustar ludousersdumpFile: testfile.java strict /testfile.java,v 1.3 4 4 dumpSymbolicNamesList: 1,2 1. - vetev2 - 1.2.0.2 dumpRevisionList: 4,6 1. - 1.1 - test - no message - Exp - null 2. - 1.2 - test - - Exp - +1 -0 3. - 1.2.2.1 - test - no message - Exp - +3 -1 4. - 1.3 - test - Merged with branch. - Exp - +3 -1 dumpLogMessage: 4 no message no message Merged with branch. ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootnetbeans-cvsclient_6.5/test/qa-functional/src/validation/data/goldenfiles/JavaCVSValidationTest/testStatus.passnetbeans-cvsclient_6.5/test/qa-functional/src/validation/data/goldenfiles/JavaCVSValidationTest/test0000644000175300001440000000014011175407010032770 0ustar ludousersdumpFile: testfile.java Up-to-date /testfile.java,v 1.3 1.3 (none) (none) dumpExistingTags: 0,2 netbeans-cvsclient_6.5/test/unit/0000755000175300001440000000000011175434236016066 5ustar ludousersnetbeans-cvsclient_6.5/test/unit/src/0000755000175300001440000000000011175434236016655 5ustar ludousersnetbeans-cvsclient_6.5/test/unit/src/org/0000755000175300001440000000000011175434236017444 5ustar ludousersnetbeans-cvsclient_6.5/test/unit/src/org/netbeans/0000755000175300001440000000000011175434236021243 5ustar ludousersnetbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/0000755000175300001440000000000011175434236022011 5ustar ludousersnetbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/0000755000175300001440000000000011175434236024003 5ustar ludousersnetbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/CVSRootTest.java0000644000175300001440000002153311175407011027000 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient; import java.io.*; import junit.framework.*; /** * Test of CVSRoot class. * * @author Martin Entlicher */ public class CVSRootTest extends TestCase { /** Creates a new instance of CVSRootTest */ public CVSRootTest(String name) { super(name); } private void compareRoot(CVSRoot root, String method, String user, String password, String host, int port, String repository) { if (!(method == root.getMethod())) { fail("Bad connection method is parsed: '"+root.getMethod()+"', expected was '"+method+"'"); } if (user != null && !user.equals(root.getUserName())) { fail("Bad user name is parsed: '"+root.getUserName()+"', expected was '"+user+"'"); } if (password != null && !password.equals(root.getPassword())) { fail("Bad password is parsed: '"+root.getPassword()+"', expected was '"+password+"'"); } if (host != null && !host.equals(root.getHostName())) { fail("Bad host name is parsed: '"+root.getHostName()+"', expected was '"+host+"'"); } if (port != root.getPort()) { fail("Bad port is parsed: '"+root.getPort()+"', expected was '"+port+"'"); } if (!repository.equals(root.getRepository())) { fail("Bad repository is parsed: '"+root.getRepository()+"', expected was '"+repository+"'"); } } /** * Test of CVSRoot.parse() method. * It should parse the CVSROOT String of the form * [:method:][[user][:password]@][hostname:[port]]/path/to/repository * * For remote repositories the colon between hostname and path to repository * is optional when port is not specified: * [:method:][[user][:password]@]hostname[:[port]]/path/to/repository */ public void testParseCorrectURLS() throws Exception { CVSRoot root = CVSRoot.parse("/path/to/repository"); compareRoot(root, CVSRoot.METHOD_LOCAL, null, null, null, 0, "/path/to/repository"); root = CVSRoot.parse(":local:/path/to/repository"); compareRoot(root, CVSRoot.METHOD_LOCAL, null, null, null, 0, "/path/to/repository"); root = CVSRoot.parse(":local:user@hostname:/path/to/repository"); compareRoot(root, CVSRoot.METHOD_LOCAL, null, null, null, 0, "user@hostname:/path/to/repository"); root = CVSRoot.parse("hostname:/path/to/repository"); compareRoot(root, "ext", null, null, "hostname", 0, "/path/to/repository"); root = CVSRoot.parse("hostname:/path:/to/repository"); compareRoot(root, "ext", null, null, "hostname", 0, "/path:/to/repository"); root = CVSRoot.parse(":server:hostname:/path/to/repository"); compareRoot(root, CVSRoot.METHOD_SERVER, null, null, "hostname", 0, "/path/to/repository"); root = CVSRoot.parse(":pserver:hostname:/path/to/repository"); compareRoot(root, CVSRoot.METHOD_PSERVER, null, null, "hostname", 0, "/path/to/repository"); root = CVSRoot.parse(":pserver:user@hostname:/path/to/repository"); compareRoot(root, CVSRoot.METHOD_PSERVER, "user", null, "hostname", 0, "/path/to/repository"); root = CVSRoot.parse(":pserver:user:password@hostname:/path/to/repository"); compareRoot(root, CVSRoot.METHOD_PSERVER, "user", "password", "hostname", 0, "/path/to/repository"); root = CVSRoot.parse(":pserver:hostname:2403/path/to/repository"); compareRoot(root, CVSRoot.METHOD_PSERVER, null, null, "hostname", 2403, "/path/to/repository"); root = CVSRoot.parse(":pserver:user:password@hostname:2403/path/to/repository"); compareRoot(root, CVSRoot.METHOD_PSERVER, "user", "password", "hostname", 2403, "/path/to/repository"); // #67504 root = CVSRoot.parse("c:\\CVSROOT"); compareRoot(root, CVSRoot.METHOD_LOCAL, null, null, null, 0, "c:\\CVSROOT"); // No last colon: root = CVSRoot.parse("hostname/path/to/repository"); compareRoot(root, "server", null, null, "hostname", 0, "/path/to/repository"); //??? ext or server root = CVSRoot.parse(":server:hostname/path/to/repository"); compareRoot(root, CVSRoot.METHOD_SERVER, null, null, "hostname", 0, "/path/to/repository"); root = CVSRoot.parse(":pserver:hostname/path/to/repository"); compareRoot(root, CVSRoot.METHOD_PSERVER, null, null, "hostname", 0, "/path/to/repository"); root = CVSRoot.parse(":pserver:user@hostname/path/to/repository"); compareRoot(root, CVSRoot.METHOD_PSERVER, "user", null, "hostname", 0, "/path/to/repository"); root = CVSRoot.parse(":pserver:user:password@hostname/path/to/repository"); compareRoot(root, CVSRoot.METHOD_PSERVER, "user", "password", "hostname", 0, "/path/to/repository"); // WinCVS, CVS 1.12 has method options root = CVSRoot.parse(":pserver;hostname=host;username=user:/path/to/repository"); compareRoot(root, CVSRoot.METHOD_PSERVER, "user", null, "host", 0, "/path/to/repository"); root = CVSRoot.parse(":pserver;username=SCR_Roland;hostname=mainsrv:/Software"); compareRoot(root, CVSRoot.METHOD_PSERVER, "SCR_Roland", null, "mainsrv", 0, "/Software"); // CVSNT root = CVSRoot.parse(":ssh;ver=2:username@cvs.sf.net:/cvsroot/xoops"); compareRoot(root, CVSRoot.METHOD_EXT, "username", null, "cvs.sf.net", 0, "/cvsroot/xoops"); root = CVSRoot.parse(":pserver:mike@javadev.zappmobile.ro:2401:/home/cvsroot"); // #71032 compareRoot(root, CVSRoot.METHOD_PSERVER, "mike", null, "javadev.zappmobile.ro", 2401, "/home/cvsroot"); } /** * Test of CVSRoot.parse() method. * It should not parse the CVSROOT String if not of the form * [:method:][[user][:password]@][hostname:[port]]/path/to/repository */ public void testParseBadURLS() { CVSRoot root; boolean isBad = false; try { root = CVSRoot.parse(":pserver:/path/to/repository"); } catch (IllegalArgumentException iaex) { isBad = true; } if (!isBad) fail("CVSROOT ':pserver:/path/to/repository' is not considered as bad."); isBad = false; try { root = CVSRoot.parse(":somethig that does not end with a colon"); } catch (IllegalArgumentException iaex) { isBad = true; } if (!isBad) fail("CVSROOT ':somethig that does not end with a colon' is not considered as bad."); isBad = false; try { root = CVSRoot.parse("somethig that does not have neither slash, nor a colon"); } catch (IllegalArgumentException iaex) { isBad = true; } if (!isBad) fail("CVSROOT 'somethig that does not have neither slash, nor a colon' is not considered as bad."); } } netbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/TestKit.java0000644000175300001440000000614011175407011026225 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient; import java.io.File; import java.io.IOException; /** * Set of utility methods. * * @author Petr Kuzel */ public class TestKit { public static File createTmpFolder(String prefix) throws IOException { String tmpDir = System.getProperty("java.io.tmpdir"); // NOI18N File tmpFolder = new File(tmpDir); // generate unique name for tmp folder File tmp = File.createTempFile(prefix, "", tmpFolder); // NOI18N if (tmp.delete() == false) { throw new IOException("Can not delete " + tmp); }; if (tmp.mkdirs() == false) { throw new IOException("Can not create " + tmp); }; return tmp; } public static void deleteRecursively(File file) { if (file.isDirectory()) { File[] files = file.listFiles(); for (int i = 0; i < files.length; i++) { File next = files[i]; deleteRecursively(next); // RECURSION } file.delete(); } } } netbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/admin/0000755000175300001440000000000011175434236025073 5ustar ludousersnetbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/admin/StandardAdminHandlerTest.java0000644000175300001440000001356411175407011032605 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient.admin; import junit.framework.*; import java.io.*; import java.util.*; import org.netbeans.lib.cvsclient.TestKit; import org.netbeans.lib.cvsclient.command.*; import org.netbeans.lib.cvsclient.file.FileUtils; /** * * @author Petr Kuzel */ public class StandardAdminHandlerTest extends TestCase { public StandardAdminHandlerTest(String testName) { super(testName); } protected void setUp() throws Exception { } protected void tearDown() throws Exception { } public static Test suite() { TestSuite suite = new TestSuite(StandardAdminHandlerTest.class); return suite; } int test70625ThreadDone; /** * Simulates 70625 issue. * It can randomly pass for incorrect code but never fails for correct code. */ public void test70625() throws Exception { try { System.err.println("test70625()"); File tmpDir = TestKit.createTmpFolder("test_StandardAdminHandlerTest"); final File file = new File(tmpDir, "test70625"); final Entry entry = new Entry(); entry.setName("test70625"); final StandardAdminHandler instance = new StandardAdminHandler(); // create CVS structure that simulates rename in progress new File(tmpDir, "CVS").mkdirs(); new File(tmpDir, "CVS/Entries.Backup").createNewFile(); SyncTwo lock = new SyncTwo(); instance.t9yBeforeRenameSync(lock); final Runnable r = new Runnable() { public void run() { try { instance.setEntry(file, entry); } catch (IOException ex) { System.err.println("Ignoring " + ex.getMessage() + " ..."); } finally { test70625ThreadDone ++; synchronized(StandardAdminHandlerTest.this) { StandardAdminHandlerTest.this.notifyAll(); } } } }; final Runnable r2 = new Runnable() { public void run() { try { instance.getEntry(file); } catch (IOException ex) { System.err.println("Ignoring " + ex.getMessage() + " ..."); } finally { test70625ThreadDone ++; synchronized(StandardAdminHandlerTest.this) { StandardAdminHandlerTest.this.notifyAll(); } } } }; new Thread(r, "Update").start(); new Thread(r2, "Annotator").start(); synchronized(this) { while (test70625ThreadDone < 2) { wait(); } } if (new File(tmpDir, "CVS/Entries").exists() == false) { fail("CVS/Entries gone."); } } catch (Exception ex) { ex.printStackTrace(); throw ex; } } private class SyncTwo implements Runnable { int counter; public synchronized void run() { counter++; Thread.dumpStack(); while (counter < 2) { try { System.err.println(Thread.currentThread().getName() + " is waiting for sibling..."); wait(100); // correct code will always wait return; } catch (InterruptedException ex) { ex.printStackTrace(); } } notifyAll(); } } } netbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/package.html0000644000175300001440000000022411175407011026251 0ustar ludousers

Library unit tests

TODO develop TestCase that eliminates boilerpate code with PseudoCvsServer and timeouted waiting on operation results.netbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/AddTest.java0000644000175300001440000001250311175416504026175 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient; import junit.framework.TestCase; import java.io.*; import org.netbeans.lib.cvsclient.command.GlobalOptions; import org.netbeans.lib.cvsclient.command.add.AddCommand; import org.netbeans.lib.cvsclient.connection.Connection; import org.netbeans.lib.cvsclient.connection.PServerConnection; import org.netbeans.lib.cvsclient.admin.StandardAdminHandler; /** * Add command test suite. * * @author Petr Kuzel */ public class AddTest extends TestCase { /** * Tests cvswrappers compliance. *

* Uses fake PseudoCvsServer. */ public void test36289() throws Exception { File tmpDir = TestKit.createTmpFolder("serverAbortTest"); String protocolLog = new File(tmpDir, "protocol").getAbsolutePath(); System.setProperty("cvsClientLog", protocolLog); System.setProperty("Env-CVSWRAPPERS", "*.wrap -k 'b'"); System.out.println(protocolLog); InputStream in = getClass().getResourceAsStream("protocol/iz36289.in"); final PseudoCvsServer cvss = new PseudoCvsServer(in); File requestsLog = File.createTempFile("requests", null, tmpDir); cvss.logRequests(new FileOutputStream(requestsLog)); new Thread(cvss).start(); String cvsRoot = cvss.getCvsRoot(); CVSRoot root = CVSRoot.parse(cvsRoot); final GlobalOptions gtx = new GlobalOptions(); gtx.setCVSRoot(cvsRoot); Connection connection = new PServerConnection(root); final Client client = new Client(connection, new StandardAdminHandler()); client.setLocalPath(tmpDir.getAbsolutePath()); // prepare working directory File CVSdir = new File(tmpDir, "CVS"); CVSdir.mkdirs(); OutputStream out; File rootFile = new File(CVSdir, "Root"); out = new FileOutputStream(rootFile); out.write(cvsRoot.getBytes("utf8")); out.flush(); out.close(); File repo = new File(CVSdir, "Repository"); out = new FileOutputStream(repo); out.write("/cvs".getBytes("utf8")); out.flush(); out.close(); // execute the command AddCommand add = new AddCommand(); File wrap = new File(tmpDir, "test.wrap"); File txt = new File(tmpDir, "test.txt"); if (wrap.createNewFile() == false) { throw new IOException("Can not create " + wrap); } if (txt.createNewFile() == false) { throw new IOException("Can not create " + txt); } File[] files = new File[] {wrap, txt}; add.setFiles(files); client.executeCommand(add, gtx); cvss.stop(); // check test matching golden file (here critical line from issue #36289) InputStream actual = new FileInputStream(requestsLog); LineNumberReader lineReader = new LineNumberReader(new InputStreamReader(actual, "utf8")); String line = lineReader.readLine(); StringBuffer sb = new StringBuffer(); while (line != null) { sb.append(line + "\n"); line = lineReader.readLine(); } String requests = sb.toString(); assertTrue(requests, requests.indexOf("Kopt -kb\n" + "Is-modified test.wrap") != -1); TestKit.deleteRecursively(tmpDir); } } netbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/CheckoutTest.java0000644000175300001440000001315411175416504027255 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient; import junit.framework.TestCase; import java.io.File; import java.io.InputStream; import org.netbeans.lib.cvsclient.command.GlobalOptions; import org.netbeans.lib.cvsclient.command.CommandException; import org.netbeans.lib.cvsclient.command.checkout.CheckoutCommand; import org.netbeans.lib.cvsclient.connection.Connection; import org.netbeans.lib.cvsclient.connection.PServerConnection; import org.netbeans.lib.cvsclient.admin.StandardAdminHandler; /** * Checkout test suite. Works at C/S protocol wire level. * * @author Petr Kuzel */ public class CheckoutTest extends TestCase { /** * Test how client handles unxpected IOException caused * by line drop from checkout command. *

* Uses fake PseudoCvsServer. */ public void test56552_21126() throws Exception { final File tmpDir = TestKit.createTmpFolder("checkoutDropTest"); String protocolLog = new File(tmpDir, "protocol").getAbsolutePath(); System.setProperty("cvsClientLog", protocolLog); System.out.println(protocolLog); final InputStream in = getClass().getResourceAsStream("protocol/iz56552_21126.in"); if (in == null) { System.err.println(getClass().getProtectionDomain().getCodeSource().getLocation().toExternalForm()); in.markSupported(); } // command exception expected // infinite *1s) blocking is a failure // other exception is test failre final Exception expectedException[] = new Exception [1]; final Exception testException[] = new Exception[1]; Runnable run = new Runnable() { public void run() { try { PseudoCvsServer cvss = new PseudoCvsServer(in); try { cvss.simulateNetworkFailure(1000, -1); new Thread(cvss).start(); String cvsRoot = cvss.getCvsRoot(); CVSRoot root = CVSRoot.parse(cvsRoot); GlobalOptions gtx = new GlobalOptions(); gtx.setCVSRoot(cvsRoot); Connection connection = new PServerConnection(root); Client client = new Client(connection, new StandardAdminHandler()); client.setLocalPath(tmpDir.getAbsolutePath()); CheckoutCommand checkout = new CheckoutCommand(); checkout.setModule("a11y"); client.executeCommand(checkout, gtx); expectedException.notify(); } catch (CommandException ex) { // expected expected, infinite wait would be a bug synchronized(expectedException) { expectedException[0] = ex; expectedException.notify(); } } finally { cvss.stop();; } } catch (Exception ex) { testException[0] = ex; } } }; Thread t = new Thread(run); t.start(); synchronized(expectedException) { if (expectedException[0] == null) { expectedException.wait(1000); // 'INFINITE' TIMEOUT } } t.interrupt(); if (testException[0] != null) { throw testException[0]; } assertTrue(expectedException[0] != null); TestKit.deleteRecursively(tmpDir); } } netbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/ClientTest.java0000644000175300001440000002466511175416504026737 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient; import junit.framework.TestCase; import org.netbeans.lib.cvsclient.connection.Connection; import org.netbeans.lib.cvsclient.connection.PServerConnection; import org.netbeans.lib.cvsclient.admin.StandardAdminHandler; import org.netbeans.lib.cvsclient.admin.Entry; import org.netbeans.lib.cvsclient.command.status.StatusCommand; import org.netbeans.lib.cvsclient.command.GlobalOptions; import org.netbeans.lib.cvsclient.command.FileInfoContainer; import org.netbeans.lib.cvsclient.command.PipedFileInformation; import org.netbeans.lib.cvsclient.command.CommandException; import org.netbeans.lib.cvsclient.command.log.RlogCommand; import org.netbeans.lib.cvsclient.command.add.AddCommand; import org.netbeans.lib.cvsclient.command.commit.CommitCommand; import org.netbeans.lib.cvsclient.command.update.UpdateCommand; import org.netbeans.lib.cvsclient.command.checkout.CheckoutCommand; import org.netbeans.lib.cvsclient.event.*; import java.io.*; import java.util.Date; /** * Compares output and input streams. *

* NON PORTABLE * * @author Petr Kuzel */ public class ClientTest extends TestCase { /** * Tests single file status command for local file that is * in repository Attic. It's should be Unknown = unversioned. */ public void test50963() throws Exception { File tmpDir = TestKit.createTmpFolder("localFileStatusTest"); File localCheckout = tmpDir; String relativePath = "javacvs" + File.separator + "test" + File.separator + "data" + File.separator + "iz50963" + File.separator + "removed.txt"; String cvsRoot = ":pserver:anoncvs@netbeans.org:/cvs"; System.setProperty("cvsClientLog", new File(tmpDir, "protocol").getAbsolutePath()); // System.setProperty("socksProxyHost", "icsocks.holland.sun.com"); CVSRoot root = CVSRoot.parse(cvsRoot); GlobalOptions gtx = new GlobalOptions(); gtx.setCVSRoot(cvsRoot); // prepare local environment, checkout and create a local file Connection connection = new PServerConnection(root); Client client = new Client(connection, new StandardAdminHandler()); client.setLocalPath(tmpDir.getAbsolutePath()); CheckoutCommand checkout = new CheckoutCommand(); checkout.setModule("javacvs/test/data/iz50963"); checkout.setPruneDirectories(true); checkout.setNotShortenPaths(true); checkout.setRecursive(true); client.executeCommand(checkout, gtx); File localFile = new File(localCheckout, relativePath); if (localFile.createNewFile() == false) { throw new IOException("Cannot create " + localFile); } // run status on *single* local file that is Attic in repository connection = new PServerConnection(root); client = new Client(connection, new StandardAdminHandler()); client.setLocalPath(tmpDir.getAbsolutePath()); StatusCommand status = new StatusCommand(); File[] files = new File[] {new File(localCheckout, relativePath)}; status.setFiles(files); client.getEventManager().addCVSListener(new CVSListener() { public void messageSent(MessageEvent e) { } public void messageSent(BinaryMessageEvent e) { } public void fileAdded(FileAddedEvent e) { } public void fileToRemove(FileToRemoveEvent e) { } public void fileRemoved(FileRemovedEvent e) { } public void fileUpdated(FileUpdatedEvent e) { } public void fileInfoGenerated(FileInfoEvent e) { FileInfoContainer fic = e.getInfoContainer(); System.err.println("Fic: " + fic); } public void commandTerminated(TerminationEvent e) { } public void moduleExpanded(ModuleExpansionEvent e) { } }); client.executeCommand(status, gtx); // check result "Unknown" expected assertTrue(false); // all OK clean up TestKit.deleteRecursively(tmpDir); } /** * Tests checkou command prune empty directories option. * It must eliminate pruned folder from Entries file. */ public void test53239() throws Exception { String checkoutModule = "javacvs/test/data"; File tmpDir = TestKit.createTmpFolder("pruneTest"); String localCheckout = tmpDir.getAbsolutePath(); String cvsRoot = ":pserver:anoncvs@netbeans.org/cvs"; System.setProperty("cvsClientLog", new File(tmpDir, "protocol").getAbsolutePath()); // System.setProperty("socksProxyHost", "icsocks.holland.sun.com"); CVSRoot root = CVSRoot.parse(cvsRoot); Connection connection = new PServerConnection(root); Client client = new Client(connection, new StandardAdminHandler()); client.setLocalPath(localCheckout); CheckoutCommand checkout = new CheckoutCommand(); checkout.setModule(checkoutModule); checkout.setPruneDirectories(true); checkout.setNotShortenPaths(true); checkout.setRecursive(true); GlobalOptions gtx = new GlobalOptions(); gtx.setCVSRoot(cvsRoot); client.executeCommand(checkout, gtx); // check results, there must not be iz53239 entry String relativePath = "javacvs" + File.separator + "test" + File.separator + "data" + File.separator + "CVS" + File.separator + "Entries"; FileReader reader = new FileReader(new File(localCheckout, relativePath)); BufferedReader buffy = new BufferedReader(reader); String line = buffy.readLine(); do { assertTrue(line.indexOf("iz53239") == -1); line = buffy.readLine(); } while (line != null); // all OK clean up TestKit.deleteRecursively(tmpDir); } /** * Test handling of binary file piped out to standard output * (these are sent as as pure M responses instead of Mbinary responses) */ public void test56710() throws Exception { File tmpDir = TestKit.createTmpFolder("binaryToStdoutTest"); String relativePath = "javacvs" + File.separator + "test" + File.separator + "data" + File.separator + "iz56710" + File.separator + "binary.out"; String localCheckout = tmpDir.getAbsolutePath(); String cvsRoot = ":pserver:anoncvs@netbeans.org/cvs"; String protocolLog = new File(tmpDir, "protocol").getAbsolutePath(); System.setProperty("cvsClientLog", protocolLog); // System.setProperty("socksProxyHost", "icsocks.holland.sun.com"); CVSRoot root = CVSRoot.parse(cvsRoot); Connection connection = new PServerConnection(root); Client client = new Client(connection, new StandardAdminHandler()); client.setLocalPath(localCheckout); UpdateCommand update = new UpdateCommand(); update.setPipeToOutput(true); File[] files = new File[] {new File(tmpDir, relativePath)}; update.setFiles(files); final File[] pipedTmpFile = new File[1]; client.getEventManager().addCVSListener(new CVSListener() { public void messageSent(MessageEvent e) { } public void messageSent(BinaryMessageEvent e) { } public void fileAdded(FileAddedEvent e) { } public void fileToRemove(FileToRemoveEvent e) { } public void fileRemoved(FileRemovedEvent e) { } public void fileUpdated(FileUpdatedEvent e) { } public void fileInfoGenerated(FileInfoEvent e) { PipedFileInformation pfi = (PipedFileInformation) e.getInfoContainer(); pipedTmpFile[0] = pfi.getTempFile(); } public void commandTerminated(TerminationEvent e) { } public void moduleExpanded(ModuleExpansionEvent e) { } }); GlobalOptions gtx = new GlobalOptions(); gtx.setCVSRoot(cvsRoot); client.executeCommand(update, gtx); FileInputStream in = new FileInputStream(pipedTmpFile[0]); byte[] bytes = new byte[257]; int len = in.read(bytes); assertEquals(len, 256); for (int i = 0; i<256; i++) { assertEquals(bytes[i], (byte)i); } TestKit.deleteRecursively(tmpDir); } } netbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/CommitTest.java0000644000175300001440000001450411175416504026740 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient; import junit.framework.TestCase; import java.io.*; import java.util.Date; import org.netbeans.lib.cvsclient.admin.Entry; import org.netbeans.lib.cvsclient.admin.StandardAdminHandler; import org.netbeans.lib.cvsclient.command.GlobalOptions; import org.netbeans.lib.cvsclient.command.commit.CommitCommand; import org.netbeans.lib.cvsclient.connection.Connection; import org.netbeans.lib.cvsclient.connection.PServerConnection; /** * Commit command test suite. * * @author Petr Kuzel */ public class CommitTest extends TestCase { /** * Client must checks conflicted files timestamps. Until * it changes it should not commit the file (it actually * decides server by testing sent entry). *

* Uses fake PseudoCvsServer. */ public void test36288() throws Exception { File tmpDir = TestKit.createTmpFolder("commitConflictTest"); String protocolLog = new File(tmpDir, "protocol").getAbsolutePath(); System.setProperty("cvsClientLog", protocolLog); System.out.println(protocolLog); // prepare working directory File CVSdir = new File(tmpDir, "CVS"); CVSdir.mkdirs(); File entries = new File(CVSdir, "Entries"); OutputStream out = new FileOutputStream(entries); String dateString = "Thu Mar 24 15:14:27 2005"; String data = "/conflict.txt/1.2/Result of merge+" + dateString + "//\nD"; out.write(data.getBytes("utf8")); out.flush(); out.close(); File conflict_txt = new File(tmpDir, "conflict.txt"); out = new FileOutputStream(conflict_txt); data = "AAA\n" + "BBB\n" + "<<<<<<< conflict.txt\n" + "YYY <= fix\n" + "=======\n" + "222 <= fix\n" + ">>>>>>> 1.2\n" + "DDD\n" + "EEE\n"; out.write(data.getBytes("utf8")); out.flush(); out.close(); Date date = Entry.getLastModifiedDateFormatter().parse(dateString); conflict_txt.setLastModified(date.getTime()); InputStream in = getClass().getResourceAsStream("protocol/iz36288.in"); if (in == null) { System.err.println(getClass().getProtectionDomain().getCodeSource().getLocation().toExternalForm()); in.markSupported(); } PseudoCvsServer cvss = new PseudoCvsServer(in); File requestsLog = File.createTempFile("requests", null, tmpDir); cvss.logRequests(new FileOutputStream(requestsLog)); new Thread(cvss).start(); String cvsRoot = cvss.getCvsRoot(); File root = new File(CVSdir, "Root"); out = new FileOutputStream(root); out.write(cvsRoot.getBytes("utf8")); out.flush(); out.close(); File repo = new File(CVSdir, "Repository"); out = new FileOutputStream(repo); out.write("/cvs".getBytes("utf8")); out.flush(); out.close(); // commit command CVSRoot CvsRoot = CVSRoot.parse(cvsRoot); GlobalOptions gtx = new GlobalOptions(); gtx.setCVSRoot(cvsRoot); Connection connection = new PServerConnection(CvsRoot); Client client = new Client(connection, new StandardAdminHandler()); client.setLocalPath(tmpDir.getAbsolutePath()); CommitCommand commit = new CommitCommand(); File[] files = new File[] {new File(tmpDir, "conflict.txt")}; commit.setFiles(files); client.executeCommand(commit, gtx); cvss.stop(); // check test matching golden file (here critical line from iz36288.out) InputStream actual = new FileInputStream(requestsLog); LineNumberReader lineReader = new LineNumberReader(new InputStreamReader(actual, "utf8")); boolean foundConflictLine = false; String line = lineReader.readLine(); StringBuffer sb = new StringBuffer(); while (foundConflictLine == false && line != null) { sb.append(line + "\n"); foundConflictLine |= "Entry /conflict.txt/1.2/+=//".equals(line); line = lineReader.readLine(); } assertTrue("Missing 'Entry /conflict.txt/1.2/+=//' in:\n" + sb.toString(), foundConflictLine); TestKit.deleteRecursively(tmpDir); } } netbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/ErrorHandlingTest.java0000644000175300001440000001174111175416504030246 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient; import junit.framework.TestCase; import java.io.File; import java.io.InputStream; import org.netbeans.lib.cvsclient.command.GlobalOptions; import org.netbeans.lib.cvsclient.command.status.StatusCommand; import org.netbeans.lib.cvsclient.connection.Connection; import org.netbeans.lib.cvsclient.connection.PServerConnection; import org.netbeans.lib.cvsclient.admin.StandardAdminHandler; /** * Tescase covering handling network unreliability and * known server protocol errors (library contains workarounds). * * @author Petr Kuzel */ public class ErrorHandlingTest extends TestCase { /** * Test how client workarounds [server abort] signals. *

* Uses fake PseudoCvsServer. */ public void test56552() throws Exception { File tmpDir = TestKit.createTmpFolder("serverAbortTest"); String protocolLog = new File(tmpDir, "protocol").getAbsolutePath(); System.setProperty("cvsClientLog", protocolLog); System.out.println(protocolLog); InputStream in = getClass().getResourceAsStream("protocol/iz56552.in"); final PseudoCvsServer cvss = new PseudoCvsServer(in); new Thread(cvss).start(); String cvsRoot = cvss.getCvsRoot(); CVSRoot root = CVSRoot.parse(cvsRoot); final GlobalOptions gtx = new GlobalOptions(); gtx.setCVSRoot(cvsRoot); Connection connection = new PServerConnection(root); final Client client = new Client(connection, new StandardAdminHandler()); client.setLocalPath(tmpDir.getAbsolutePath()); final StatusCommand status = new StatusCommand(); File[] files = new File[] {new File(tmpDir, "placeholder")}; status.setFiles(files); final Exception testException[] = new Exception[1]; final boolean completedFlag[] = new boolean[] {false}; Runnable run = new Runnable() { public void run() { try { try { client.executeCommand(status, gtx); synchronized(completedFlag) { completedFlag[0] = true; completedFlag.notifyAll(); } } finally { cvss.stop(); } } catch (Exception ex) { testException[0] = ex; } } }; // test mus finish in reasonable time (compare to blocking forever that'd be a bug) Thread t = new Thread(run); t.start(); synchronized(completedFlag) { if (completedFlag[0] == false) { completedFlag.wait(1000); // 'INFINITE' TIMEOUT } } t.interrupt(); if (testException[0] != null) { throw testException[0]; } assertTrue(completedFlag[0]); TestKit.deleteRecursively(tmpDir); } } netbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/PseudoCvsServer.java0000644000175300001440000002767011175416504027762 0ustar ludousers/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.lib.cvsclient; import java.io.*; import java.net.ServerSocket; import java.net.Socket; /** * Unit testing CVS server implementation that provides * constant replies coming from prepared files and * simulates network and server overload failures. * *

Typical server usage in unit test sequence: *

 *   InputStream in = getClass().getResourceAsStream("...");
 *   PseudoCvsServer cvss = new PseudoCvsServer(in);
 *   new Thread(cvss).start();
 *   String cvsRoot = cvss.getCvsRoot();
 *   <client operations>
 *   cvss.stop();  // check test failure
 *   <tested client asserts>
 * 
* *

Fake input and output streams can be on Unix systems * catched using nc program. To catch command line * cvs: *

    *
  • outgoing requests stream use
    nc -l -p $3000 | tee $requests.log
    and *
    cvs -d :pserver:$ano@127.0.0.1:$3000/$cvs -z0 $whateEverCommand
    *
  • incoming responses stream use
    nc $cvs.netbeans.org $2401 | tee $reponses.log
    *
* * @author Petr Kuzel */ public final class PseudoCvsServer implements Runnable { private final int SIMULATE_SLOWNESS = 1; private final int SIMULATE_OVERLOAD = 2; private final int SIMULATE_DROP = 4; private final InputStream fakeDataStream; private OutputStream requestsStream; private final ServerSocket serverSocket; private Socket clientSocket; private OutputStream socketOut; private InputStream socketIn; private int outputCounter = -1; private int inputCounter = -1; private int simulationMode; private Exception throwable; private boolean stopped; private boolean running; private boolean ignoreProbe; /** * Creates new server that replies with given data. * @param in input stream that is consumend and closed * once server runnable terminates. * * @throws IOException if cannot create server socket */ public PseudoCvsServer(InputStream in) throws IOException { try { this.fakeDataStream = in; serverSocket = new ServerSocket(); serverSocket.bind(null, 2); } catch (IOException ex) { in.close(); throw ex; } } /** * returns port that accepts client requests. */ public int getPort() { return serverSocket.getLocalPort(); } /** * Utility method returning typical CVSRoot sutable for * local CVSClient testing. * * @return ":pserver:anoncvs@127.0.0.1:" + getPort() + "/cvs" */ public synchronized String getCvsRoot() { try { while (running == false) { this.wait(); } } catch (InterruptedException e) { } return ":pserver:anoncvs@127.0.0.1:" + getPort() + "/cvs"; } /** * Enters hard network failure simulation mode, silentry * dropping down connection after specified number of in/outgoing bytes. * * @param write specifies number of bytes send before * closing socket output stream. -1 for unlimited. * @param read specifies number of bytes received before * closing socket input stream. -1 for unlimited. */ public void simulateNetworkFailure(int write, int read) { simulationMode |= SIMULATE_DROP; outputCounter = write; inputCounter = read; } /** * Enters server overload simulation mode. * Server properly closes streams sending TCP signals to client. * * @param write specifies number of bytes send before * shuting down socket output stream. -1 for unlimited. * @param read specifies number of bytes received before * shuting down socket input stream. -1 for unlimited. */ public void simulateServerOverload(int write, int read) { simulationMode |= SIMULATE_OVERLOAD; outputCounter = write; inputCounter = read; } public void simulateSlowNetwork(int write, int read) { simulationMode |= SIMULATE_SLOWNESS; outputCounter = write; inputCounter = read; } /** * Enters ignore very first connect mode (connection probe). * It means that actual data are send out to second requestor. */ public void ignoreProbe() { ignoreProbe = true; } /** * Logs server input intu specified stream. * * @param out log stream. The stream is closed on server termination. */ public void logRequests(OutputStream out) { requestsStream = out; } /** * Entry point, starts listening at port and sends out * predefined replies. HAndles only first request. */ public void run() { try { synchronized (this) { running = true; notifyAll(); } while (true) { try { clientSocket = serverSocket.accept(); if (ignoreProbe == false) { break; } ignoreProbe = false; } catch (IOException e) { throwable = e; return; } } try { socketOut = clientSocket.getOutputStream(); socketIn = clientSocket.getInputStream(); if (consumeInput()) { return; } int nextByte = fakeDataStream.read(); while (nextByte != -1) { if (outputCounter-- == 0) { if ((simulationMode & SIMULATE_DROP) != 0) { socketOut.flush(); socketOut.close(); } if ((simulationMode & SIMULATE_OVERLOAD) != 0) { clientSocket.shutdownOutput(); } if ((simulationMode & SIMULATE_SLOWNESS) != 0) { try { Thread.sleep(5000); } catch (InterruptedException e) { throwable = e; } } if ((simulationMode & (SIMULATE_OVERLOAD | SIMULATE_DROP)) != 0) { consumeInputUntilStopped(); return; } } socketOut.write(nextByte); if (consumeInput()) { return; } nextByte = fakeDataStream.read(); } socketOut.flush(); // socketOut.close(); // need to propagate to client ASAP, otherwise all reads and available wait forever // on the other hand it causes premature BrokenPipe signal because it // immediately clears receiver's input buffers // do not close input streams prematurely consumeInputUntilStopped(); } catch (IOException e) { throwable = e; return; } } finally { try { fakeDataStream.close(); } catch (IOException alreadyClosed) { } try { if (socketIn != null) socketIn.close(); } catch (IOException alreadyClosed) { } try { if (socketOut != null) socketOut.close(); } catch (IOException alreadyClosed) { } try { if (requestsStream != null) { requestsStream.flush(); requestsStream.close(); } } catch (IOException alreadyClosed) { } } } /** * Stops server and optionaly rethrows internal server exception if any. */ public synchronized void stop() throws Exception { stopped = true; notifyAll(); if (throwable != null) { throw throwable; } } /** For diagnostics purpoes only. */ public String toString() { StringWriter sw = new StringWriter(); PrintWriter ps = new PrintWriter(sw); ps.write("PseudoCvsServer on " + serverSocket + "\n"); if (throwable != null) { throwable.fillInStackTrace(); throwable.printStackTrace(ps); } ps.flush(); ps.close(); return sw.getBuffer().toString(); } /** * Reads client input stream possibly simulating errors. */ private boolean consumeInput() throws IOException { int available = socketIn.available(); for (int i = 0; i>>>>>> 1.2 DDD EEE Argument conflict.txt ci netbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/protocol/iz36289.in0000644000175300001440000000106211175416504027227 0ustar ludousersI LOVE YOU Valid-requests Root Valid-responses valid-requests Repository Directory Max-dotdot Static-directory Sticky Checkin-prog Update-prog Entry Kopt Checkin-time Modified Is-modified UseUnchanged Unchanged Notify Questionable Case Argument Argumentx Global_option Gzip-stream wrapper-sendme-rcsOptions Set expand-modules ci co update diff log rlog add remove update-patches gzip-file-contents status rdiff tag rtag import admin export history release watch-on watch-off watch-add watch-remove watchers editors init annotate rannotate noop version ok ok ok netbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/protocol/iz56552.in0000644000175300001440000000113711175416504027225 0ustar ludousersI LOVE YOU Valid-requests Root Valid-responses valid-requests Repository Directory Max-dotdot Static-directory Sticky Checkin-prog Update-prog Entry Kopt Checkin-time Modified Is-modified UseUnchanged Unchanged Notify Questionable Case Argument Argumentx Global_option Gzip-stream wrapper-sendme-rcsOptions Set expand-modules ci co update diff log rlog add remove update-patches gzip-file-contents status rdiff tag rtag import admin export history release watch-on watch-off watch-add watch-remove watchers editors init annotate rannotate noop version ok E cvs [server aborted]: received broken pipe signal netbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/protocol/iz56552_21126.in0000644000175300001440000000412211175416504027755 0ustar ludousersI LOVE YOU Valid-requests Root Valid-responses valid-requests Repository Directory Max-dotdot Static-directory Sticky Checkin-prog Update-prog Entry Kopt Checkin-time Modified Is-modified UseUnchanged Unchanged Notify Questionable Case Argument Argumentx Global_option Gzip-stream wrapper-sendme-rcsOptions Set expand-modules ci co update diff log rlog add remove update-patches gzip-file-contents status rdiff tag rtag import admin export history release watch-on watch-off watch-add watch-remove watchers editors init annotate rannotate noop version ok Module-expansion a11y ok MT +updated MT text U MT fname a11y/build.xml MT newline MT -updated Created a11y/ /cvs/a11y/build.xml /build.xml/1.11/// u=rw,g=rw,o=rw 1186 Mod-time 2 Sep 2003 14:10:34 -0000 netbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/protocol/iz56710.in0000644000175300001440000000200611175416504027215 0ustar ludousersI LOVE YOU Valid-requests Root Valid-responses valid-requests Repository Directory Max-dotdot Static-directory Sticky Checkin-prog Update-prog Entry Kopt Checkin-time Modified Is-modified UseUnchanged Unchanged Notify Questionable Case Argument Argumentx Global_option Gzip-stream wrapper-sendme-rcsOptions Set expand-modules ci co update diff log rlog add remove update-patches gzip-file-contents status rdiff tag rtag import admin export history release watch-on watch-off watch-add watch-remove watchers editors init annotate rannotate noop version ok E =================================================================== E Checking out javacvs/test/data/iz56710/binary.out E RCS: /cvs/javacvs/test/data/iz56710/binary.out,v E VERS: 1.1 E *************** Mbinary 256   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ok netbeans-cvsclient_6.5/test/unit/src/org/netbeans/lib/cvsclient/protocol/iz57365.in0000644000175300001440000000105311175416504027225 0ustar ludousersI LOVE YOU Valid-requests Root Valid-responses valid-requests Repository Directory Max-dotdot Static-directory Sticky Checkin-prog Update-prog Entry Kopt Checkin-time Modified Is-modified UseUnchanged Unchanged Notify Questionable Case Argument Argumentx Global_option Gzip-stream wrapper-sendme-rcsOptions Set expand-modules ci co update diff log rlog add remove update-patches gzip-file-contents status rdiff tag rtag import admin export history release watch-on watch-off watch-add watch-remove watchers editors init annotate rannotate noop version ok