Class: Capistrano::SCM::Hg

Inherits:
Plugin show all
Defined in:
lib/capistrano/scm/hg.rb

Instance Method Summary collapse

Methods inherited from Plugin

#scm?

Methods inherited from Plugin

#set_defaults

Methods included from DSL

#execute, #invoke, #invoke!, #local_user, #lock, #on, #revision_log_message, #rollback_log_message, #run_locally, #scm, #sudo, #t

Methods included from DSL::Stages

#stage_definitions, #stage_set?, #stages

Methods included from DSL::Paths

#asset_timestamp, #current_path, #deploy_config_path, #deploy_path, #deploy_to, #join_paths, #linked_dir_parents, #linked_dirs, #linked_file_dirs, #linked_files, #map_dirnames, #now, #release_path, #releases_path, #repo_path, #repo_url, #revision_log, #set_release_path, #shared_path, #stage_config_path

Methods included from DSL::Env

#asset_timestamp, #env, #release_roles, #release_timestamp, #role_properties, #roles

Methods included from TaskEnhancements

#after, #before, #default_tasks, #define_remote_file_task, #deploying?, #ensure_stage, #exit_deploy_because_of_exception, #tasks_without_stage_dependency

Instance Method Details

#archive_to_release_pathObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/capistrano/scm/hg.rb', line 36

def archive_to_release_path
  if (tree = fetch(:repo_tree))
    tree = tree.slice %r#^/?(.*?)/?$#, 1
    components = tree.split("/").size
    temp_tar = "#{fetch(:tmp_dir)}/#{SecureRandom.hex(10)}.tar"

    hg "archive -p . -I", tree, "--rev", fetch(:branch), temp_tar

    backend.execute :mkdir, "-p", release_path
    backend.execute :tar, "-x --strip-components #{components} -f", temp_tar, "-C", release_path
    backend.execute :rm, temp_tar
  else
    hg "archive", release_path, "--rev", fetch(:branch)
  end
end

#check_repo_is_reachableObject



24
25
26
# File 'lib/capistrano/scm/hg.rb', line 24

def check_repo_is_reachable
  hg "id", repo_url
end

#clone_repoObject



28
29
30
# File 'lib/capistrano/scm/hg.rb', line 28

def clone_repo
  hg "clone", "--noupdate", repo_url, repo_path.to_s
end

#define_tasksObject



11
12
13
# File 'lib/capistrano/scm/hg.rb', line 11

def define_tasks
  eval_rakefile File.expand_path("../tasks/hg.rake", __FILE__)
end

#fetch_revisionObject



52
53
54
# File 'lib/capistrano/scm/hg.rb', line 52

def fetch_revision
  backend.capture(:hg, "log --rev #{fetch(:branch)} --template \"{node}\n\"")
end

#hg(*args) ⇒ Object



15
16
17
18
# File 'lib/capistrano/scm/hg.rb', line 15

def hg(*args)
  args.unshift(:hg)
  backend.execute(*args)
end

#register_hooksObject



5
6
7
8
9
# File 'lib/capistrano/scm/hg.rb', line 5

def register_hooks
  after "deploy:new_release_path", "hg:create_release"
  before "deploy:check", "hg:check"
  before "deploy:set_current_revision", "hg:set_current_revision"
end

#repo_mirror_exists?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/capistrano/scm/hg.rb', line 20

def repo_mirror_exists?
  backend.test " [ -d #{repo_path}/.hg ] "
end

#update_mirrorObject



32
33
34
# File 'lib/capistrano/scm/hg.rb', line 32

def update_mirror
  hg "pull"
end