class Mercurial::BranchFactory
This class represents a factory for {Mercurial::Branch Branch} instances.
Attributes
repository[R]
Instance of {Mercurial::Repository Repository}.
Public Class Methods
new(repository)
click to toggle source
# File lib/mercurial-ruby/factories/branch_factory.rb, line 12 def initialize(repository) @repository = repository end
Public Instance Methods
active(cmd_options={})
click to toggle source
all(cmd_options={})
click to toggle source
by_name(name, cmd_options={})
click to toggle source
closed(cmd_options={})
click to toggle source
each(cmd_options={}, &block)
click to toggle source
Run a block for every {Mercurial::Branch Branch} instance of all branches in the repository.
Example:¶ ↑
repository.branches.each {|commit| ... }
# File lib/mercurial-ruby/factories/branch_factory.rb, line 32 def each(cmd_options={}, &block) all(cmd_options).each do |branch| block.call(branch) end end
for_commit(hash_id, cmd_options={})
click to toggle source
Return an array of {Mercurial::Branch Branch} instances where a specified commit exists. Experimental, doesn't always return a correct list of branches.
Example:¶ ↑
repository.branches.for_commit('291a498f04e9')
# File lib/mercurial-ruby/factories/branch_factory.rb, line 88 def for_commit(hash_id, cmd_options={}) hg_to_array(["log -r 'descendants(?) and head()' --template '\n{branches}'", hash_id], {}, cmd_options) do |line| build_with_name_only(line) end.compact.uniq end
inactive(cmd_options={})
click to toggle source
Private Instance Methods
build(data)
click to toggle source
# File lib/mercurial-ruby/factories/branch_factory.rb, line 96 def build(data) name, last_commit, status = *data.scan(/([\w\- ]+)\s+\d+:(\w+)\s*\(*(\w*)\)*/).first Mercurial::Branch.new( repository, name, :commit => last_commit, :status => status ) end
build_with_name_only(name)
click to toggle source
# File lib/mercurial-ruby/factories/branch_factory.rb, line 106 def build_with_name_only(name) name = 'default' if name == '' Mercurial::Branch.new(repository, name) end