Class: BuildTool::VCS::Mercurial
- Defined in:
- lib/build-tool/vcs/mercurial.rb
Overview
Implementation for the hg version control system.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#checkedout? ⇒ Boolean
METHODS.
-
#clone ⇒ Object
Initialize the local repository.
-
#fetch ⇒ Object
Fetch from
repository
. - #fetching_supported? ⇒ Boolean
- #hg(command, wd = local_path, &block) ⇒ Object
-
#initialize(config) ⇒ Mercurial
constructor
A new instance of Mercurial.
-
#name ⇒ Object
ATTRIBUTES.
- #rebase ⇒ Object
Methods inherited from Base
#apply_patches_after_rebase?, #configure, #gc, #local_path, #local_path_exist?, #patches_supported?, #prepare_for_vcs_access, #recipe
Constructor Details
#initialize(config) ⇒ Mercurial
Returns a new instance of Mercurial.
42 43 44 45 46 |
# File 'lib/build-tool/vcs/mercurial.rb', line 42 def initialize( config ) super( config ) @remote = {} @vcs = nil end |
Instance Method Details
#checkedout? ⇒ Boolean
METHODS
63 64 65 66 67 68 69 |
# File 'lib/build-tool/vcs/mercurial.rb', line 63 def checkedout? return false if !local_path_exist? if !Pathname.new( local_path ).join( ".hg" ).exist? raise Base::VcsError, "Checkout path #{local_path} is not a mercurial repo!" end return true end |
#clone ⇒ Object
Initialize the local repository
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/build-tool/vcs/mercurial.rb', line 72 def clone # Check if path exists if local_path_exist? raise MercurialError, "Failed to create repository at '#{local_path}': Path exists" end FileUtils.mkdir_p Pathname.new( local_path ).dirname if ! $noop # Initialize the repository if hg( "clone #{repository.url} #{local_path}", Pathname.new( local_path ).dirname) != 0 raise MercurialError, "Error while initializing the repo `hg init #{local_path}'`: #{$?}" end fetch() rebase() end |
#fetch ⇒ Object
Fetch from repository
Initializes the local clone if it does not exist.
91 92 93 94 95 96 97 98 99 |
# File 'lib/build-tool/vcs/mercurial.rb', line 91 def fetch() if !checkedout? and !$noop clone end cmd = "pull #{repository.url}" if ( rc = hg( cmd ) ) != 0 raise MercurialError, "Error while fetching: #{rc}" end end |
#fetching_supported? ⇒ Boolean
55 56 57 |
# File 'lib/build-tool/vcs/mercurial.rb', line 55 def fetching_supported? true end |
#hg(command, wd = local_path, &block) ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/build-tool/vcs/mercurial.rb', line 101 def hg( command, wd = local_path, &block ) rc = self.class.execute "hg #{command}", wd, &block if rc != 0 raise MercurialError, "hg #{command || "" } failed with error code #{rc}"; end rc end |
#name ⇒ Object
ATTRIBUTES
51 52 53 |
# File 'lib/build-tool/vcs/mercurial.rb', line 51 def name "mercurial" end |
#rebase ⇒ Object
109 110 111 112 113 |
# File 'lib/build-tool/vcs/mercurial.rb', line 109 def rebase if 0 != ( hg "update #{config.branch}" ) raise MercurialSvnError, "Error while rebasing the repo with `hg update: #{$?}" end end |