Class Capistrano::Deploy::SCM::Accurev
In: lib/capistrano/recipes/deploy/scm/accurev.rb
lib/capistrano/recipes/deploy/scm/accurev.rb
Parent: Base

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'.

Methods

diff   diff   export   export   head   head   log   log   query_revision   query_revision  

Included Modules

REXML REXML

Classes and Modules

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

Public Instance methods

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.

[Source]

     # File lib/capistrano/recipes/deploy/scm/accurev.rb, line 95
 95:         def diff(from, to=head)
 96:           from = InternalRevision.parse(from)
 97:           to = InternalRevision.parse(to)
 98: 
 99:           from_stream = "#{from.stream}-capistrano-diff-from"
100:           to_stream = "#{to.stream}-capistrano-diff-to"
101: 
102:           [
103:             change_or_create_stream(from_stream, from),
104:             change_or_create_stream(to_stream, to),
105:             scm(:diff, '-v', from_stream, '-V', to_stream, '-a')
106:           ].join(' && ')
107:         end

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.

[Source]

     # File lib/capistrano/recipes/deploy/scm/accurev.rb, line 95
 95:         def diff(from, to=head)
 96:           from = InternalRevision.parse(from)
 97:           to = InternalRevision.parse(to)
 98: 
 99:           from_stream = "#{from.stream}-capistrano-diff-from"
100:           to_stream = "#{to.stream}-capistrano-diff-to"
101: 
102:           [
103:             change_or_create_stream(from_stream, from),
104:             change_or_create_stream(to_stream, to),
105:             scm(:diff, '-v', from_stream, '-V', to_stream, '-a')
106:           ].join(' && ')
107:         end

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.

[Source]

    # File lib/capistrano/recipes/deploy/scm/accurev.rb, line 62
62:         def export(revision_id, destination)
63:           revision = InternalRevision.parse(revision_id)
64:           logger.debug("Exporting #{revision.stream}/#{revision.transaction_id} to #{destination}")
65: 
66:           commands = [
67:             change_or_create_stream("#{revision.stream}-capistrano-deploy", revision),
68:             "mkdir -p #{destination}",
69:             scm_quiet(:pop, "-Rv #{stream}", "-L #{destination}", "'/./#{subdir}'")
70:           ]
71:           if subdir
72:             commands.push(
73:               "mv #{destination}/#{subdir}/* #{destination}",
74:               "rm -rf #{File.join(destination, subdir)}"
75:             )
76:           end
77:           commands.join(' && ')
78:         end

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.

[Source]

    # File lib/capistrano/recipes/deploy/scm/accurev.rb, line 62
62:         def export(revision_id, destination)
63:           revision = InternalRevision.parse(revision_id)
64:           logger.debug("Exporting #{revision.stream}/#{revision.transaction_id} to #{destination}")
65: 
66:           commands = [
67:             change_or_create_stream("#{revision.stream}-capistrano-deploy", revision),
68:             "mkdir -p #{destination}",
69:             scm_quiet(:pop, "-Rv #{stream}", "-L #{destination}", "'/./#{subdir}'")
70:           ]
71:           if subdir
72:             commands.push(
73:               "mv #{destination}/#{subdir}/* #{destination}",
74:               "rm -rf #{File.join(destination, subdir)}"
75:             )
76:           end
77:           commands.join(' && ')
78:         end

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

[Source]

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

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

[Source]

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

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

[Source]

    # File lib/capistrano/recipes/deploy/scm/accurev.rb, line 81
81:         def log(from, to=head)
82:           logger.info("Getting transactions between #{from} and #{to}")
83:           from_rev = InternalRevision.parse(from)
84:           to_rev = InternalRevision.parse(to)
85: 
86:           [
87:             scm(:hist, '-s', from_rev.stream, '-t', "#{to_rev.transaction_id}-#{from_rev.transaction_id}"),
88:             "sed -e '/transaction #{from_rev.transaction_id}/ { Q }'"
89:           ].join(' | ')
90:         end

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

[Source]

    # File lib/capistrano/recipes/deploy/scm/accurev.rb, line 81
81:         def log(from, to=head)
82:           logger.info("Getting transactions between #{from} and #{to}")
83:           from_rev = InternalRevision.parse(from)
84:           to_rev = InternalRevision.parse(to)
85: 
86:           [
87:             scm(:hist, '-s', from_rev.stream, '-t', "#{to_rev.transaction_id}-#{from_rev.transaction_id}"),
88:             "sed -e '/transaction #{from_rev.transaction_id}/ { Q }'"
89:           ].join(' | ')
90:         end

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.

[Source]

    # File lib/capistrano/recipes/deploy/scm/accurev.rb, line 32
32:         def query_revision(revision)
33:           internal_revision = InternalRevision.parse(revision)
34:           return revision unless internal_revision.psuedo_revision?
35: 
36:           logger.debug("Querying for real revision for #{internal_revision}")
37:           rev_stream = internal_revision.stream
38: 
39:           logger.debug("Determining what type of stream #{rev_stream} is...")
40:           stream_xml = yield show_streams_for(rev_stream)
41:           stream_doc = Document.new(stream_xml)
42:           type = XPath.first(stream_doc, '//streams/stream/@type').value
43: 
44:           case type
45:           when 'snapshot'
46:             InternalRevision.new(rev_stream, 'highest').to_s
47:           else
48:             logger.debug("Getting latest transaction id in #{rev_stream}")
49:             # Doing another yield for a second Accurev call. Hopefully this is ok.
50:             hist_xml = yield scm(:hist, '-ftx', '-s', rev_stream, '-t', 'now.1')
51:             hist_doc = Document.new(hist_xml)
52:             transaction_id = XPath.first(hist_doc, '//AcResponse/transaction/@id').value
53:             InternalRevision.new(stream, transaction_id).to_s
54:           end
55:         end

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.

[Source]

    # File lib/capistrano/recipes/deploy/scm/accurev.rb, line 32
32:         def query_revision(revision)
33:           internal_revision = InternalRevision.parse(revision)
34:           return revision unless internal_revision.psuedo_revision?
35: 
36:           logger.debug("Querying for real revision for #{internal_revision}")
37:           rev_stream = internal_revision.stream
38: 
39:           logger.debug("Determining what type of stream #{rev_stream} is...")
40:           stream_xml = yield show_streams_for(rev_stream)
41:           stream_doc = Document.new(stream_xml)
42:           type = XPath.first(stream_doc, '//streams/stream/@type').value
43: 
44:           case type
45:           when 'snapshot'
46:             InternalRevision.new(rev_stream, 'highest').to_s
47:           else
48:             logger.debug("Getting latest transaction id in #{rev_stream}")
49:             # Doing another yield for a second Accurev call. Hopefully this is ok.
50:             hist_xml = yield scm(:hist, '-ftx', '-s', rev_stream, '-t', 'now.1')
51:             hist_doc = Document.new(hist_xml)
52:             transaction_id = XPath.first(hist_doc, '//AcResponse/transaction/@id').value
53:             InternalRevision.new(stream, transaction_id).to_s
54:           end
55:         end

[Validate]