public class HgCommandProcessor extends Object implements Serializable, ProxyErrorReceiver
Modifier and Type | Class and Description |
---|---|
static class |
HgCommandProcessor.HgStringOutputHandler |
Modifier and Type | Method and Description |
---|---|
void |
checkHgExistenceInSystem(File workingDirectory)
Checks whether mercurial exist in current system.
|
HgCommandBuilder |
createCommandBuilder(String... commands) |
Pair<ArrayList<CommitContext>,Integer> |
getChangesetsSinceRevision(File workingDirectory,
String branch,
String previousRevision,
String targetRevision,
int maxCommitsToReturn)
Returns list of commit extracted from hg log command.
|
String |
getCurrentBranch(File checkoutPath) |
CommitContext |
getFirstCommit(File workingDirectory,
String branchName) |
List<CommitContext> |
getHeads(File workingDirectory,
String repositoryUrl,
String branchName) |
String |
getLocalChangesetId(File workingDirectory)
Returns 40char hash code of the current revision in repository.
|
String |
getLocalTipInDirectory(File workingDirectory,
String branch)
Returns 40char hash code of the tip-most changeset in repository contained in workingDirectory (or it parents).
|
String |
getRemoteTipForBranch(File workingDirectory,
String repositoryUrl,
String branch)
Returns 40char hash code of the tip-most changeset in remote repository.
|
int |
getTotalChangesetsCountSinceRevision(File workingDirectory,
HgCommandBuilder commandBuilder)
Returns total count of commits since previousRevision up to tip revision.
|
boolean |
isWorkingCopyClean(File workingDirectory)
Checks whether the directory is at clean state (no uncommitted changes).
|
boolean |
merge(File workspace,
String targetRevision) |
void |
reportProxyError(String message,
Throwable exception) |
void |
runArchiveCommand(File destinationDirectory,
File repository,
String revision,
String[] includePattern)
Archives (exports) contents of specified revision, applying the optional include pattern.
|
void |
runCloneCommand(File workingDirectory,
String repositoryUrl,
String revision)
Clones remote repository into local directory.
|
void |
runCommand(HgCommandBuilder commandBuilder,
File workingDirectory) |
void |
runCommand(HgCommandBuilder commandBuilder,
File workingDirectory,
com.atlassian.bamboo.plugins.hg.HgCommandProcessor.HgOutputHandler outputHandler,
com.google.common.collect.ImmutableMap<String,String> env) |
void |
runInitCommand(File workingDirectory)
Creates .hg repository in a given directory.
|
void |
runPullCommand(File workingDirectory,
String repositoryUrl,
String revision)
Updates (pulls changesets from remote repository) workingDirectory to specified revision.
|
void |
runUpdateCommand(File workingDirectory,
String revision)
Updates working copy in workingDirectory to specified revision.
|
protected String |
sanitizeStderr(String stderr) |
void |
setSshCommand(String sshCommand) |
void |
setSshCompression(boolean sshCompression) |
void |
setSshKeyFile(String sshKeyFile) |
public void checkHgExistenceInSystem(@NotNull File workingDirectory) throws RepositoryException
workingDirectory
- specifies arbitrary directory.RepositoryException
- when mercurial wasn't found in current system.public void runInitCommand(@NotNull File workingDirectory) throws RepositoryException
workingDirectory
- - directory in which we want to create empty repository.RepositoryException
- when init command failspublic boolean merge(@NotNull File workspace, @NotNull String targetRevision) throws RepositoryException
RepositoryException
public void runCloneCommand(@NotNull File workingDirectory, @NotNull String repositoryUrl, @Nullable String revision) throws RepositoryException
workingDirectory
- specifies directory in which we want to clone remote repository. It has to be either empty directory or non existent.repositoryUrl
- specifies remote repository.revision
- specifies revision we want to clone to - especially it might point to a branch.RepositoryException
- when clone command fails.public void runPullCommand(@NotNull File workingDirectory, @NotNull String repositoryUrl, @Nullable String revision) throws RepositoryException
repositoryUrl
- specifies remote repository to pull from.workingDirectory
- specifies directory we want to update.revision
- specifies revision we want to update/pull to.RepositoryException
- when pull command fails.public void runUpdateCommand(@NotNull File workingDirectory, @Nullable String revision) throws RepositoryException
workingDirectory
- specifies directory we want to update. It must have hg repository.revision
- specifies revision we want to update to.RepositoryException
- when update command fails.public void runArchiveCommand(@NotNull File destinationDirectory, @NotNull File repository, @Nullable String revision, @Nullable String[] includePattern) throws RepositoryException
destinationDirectory
- specifies directory to export torepository
- hg repository to export from.revision
- specifies revision we want to export.includePattern
- set of include patternsRepositoryException
- when update command fails.public int getTotalChangesetsCountSinceRevision(@NotNull File workingDirectory, @NotNull HgCommandBuilder commandBuilder) throws RepositoryException
workingDirectory
- specifies directory contained by hg repository.RepositoryException
- when hg repository is not found or parsing log file failed.public List<CommitContext> getHeads(@NotNull File workingDirectory, @NotNull String repositoryUrl, @Nullable String branchName) throws RepositoryException
RepositoryException
@NotNull public CommitContext getFirstCommit(@NotNull File workingDirectory, @Nullable String branchName) throws RepositoryException
RepositoryException
@NotNull public Pair<ArrayList<CommitContext>,Integer> getChangesetsSinceRevision(@NotNull File workingDirectory, @NotNull String branch, @Nullable String previousRevision, @Nullable String targetRevision, int maxCommitsToReturn) throws RepositoryException
workingDirectory
- specifies directory contained by hg repository.previousRevision
- specifies the starting point of changeset history we are interested in.targetRevision
- the latest revision we are interested in or tip if nullmaxCommitsToReturn
- the maximum amount of changesets to be reportedRepositoryException
- when hg repository is not found or parsing log file failed.@NotNull public String getRemoteTipForBranch(@NotNull File workingDirectory, @NotNull String repositoryUrl, @Nullable String branch) throws RepositoryException
workingDirectory
- specifies where to run clone command from.repositoryUrl
- specifies remote repository.branch
- specifies which branch to check (might be null, which means "default" branch).RepositoryException
- when clone command fails.@NotNull public String getLocalTipInDirectory(@NotNull File workingDirectory, @Nullable String branch) throws RepositoryException
workingDirectory
- directory contained by hg repository.branch
- specifies which branch tip we want to retrieve.RepositoryException
- when workingDirectory is not versioned by hg repository.@NotNull public String getLocalChangesetId(@NotNull File workingDirectory) throws RepositoryException
workingDirectory
- directory contained by hg repositoryRepositoryException
- when workingDirectory is not versioned by hg repository.public boolean isWorkingCopyClean(@NotNull File workingDirectory) throws RepositoryException
workingDirectory
- directory into which Mercurial repository was checked outRepositoryException
- on any errorpublic HgCommandBuilder createCommandBuilder(String... commands)
public void reportProxyError(String message, Throwable exception)
reportProxyError
in interface ProxyErrorReceiver
public String getCurrentBranch(File checkoutPath) throws RepositoryException
RepositoryException
public void runCommand(@NotNull HgCommandBuilder commandBuilder, @NotNull File workingDirectory) throws RepositoryException
RepositoryException
public void runCommand(@NotNull HgCommandBuilder commandBuilder, @NotNull File workingDirectory, @NotNull com.atlassian.bamboo.plugins.hg.HgCommandProcessor.HgOutputHandler outputHandler, @Nullable com.google.common.collect.ImmutableMap<String,String> env) throws RepositoryException
RepositoryException
public void setSshCommand(String sshCommand)
public void setSshKeyFile(String sshKeyFile)
public void setSshCompression(boolean sshCompression)
Copyright © 2019 Atlassian Software Systems Pty Ltd. All rights reserved.