Author: tchemit Date: 2008-04-06 09:33:33 +0000 (Sun, 06 Apr 2008) New Revision: 382 Added: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSCommon.java Log: introduce VCSCommon contract tobe realized by VCSHandler and VCSConnexion Copied: trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSCommon.java (from rev 376, trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSHandler.java) =================================================================== --- trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSCommon.java (rev 0) +++ trunk/lutinvcs/lutinvcs-api/src/main/java/org/codelutin/vcs/VCSCommon.java 2008-04-06 09:33:33 UTC (rev 382) @@ -0,0 +1,302 @@ +/* *##% +* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Code Lutin, +* Benjamin Poussin, Tony Chemit +* +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*##%*/ +package org.codelutin.vcs; + +import org.codelutin.vcs.type.VCSState; + +import java.io.File; +import java.io.FileFilter; +import java.io.FilenameFilter; +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +/** + * Contract of operations to realized by a handler or a connexion + * + * @author chemit + */ + +public interface VCSCommon { + + /** + * init working copy, says if it is the first we use it it, we will checkout + * the databaseDirectory directory + * + * @throws org.codelutin.vcs.VCSException if any exception while init + */ + void initWorkingCopy() throws VCSException; + + /** delete the local working copy with all his files */ + void deleteWorkingCopy(); + + /** + * @return a <code>FilenameFilter<code> to detect all files and directories in a vcs working copy that + * must be handled by vcs + */ + FilenameFilter getVersionnableFilenameFilter(); + + /** + * @return a <code>FileFilter<code> to detect all files and directories in a vcs working copy that + * must be handled by vcs + */ + FileFilter getVersionnableFileFilter(); + + /** + * @return name of directory used by vcs to store in working copy, a data's + * directory configuration (e.g CVS for cvs and .svn for svn) + */ + String getConfLocalDirname(); + + /** + * @return name of the file used by vcs to store in working copy + * configuration directory entries of data's directory (e.g Entries + * for cvs and entries for svn) + */ + String getConfLocalEntriesFilename(); + + VCSState getState(File file, Collection tmp) throws VCSException; + + VCSState getState(File file, Collection tmp, boolean noremote) throws VCSException; + + /** + * @param file file to test + * @return <code>true</code> if <code>file</code> is on remote + * repository, <code>false</code> otherwise. + */ + boolean isOnRemote(File file); + + /** + * @param file file to test + * @return <code>true</code> if file is uptodate,<code>false</code> + * otherwise. + * @throws org.codelutin.vcs.VCSException if any exception while operation + */ + boolean isUpToDate(File file) throws VCSException; + + /** + * @param file file to test + * @return <code>true</code> if file is handled by VCS,<code>false</code> + * otherwise. + */ + boolean isVersionnableFile(File file); + + /** + * add on remote repository somes directories + * + * @param commitMessage commit message + * @param dirNames names of the directories to create on remote repository (could + * used multi-level directories) + * @throws org.codelutin.vcs.VCSException if any exception while operation + */ + void makeRemoteDir(String commitMessage, String... dirNames) + throws VCSException; + + /** + * delete on remote repository somes directories + * + * @param commitMessage commit message + * @param dirNames names of the directories to delete on remote repository (could + * used multi-level directories) + * @throws org.codelutin.vcs.VCSException if any exception while operation + */ + void deleteRemoteDir(String commitMessage, String... dirNames) + throws VCSException; + + /** + * add a list of files into repository + * + * @param files files to add + * @param msg message for VCS commit, if <code>null</code> then no commit + * is performed + * @return revision of the operation + * @throws org.codelutin.vcs.VCSException if any exception while operation + */ + long add(List<File> files, String msg) throws VCSException; + + // void add(File file, String msg) throws VCSException; + + /** + * delete a list of files from repository + * + * @param files files to delete + * @param msg message for VCS commit, if <code>null</code> then no commit + * is performed + * @throws org.codelutin.vcs.VCSException if any exception while operation + */ + void delete(List<File> files, String msg) throws VCSException; + + /** + * revert a list of files from repository + * + * @param files files to revert + * @throws org.codelutin.vcs.VCSException if any exception while operation + */ + void revert(List<File> files) throws VCSException; + + /** + * commit a list of files into repository + * + * @param files files to commit + * @param msg message for VCS commit + * @return revision of the operation + * @throws org.codelutin.vcs.VCSException if any exception while operation + */ + long commit(List<File> files, String msg) throws VCSException; + + /** + * update a file to repository to a certain revision + * + * @param file file to update + * @param revision object representing a revision for the current VCS + * @throws org.codelutin.vcs.VCSException if any exception while operation + */ + void update(File file, Object revision) throws VCSException; + + /** + * update a file to repository + * + * @param file file to update + * @throws org.codelutin.vcs.VCSException if any exception while operation + */ + void update(File file) throws VCSException; + + /** + * checkout a module from repository to a local file + * + * @param destDir local file where to checkout + * @param module module's name to checkout + * @param recurse flag to say to recurse checkout or not. + * @throws org.codelutin.vcs.VCSException if any exception while operation + */ + void checkout(File destDir, String module, boolean recurse) throws VCSException; + + void checkoutFile(File destDir, String module) throws VCSException; + + long checkoutOnlyTheDirectory(File root, Object revision) throws VCSException; + + /** + * TODO This is not the good place : VCS != Storage + * + * @param directory directory to treate + * @return TODO + * @throws org.codelutin.vcs.VCSException TODO + */ + List<String> getRemoteStorageNames(File directory) throws VCSException; + + /** + * TODO This is not the good place : VCS != Storage + * + * @param directory directory to treate + * @return TODO + */ + List<String> getLocalStorageNames(File directory); + + /** + * @param f local file to treate + * @return current local revision of a file + * @throws org.codelutin.vcs.VCSException TODO + */ + Object getRevision(File f) throws VCSException; + + /** + * Obtain the list of log entries for the file + * + * @param startRevision TODO + * @param endRevision TODO + * @param file file to treate + * @return list of log entries for this file between two revisions + * @throws org.codelutin.vcs.VCSException if any exception while grabbing infos + */ + List getLog(Object startRevision, Object endRevision, File file) + throws VCSException; + + /** + * obtain the content of a file for a specific revision + * + * @param file file to obtain + * @param revision revision treated + * @return the content of the file on repository for the specific revision + * passed as arguement. + * @throws org.codelutin.vcs.VCSException if any exception while operation + * @throws java.io.IOException TODO + */ + String getFileContent(File file, Object revision) throws VCSException, IOException; + + /** + * Build the changelog for <code>file</code> from current revision of this + * local file against head repository head version. For each revision + * between current revision and head revision of this file, we give the + * following informations : + * <ul> + * <li>revision number</li> + * <li>author</li> + * <li>date</li> + * <li>commit message</li> + * </ul> + * + * @param file file to treate + * @return a string representation of change log for the local file to the + * head ? + * @throws org.codelutin.vcs.VCSException if any exception while building changelog + */ + String getChangeLog(File file) throws VCSException; + + /** + * Generate in the ouputstream the diff between the current revision of the + * local file against headest revision on repository. <br> + * If file is uptodate, then does nothing. + * + * @param file the file to treate + * @return the diff + * @throws org.codelutin.vcs.VCSException inf any exception while building diff, such as : + * <ul> + * <li>unversionned file</li> + * <li>unexistant file locally</li> + * <li>locally modified file ?</li> + * <li>...</li> + * </ul> + * @throws java.io.IOException if io problem with streams + */ + String getDiff(File file) throws VCSException, IOException; + + + /** + * Generate in the ouputstream the diff between the current revision of the + * local file against another revision (<code>againstRevision</code>) on + * repository. <br> + * If file is uptodate, then does nothing. + * + * @param file the file to treate + * @param againstRevision the against revision to use + * @return the diff + * @throws org.codelutin.vcs.VCSException inf any exception while building diff, such as : + * <ul> + * <li>unversionned file</li> + * <li>unexistant file locally</li> + * <li>locally modified file ?</li> + * <li>...</li> + * </ul> + * @throws java.io.IOException if problem with streams + */ + String getDiff(File file, Object againstRevision) throws VCSException, IOException; + + boolean hasProtocoleChanged() throws VCSException; +} \ No newline at end of file
participants (1)
-
tchemit@users.labs.libre-entreprise.org