Class: Autobuild::Hg
Instance Attribute Summary collapse
-
#branch ⇒ Object
The tip this importer is tracking.
-
#repository ⇒ Object
The remote repository URL.
Attributes inherited from Importer
#interactive, #options, #post_hooks, #repository_id, #source_id
Instance Method Summary collapse
- #checkout(package, _options = Hash.new) ⇒ Object
-
#initialize(repository, options = {}) ⇒ Hg
constructor
Creates an importer which tracks the given repository and (optionally) a branch.
-
#relocate(repository, options = Hash.new) ⇒ Object
Changes the repository this importer is pointing to.
- #update(package, options = Hash.new) ⇒ Object
-
#validate_importdir(package) ⇒ Object
Raises ConfigException if the current directory is not a hg repository.
Methods inherited from Importer
#add_post_hook, add_post_hook, #apply, cache_dirs, #call_patch, #currently_applied_patches, default_cache_dirs, default_cache_dirs=, each_post_hook, #each_post_hook, #execute_post_hooks, fallback, #fallback, #fingerprint, #import, #interactive?, #parse_patch_list, #patch, #patchdir, #patches, #patches_fingerprint, #patchlist, #perform_checkout, #perform_update, #retry_count, #retry_count=, #save_patch_state, set_cache_dirs, #supports_relocation?, #unapply, unset_cache_dirs, #update_retry_count, #vcs_fingerprint
Constructor Details
#initialize(repository, options = {}) ⇒ Hg
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/autobuild/import/hg.rb', line 18 def initialize(repository, = {}) hgopts, _common = Kernel. , branch: 'default' sourceopts, common = Kernel. , :repository_id, :source_id super(common) @branch = hgopts[:branch] relocate(repository, sourceopts) end |
Instance Attribute Details
#branch ⇒ Object
The tip this importer is tracking
44 45 46 |
# File 'lib/autobuild/import/hg.rb', line 44 def branch @branch end |
#repository ⇒ Object
The remote repository URL.
41 42 43 |
# File 'lib/autobuild/import/hg.rb', line 41 def repository @repository end |
Instance Method Details
#checkout(package, _options = Hash.new) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/autobuild/import/hg.rb', line 70 def checkout(package, = Hash.new) base_dir = File.('..', package.importdir) FileUtils.mkdir_p(base_dir) unless File.directory?(base_dir) package.run(:import, Autobuild.tool('hg'), 'clone', '-u', branch, repository, package.importdir, retry: true) end |
#relocate(repository, options = Hash.new) ⇒ Object
Changes the repository this importer is pointing to
30 31 32 33 34 35 36 37 38 |
# File 'lib/autobuild/import/hg.rb', line 30 def relocate(repository, = Hash.new) @repository = repository @repository_id = [:repository_id] || "hg:#{@repository}" @source_id = [:source_id] || "#{repository_id} branch=#{branch}" end |
#update(package, options = Hash.new) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/autobuild/import/hg.rb', line 56 def update(package, = Hash.new) if [:only_local] package.warn "%s: the Mercurial importer does not support "\ "local updates, skipping" return false end validate_importdir(package) package.run(:import, Autobuild.tool('hg'), 'pull', repository, retry: true, working_directory: package.importdir) package.run(:import, Autobuild.tool('hg'), 'update', branch, working_directory: package.importdir) true # no easy to know if package was updated, keep previous behavior end |
#validate_importdir(package) ⇒ Object
Raises ConfigException if the current directory is not a hg repository
48 49 50 51 52 53 54 |
# File 'lib/autobuild/import/hg.rb', line 48 def validate_importdir(package) unless File.directory?(File.join(package.importdir, '.hg')) raise ConfigException.new(package, 'import'), "while importing #{package.name}, "\ "#{package.importdir} is not a hg repository" end end |