Class: Capistrano::Deploy::SCM::Bzr
- Defined in:
- lib/capistrano/recipes/deploy/scm/bzr.rb
Overview
Implements the Capistrano SCM interface for the Bazaar-NG revision control system (bazaar-vcs.org/).
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#checkout(revision, destination) ⇒ Object
Returns the command that will check out the given revision to the given destination.
-
#diff(from, to = nil) ⇒ Object
The bzr “diff” command doesn’t accept a repository argument, so it must be run from within a working tree.
-
#export(revision, destination) ⇒ Object
The bzr ‘export’ command would work fine, except it doesn’t let you specify the repository itself, so it only works if there is a working tree handy, locally.
-
#head ⇒ Object
Bazaar-NG doesn’t support any pseudo-id’s, so we’ll use the convention in this adapter that the :head symbol means the most recently committed revision.
-
#log(from, to = nil) ⇒ Object
Returns a log of changes between the two revisions (inclusive).
-
#query_revision(revision) ⇒ Object
Attempts to translate the given revision identifier to a “real” revision.
-
#sync(revision, destination) ⇒ Object
The bzr ‘update’ command does not support updating to a specific revision, so this just does update, followed by revert (unless updating to head).
Methods inherited from Base
#command, default_command, #handle_data, #initialize, #local, #local?
Constructor Details
This class inherits a constructor from Capistrano::Deploy::SCM::Base
Instance Method Details
#checkout(revision, destination) ⇒ Object
Returns the command that will check out the given revision to the given destination.
23 24 25 |
# File 'lib/capistrano/recipes/deploy/scm/bzr.rb', line 23 def checkout(revision, destination) scm :branch, revswitch(revision), repository, destination end |
#diff(from, to = nil) ⇒ Object
The bzr “diff” command doesn’t accept a repository argument, so it must be run from within a working tree.
47 48 49 50 51 52 |
# File 'lib/capistrano/recipes/deploy/scm/bzr.rb', line 47 def diff(from, to=nil) switch = "-r#{from}" switch << "..#{to}" if to scm :diff, switch end |
#export(revision, destination) ⇒ Object
The bzr ‘export’ command would work fine, except it doesn’t let you specify the repository itself, so it only works if there is a working tree handy, locally. Since this needs to work even on a remote host where there is no working tree, we’ll just do a checkout, followed by a deletion of the “.bzr” metadata directory.
41 42 43 |
# File 'lib/capistrano/recipes/deploy/scm/bzr.rb', line 41 def export(revision, destination) [checkout(revision, destination) && "rm -rf #{destination}/.bzr"].join(" && ") end |
#head ⇒ Object
Bazaar-NG doesn’t support any pseudo-id’s, so we’ll use the convention in this adapter that the :head symbol means the most recently committed revision.
17 18 19 |
# File 'lib/capistrano/recipes/deploy/scm/bzr.rb', line 17 def head :head end |
#log(from, to = nil) ⇒ Object
Returns a log of changes between the two revisions (inclusive).
55 56 57 |
# File 'lib/capistrano/recipes/deploy/scm/bzr.rb', line 55 def log(from, to=nil) scm :log, "--short", "-r#{from}..#{to}", repository end |
#query_revision(revision) ⇒ Object
Attempts to translate the given revision identifier to a “real” revision. If the identifier is :head, the “bzr revno” command will be yielded, and the block must execute the command and return the output. The revision will be extracted from the output and returned. If the ‘revision’ argument, on the other hand, is not :head, it is simply returned.
65 66 67 68 69 70 71 |
# File 'lib/capistrano/recipes/deploy/scm/bzr.rb', line 65 def query_revision(revision) if revision == head yield(scm(:revno, repository)).chomp else revision end end |
#sync(revision, destination) ⇒ Object
The bzr ‘update’ command does not support updating to a specific revision, so this just does update, followed by revert (unless updating to head).
30 31 32 33 34 |
# File 'lib/capistrano/recipes/deploy/scm/bzr.rb', line 30 def sync(revision, destination) commands = [scm(:update, destination)] commands << [scm(:revert, revswitch(revision), destination)] if revision != head commands.join(" && ") end |