Source

amp / bugs / 24.rb

require 'fileutils'

Amp::Bug.new do |b|
  dir  = "test_#{rand(1000)}"
  repo = nil # scoping
  
  b.number 24
           
  b.desc   "Unable to change branches"
  
  b.setup do
    repo = Amp::Repositories::Mercurial::LocalRepository.new dir, true # Create the repo
    repo.staging_area.add 'Ampfile'                                    # Add a file
    repo.commit :modified => ['Ampfile'], :message => 'initial commit' # Commit
    
    repo.dirstate.branch = 'new_branch'                                # Create a new branch
    repo.commit :message => 'added a new branch'                       # Save it
    
    puts repo[nil].branch
  end
  
  b.success do
    repo[nil].branch == 'new_branch'
  end
  
  b.cleanup { FileUtils.rm_rf Dir['test_*'] } # destory all similar looking dirs
end