org.paylogic.jenkins.advancedscm.backends
Class MercurialBackend

java.lang.Object
  extended by org.paylogic.jenkins.advancedscm.backends.MercurialBackend
All Implemented Interfaces:
AdvancedSCMManager

public class MercurialBackend
extends Object
implements AdvancedSCMManager

Mercurial Implementation of AdvancedSCMManager


Constructor Summary
MercurialBackend(hudson.model.AbstractBuild build, hudson.Launcher launcher, hudson.model.BuildListener listener, hudson.plugins.mercurial.MercurialSCM scm)
          Please do not instantiate objects of this class yourself, use SCMManagerFactory.
 
Method Summary
 void clean()
          Cleans workspace from artifact.
 void closeBranch(String branch, String message, String username)
          Close given branch.
 String getBranch()
          Get the current branch name in the workspace.
 List<Branch> getBranches(boolean all)
          Get Mercurial branches from command line output, and put them in a List with MercurialBranches so it's nice to work with.
 List<String> getBranchNames(boolean all)
          Get branches from command line output, and put them in a List so it's nice to work with.
 ReleaseBranch getReleaseBranch(String branch)
          Get release branch from given branch name.
 String merge(String message, String username)
          Merge possible current branch's heads.
 String mergeWorkspaceWith(String revision, String updateTo, String message, String username)
          Merge current workspace with given revision.
 String pull()
          Executes 'hg pull'
 String pull(String remote)
          Executes 'hg pull '.
 String pull(String remote, String branch)
          Executes 'hg pull -b '.
 String push(String... branchNames)
          Executes 'hg push'
 void stripLocal()
          Strip out local commits which are not pushed yet.
 void update(String revision)
          Updates workspace to given revision/branch.
 void updateClean(String revision)
          Updates workspace to given revision/branch with cleaning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.paylogic.jenkins.advancedscm.AdvancedSCMManager
getBranchNames
 

Constructor Detail

MercurialBackend

public MercurialBackend(hudson.model.AbstractBuild build,
                        hudson.Launcher launcher,
                        hudson.model.BuildListener listener,
                        hudson.plugins.mercurial.MercurialSCM scm)
                 throws IOException,
                        InterruptedException
Please do not instantiate objects of this class yourself, use SCMManagerFactory.

Throws:
IOException
InterruptedException
Method Detail

getBranches

public List<Branch> getBranches(boolean all)
Get Mercurial branches from command line output, and put them in a List with MercurialBranches so it's nice to work with.

Specified by:
getBranches in interface AdvancedSCMManager
Parameters:
all: - get all or only open branches
Returns:
List of MercurialBranches, empty if no branches are there.

getBranch

public String getBranch()
                 throws AdvancedSCMException
Get the current branch name in the workspace. Executes 'hg branch'

Specified by:
getBranch in interface AdvancedSCMManager
Returns:
String with branch name in it.
Throws:
AdvancedSCMException

update

public void update(String revision)
            throws AdvancedSCMException
Updates workspace to given revision/branch. Executes hg update .

Specified by:
update in interface AdvancedSCMManager
Parameters:
revision - : String with revision, hash of branchname to update to.
Throws:
AdvancedSCMException

updateClean

public void updateClean(String revision)
                 throws AdvancedSCMException
Updates workspace to given revision/branch with cleaning. Executes hg update -C .

Specified by:
updateClean in interface AdvancedSCMManager
Parameters:
revision - : String with revision, hash of branchname to update to.
Throws:
AdvancedSCMException

stripLocal

public void stripLocal()
                throws AdvancedSCMException
Strip out local commits which are not pushed yet.

Specified by:
stripLocal in interface AdvancedSCMManager
Throws:
AdvancedSCMException

clean

public void clean()
           throws AdvancedSCMException
Cleans workspace from artifact. Executes hg purge.

Specified by:
clean in interface AdvancedSCMManager
Throws:
AdvancedSCMException

closeBranch

public void closeBranch(String branch,
                        String message,
                        String username)
                 throws AdvancedSCMException
Close given branch. Execute hg commit --close-branch -m"message".

Specified by:
closeBranch in interface AdvancedSCMManager
Parameters:
branch: - String branch name.
message - : String with message to give this commit.
username - : String commit user name (with email)
Throws:
AdvancedSCMException

mergeWorkspaceWith

public String mergeWorkspaceWith(String revision,
                                 String updateTo,
                                 String message,
                                 String username)
                          throws AdvancedSCMException
Merge current workspace with given revision. Executes hg merge . Do not forget to commit merge afterwards manually.

Specified by:
mergeWorkspaceWith in interface AdvancedSCMManager
Parameters:
revision - : String with revision, hash or branchname to merge with.
updateTo - : String with revision, hash or branchname to update working copy to before actual merge.
message - : String commit message
username - : String commit user name (with email)
Returns:
String : Output of merge command (should be empty if all went well)
Throws:
AdvancedSCMException

merge

public String merge(String message,
                    String username)
             throws AdvancedSCMException
Merge possible current branch's heads.

Specified by:
merge in interface AdvancedSCMManager
Parameters:
message - : String commit message
username - : String commit user name (with email)
Returns:
String : Output of merge command (should be empty if all went well)
Throws:
AdvancedSCMException

push

public String push(String... branchNames)
            throws AdvancedSCMException
Executes 'hg push'

Specified by:
push in interface AdvancedSCMManager
Throws:
AdvancedSCMException

pull

public String pull()
            throws AdvancedSCMException
Executes 'hg pull'

Specified by:
pull in interface AdvancedSCMManager
Throws:
AdvancedSCMException

pull

public String pull(String remote)
            throws AdvancedSCMException
Executes 'hg pull '. Give it a remote to pull changes from there.

Specified by:
pull in interface AdvancedSCMManager
Throws:
AdvancedSCMException

pull

public String pull(String remote,
                   String branch)
            throws AdvancedSCMException
Executes 'hg pull -b '. Give it a remote to pull changes from there.

Specified by:
pull in interface AdvancedSCMManager
Throws:
AdvancedSCMException

getReleaseBranch

public ReleaseBranch getReleaseBranch(String branch)
                               throws ReleaseBranchInvalidException
Description copied from interface: AdvancedSCMManager
Get release branch from given branch name.

Specified by:
getReleaseBranch in interface AdvancedSCMManager
Parameters:
branch - : String branch name
Returns:
ReleaseBranch : release branch object
Throws:
ReleaseBranchInvalidException

getBranchNames

public List<String> getBranchNames(boolean all)
                            throws AdvancedSCMException
Get branches from command line output, and put them in a List so it's nice to work with.

Parameters:
all: - get all or only open branches
Returns:
List of String
Throws:
AdvancedSCMException


Copyright © 2004-2014. All Rights Reserved.