Class: Origen::RevisionControl::Base
- Defined in:
- lib/origen/revision_control/base.rb
Overview
Base class of all revision control system drivers, all drivers should support the API methods defined here.
Each instance of this class represents the concept of mapping a local directory to a remote repository.
Origen.app.rc will return an instance of this class for the revision control system used by the current application, the :local attribute will be automatically set to Origen.root and the :remote attribute will be set per the revision control attributes defined in config/application.rb.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#local ⇒ Object
readonly
Returns a pointer to the local location (a Pathname object).
-
#remote ⇒ Object
readonly
Returns a pointer to the remote location (a Pathname object).
-
#remotes_method ⇒ Object
readonly
Method to use by Origen::RemoteManager to handle fetching a remote file.
Instance Method Summary collapse
-
#build(options = {}) ⇒ Object
Build the local workspace for the first time.
-
#changes(dir = nil, options = {}) ⇒ Object
Returns a hash containing the list of files that have changes compared to the given tag or compared to the latest version (on the server).
-
#checkin(path = nil, options = {}) ⇒ Object
Checkin the given file or directory, it returns a path to the local file.
-
#checkout(path = nil, options = {}) ⇒ Object
Checkout the given file or directory, it returns a path to the local file.
-
#current_branch ⇒ Object
Returns the name of the current branch in the local workspace.
-
#diff_cmd(file, version) ⇒ Object
Returns the command the user must run to execute a diff of the current version of the given file against the given version of it.
-
#dssc? ⇒ Boolean
(also: #design_sync?)
Returns true if the revision controller object uses Design Sync.
-
#git? ⇒ Boolean
Returns true if the revision controller object uses Git.
-
#initialize(options = {}) ⇒ Base
constructor
All revision control instances represent a remote server mapping to a local directory, :remote and :local options are required.
-
#local_modifications(dir = nil, options = {}) ⇒ Object
Returns an array containing the files that have un-committed local changes.
-
#p4? ⇒ Boolean
(also: #perforce?)
Returns true if the revision controller object uses Perforce.
-
#root ⇒ Object
Returns what is considered to be the top-level root directory by the revision control system.
-
#svn? ⇒ Boolean
(also: #subversion?)
Returns true if the revision controller object uses Subversion.
-
#unmanaged(dir = nil, options = {}) ⇒ Object
Returns an array containing the list of files that are present in the given directory but which are not managed by the revision control system.
Constructor Details
#initialize(options = {}) ⇒ Base
All revision control instances represent a remote server mapping to a local directory, :remote and :local options are required
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/origen/revision_control/base.rb', line 24 def initialize( = {}) unless [:remote] && [:local] fail ':remote and :local options must be supplied when instantiating a new RevisionControl object' end @remote = Pathname.new([:remote]) @local = Pathname.new([:local]). @remotes_method = :checkout initialize_local_dir() end |
Instance Attribute Details
#local ⇒ Object (readonly)
Returns a pointer to the local location (a Pathname object)
18 19 20 |
# File 'lib/origen/revision_control/base.rb', line 18 def local @local end |
#remote ⇒ Object (readonly)
Returns a pointer to the remote location (a Pathname object)
16 17 18 |
# File 'lib/origen/revision_control/base.rb', line 16 def remote @remote end |
#remotes_method ⇒ Object (readonly)
Method to use by Origen::RemoteManager to handle fetching a remote file
20 21 22 |
# File 'lib/origen/revision_control/base.rb', line 20 def remotes_method @remotes_method end |
Instance Method Details
#build(options = {}) ⇒ Object
Build the local workspace for the first time.
This is roughly equivalent to running the checkout command, but should be used in the case where the local workspace is being setup for the first time.
39 40 41 |
# File 'lib/origen/revision_control/base.rb', line 39 def build( = {}) fail "The #{self.class} driver does not support the build method!" end |
#changes(dir = nil, options = {}) ⇒ Object
Returns a hash containing the list of files that have changes compared to the given tag or compared to the latest version (on the server).
{
:added => [], # Paths to files that have been added since the previous tag
:removed => [], # Paths to files that have been removed since the previous tag
:changed => [], # Paths to files that have changed since the previous tag
:present => true/false, # Convenience attribute for the caller to check if there are any changes, when
# true at least one of the other arrays will contain a value
}
The dir argument is optional and when not supplied the entire directory will be checked for changes.
Note that added files only refers to those files which have been checked into revision control since the compared to version, it does not refer to unmanaged files in the workspace. Use the unmanaged method to get a list of those.
Note also that while a file is considered added or removed depends on the chronological relationship between the current version (the user's workspace) and the reference version. If the reference version is older than the current version (i.e. an earlier tag), then an added file means a file that the current version has and the reference (previous) version did not have.
However if the reference version is newer than the current version (e.g. when comparing to a newer tag or the latest version on the server), then an added file means a file that the current version does not have and which has been added in a newer version of the remote directory.
120 121 122 |
# File 'lib/origen/revision_control/base.rb', line 120 def changes(dir = nil, = {}) fail "The #{self.class} driver does not support the changes method!" end |
#checkin(path = nil, options = {}) ⇒ Object
Checkin the given file or directory, it returns a path to the local file.
The path argument is optional and when not supplied the entire directory will be checked in.
79 80 81 |
# File 'lib/origen/revision_control/base.rb', line 79 def checkin(path = nil, = {}) fail "The #{self.class} driver does not support the checkin method!" end |
#checkout(path = nil, options = {}) ⇒ Object
Checkout the given file or directory, it returns a path to the local file.
The path argument is optional and when not supplied the entire directory will be checked out.
58 59 60 |
# File 'lib/origen/revision_control/base.rb', line 58 def checkout(path = nil, = {}) fail "The #{self.class} driver does not support the checkout method!" end |
#current_branch ⇒ Object
Returns the name of the current branch in the local workspace
182 183 184 |
# File 'lib/origen/revision_control/base.rb', line 182 def current_branch fail "The #{self.class} driver does not support the current_branch method!" end |
#diff_cmd(file, version) ⇒ Object
Returns the command the user must run to execute a diff of the current version of the given file against the given version of it.
166 167 168 |
# File 'lib/origen/revision_control/base.rb', line 166 def diff_cmd(file, version) fail "The #{self.class} driver does not support the diff_cmd method!" end |
#dssc? ⇒ Boolean Also known as: design_sync?
Returns true if the revision controller object uses Design Sync
187 188 189 |
# File 'lib/origen/revision_control/base.rb', line 187 def dssc? is_a?(DesignSync) end |
#git? ⇒ Boolean
Returns true if the revision controller object uses Git
193 194 195 |
# File 'lib/origen/revision_control/base.rb', line 193 def git? is_a?(Git) # :-) end |
#local_modifications(dir = nil, options = {}) ⇒ Object
Returns an array containing the files that have un-committed local changes.
The dir argument is optional and when not supplied the entire directory will be checked for changes.
137 138 139 |
# File 'lib/origen/revision_control/base.rb', line 137 def local_modifications(dir = nil, = {}) fail "The #{self.class} driver does not support the local_modifications method!" end |
#p4? ⇒ Boolean Also known as: perforce?
Returns true if the revision controller object uses Perforce
198 199 200 |
# File 'lib/origen/revision_control/base.rb', line 198 def p4? is_a?(Perforce) end |
#root ⇒ Object
Returns what is considered to be the top-level root directory by the revision control system.
In the case of an application's revision controller (returned by Origen.app.rc) this method will often return the same directory as Origen.root. However in some cases an application owner may choose to store their application in a sub directory of a larger project entity that is revision controlled. In that case Origen.root will return the sub directory and this method will return the top-level directory of the wider project.
177 178 179 |
# File 'lib/origen/revision_control/base.rb', line 177 def root fail "The #{self.class} driver does not support the root method!" end |
#svn? ⇒ Boolean Also known as: subversion?
Returns true if the revision controller object uses Subversion
204 205 206 |
# File 'lib/origen/revision_control/base.rb', line 204 def svn? is_a?(Subversion) # :-) end |
#unmanaged(dir = nil, options = {}) ⇒ Object
Returns an array containing the list of files that are present in the given directory but which are not managed by the revision control system.
The dir argument is optional and when not supplied the entire directory will be checked for unmanaged files.
155 156 157 |
# File 'lib/origen/revision_control/base.rb', line 155 def unmanaged(dir = nil, = {}) fail "The #{self.class} driver does not support the unmanaged method!" end |