Class: Basketcase::UpdateCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/basketcase/update_command.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



75
76
77
78
# File 'lib/basketcase/update_command.rb', line 75

def execute
  execute_update
  execute_merge unless @nomerge
end

#execute_mergeObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/basketcase/update_command.rb', line 58

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



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/basketcase/update_command.rb', line 29

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



11
12
13
14
15
16
17
18
# File 'lib/basketcase/update_command.rb', line 11

def help
  "Update your (snapshot) view.\n\n-nomerge    Don\\'t attempt to merge in changes to checked-out files.\n"

end

#option_nomergeObject



20
21
22
# File 'lib/basketcase/update_command.rb', line 20

def option_nomerge
  @nomerge = true
end

#relative_path(s) ⇒ Object



24
25
26
27
# File 'lib/basketcase/update_command.rb', line 24

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

#synopsisObject



7
8
9
# File 'lib/basketcase/update_command.rb', line 7

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