Class: SwitchTower::SCM::Bzr

Inherits:
Base
  • Object
show all
Defined in:
lib/switchtower/scm/bzr.rb

Overview

An SCM module for using Bazaar-NG (bzr) as your source control tool. You can use it by placing the following line in your configuration:

set :scm, :bzr

Also, this module accepts a :bzr configuration variable, which (if specified) will be used as the full path to the bzr executable on the remote machine:

set :bzr, "/opt/local/bin/bzr"

Instance Attribute Summary

Attributes inherited from Base

#configuration

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from SwitchTower::SCM::Base

Instance Method Details

#checkout(actor) ⇒ Object

Check out (on all servers associated with the current task) the latest revision. Uses the given actor instance to execute the command. If bzr asks for a password this will automatically provide it (assuming the requested password is the same as the password for logging into the remote server.)



46
47
48
49
50
# File 'lib/switchtower/scm/bzr.rb', line 46

def checkout(actor)
  op = configuration[:checkout] || "branch"
  command = "#{bzr} #{op} -r#{configuration.revision} #{configuration.repository} #{actor.release_path} &&"
  run_checkout(actor, command, &bzr_stream_handler(actor)) 
end

#current_revision(actor) ⇒ Object

Return the number of the revision currently deployed.



24
25
26
27
# File 'lib/switchtower/scm/bzr.rb', line 24

def current_revision(actor)
  command = "#{bzr} revno #{actor.release_path} &&"        
  run_update(actor, command, &bzr_stream_handler(actor)) 
end

#diff(actor, from = nil, to = nil) ⇒ Object

Return a string containing the diff between the two revisions. from and to may be in any format that bzr recognizes as a valid revision identifier. If from is nil, it defaults to the last deployed revision. If to is nil, it defaults to the last developed revision. Pay attention to the fact that as of now bzr does NOT support diff on remote locations.



35
36
37
38
39
# File 'lib/switchtower/scm/bzr.rb', line 35

def diff(actor, from=nil, to=nil)
  from ||= current_revision(actor)
  to ||= ""
  `#{bzr} diff -r #{from}..#{to} #{configuration.repository}`
end

#latest_revisionObject

Return an integer identifying the last known revision in the bzr repository. (This integer is currently the revision number.)



19
20
21
# File 'lib/switchtower/scm/bzr.rb', line 19

def latest_revision
  `#{bzr} revno #{configuration.repository}`.to_i
end

#update(actor) ⇒ Object



52
53
54
55
# File 'lib/switchtower/scm/bzr.rb', line 52

def update(actor)
  command = "cd #{actor.current_path} && #{bzr} pull -q &&"
  run_update(actor, command, &bzr_stream_handler(actor)) 
end