Class: Perforce2Svn::Migrator

Inherits:
Object
  • Object
show all
Includes:
Choosy::Terminal, Logging
Defined in:
lib/perforce2svn/migrator.rb

Instance Method Summary collapse

Methods included from Logging

configure, log, #log

Constructor Details

#initialize(migrator_file, options) ⇒ Migrator

Returns a new instance of Migrator.



15
16
17
18
19
20
21
22
23
24
# File 'lib/perforce2svn/migrator.rb', line 15

def initialize(migrator_file, options)
  Logging.configure(options[:debug])
  Environment.new.check!

  @migration_file = Mapping::MappingFile.new(migrator_file, options)
  @svnRepo = Perforce2Svn::Subversion::SvnRepo.new(options[:repository])
  @commit_builder = Perforce::CommitBuilder.new(@migration_file.mappings)
  @version_range = options[:changes] || VersionRange.new(1)
  @options = options
end

Instance Method Details

#run!Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/perforce2svn/migrator.rb', line 26

def run!
  begin
    @commit_builder.commits_in(@version_range) do |commit|
      migrate_commit(commit)
    end unless @options[:skip_perforce]

    execute_commands unless @options[:skip_commands]
  rescue SystemExit
    raise
  rescue Interrupt
    @svnRepo.clean_transactions!
    die "Interrupted. Not continuing."
  rescue Exception => e
    puts e.backtrace
    log.error e
    die "Unable to complete migration."
  end
end