Class: Capistrano::Deploy::SCM::Accurev

### Home Classes Methods

### In Files

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

### Parent

Base

### Namespace

- CLASS Capistrano::Deploy::SCM::Accurev::InternalRevision

### Methods

- #diff
- #export
- #head
- #log
- #query_revision

### Included Modules

- REXML

### 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::Accurev

Accurev bridge for use by Capistrano. This implementation does not implement all features of a Capistrano SCM module. The ones that are left out are either exceedingly difficult to implement with Accurev or are considered bad form.

When using this module in a project, the following variables are used:

    * :repository - This should match the depot that code lives in. If your code
                    exists in a subdirectory, you can append the path depot.
                    eg. foo-depot/bar_dir
    * :stream - The stream in the depot that code should be pulled from. If
                left blank, the depot stream will be used
    * :revision - Should be in the form 'stream/transaction'.

### Public Instance Methods

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

Returns the command needed to show the diff between what is deployed and what is pending. Because Accurev can not do this task without creating some streams, two time basis streams will be created for the purposes of doing the diff.

    # File lib/capistrano/recipes/deploy/scm/accurev.rb, line 95
    def diff(from, to=head)
      from = InternalRevision.parse(from)
      to = InternalRevision.parse(to)

      from_stream = "#{from.stream}-capistrano-diff-from"
      to_stream = "#{to.stream}-capistrano-diff-to"

      [
        change_or_create_stream(from_stream, from),
        change_or_create_stream(to_stream, to),
        scm(:diff, '-v', from_stream, '-V', to_stream, '-a')
      ].join(' && ')
    end

export(revision_id, destination) click to toggle source

Pops a copy of the code for the specified Accurev revision identifier. The revision identifier is represented as a stream & transaction ID combo. Accurev can only pop a particular transaction if a stream is created on the server with a time basis of that transaction id. Therefore, we will create a stream with the required criteria and pop that.

    # File lib/capistrano/recipes/deploy/scm/accurev.rb, line 62
    def export(revision_id, destination)
      revision = InternalRevision.parse(revision_id)
      logger.debug("Exporting #{revision.stream}/#{revision.transaction_id} to #{destination}")

      commands = [
        change_or_create_stream("#{revision.stream}-capistrano-deploy", revision),
        "mkdir -p #{destination}",
        scm_quiet(:pop, "-Rv #{stream}", "-L #{destination}", "'/./#{subdir}'")
      ]
      if subdir
        commands.push(
          "mv #{destination}/#{subdir}/* #{destination}",
          "rm -rf #{File.join(destination, subdir)}"
        )
      end
      commands.join(' && ')
    end

head() click to toggle source

Defines pseudo-revision value for the most recent changes to be deployed.

    # File lib/capistrano/recipes/deploy/scm/accurev.rb, line 25
    def head
      "#{stream}/highest"
    end

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

Returns the command needed to show the changes that exist between the two revisions.

    # File lib/capistrano/recipes/deploy/scm/accurev.rb, line 81
    def log(from, to=head)
      logger.info("Getting transactions between #{from} and #{to}")
      from_rev = InternalRevision.parse(from)
      to_rev = InternalRevision.parse(to)

      [
        scm(:hist, '-s', from_rev.stream, '-t', "#{to_rev.transaction_id}-#{from_rev.transaction_id}"),
        "sed -e '/transaction #{from_rev.transaction_id}/ { Q }'"
      ].join(' | ')
    end

query_revision(revision) click to toggle source

Given an Accurev revision identifier, this method returns an identifier that can be used for later SCM calls. This returned identifier will not change as a result of further SCM activity.

    # File lib/capistrano/recipes/deploy/scm/accurev.rb, line 32
    def query_revision(revision)
      internal_revision = InternalRevision.parse(revision)
      return revision unless internal_revision.psuedo_revision?

      logger.debug("Querying for real revision for #{internal_revision}")
      rev_stream = internal_revision.stream

      logger.debug("Determining what type of stream #{rev_stream} is...")
      stream_xml = yield show_streams_for(rev_stream)
      stream_doc = Document.new(stream_xml)
      type = XPath.first(stream_doc, '//streams/stream/@type').value

      case type
      when 'snapshot'
        InternalRevision.new(rev_stream, 'highest').to_s
      else
        logger.debug("Getting latest transaction id in #{rev_stream}")
        # Doing another yield for a second Accurev call. Hopefully this is ok.
        hist_xml = yield scm(:hist, '-ftx', '-s', rev_stream, '-t', 'now.1')
        hist_doc = Document.new(hist_xml)
        transaction_id = XPath.first(hist_doc, '//AcResponse/transaction/@id').value
        InternalRevision.new(stream, transaction_id).to_s
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.