Class: Mercurial::Branch
- Inherits:
-
Object
- Object
- Mercurial::Branch
- Defined in:
- lib/mercurial-ruby/branch.rb
Overview
The class represents Mercurial branch. Obtained by running an hg branches command.
The class represents Branch object itself, BranchFactory is responsible for assembling instances of Branch. For the list of all possible branch-related operations please look documentation for BranchFactory.
Read more about Mercurial branches:
Instance Attribute Summary collapse
-
#latest_commit ⇒ Object
readonly
Mercurial changeset ID of the latest commit in the branch.
-
#name ⇒ Object
readonly
Name of the branch.
-
#repository ⇒ Object
readonly
Instance of Repository.
-
#status ⇒ Object
readonly
State of the branch: closed or active.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #closed? ⇒ Boolean
-
#initialize(repository, name, options = {}) ⇒ Branch
constructor
A new instance of Branch.
Constructor Details
#initialize(repository, name, options = {}) ⇒ Branch
Returns a new instance of Branch.
28 29 30 31 32 33 |
# File 'lib/mercurial-ruby/branch.rb', line 28 def initialize(repository, name, ={}) @repository = repository @name = name @status = [:status] == 'closed' ? 'closed' : 'active' @latest_commit = [:commit] end |
Instance Attribute Details
#latest_commit ⇒ Object (readonly)
Mercurial changeset ID of the latest commit in the branch. 40-chars long SHA1 hash.
26 27 28 |
# File 'lib/mercurial-ruby/branch.rb', line 26 def latest_commit @latest_commit end |
#name ⇒ Object (readonly)
Name of the branch.
20 21 22 |
# File 'lib/mercurial-ruby/branch.rb', line 20 def name @name end |
#repository ⇒ Object (readonly)
Instance of Repository.
17 18 19 |
# File 'lib/mercurial-ruby/branch.rb', line 17 def repository @repository end |
#status ⇒ Object (readonly)
State of the branch: closed or active.
23 24 25 |
# File 'lib/mercurial-ruby/branch.rb', line 23 def status @status end |
Instance Method Details
#active? ⇒ Boolean
35 36 37 |
# File 'lib/mercurial-ruby/branch.rb', line 35 def active? status == 'active' end |
#closed? ⇒ Boolean
39 40 41 |
# File 'lib/mercurial-ruby/branch.rb', line 39 def closed? status == 'closed' end |