Implements the Capistrano SCM interface for the Mercurial revision control system (www.selenic.com/mercurial/). Latest updates at tackletechnology.org/oss/cap2-mercurial
Clone the repository and update to the specified changeset.
# File lib/capistrano/recipes/deploy/scm/mercurial.rb, line 25 25: def checkout(changeset, destination) 26: clone(destination) + " && " + update(changeset, destination) 27: end
Compute the difference between the two changesets from and to as a unified diff.
# File lib/capistrano/recipes/deploy/scm/mercurial.rb, line 42 42: def diff(from, to=nil) 43: scm :diff, 44: "--rev #{from}", 45: (to ? "--rev #{to}" : nil) 46: end
One day we will have hg archive, although i think its not needed
# File lib/capistrano/recipes/deploy/scm/mercurial.rb, line 35 35: def export(revision, destination) 36: raise NotImplementedError, "`diff' is not implemented by #{self.class.name}" + 37: "use checkout strategy" 38: end
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
# File lib/capistrano/recipes/deploy/scm/mercurial.rb, line 69 69: def handle_data(state, stream, text) 70: host = state[:channel][:host] 71: logger.info "[#{host} :: #{stream}] #{text}" 72: case text 73: when /^user:/i 74: # support :scm_user for backwards compatibility of this module 75: if user = variable(:scm_username) || variable(:scm_user) 76: "#{user}\n" 77: else 78: raise "No variable :scm_username specified and Mercurial asked!\n" + 79: "Prompt was: #{text}" 80: end 81: when /\bpassword:/i 82: unless pass = scm_password_or_prompt 83: # fall back on old behavior of erroring out with msg 84: raise "No variable :scm_password specified and Mercurial asked!\n" + 85: "Prompt was: #{text}" 86: end 87: "#{pass}\n" 88: when /yes\/no/ 89: "yes\n" 90: end 91: end
For mercurial HEAD == tip except that it bases this assumption on what tip is in the current repository (so push before you deploy)
# File lib/capistrano/recipes/deploy/scm/mercurial.rb, line 20 20: def head 21: variable(:branch) || "tip" 22: end
Return a log of all changes between the two specified changesets, from and to, inclusive or the log for from if to is omitted.
# File lib/capistrano/recipes/deploy/scm/mercurial.rb, line 50 50: def log(from, to=nil) 51: scm :log, 52: verbose, 53: "--rev #{from}" + 54: (to ? ":#{to}" : "") 55: end
Translates a tag to a changeset if needed or just returns changeset.
# File lib/capistrano/recipes/deploy/scm/mercurial.rb, line 58 58: def query_revision(changeset) 59: cmd = scm :log, 60: verbose, 61: "-r #{changeset}", 62: '--template "{node|short}"' 63: yield cmd 64: end
Fine grained mercurial commands
# File lib/capistrano/recipes/deploy/scm/mercurial.rb, line 96 96: def clone(destination) 97: scm :clone, 98: verbose, 99: "--noupdate", # do not update to tip when cloning is done 100: repository, # clone which repository? 101: destination # and put the clone where? 102: end
# File lib/capistrano/recipes/deploy/scm/mercurial.rb, line 104 104: def pull(destination) 105: scm :pull, 106: verbose, 107: "--repository #{destination}", # pull changes into what? 108: repository # and pull the changes from? 109: end
honor Cap 2.1+’s :scm_prefer_prompt if present
# File lib/capistrano/recipes/deploy/scm/mercurial.rb, line 129 129: def scm_password_or_prompt 130: @scm_password_or_prompt ||= variable(:scm_password) || 131: (Capistrano::CLI.password_prompt("hg password: ") if variable(:scm_prefer_prompt)) 132: end
# File lib/capistrano/recipes/deploy/scm/mercurial.rb, line 111 111: def update(changeset, destination) 112: scm :update, 113: verbose, 114: "--repository #{destination}", # update what? 115: "--clean", # ignore untracked changes 116: changeset # update to this changeset 117: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.