Class: Capistrano::Deploy::SCM::Base

### Home Classes Methods

### In Files

- lib/capistrano/recipes/deploy/scm/base.rb

### Parent

Object

### Namespace

- CLASS Capistrano::Deploy::SCM::Base::LocalProxy

### Methods

- ::default_command
- ::new
- #checkout
- #command
- #diff
- #handle_data
- #head
- #local
- #local?
- #log
- #next_revision
- #query_revision
- #scm
- #sync

### Files

- help.txt

### Class/Module Index

Quicksearch

- Capistrano
- Capistrano::CLI
- Capistrano::CLI::Execute
- Capistrano::CLI::Execute::ClassMethods
- Capistrano::CLI::Help
- Capistrano::CLI::Options
- Capistrano::CLI::Options::ClassMethods
- Capistrano::CLI::UI
- Capistrano::CLI::UI::ClassMethods
- Capistrano::Callback
- Capistrano::Command
- Capistrano::Command::Tree
- Capistrano::Command::Tree::Branch
- Capistrano::Command::Tree::ConditionBranch
- Capistrano::Command::Tree::ConditionBranch::Evaluator
- Capistrano::Command::Tree::ElseBranch
- Capistrano::Configuration
- Capistrano::Configuration::Actions
- Capistrano::Configuration::Actions::FileTransfer
- Capistrano::Configuration::Actions::Inspect
- Capistrano::Configuration::Actions::Invocation
- Capistrano::Configuration::Actions::Invocation::ClassMethods
- Capistrano::Configuration::AliasTask
- Capistrano::Configuration::Callbacks
- Capistrano::Configuration::Connections
- Capistrano::Configuration::Execution
- Capistrano::Configuration::Loading
- Capistrano::Configuration::Loading::ClassMethods
- Capistrano::Configuration::LogFormatters
- Capistrano::Configuration::Namespaces
- Capistrano::Configuration::Namespaces::Namespace
- Capistrano::Configuration::Roles
- Capistrano::Configuration::Servers
- Capistrano::Configuration::Variables
- Capistrano::Deploy
- Capistrano::Deploy::Dependencies
- Capistrano::Deploy::LocalDependency
- Capistrano::Deploy::RemoteDependency
- Capistrano::Deploy::SCM
- Capistrano::Deploy::SCM::Accurev
- Capistrano::Deploy::SCM::Accurev::InternalRevision
- Capistrano::Deploy::SCM::Base
- Capistrano::Deploy::SCM::Base::LocalProxy
- Capistrano::Deploy::SCM::Bzr
- Capistrano::Deploy::SCM::Cvs
- Capistrano::Deploy::SCM::Darcs
- Capistrano::Deploy::SCM::Git
- Capistrano::Deploy::SCM::Mercurial
- Capistrano::Deploy::SCM::None
- Capistrano::Deploy::SCM::Perforce
- Capistrano::Deploy::SCM::Subversion
- Capistrano::Deploy::Strategy
- Capistrano::Deploy::Strategy::Base
- Capistrano::Deploy::Strategy::Checkout
- Capistrano::Deploy::Strategy::Copy
- Capistrano::Deploy::Strategy::Export
- Capistrano::Deploy::Strategy::Remote
- Capistrano::Deploy::Strategy::RemoteCache
- Capistrano::Deploy::Strategy::UnsharedRemoteCache
- Capistrano::ProcCallback
- Capistrano::Processable
- Capistrano::Processable::SessionAssociation
- Capistrano::RemoteError
- Capistrano::Role
- Capistrano::Role::DynamicServerList
- Capistrano::SSH
- Capistrano::ServerDefinition
- Capistrano::Shell
- Capistrano::TaskCallback
- Capistrano::TaskDefinition
- Capistrano::Transfer
- Capistrano::Transfer::SFTPTransferWrapper
- Capistrano::Version
- Kernel
- Object
- String

No matching classes.

# Capistrano::Deploy::SCM::Base

The ancestor class for all Capistrano SCM implementations. It provides minimal infrastructure for subclasses to build upon and override.

Note that subclasses that implement this abstract class only return the commands that need to be executed--they do not execute the commands themselves. In this way, the deployment method may execute the commands either locally or remotely, as necessary.

### Attributes

configuration[R]

The options available for this SCM instance to reference. Should be treated like a hash.

### Public Class Methods

default_command(value=nil) click to toggle source

If no parameters are given, it returns the current configured name of the command-line utility of this SCM. If a parameter is given, the defeault command is set to that value.

    # File lib/capistrano/recipes/deploy/scm/base.rb, line 17
    def default_command(value=nil)
      if value
        @default_command = value
      else
        @default_command
      end
    end

new(configuration={}) click to toggle source

Creates a new SCM instance with the given configuration options.

    # File lib/capistrano/recipes/deploy/scm/base.rb, line 44
    def initialize(configuration={})
      @configuration = configuration
    end

### Public Instance Methods

checkout(revision, destination) click to toggle source

Checkout a copy of the repository, at the given `revision`, to the given `destination`. The checkout is suitable for doing development work in, e.g. allowing subsequent commits and updates.

    # File lib/capistrano/recipes/deploy/scm/base.rb, line 87
    def checkout(revision, destination)
      raise NotImplementedError, "`checkout' is not implemented by #{self.class.name}"
    end

command() click to toggle source

Returns the name of the command-line utility for this SCM. It first looks at the :scm_command variable, and if it does not exist, it then falls back to whatever was defined by `default_command`.

If scm_command is set to :default, the default_command will be returned.

    # File lib/capistrano/recipes/deploy/scm/base.rb, line 147
    def command
      command = variable(:scm_command)
      command = nil if command == :default
      command || default_command
    end

diff(from, to=nil) click to toggle source

Compute the difference between the two revisions, `from` and `to`.

    # File lib/capistrano/recipes/deploy/scm/base.rb, line 98
    def diff(from, to=nil)
      raise NotImplementedError, "`diff' is not implemented by #{self.class.name}"
    end

handle_data(state, stream, text) click to toggle source

Should analyze the given text and determine whether or not a response is expected, and if so, return the appropriate response. If no response is expected, return nil. The `state` parameter is a hash that may be used to preserve state between calls. This method is used to define how Capistrano should respond to common prompts and messages from the SCM, like password prompts and such. By default, the output is simply displayed.

    # File lib/capistrano/recipes/deploy/scm/base.rb, line 136
    def handle_data(state, stream, text)
      logger.info "[#{stream}] #{text}"
      nil
    end

head() click to toggle source

Returns the string used to identify the latest revision in the repository. This will be passed as the "revision" parameter of the methods below.

    # File lib/capistrano/recipes/deploy/scm/base.rb, line 80
    def head
      raise NotImplementedError, "`head' is not implemented by #{self.class.name}"
    end

local() click to toggle source

Returns a proxy that wraps the SCM instance and forces it to operate in "local" mode, which changes how variables are looked up in the configuration. Normally, if the value of a variable "foo" is needed, it is queried for in the configuration as "foo". However, in "local" mode, first "local_foo" would be looked for, and only if it is not found would "foo" be used. This allows for both (e.g.) "scm_command" and "local_scm_command" to be set, if the two differ.

Alternatively, it may be called with a block, and for the duration of the block, all requests on this configuration object will be considered local.

    # File lib/capistrano/recipes/deploy/scm/base.rb, line 59
    def local
      if block_given?
        begin
          saved, @local_mode = @local_mode, true
          yield
        ensure
          @local_mode = saved
        end
      else
        LocalProxy.new(self)
      end
    end

local?() click to toggle source

Returns true if running in "local" mode. See local.

    # File lib/capistrano/recipes/deploy/scm/base.rb, line 73
    def local?
      @local_mode
    end

log(from, to=nil) click to toggle source

Return a log of all changes between the two specified revisions, `from` and `to`, inclusive.

    # File lib/capistrano/recipes/deploy/scm/base.rb, line 104
    def log(from, to=nil)
      raise NotImplementedError, "`log' is not implemented by #{self.class.name}"
    end

next_revision(revision) click to toggle source

Returns the revision number immediately following revision, if at all possible. A block should always be passed to this method, which accepts a command to invoke and returns the result, although a particular SCM's implementation is not required to invoke the block.

By default, this method simply returns the revision itself. If a particular SCM is able to determine a subsequent revision given a revision identifier, it should override this method.

    # File lib/capistrano/recipes/deploy/scm/base.rb, line 125
    def next_revision(revision)
      revision
    end

query_revision(revision) click to toggle source

If the given revision represents a "real" revision, this should simply return the revision value. If it represends a pseudo-revision (like Subversions "HEAD" identifier), it should yield a string containing the commands that, when executed will return a string that this method can then extract the real revision from.

    # File lib/capistrano/recipes/deploy/scm/base.rb, line 113
    def query_revision(revision)
      raise NotImplementedError, "`query_revision' is not implemented by #{self.class.name}"
    end

scm(*args) click to toggle source

A helper method that can be used to define SCM commands naturally. It returns a single string with all arguments joined by spaces, with the scm command prefixed onto it.

    # File lib/capistrano/recipes/deploy/scm/base.rb, line 156
    def scm(*args)
      [command, *args].compact.join(" ")
    end

sync(revision, destination) click to toggle source

Resynchronize the working copy in `destination` to the specified `revision`.

    # File lib/capistrano/recipes/deploy/scm/base.rb, line 93
    def sync(revision, destination)
      raise NotImplementedError, "`sync' is not implemented by #{self.class.name}"
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.