Class: Mercurial::Branch

Inherits:
Object
  • Object
show all
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:

mercurial.selenic.com/wiki/Branch

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options={})
  @repository    = repository
  @name          = name
  @status        = options[:status] == 'closed' ? 'closed' : 'active'
  @latest_commit = options[:commit]
end

Instance Attribute Details

#latest_commitObject (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

#nameObject (readonly)

Name of the branch.



20
21
22
# File 'lib/mercurial-ruby/branch.rb', line 20

def name
  @name
end

#repositoryObject (readonly)

Instance of Repository.



17
18
19
# File 'lib/mercurial-ruby/branch.rb', line 17

def repository
  @repository
end

#statusObject (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

Returns:

  • (Boolean)


35
36
37
# File 'lib/mercurial-ruby/branch.rb', line 35

def active?
  status == 'active'
end

#closed?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/mercurial-ruby/branch.rb', line 39

def closed?
  status == 'closed'
end