com.atlassian.bamboo.plugins.hg
Class HgRepositoryAccessImpl

java.lang.Object
  extended by com.atlassian.bamboo.plugins.hg.HgRepositoryAccessImpl
All Implemented Interfaces:
HgRepositoryAccess

@NotThreadSafe
public class HgRepositoryAccessImpl
extends Object
implements HgRepositoryAccess


Field Summary
static String DEFAULT_SSH_COMMAND
           
static SecureTemporaryFiles.FileSpecBuilder TEMPORARY_FILE_SPEC
           
 
Constructor Summary
HgRepositoryAccessImpl(com.atlassian.sal.api.message.I18nResolver i18nResolver, BuildLogger buildLogger, SshProxyService sshProxyService, HgRepository repository, ScopedExclusionService exclusionService)
           
 
Method Summary
 void archiveSourceCode(File destinationDirectory, File cacheDirectory, String vcsRevision, String[] includePattern)
          "Archive" (as in svn export) contents of specified revision, applying specified --include pattern
 void close()
          Cleans up resources, connections, etc...
 BuildRepositoryChanges collectChangesSinceLastBuild(File cacheDirectory, String previousVcsRevisionKey, int maxCommitsToReturn)
          Checks whether remote repository has newer revision(s).
 CommitContext getFirstCommit(File cacheDirectory)
           
 CommitContext getLastCommit(File cacheDirectory)
           
 String retrieveSourceCode(File sourceDirectory, File cacheDirectory, String vcsRevision)
          Updates sources in sourceDirectory from remote repository to targetRevision.
 String retrieveSourceCode(File sourceDirectory, File cacheDirectory, String vcsRevision, int attempt)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SSH_COMMAND

public static final String DEFAULT_SSH_COMMAND
See Also:
Constant Field Values

TEMPORARY_FILE_SPEC

public static final SecureTemporaryFiles.FileSpecBuilder TEMPORARY_FILE_SPEC
Constructor Detail

HgRepositoryAccessImpl

public HgRepositoryAccessImpl(com.atlassian.sal.api.message.I18nResolver i18nResolver,
                              BuildLogger buildLogger,
                              SshProxyService sshProxyService,
                              HgRepository repository,
                              ScopedExclusionService exclusionService)
                       throws RepositoryException
Throws:
RepositoryException
Method Detail

collectChangesSinceLastBuild

public BuildRepositoryChanges collectChangesSinceLastBuild(@NotNull
                                                           File cacheDirectory,
                                                           @Nullable
                                                           String previousVcsRevisionKey,
                                                           int maxCommitsToReturn)
                                                    throws RepositoryException
Description copied from interface: HgRepositoryAccess
Checks whether remote repository has newer revision(s). If pullAndCollect is true then updates local cache directory and returns changesets since last checked revision

Specified by:
collectChangesSinceLastBuild in interface HgRepositoryAccess
Parameters:
cacheDirectory - specifies where to store updated repository. Perfectly it should be the 'cache' directory holding shared repository for all plans using the same repository URL
previousVcsRevisionKey - specifies since which revision we want to collect changesets
Returns:
BuildChanges object which will have filled vcsRevisionKey with newest revision from remote repository. If pullAndCollect is true then BuildChanges will have filled changes with repository changesets between previousRevision and newest revision
Throws:
RepositoryException

retrieveSourceCode

public String retrieveSourceCode(@NotNull
                                 File sourceDirectory,
                                 @Nullable
                                 File cacheDirectory,
                                 @Nullable
                                 String vcsRevision)
                          throws RepositoryException
Description copied from interface: HgRepositoryAccess
Updates sources in sourceDirectory from remote repository to targetRevision. Extracts changesets since previousRevision and stores them in collectedChangesetsReceiver. If cacheDirectory is not null it will use it as a mid-repository. Otherwise will pull from remote repository directly.

Specified by:
retrieveSourceCode in interface HgRepositoryAccess
Parameters:
sourceDirectory - specifies where we want to retrieve sources
cacheDirectory - specifies where is kept local cache directory, which will hold presumably a more updated repository than sourceDirectory.
vcsRevision - specifies since which revision we want to collect changesets
Returns:
targetRevision
Throws:
RepositoryException

retrieveSourceCode

public String retrieveSourceCode(@NotNull
                                 File sourceDirectory,
                                 @Nullable
                                 File cacheDirectory,
                                 @Nullable
                                 String vcsRevision,
                                 int attempt)
                          throws RepositoryException
Throws:
RepositoryException

archiveSourceCode

public void archiveSourceCode(@NotNull
                              File destinationDirectory,
                              @NotNull
                              File cacheDirectory,
                              @NotNull
                              String vcsRevision,
                              @Nullable
                              String[] includePattern)
                       throws RepositoryException
Description copied from interface: HgRepositoryAccess
"Archive" (as in svn export) contents of specified revision, applying specified --include pattern

Differs from {link #retrieveSourceCode} by not cloning the repository first (think "svn checkout" vs. "svn export")

Specified by:
archiveSourceCode in interface HgRepositoryAccess
Parameters:
destinationDirectory - directory to extract files to
cacheDirectory - local repository to extract from
vcsRevision - revision to extract, tip if null
includePattern - include patterns to limit extracted files, all files if null or empty
Throws:
RepositoryException - on any error

close

public void close()
Description copied from interface: HgRepositoryAccess
Cleans up resources, connections, etc...

Specified by:
close in interface HgRepositoryAccess

getLastCommit

public CommitContext getLastCommit(@NotNull
                                   File cacheDirectory)
                            throws RepositoryException
Specified by:
getLastCommit in interface HgRepositoryAccess
Throws:
RepositoryException

getFirstCommit

public CommitContext getFirstCommit(@NotNull
                                    File cacheDirectory)
                             throws RepositoryException
Specified by:
getFirstCommit in interface HgRepositoryAccess
Throws:
RepositoryException


Copyright © 2015 Atlassian Software Systems Pty Ltd. All rights reserved.