Sha256: af7d843cd0ac7a493045f03ecfc5edaf487e29eef6e64a8c84d82eb886443e72

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

module Mercurial
  
  #
  # The class represents Mercurial branch. Obtained by running an +hg branches+ command.
  #
  # The class represents Branch object itself, {Mercurial::BranchFactory BranchFactory} is responsible
  # for assembling instances of Branch. For the list of all possible branch-related operations 
  # check {Mercurial::BranchFactory BranchFactory}.
  #
  # For general information on Mercurial branches:
  #
  # http://mercurial.selenic.com/wiki/Branch
  #
  class Branch
   
    # Instance of {Mercurial::Repository Repository}.
    attr_reader :repository
    
    # Name of the branch.
    attr_reader :name
    
    # State of the branch: closed or active.
    attr_reader :status
    
    # ID of a commit associated with the branch. 40-chars long SHA1 hash.
    attr_reader :hash_id
    
    def initialize(repository, name, options={})
      @repository    = repository
      @name          = name
      @status        = options[:status] == 'closed' ? 'closed' : 'active'
      @hash_id       = options[:commit]
    end

    def commit
      repository.commits.by_hash_id(hash_id)
    end
    
    def active?
      status == 'active'
    end
    
    def closed?
      status == 'closed'
    end
    
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mercurial-ruby-0.7.11 lib/mercurial-ruby/branch.rb
mercurial-ruby-0.7.10 lib/mercurial-ruby/branch.rb
mercurial-ruby-0.7.9 lib/mercurial-ruby/branch.rb
mercurial-ruby-0.7.8 lib/mercurial-ruby/branch.rb
mercurial-ruby-0.7.7 lib/mercurial-ruby/branch.rb