nl.toolforge.karma.core.vc.cvsimpl
Class CVSRunner

java.lang.Object
  extended bynl.toolforge.karma.core.vc.cvsimpl.CVSRunner
All Implemented Interfaces:
Runner

public final class CVSRunner
extends java.lang.Object
implements Runner

Runner class for CVS. Executes stuff on a CVS repository.

TODO : the CVSRunner could be made multi-threaded, to use bandwidth to a remote repository much better ...

Version:
$Id: CVSRunner.java,v 1.33 2004/11/16 22:31:57 asmedes Exp $
Author:
D.A. Smedes

Constructor Summary
CVSRunner(Location location)
          Constructs a runner to fire commands on a CVS repository.
 
Method Summary
 void add(Module module, java.io.File[] files, java.io.File[] dirs)
          Adds a set of files and/or a set of directories (recursively) to the version control system.
 void add(Module module, java.lang.String[] files, java.lang.String[] dirs)
          See add(Module, File[], File[]).
 void addModule(Module module, java.lang.String comment)
           
 void checkout(Module module)
          Checks out a module from a version control system.
 void checkout(Module module, DevelopmentLine developmentLine, Version version)
          See checkout(Module, Version).
 void checkout(Module module, Version version)
          Performs the cvs checkout [-r <symbolic-name>] <module>command for a module.
 void commit(java.io.File file)
          Commits file in the version control system.
 void createPatchLine(Module module)
          Creates a patchline for the module, given the modules' current version.
 boolean existsInRepository(Module module)
          A check if a module exists is done by trying to checkout the modules' module.info file in a temporary location.
 boolean hasPatchLine(Module module)
          Checks if the module has a CVS branch tag module.getPatchLine().getName() attached.
 org.netbeans.lib.cvsclient.command.log.LogInformation log(Module module)
          Provide log information on a module.
 void promote(Module module, java.lang.String comment, Version version)
           
 void setCommandResponse(CommandResponse response)
          Assigns a CommandResponse instance to the runner to optionally promote interactivity.
 void update(Module module)
          Updates an already checked out module.
 void update(Module module, DevelopmentLine developmentLine, Version version)
          For a module, the cvs -q update -d -r <symbolic-name> command is executed.
 void update(Module module, Version version)
          Updates an already checked out module to a specified version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CVSRunner

public CVSRunner(Location location)
          throws CVSException,
                 AuthenticationException
Constructs a runner to fire commands on a CVS repository. A typical client for a CVSRunner instance is a Command implementation, as that one knows what to fire away on CVS. The runner is instantiated with a location and a manifest. The location must be a CVSLocationImpl instance, reprenting a CVS repository. The manifest is required because it determines the base point from where CVS commands will be run; modules are checked out in a directory structure, relative to Manifest.getModuleBaseDirectory().

Parameters:
location - A Location instance (typically a CVSLocationImpl instance), containing the location and connection details of the CVS repository.
Throws:
CVSException - AUTHENTICATION_ERROR is thrown when location cannot be authenticated.
AuthenticationException - If the location cannot be authenticated.
Method Detail

setCommandResponse

public void setCommandResponse(CommandResponse response)
Assigns a CommandResponse instance to the runner to optionally promote interactivity.

Specified by:
setCommandResponse in interface Runner
Parameters:
response - A - possibly null response instance.

commit

public void commit(java.io.File file)
            throws VersionControlException
Description copied from interface: Runner
Commits file in the version control system. If file is not yet under version control it will be added.

Specified by:
commit in interface Runner
Throws:
VersionControlException - Exceptions related to version control operations.

addModule

public void addModule(Module module,
                      java.lang.String comment)
               throws CVSException
Specified by:
addModule in interface Runner
Throws:
CVSException

checkout

public void checkout(Module module,
                     Version version)
              throws CVSException
Performs the cvs checkout [-r <symbolic-name>] <module>command for a module. version is used when not null to checkout a module with a symbolic name.

Specified by:
checkout in interface Runner
Parameters:
module - The module to check out.
version - The version number for the module to check out.
Throws:
CVSException - With errorcodes NO_SUCH_MODULE_IN_REPOSITORY when the module does not exist in the repository and INVALID_SYMBOLIC_NAME, when the version does not exists for the module.

checkout

public void checkout(Module module)
              throws CVSException
Description copied from interface: Runner
Checks out a module from a version control system.

Specified by:
checkout in interface Runner
Parameters:
module - The module that should be checked out of the version control repository.
Throws:
CVSException

checkout

public void checkout(Module module,
                     DevelopmentLine developmentLine,
                     Version version)
              throws CVSException
See checkout(Module, Version). This method defaults to the HEAD of the development branch at hand.

Specified by:
checkout in interface Runner
Parameters:
module - The module to check out.
developmentLine - The development line or null when the TRUNK is the context line.
version - The version of the module that should be checked out.
Throws:
CVSException - With errorcodes NO_SUCH_MODULE_IN_REPOSITORY when the module does not exist in the repository and INVALID_SYMBOLIC_NAME, when the version does not exists for the module.

update

public void update(Module module)
            throws CVSException
Description copied from interface: Runner
Updates an already checked out module.

Specified by:
update in interface Runner
Parameters:
module - The module that should be updated.
Throws:
CVSException
See Also:
update(Module, DevelopmentLine, Version)

update

public void update(Module module,
                   Version version)
            throws CVSException
Description copied from interface: Runner
Updates an already checked out module to a specified version.

Specified by:
update in interface Runner
Parameters:
module - The module that should be updated.
version - The version to which the the module should be updated,
Throws:
CVSException
See Also:
update(Module, DevelopmentLine, Version)

update

public void update(Module module,
                   DevelopmentLine developmentLine,
                   Version version)
            throws CVSException
For a module, the cvs -q update -d -r <symbolic-name> command is executed. Note that empty directories are not pruned.

Specified by:
update in interface Runner
Parameters:
module - The module to update.
developmentLine - The development line or null when the TRUNK is the context line.
version - The version of the module or null when no specific version applies.
Throws:
CVSException

add

public void add(Module module,
                java.io.File[] files,
                java.io.File[] dirs)
         throws CVSException
Description copied from interface: Runner
Adds a set of files and/or a set of directories (recursively) to the version control system. Files and directories will be created when they don't exist.

Specified by:
add in interface Runner
Parameters:
module - The module to which the files apply.
files - The filenames that should be added to the version control system repository.
dirs - The directory-paths that should be added to the version control system repository.
Throws:
CVSException

add

public void add(Module module,
                java.lang.String[] files,
                java.lang.String[] dirs)
         throws CVSException
Description copied from interface: Runner
See Runner.add(Module, File[], File[]). This method converts the String items to File items.

Specified by:
add in interface Runner
Parameters:
module - The context module to which the files should be added.
files - Files to be added (each String will be added relative to the module base directory).
dirs - Directories to be added (each String will be added relative to the module base directory).
Throws:
CVSException

promote

public void promote(Module module,
                    java.lang.String comment,
                    Version version)
             throws CVSException
Specified by:
promote in interface Runner
Parameters:
module -
comment - Comment of the developer
version -
Throws:
CVSException

log

public org.netbeans.lib.cvsclient.command.log.LogInformation log(Module module)
                                                          throws CVSException
Provide log information on a module. This method checks if the setCommandResponse(nl.toolforge.karma.core.cmd.CommandResponse) method has been called, which results in this runner initializing the CVS API with the correct objects. This is a requirement for the Netbeans CVS API.

Throws:
CVSException

hasPatchLine

public boolean hasPatchLine(Module module)
Checks if the module has a CVS branch tag module.getPatchLine().getName() attached.

Specified by:
hasPatchLine in interface Runner
Parameters:
module - The module for which the patch line should be checked.
Returns:
true of the module has a patch line attached in the CVS repository, false otherwise.

createPatchLine

public void createPatchLine(Module module)
                     throws CVSException
Creates a patchline for the module, given the modules' current version.

Specified by:
createPatchLine in interface Runner
Parameters:
module - The module.
Throws:
CVSException - When an error occurred during the creation process.

existsInRepository

public boolean existsInRepository(Module module)
A check if a module exists is done by trying to checkout the modules' module.info file in a temporary location. If that succeeds, apparently the module exists in that location and we have a true to return.

Specified by:
existsInRepository in interface Runner
Parameters:
module -
Returns:
true if the module exists, false otherwise.


Copyright © 2002-2004 Toolforge. All Rights Reserved.