Class: SC::Experimental
Constant Summary
Constants inherited
from Command
Command::VALID_SET_KEYS
Instance Method Summary
collapse
Methods inherited from Command
commands, inherited, options, reset!
Instance Method Details
#create_experimental_branch ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/sc/commands/experimental.rb', line 84
def create_experimental_branch
raise "branch #@path already exists" if @has_path
unless opthash[:force]
name = @branch_name
name = @path if @prefix != 'exp'
exit unless Constants::TERMINAL.agree("Create experimental branch " +
Constants::TERMINAL.color(name, :green) + " off " +
Constants::TERMINAL.color(@project.to_s, :green) + "/trunk? ")
end
Svn.branch(@project, @project.trunk, @project.branches(@path))
Svn.branch(@project, @project.branches(@path), @project.tags("#{@prefix}/PRE-#{@branch_name}"))
unless opthash[:no_checkout]
Constants::TERMINAL.say("Checked out: " +
Constants::TERMINAL.color(Path.relative_to_home(@project.checkout(@project.branches(@path))), :green))
end
end
|
#latest_merge(prefix) ⇒ Object
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/sc/commands/experimental.rb', line 125
def latest_merge (prefix)
merges = []
Svn.list(@project.tags(@prefix)) do |line|
if m = line.match(/^#{prefix}(\d+)-#{@branch_name}\/?$/)
merges << m[1].to_i
end
end
merges.sort.last
end
|
#merge(direction, merge_to, end_tag) ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/sc/commands/experimental.rb', line 106
def merge (direction, merge_to, end_tag)
raise "there is no experimental branch with the name #{@branch_name}" unless @has_path
last_merge_number = latest_merge(direction)
start = last_merge_number ? "#{direction}#{last_merge_number}" : "PRE"
next_merge_number = last_merge_number ? last_merge_number+1 : 1
start_tag = "#{@prefix}/#{start}-#{@branch_name}"
Svn.branch(@project, end_tag, @project.tags("#{@prefix}/#{direction}#{next_merge_number}-#{@branch_name}"))
@project.merge(merge_to, start_tag, end_tag) do
"then commit your changes to finish the #{direction} merge"
end
end
|
#run(project, args) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/sc/commands/experimental.rb', line 52
def run (project, args)
if opthash[:up] and opthash[:down]
raise "you can only use one of --up or --down"
end
@branch_name = Project.clean_name(args.first)
unless opthash[:force]
if @branch_name != args.first and !Constants::TERMINAL.agree("Is #{@branch_name} OK for the branch name? ")
raise "please pick a branch name that doesn't include any special characters"
end
end
if @branch_name != args.first
Constants::TERMINAL.say("using #{Constants::TERMINAL.color(@branch_name, :green)} as the branch name")
end
@project = project
@prefix = opthash[:prefix] || 'exp'
@path = "#{@prefix}/#{@branch_name}"
@has_path = Svn.has_path(@project.branches(@path))
if opthash[:up]
merge('UP', @project.branches(@path), @project.trunk)
elsif opthash[:down]
merge('DOWN', @project.trunk, @project.branches(@path))
else
create_experimental_branch
end
end
|