gate.versioning.cmdline
Interface Repository

All Known Implementing Classes:
AbstractRepository, CvsRepository, SvnRepository

public interface Repository

This is the main entry point for the version control package. See also the package overview. The name of this interface is a little misleading: it doesn't really model version control repositories, but version control commands. In a perfect world it would be renamed.

Version control repository interface. Implementors are intended to use bean-type parameterisation and initialisation. The lifecycle is:

An exception to the rule of calling init() before other methods is create(java.lang.String), which can be called on an unitialised object (so that we can create repositories without having an existing one).

Implementors are expected to execute the command-line repository program to do the work specified by this API. The anticipated uses are with CVS and SVN. The API is kept close to the underlying version control systems, so, for example, to delete a file first delete the actual file from disk, then call delete(java.lang.String), then call checkin(java.lang.String) to commit the deletion. A Repository object may also be obtained from AbstractRepository.getRepository(java.lang.String).


Method Summary
 boolean add(String fileName)
          Add to the repository.
 boolean checkin(String fileName)
          Commit changes.
 boolean checkin(String fileName, String message)
          Commit changes.
 boolean checkout(String fileName)
          Check out a file, directory or module.
 boolean create(String dirName)
          Create a new repository filetree (i.e. not a new object but a new database/filesystem on disk).
 boolean delete(String fileName)
          Delete from the repository.
 String diff(String fileName)
          Get the difference with the repository version.
 boolean exists(String moduleName)
          Check for the existence of a module (i.e. top-level directory).
 String getCommandName()
          Name of the repository command to execute (e.g. cvs, svn).
 String getCommandOutput()
          Get a string containing the stdout and stderr from the command execution.
 String getCommandStderr()
          Get a string containing the stderr from the command execution.
 String getCommandStdout()
          Get a string containing the stdout from the command execution.
 String getRoot()
          The root / URL of the repository
 boolean importDir(String dirName)
          Import a directory.
 void init()
          Validate parameters.
 boolean isModified(String fileName)
          Use the repository's status command to figure out if the file has been locally modified.
 boolean isOutOfDate(String fileName)
          Use the repository's status command to figure out if the file is out-of-date.
 boolean isUnknown(String fileName)
          Use the repository's status command to figure out if the file is unknown.
 void setRoot(String root)
          The root / URL of the repository
 void setWorkingDir(File workingDir)
          The working directory for repository actions
 String status(String fileName)
          Status.
 boolean update(String fileName)
          Update.
 

Method Detail

init

void init()
          throws gate.util.GateException
Validate parameters.

Throws:
gate.util.GateException

getCommandName

String getCommandName()
Name of the repository command to execute (e.g. cvs, svn). This is mainly useful for implementors of this interface.


setRoot

void setRoot(String root)
The root / URL of the repository


getRoot

String getRoot()
The root / URL of the repository


setWorkingDir

void setWorkingDir(File workingDir)
The working directory for repository actions


checkout

boolean checkout(String fileName)
Check out a file, directory or module.

Parameters:
fileName - the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
Returns:
boolean representing success or failure.

checkin

boolean checkin(String fileName)
Commit changes. A default message is used.

Parameters:
fileName - the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
Returns:
boolean representing success or failure.

checkin

boolean checkin(String fileName,
                String message)
Commit changes.

Parameters:
fileName - the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
message - a commit message.
Returns:
boolean representing success or failure.

update

boolean update(String fileName)
Update.

Parameters:
fileName - the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
Returns:
boolean representing success or failure.

status

String status(String fileName)
Status.

Parameters:
fileName - the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
Returns:
String giving status output.

isModified

boolean isModified(String fileName)
Use the repository's status command to figure out if the file has been locally modified.

Parameters:
fileName - the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
Returns:
boolean giving status indication.

isOutOfDate

boolean isOutOfDate(String fileName)
Use the repository's status command to figure out if the file is out-of-date.

Parameters:
fileName - the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
Returns:
boolean giving status indication.

isUnknown

boolean isUnknown(String fileName)
Use the repository's status command to figure out if the file is unknown. This only works when you're looking for a file relative to a working copy - to check for existence use exists(java.lang.String).

Parameters:
fileName - the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
Returns:
boolean giving status indication.

exists

boolean exists(String moduleName)
Check for the existence of a module (i.e. top-level directory).

Parameters:
moduleName - directory to look for.
Returns:
boolean giving status indication.

delete

boolean delete(String fileName)
Delete from the repository.

Parameters:
fileName - the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
Returns:
boolean representing success or failure.

add

boolean add(String fileName)
Add to the repository.

Parameters:
fileName - the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
Returns:
boolean representing success or failure.

diff

String diff(String fileName)
Get the difference with the repository version.

Parameters:
fileName - the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
Returns:
a string containing the difference, or "" for no difference, or null for error.

create

boolean create(String dirName)
               throws gate.util.GateException
Create a new repository filetree (i.e. not a new object but a new database/filesystem on disk).

Parameters:
dirName - the directory to work on, which will be created (should be an absolute path).
Returns:
boolean representing success or failure.
Throws:
gate.util.GateException

importDir

boolean importDir(String dirName)
                  throws gate.util.GateException
Import a directory.

Parameters:
dirName - the directory to import (this must exist).
Returns:
boolean representing success or failure.
Throws:
gate.util.GateException - when the directory doesn't exist.

getCommandStdout

String getCommandStdout()
Get a string containing the stdout from the command execution.


getCommandStderr

String getCommandStderr()
Get a string containing the stderr from the command execution.


getCommandOutput

String getCommandOutput()
Get a string containing the stdout and stderr from the command execution.