Class: Mercurial::Manifest
- Inherits:
-
Object
- Object
- Mercurial::Manifest
- Includes:
- Helper
- Defined in:
- lib/mercurial-ruby/manifest.rb
Overview
Represents Mercurial manifest file. Use this class to get manifest’s contents and scan it for file paths at specific revisions.
Read more about Mercurial manifest:
Instance Attribute Summary collapse
-
#repository ⇒ Object
readonly
Instance of Repository.
Instance Method Summary collapse
-
#contents(revision = nil, cmd_options = {}) ⇒ Object
Returns contents of the manifest as a String at a specified revision.
-
#initialize(repository) ⇒ Manifest
constructor
A new instance of Manifest.
-
#scan_for_path(path, revision = nil) ⇒ Object
Returns an array of file paths from manifest that start with the specified
path
at a specifiedrevision
.
Methods included from Helper
Constructor Details
#initialize(repository) ⇒ Manifest
Returns a new instance of Manifest.
17 18 19 |
# File 'lib/mercurial-ruby/manifest.rb', line 17 def initialize(repository) @repository = repository end |
Instance Attribute Details
#repository ⇒ Object (readonly)
Instance of Repository.
15 16 17 |
# File 'lib/mercurial-ruby/manifest.rb', line 15 def repository @repository end |
Instance Method Details
#contents(revision = nil, cmd_options = {}) ⇒ Object
Returns contents of the manifest as a String at a specified revision. Latest version of the manifest is used if revision
is ommitted.
Example:
repository.manifest.contents
27 28 29 30 |
# File 'lib/mercurial-ruby/manifest.rb', line 27 def contents(revision=nil, ={}) revision ||= 'tip' hg(manifest_cmd(revision), ) end |
#scan_for_path(path, revision = nil) ⇒ Object
Returns an array of file paths from manifest that start with the specified path
at a specified revision
. Latest version of the manifest is used if revision
is ommitted.
Example:
repository.manifest.scan_for_path('/')
repository.manifest.scan_for_path('some-interesting-directory/', '2d32410d9629')
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/mercurial-ruby/manifest.rb', line 39 def scan_for_path(path, revision=nil) revision ||= 'tip' path = path.without_trailing_slash if path == '/' || path == '' search_for = ".*" else path_re = Regexp.escape(path) search_for = "#{ path_re }$|#{ path_re }\/.*" end contents(revision).scan(/^(\w{40}) (\d{3}) (\*?) +(#{ search_for })/) end |