gate.versioning.svnkit
Class Sandbox
java.lang.Object
gate.versioning.svnkit.Sandbox
public class Sandbox
- extends Object
This class is a thin layer over the SVNKit working copy API. All methods that
trigger write operations on the sandbox tree are synchronized, but to ensure
that there is not more than one Sandbox associated with a particular
directory tree on disk the SandboxManager
class should be used.
Constructor Summary |
Sandbox()
Construction. |
Sandbox(org.tmatesoft.svn.core.auth.ISVNAuthenticationManager authManager)
Construction with a custom authentication manager. |
Sandbox(org.tmatesoft.svn.core.auth.ISVNAuthenticationManager authManager,
File svnconfig)
|
Sandbox(String name,
String password)
Construction. |
Sandbox(String name,
String password,
File svnconfig)
|
Method Summary |
void |
addEntry(File wcPath)
Puts directories and files under version control scheduling them for
addition to a repository. |
void |
addEntry(File wcPath,
boolean recurse)
Puts directories and files under version control scheduling them for
addition to a repository. |
void |
checkCancelled()
If the current operation is preemptible and any other operations are
waiting, throw an SVNCancelException. |
long |
checkout(org.tmatesoft.svn.core.SVNURL url,
org.tmatesoft.svn.core.wc.SVNRevision revision,
File destPath,
boolean isRecursive)
Checks out a working copy from a repository. |
void |
close()
Close this sandbox, preventing any future operations. |
org.tmatesoft.svn.core.SVNCommitInfo |
commit(File[] wcPath,
boolean keepLocks,
String commitMessage)
Committs changes in a working copy to a repository. |
org.tmatesoft.svn.core.SVNCommitInfo |
copy(org.tmatesoft.svn.core.SVNURL srcURL,
org.tmatesoft.svn.core.SVNURL dstURL,
boolean isMove,
String commitMessage)
Duplicates srcURL to dstURL (URL to URL) preserving history. |
void |
delete(File wcPath,
boolean force)
Schedules directories and files for deletion from version control upon the
next commit (locally). |
void |
doResolve(File wcPath,
boolean isRecursive)
Resolve a conflict on local path(s). |
org.tmatesoft.svn.core.wc.SVNStatus |
doStatus(File wcPath,
boolean isRemote)
Collects status information on local path(s). |
org.tmatesoft.svn.core.SVNURL |
getRepositoryRoot(File file)
Returns the URL of the root of the repository containing the given working
copy file. |
org.tmatesoft.svn.core.SVNURL |
getRepositoryURL(File file)
Returns the URL corresponding to the repository location of the given
working copy file. |
org.tmatesoft.svn.core.SVNCommitInfo |
importDirectory(File localPath,
org.tmatesoft.svn.core.SVNURL dstURL,
String commitMessage,
boolean isRecursive)
Imports an unversioned directory into a repository location denoted by a
destination URL (all necessary parent non-existent paths will be created
automatically). |
void |
lock(File wcPath,
boolean isStealLock,
String lockComment)
Locks working copy paths, so that no other user can commit changes to them. |
org.tmatesoft.svn.core.SVNCommitInfo |
makeDirectory(org.tmatesoft.svn.core.SVNURL url,
String commitMessage)
Creates a new version controlled directory (doesn't create any intermediate
directories) right in a repository. |
void |
relocate(File wcPath,
org.tmatesoft.svn.core.SVNURL oldURL,
org.tmatesoft.svn.core.SVNURL newURL)
Updates a working copy in the same was as 'svn switch --relocate' |
void |
revert(File... wcPaths)
Revert uncommitted changes. |
void |
showInfo(File wcPath,
org.tmatesoft.svn.core.wc.SVNRevision revision,
boolean isRecursive)
Collects information on local path(s). |
void |
showStatus(File wcPath,
boolean isRecursive,
boolean isRemote,
boolean isReportAll,
boolean isIncludeIgnored,
boolean isCollectParentExternals)
Displays status information on local path(s). |
long |
switchToURL(File wcPath,
org.tmatesoft.svn.core.SVNURL url,
org.tmatesoft.svn.core.wc.SVNRevision updateToRevision,
boolean isRecursive)
Updates a working copy to a different URL. |
long |
update(File wcPath,
org.tmatesoft.svn.core.wc.SVNRevision updateToRevision,
boolean isRecursive)
Updates a working copy in a non-preemptible operation. |
long |
update(File wcPath,
org.tmatesoft.svn.core.wc.SVNRevision updateToRevision,
boolean isRecursive,
boolean preemptible)
Updates a working copy (brings changes from the repository into the working
copy). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Sandbox
public Sandbox()
- Construction. Not appropriate if authentication is needed.
Sandbox
public Sandbox(String name,
String password)
- Construction.
Sandbox
public Sandbox(String name,
String password,
File svnconfig)
Sandbox
public Sandbox(org.tmatesoft.svn.core.auth.ISVNAuthenticationManager authManager)
- Construction with a custom authentication manager.
Sandbox
public Sandbox(org.tmatesoft.svn.core.auth.ISVNAuthenticationManager authManager,
File svnconfig)
close
public void close()
- Close this sandbox, preventing any future operations. This method locks
the mutex before setting the close flag, so will wait for any currently
running operation to complete before returning.
makeDirectory
public org.tmatesoft.svn.core.SVNCommitInfo makeDirectory(org.tmatesoft.svn.core.SVNURL url,
String commitMessage)
throws org.tmatesoft.svn.core.SVNException
- Creates a new version controlled directory (doesn't create any intermediate
directories) right in a repository. Like 'svn mkdir URL -m "some comment"'
command. It's done by invoking
SVNCommitClient.doMkDir(SVNURL[] urls, String commitMessage)
which takes the following parameters:
urls - an array of URLs that are to be created;
commitMessage - a commit log message since a URL-based directory creation
is immediately committed to a repository.
- Returns:
- SVNCommitInfo containing information on the new revision committed
(revision number, etc.)
- Throws:
org.tmatesoft.svn.core.SVNException
importDirectory
public org.tmatesoft.svn.core.SVNCommitInfo importDirectory(File localPath,
org.tmatesoft.svn.core.SVNURL dstURL,
String commitMessage,
boolean isRecursive)
throws org.tmatesoft.svn.core.SVNException
- Imports an unversioned directory into a repository location denoted by a
destination URL (all necessary parent non-existent paths will be created
automatically). This operation commits the repository to a new revision.
Like 'svn import PATH URL (-N) -m "some comment"' command. It's done by
invoking
SVNCommitClient.doImport(File path, SVNURL dstURL, String commitMessage,
boolean recursive)
which takes the following parameters:
path - a local unversioned directory or singal file that will be imported
into a repository;
dstURL - a repository location where the local unversioned directory/file
will be imported into; this URL path may contain non-existent parent paths
that will be created by the repository server;
commitMessage - a commit log message since the new directory/file are
immediately created in the repository;
recursive - if true and path parameter corresponds to a directory then the
directory will be added with all its child subdirictories, otherwise the
operation will cover only the directory itself (only those files which are
located in the directory).
- Returns:
- SVNCommitInfo containing information on the new revision committed
(revision number, etc.).
- Throws:
org.tmatesoft.svn.core.SVNException
commit
public org.tmatesoft.svn.core.SVNCommitInfo commit(File[] wcPath,
boolean keepLocks,
String commitMessage)
throws org.tmatesoft.svn.core.SVNException
- Committs changes in a working copy to a repository. Like 'svn commit PATH
-m "some comment"' command. It's done by invoking
SVNCommitClient.doCommit(File[] paths, boolean keepLocks, String
commitMessage, boolean force, boolean recursive)
which takes the following parameters:
paths - working copy paths which changes are to be committed;
keepLocks - if true then doCommit(..) won't unlock locked paths; otherwise
they will be unlocked after a successful commit;
commitMessage - a commit log message;
force - if true then a non-recursive commit will be forced anyway;
recursive - if true and a path corresponds to a directory then doCommit(..)
recursively commits changes for the entire directory, otherwise - only for
child entries of the directory;
- Returns:
- SVNCommitInfo containing information on the new revision committed
(revision number, etc.).
- Throws:
org.tmatesoft.svn.core.SVNException
checkout
public long checkout(org.tmatesoft.svn.core.SVNURL url,
org.tmatesoft.svn.core.wc.SVNRevision revision,
File destPath,
boolean isRecursive)
throws org.tmatesoft.svn.core.SVNException
- Checks out a working copy from a repository. Like 'svn checkout URL[@REV]
PATH (-r..)' command; It's done by invoking
SVNUpdateClient.doCheckout(SVNURL url, File dstPath, SVNRevision
pegRevision, SVNRevision revision, SVNDepth depth, boolean
allowUnversionedObstructions)
which takes the following parameters:
url - a repository location from where a working copy is to be checked out;
dstPath - a local path where the working copy will be fetched into;
pegRevision - an SVNRevision representing a revision to concretize url
(what exactly URL a user means and is sure of being the URL he needs); in
other words that is the revision in which the URL is first looked up;
revision - a revision at which a working copy being checked out is to be;an
depth - whether to check out the whole tree rooted at that node, just the
directory with no contents, just the directory and its immediate children,
etc. We pass depth INFINITY if recursive == true and depth EMPTY otherwise.
allowUnversionedObstructions - how to handle the case when there is already
a file in the directory into which we are checking out that has the same
name as something from the repository. We pass false, which means the
checkout fails in this case.
- Returns:
- long the number of the revision the sandbox is at
- Throws:
org.tmatesoft.svn.core.SVNException
update
public long update(File wcPath,
org.tmatesoft.svn.core.wc.SVNRevision updateToRevision,
boolean isRecursive)
throws org.tmatesoft.svn.core.SVNException
- Updates a working copy in a non-preemptible operation.
- Throws:
org.tmatesoft.svn.core.SVNException
- See Also:
update(File,SVNRevision,boolean,boolean)
update
public long update(File wcPath,
org.tmatesoft.svn.core.wc.SVNRevision updateToRevision,
boolean isRecursive,
boolean preemptible)
throws org.tmatesoft.svn.core.SVNException
- Updates a working copy (brings changes from the repository into the working
copy). Like 'svn update PATH' command; It's done by invoking
SVNUpdateClient.doUpdate(File file, SVNRevision revision, boolean
recursive)
which takes the following parameters:
file - a working copy entry that is to be updated;
revision - a revision to which a working copy is to be updated;
recursive - if true and an entry is a directory then doUpdate(..)
recursively updates the entire directory, otherwise - only child entries of
the directory.
- Parameters:
preemptible
- whether this update can be pre-empted by a "more
important" update on the same sandbox. Typically this would be set to
true for background update jobs that update a whole sandbox and false for
interactive jobs that just update particular files.
- Returns:
- long the number of the revision the sandbox was updated to
- Throws:
org.tmatesoft.svn.core.SVNException
switchToURL
public long switchToURL(File wcPath,
org.tmatesoft.svn.core.SVNURL url,
org.tmatesoft.svn.core.wc.SVNRevision updateToRevision,
boolean isRecursive)
throws org.tmatesoft.svn.core.SVNException
- Updates a working copy to a different URL. Like 'svn switch URL' command.
It's done by invoking
SVNUpdateClient.doSwitch(File file, SVNURL url, SVNRevision revision,
boolean recursive)
which takes the following parameters:
file - a working copy entry that is to be switched to a new url;
url - a target URL a working copy is to be updated against;
revision - a revision to which a working copy is to be updated;
recursive - if true and an entry (file) is a directory then doSwitch(..)
recursively switches the entire directory, otherwise - only child entries
of the directory.
- Returns:
- long the number of the revision the sandbox was updated to
- Throws:
org.tmatesoft.svn.core.SVNException
relocate
public void relocate(File wcPath,
org.tmatesoft.svn.core.SVNURL oldURL,
org.tmatesoft.svn.core.SVNURL newURL)
throws org.tmatesoft.svn.core.SVNException
- Updates a working copy in the same was as 'svn switch --relocate'
- Throws:
org.tmatesoft.svn.core.SVNException
showStatus
public void showStatus(File wcPath,
boolean isRecursive,
boolean isRemote,
boolean isReportAll,
boolean isIncludeIgnored,
boolean isCollectParentExternals)
throws org.tmatesoft.svn.core.SVNException
- Displays status information on local path(s). Like 'svn status (-u) (-N)'
command. It's done by invoking
SVNStatusClient.doStatus(File path, boolean recursive, boolean remote,
boolean reportAll, boolean includeIgnored, boolean collectParentExternals,
ISVNStatusHandler handler)
which takes the following parameters:
path - an entry which status info to be gathered;
recursive - if true and an entry is a directory then doStatus(..) collects
status info not only for that directory but for each item inside stepping
down recursively;
remote - if true then doStatus(..) will cover the repository (not only the
working copy) as well to find out what entries are out of date;
reportAll - if true then doStatus(..) will also include unmodified entries;
includeIgnored - if true then doStatus(..) will also include entries being
ignored;
collectParentExternals - if true then externals definitions won't be
ignored;
handler - an implementation of ISVNStatusHandler to process status info per
each entry doStatus(..) traverses; such info is collected in an SVNStatus
object and is passed to a handler's handleStatus(SVNStatus status) method
where an implementor decides what to do with it.
- Throws:
org.tmatesoft.svn.core.SVNException
doStatus
public org.tmatesoft.svn.core.wc.SVNStatus doStatus(File wcPath,
boolean isRemote)
throws org.tmatesoft.svn.core.SVNException
- Collects status information on local path(s). It's done by invoking
SVNStatusClient.doStatus(File path, boolean remote) which takes the
following parameters:
path - an entry which status info to be gathered;
remote - if true then doStatus(..) will cover the repository (not only the
working copy) as well to find out what entries are out of date;
- Throws:
org.tmatesoft.svn.core.SVNException
doResolve
public void doResolve(File wcPath,
boolean isRecursive)
throws org.tmatesoft.svn.core.SVNException
- Resolve a conflict on local path(s). It's done by invoking
SVNStatusClient.doResolve(File path, boolean recursive) which takes the
following parameters:
path - an entry which status info to be gathered;
recursive - if true then doResolve(..) will cover the repository (stepping
down recursively)
- Throws:
org.tmatesoft.svn.core.SVNException
revert
public void revert(File... wcPaths)
throws org.tmatesoft.svn.core.SVNException
- Revert uncommitted changes. It's done by invoking
SVNStatusClient.doRevert(File[] wcPaths, SVNDepth depth,
Collection changelists) which takes the
following parameters:
wcPaths - paths of the entries to revert
depth - we pass SVNDepth.INFINITY, which means that if any of the wcPaths
are directories (as opposed to normal files) their contents will be
reverted recursively.
changelists - a collection of String changelist names - we pass null,
which means changelists are ignored.
- Throws:
org.tmatesoft.svn.core.SVNException
showInfo
public void showInfo(File wcPath,
org.tmatesoft.svn.core.wc.SVNRevision revision,
boolean isRecursive)
throws org.tmatesoft.svn.core.SVNException
- Collects information on local path(s). Like 'svn info (-R)' command. It's
done by invoking
SVNWCClient.doInfo(File path, SVNRevision revision, boolean recursive,
ISVNInfoHandler handler)
which takes the following parameters:
path - a local entry for which info will be collected;
revision - a revision of an entry which info is interested in; if it's not
WORKING then info is got from a repository;
recursive - if true and an entry is a directory then doInfo(..) collects
info not only for that directory but for each item inside stepping down
recursively;
handler - an implementation of ISVNInfoHandler to process info per each
entry doInfo(..) traverses; such info is collected in an SVNInfo object and
is passed to a handler's handleInfo(SVNInfo info) method where an
implementor decides what to do with it.
- Throws:
org.tmatesoft.svn.core.SVNException
addEntry
public void addEntry(File wcPath)
throws org.tmatesoft.svn.core.SVNException
- Puts directories and files under version control scheduling them for
addition to a repository. They will be added in a next commit. Like 'svn
add PATH' command. It's done by invoking
SVNWCClient.doAdd(File path, boolean force, boolean mkdir, boolean
climbUnversionedParents, boolean recursive)
which takes the following parameters:
path - an entry to be scheduled for addition;
force - set to true to force an addition of an entry anyway;
mkdir - if true doAdd(..) creates an empty directory at path and schedules
it for addition, like 'svn mkdir PATH' command;
climbUnversionedParents - if true and the parent of the entry to be
scheduled for addition is not under version control, then doAdd(..)
automatically schedules the parent for addition, too;
recursive - if true and an entry is a directory then doAdd(..) recursively
schedules all its inner dir entries for addition as well.
- Throws:
org.tmatesoft.svn.core.SVNException
addEntry
public void addEntry(File wcPath,
boolean recurse)
throws org.tmatesoft.svn.core.SVNException
- Puts directories and files under version control scheduling them for
addition to a repository. They will be added in a next commit. Like 'svn
add PATH' command.
- Parameters:
wcPath
- the file or directory to add. Its parent must already be
known to subversion (though not necessarily committed).recurse
- if true, and wcPath names a directory, recursively add all
the directories contents. If false, just add the directory itself
but not its contents. Has no effect if wcPath names a normal
file. Note this is different from the recurse parameter to most
other methods in this class, where non-recursive includes files in
the directory but not subdirectories.
- Throws:
org.tmatesoft.svn.core.SVNException
lock
public void lock(File wcPath,
boolean isStealLock,
String lockComment)
throws org.tmatesoft.svn.core.SVNException
- Locks working copy paths, so that no other user can commit changes to them.
Like 'svn lock PATH' command. It's done by invoking
SVNWCClient.doLock(File[] paths, boolean stealLock, String lockMessage)
which takes the following parameters:
paths - an array of local entries to be locked;
stealLock - set to true to steal the lock from another user or working
copy;
lockMessage - an optional lock comment string.
- Throws:
org.tmatesoft.svn.core.SVNException
delete
public void delete(File wcPath,
boolean force)
throws org.tmatesoft.svn.core.SVNException
- Schedules directories and files for deletion from version control upon the
next commit (locally). Like 'svn delete PATH' command. It's done by
invoking
SVNWCClient.doDelete(File path, boolean force, boolean dryRun)
which takes the following parameters:
path - an entry to be scheduled for deletion;
force - a boolean flag which is set to true to force a deletion even if an
entry has local modifications;
dryRun - set to true not to delete an entry but to check if it can be
deleted; if false - then it's a deletion itself.
- Throws:
org.tmatesoft.svn.core.SVNException
copy
public org.tmatesoft.svn.core.SVNCommitInfo copy(org.tmatesoft.svn.core.SVNURL srcURL,
org.tmatesoft.svn.core.SVNURL dstURL,
boolean isMove,
String commitMessage)
throws org.tmatesoft.svn.core.SVNException
- Duplicates srcURL to dstURL (URL to URL) preserving history. Like 'svn copy
srcURL dstURL -m "some comment"' command. It's done by invoking
doCopy(SVNURL srcURL, SVNRevision srcRevision, SVNURL dstURL, boolean
isMove, String commitMessage)
which takes the following parameters:
srcURL - a source URL that is to be copied;
srcRevision - a definite revision of srcURL
dstURL - a URL where srcURL will be copied; if srcURL and dstURL are both
directories then there are two cases: a) dstURL already exists - then
doCopy(..) will duplicate the entire source directory and put it inside
dstURL (for example, consider srcURL = svn://localhost/rep/MyRepos, dstURL
= svn://localhost/rep/MyReposCopy, in this case if doCopy(..) succeeds
MyRepos will be in MyReposCopy - svn://localhost/rep/MyReposCopy/MyRepos);
b) dstURL doesn't exist yet - then doCopy(..) will create a directory and
recursively copy entries from srcURL into dstURL (for example, consider the
same srcURL = svn://localhost/rep/MyRepos, dstURL =
svn://localhost/rep/MyReposCopy, in this case if doCopy(..) succeeds
MyRepos entries will be in MyReposCopy, like:
svn://localhost/rep/MyRepos/Dir1 ....
svn://localhost/rep/MyReposCopy/Dir1...);
isMove - if false then srcURL is only copied to dstURL what corresponds to
'svn copy srcURL dstURL -m "some comment"'; but if it's true then srcURL
will be copied and deleted - 'svn move srcURL dstURL -m "some comment"';
commitMessage - a commit log message since URL/URL copying is immediately
committed to a repository.
- Returns:
- SVNCommitInfo containing information on the new revision.
- Throws:
org.tmatesoft.svn.core.SVNException
getRepositoryURL
public org.tmatesoft.svn.core.SVNURL getRepositoryURL(File file)
throws org.tmatesoft.svn.core.SVNException
- Returns the URL corresponding to the repository location of the given
working copy file.
- Parameters:
file
- the file, which must be under version control in a sandbox. The
file need not be checked in but it must be known to subversion
(e.g. it could be added but not yet committed).
- Returns:
- the repository URL
- Throws:
org.tmatesoft.svn.core.SVNException
getRepositoryRoot
public org.tmatesoft.svn.core.SVNURL getRepositoryRoot(File file)
throws org.tmatesoft.svn.core.SVNException
- Returns the URL of the root of the repository containing the given working
copy file.
- Parameters:
file
- the file, which must be under version control in a sandbox. The
file need not be checked in but it must be known to subversion
(e.g. it could be added but not yet committed).
- Returns:
- the repository root URL
- Throws:
org.tmatesoft.svn.core.SVNException
checkCancelled
public void checkCancelled()
throws org.tmatesoft.svn.core.SVNCancelException
- If the current operation is preemptible and any other operations are
waiting, throw an SVNCancelException.
- Throws:
org.tmatesoft.svn.core.SVNCancelException