Class: Capistrano::Deploy::SCM::Mercurial
- Defined in:
- lib/capistrano/recipes/deploy/scm/mercurial.rb
Overview
Implements the Capistrano SCM interface for the Mercurial revision control system (www.selenic.com/mercurial/). Latest updates at tackletechnology.org/oss/cap2-mercurial
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#checkout(changeset, destination) ⇒ Object
Clone the repository and update to the specified changeset.
-
#diff(from, to = nil) ⇒ Object
Compute the difference between the two changesets
from
andto
as a unified diff. -
#export(revision, destination) ⇒ Object
One day we will have hg archive, although i think its not needed.
-
#handle_data(state, stream, text) ⇒ Object
Determine response for SCM prompts user/pass can come from ssh and http distribution methods yes/no is for when ssh asks you about fingerprints.
-
#head ⇒ Object
For mercurial HEAD == tip except that it bases this assumption on what tip is in the current repository (so push before you deploy).
-
#log(from, to = nil) ⇒ Object
Return a log of all changes between the two specified changesets,
from
andto
, inclusive or the log forfrom
ifto
is omitted. -
#query_revision(changeset) {|cmd| ... } ⇒ Object
Translates a tag to a changeset if needed or just returns changeset.
-
#sync(changeset, destination) ⇒ Object
Pull from the repository and update to the specified changeset.
Methods inherited from Base
#command, default_command, #initialize, #local, #local?, #next_revision, #scm
Constructor Details
This class inherits a constructor from Capistrano::Deploy::SCM::Base
Instance Method Details
#checkout(changeset, destination) ⇒ Object
Clone the repository and update to the specified changeset.
25 26 27 |
# File 'lib/capistrano/recipes/deploy/scm/mercurial.rb', line 25 def checkout(changeset, destination) clone(destination) + " && " + update(changeset, destination) end |
#diff(from, to = nil) ⇒ Object
Compute the difference between the two changesets from
and to
as a unified diff.
42 43 44 45 46 |
# File 'lib/capistrano/recipes/deploy/scm/mercurial.rb', line 42 def diff(from, to=nil) scm :diff, "--rev #{from}", (to ? "--rev #{to}" : nil) end |
#export(revision, destination) ⇒ Object
One day we will have hg archive, although i think its not needed
35 36 37 38 |
# File 'lib/capistrano/recipes/deploy/scm/mercurial.rb', line 35 def export(revision, destination) raise NotImplementedError, "`diff' is not implemented by #{self.class.name}" + "use checkout strategy" end |
#handle_data(state, stream, text) ⇒ Object
Determine response for SCM prompts user/pass can come from ssh and http distribution methods yes/no is for when ssh asks you about fingerprints
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/capistrano/recipes/deploy/scm/mercurial.rb', line 69 def handle_data(state, stream, text) host = state[:channel][:host] logger.info "[#{host} :: #{stream}] #{text}" case text when /^user:/mi # support :scm_user for backwards compatibility of this module if user = variable(:scm_username) || variable(:scm_user) "#{user}\n" else raise "No variable :scm_username specified and Mercurial asked!\n" + "Prompt was: #{text}" end when /\bpassword:/mi unless pass = scm_password_or_prompt # fall back on old behavior of erroring out with msg raise "No variable :scm_password specified and Mercurial asked!\n" + "Prompt was: #{text}" end "#{pass}\n" when /yes\/no/i "yes\n" end end |
#head ⇒ Object
For mercurial HEAD == tip except that it bases this assumption on what tip is in the current repository (so push before you deploy)
20 21 22 |
# File 'lib/capistrano/recipes/deploy/scm/mercurial.rb', line 20 def head "tip" end |
#log(from, to = nil) ⇒ Object
Return a log of all changes between the two specified changesets, from
and to
, inclusive or the log for from
if to
is omitted.
50 51 52 53 54 55 |
# File 'lib/capistrano/recipes/deploy/scm/mercurial.rb', line 50 def log(from, to=nil) scm :log, verbose, "--rev #{from}" + (to ? ":#{to}" : "") end |
#query_revision(changeset) {|cmd| ... } ⇒ Object
Translates a tag to a changeset if needed or just returns changeset.
58 59 60 61 62 63 64 |
# File 'lib/capistrano/recipes/deploy/scm/mercurial.rb', line 58 def query_revision(changeset) cmd = scm :log, verbose, "-r #{changeset}", "--template '{node|short}'" yield cmd end |
#sync(changeset, destination) ⇒ Object
Pull from the repository and update to the specified changeset.
30 31 32 |
# File 'lib/capistrano/recipes/deploy/scm/mercurial.rb', line 30 def sync(changeset, destination) pull(destination) + " && " + update(changeset, destination) end |