Class: Basketcase::UpdateCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/basketcase.rb

Instance Attribute Summary

Attributes inherited from Command

#comment, #listener, #targets

Instance Method Summary collapse

Methods inherited from Command

#accept_args, #effective_targets, #initialize, #option_comment, #option_graphical, #option_recurse, #report, #specified_targets

Methods included from Utils

#mkpath

Constructor Details

This class inherits a constructor from Basketcase::Command

Instance Method Details

#executeObject



472
473
474
475
# File 'lib/basketcase.rb', line 472

def execute
  execute_update
  execute_merge unless @nomerge
end

#execute_mergeObject



455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
# File 'lib/basketcase.rb', line 455

def execute_merge
  args = '-log nul -flatest '
  if just_testing?
    args += "-print"
  elsif @graphical
    args += "-gmerge"
  else
    args += "-merge -gmerge"
  end
  cleartool("findmerge #{effective_targets} #{args}") do |line|
    case line
    when /^Needs Merge "(.+)" \[to \S+ from (\S+) base (\S+)\]/
      report(:MERGE, mkpath($1), $2)
    end
  end
end

#execute_updateObject



426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
# File 'lib/basketcase.rb', line 426

def execute_update
  args = '-log nul -force'
  args += ' -print' if just_testing?
  cleartool("update #{args} #{effective_targets}") do |line|
    case line
    when /^Processing dir "(.*)"/
      # ignore
    when /^\.*$/
      # ignore
    when /^Making dir "(.*)"/
      report(:NEW, relative_path($1))
    when /^Loading "(.*)"/
      report(:UPDATED, relative_path($1))
    when /^Unloaded "(.*)"/
      report(:REMOVED, relative_path($1))
    when /^Keeping hijacked object "(.*)" - base "(.*)"/
      report(:HIJACK, relative_path($1), $2)
    when /^Keeping "(.*)"/
      # ignore
    when /^End dir/
      # ignore
    when /^Done loading/
      # ignore
    else
      cannot_deal_with line
    end
  end
end

#helpObject



408
409
410
411
412
413
414
415
# File 'lib/basketcase.rb', line 408

def help
  <<EOF
Update your (snapshot) view.

-nomerge    Don\'t attempt to merge in changes to checked-out files.
EOF

end

#option_nomergeObject



417
418
419
# File 'lib/basketcase.rb', line 417

def option_nomerge
  @nomerge = true
end

#relative_path(s) ⇒ Object



421
422
423
424
# File 'lib/basketcase.rb', line 421

def relative_path(s)
  full_path = view_root + mkpath(s)
  full_path.relative_path_from(Pathname.pwd)
end

#synopsisObject



404
405
406
# File 'lib/basketcase.rb', line 404

def synopsis
  "[-nomerge] [<element> ...]"
end