public
Description: Piston is a utility that eases vendor branch management. This repository is a complete reimplementation of Piston to provide different backends, depending on the repositories and working copies you pistonize from.
Homepage: http://piston.rubyforge.org/
Clone URL: git://github.com/francois/piston.git
Search Repo:
Renamed Piston::Commands::Lock to Piston::Commands:LockUnlock.

Whitespace cleanup, CLI interface cleanup.
francois (author)
Fri May 09 07:19:01 -0700 2008
commit  24c8b6fae1e43014a140a04e0fbfd97efee866f9
tree    44d0219477ef162101dfe1923c56b44feafc7288
parent  50744c398a3e686abd5eb743a5e59ed67929c4ff
...
12
13
14
15
 
16
17
18
...
12
13
14
 
15
16
17
18
0
@@ -12,7 +12,7 @@ lib/piston/cli.rb
0
 lib/piston/commands.rb
0
 lib/piston/commands/base.rb
0
 lib/piston/commands/import.rb
0
-lib/piston/commands/lock.rb
0
+lib/piston/commands/lock_unlock.rb
0
 lib/piston/git.rb
0
 lib/piston/git/client.rb
0
 lib/piston/git/commit.rb
...
108
109
110
111
112
 
 
 
113
114
115
116
117
118
119
120
121
 
 
 
 
 
122
123
124
...
132
133
134
135
136
 
 
 
137
138
139
140
141
142
143
144
145
 
 
 
 
 
146
147
148
...
108
109
110
 
 
111
112
113
114
115
116
117
118
 
 
 
 
119
120
121
122
123
124
125
126
...
134
135
136
 
 
137
138
139
140
141
142
143
144
 
 
 
 
145
146
147
148
149
150
151
152
0
@@ -108,17 +108,19 @@ Main {
0
     mixin :standard_options
0
     
0
     argument "directory" do
0
- required
0
- description "Where to put the lock"
0
+ argument_required
0
+ optional
0
+ description "Which directory to lock"
0
     end
0
 
0
     logger_level Logger::DEBUG
0
     def run
0
       configure_logging!
0
- cmd = Piston::Commands::Lock.new( :wcdir => params["directory"].value,
0
- :verbose => params["verbose"].value,
0
- :quiet => params["quiet"].value,
0
- :force => params["force"].value)
0
+
0
+ cmd = Piston::Commands::LockUnlock.new(:wcdir => params["directory"].value,
0
+ :verbose => params["verbose"].value,
0
+ :quiet => params["quiet"].value,
0
+ :force => params["force"].value)
0
       begin
0
         cmd.run(true)
0
         puts "#{params["directory"].value} locked"
0
@@ -132,17 +134,19 @@ Main {
0
     mixin :standard_options
0
     
0
     argument "directory" do
0
- required
0
- description "Where to put the lock"
0
+ argument_required
0
+ optional
0
+ description "Which directory to lock"
0
     end
0
 
0
     logger_level Logger::DEBUG
0
     def run
0
       configure_logging!
0
- cmd = Piston::Commands::Lock.new( :wcdir => params["directory"].value,
0
- :verbose => params["verbose"].value,
0
- :quiet => params["quiet"].value,
0
- :force => params["force"].value)
0
+
0
+ cmd = Piston::Commands::LockUnlock.new(:wcdir => params["directory"].value,
0
+ :verbose => params["verbose"].value,
0
+ :quiet => params["quiet"].value,
0
+ :force => params["force"].value)
0
       begin
0
         cmd.run(false)
0
         puts "#{params["directory"].value} unlocked"
...
1
2
 
...
1
 
2
0
@@ -1,2 +1,2 @@
0
 require "piston/commands/import"
0
-require "piston/commands/lock"
0
+require "piston/commands/lock_unlock"
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,17 +0,0 @@
0
-require "piston/commands/base"
0
-
0
-module Piston
0
- module Commands
0
- class Lock < Piston::Commands::Base
0
- attr_reader :options
0
- def run(lock)
0
- working_copy = Piston::WorkingCopy.guess(options[:wcdir])
0
- raise Piston::WorkingCopy::NotWorkingCopy if !working_copy.exist? || !working_copy.pistonized?
0
- values = working_copy.recall
0
- values["lock"] = lock
0
- working_copy.remember(values, values["handler"])
0
- working_copy.finalize
0
- end
0
- end
0
- end
0
-end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
0
@@ -0,0 +1,19 @@
0
+require "piston/commands/base"
0
+
0
+module Piston
0
+ module Commands
0
+ class LockUnlock < Piston::Commands::Base
0
+ attr_reader :options
0
+
0
+ def run(lock)
0
+ working_copy = Piston::WorkingCopy.guess(options[:wcdir])
0
+ raise Piston::WorkingCopy::NotWorkingCopy if !working_copy.exist? || !working_copy.pistonized?
0
+
0
+ values = working_copy.recall
0
+ values["lock"] = lock
0
+ working_copy.remember(values, values["handler"])
0
+ working_copy.finalize
0
+ end
0
+ end
0
+ end
0
+end
...
2
3
4
5
6
7
8
...
48
49
50
 
51
52
53
54
 
55
56
57
...
2
3
4
 
5
6
7
...
47
48
49
50
51
52
53
 
54
55
56
57
0
@@ -2,7 +2,6 @@ module Piston
0
   class WorkingCopy
0
     class UnhandledWorkingCopy < RuntimeError; end
0
     class NotWorkingCopy < RuntimeError; end
0
-
0
 
0
     class << self
0
       def logger
0
@@ -48,10 +47,11 @@ module Piston
0
     end
0
 
0
     def exist?
0
+ @path.exist? && @path.directory?
0
     end
0
     
0
     def pistonized?
0
- File.exist?(yaml_path)
0
+ yaml_path.exist? && yaml_path.file?
0
     end
0
 
0
     # Creates the initial working copy for pistonizing a new repository.
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,52 +0,0 @@
0
-require File.dirname(__FILE__) + "/../test_helper"
0
-
0
-class TestLock < Test::Unit::TestCase
0
-
0
- def setup
0
- @values_mock = {:lock => "false", "handler" => { :repository => "repository" }}
0
- @wc_mock = mock("WorkingCopy")
0
- end
0
-
0
- def test_run
0
- run_and_verify do
0
- @wc_mock.expects(:exist?).returns(true)
0
- @wc_mock.expects(:pistonized?).returns(true)
0
- @wc_mock.expects(:recall).returns(@values_mock)
0
- @wc_mock.expects(:finalize).returns(@values_mock)
0
- @wc_mock.expects(:remember).with(@values_mock, @values_mock["handler"]).returns(@values_mock)
0
- end
0
- end
0
-
0
- def test_run_when_directory_not_exist
0
- assert_raise(Piston::WorkingCopy::NotWorkingCopy) do
0
- run_and_verify do
0
- @wc_mock.expects(:exist?).returns(false)
0
- end
0
- end
0
- end
0
-
0
- def test_run_when_directory_exist_but_yml_not_exit
0
- assert_raise(Piston::WorkingCopy::NotWorkingCopy) do
0
- run_and_verify do
0
- @wc_mock.expects(:exist?).returns(true)
0
- @wc_mock.expects(:pistonized?).returns(false)
0
- end
0
- end
0
- end
0
-
0
- private
0
-
0
- def run_and_verify
0
- yield
0
- get_piston_lock.run(true)
0
- end
0
-
0
- def get_piston_lock
0
- Piston::WorkingCopy.expects(:guess).with("directory").returns(@wc_mock)
0
- Piston::Commands::Lock.new( :wcdir => "directory",
0
- :verbose => "verbose",
0
- :quiet => "quiet",
0
- :force => "force")
0
- end
0
-
0
-end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
0
@@ -0,0 +1,47 @@
0
+require File.dirname(__FILE__) + "/../test_helper"
0
+
0
+class TestLockUnlock < Test::Unit::TestCase
0
+ def setup
0
+ @values = {:lock => "false", "handler" => { :repository => "repository" }}
0
+ @wc = mock("WorkingCopy")
0
+ end
0
+
0
+ def test_run
0
+ run_and_verify do
0
+ @wc.expects(:exist?).returns(true)
0
+ @wc.expects(:pistonized?).returns(true)
0
+ @wc.expects(:recall).returns(@values)
0
+ @wc.expects(:finalize).returns(@values)
0
+ @wc.expects(:remember).with(@values, @values["handler"]).returns(@values)
0
+ end
0
+ end
0
+
0
+ def test_run_when_directory_not_exist
0
+ assert_raise(Piston::WorkingCopy::NotWorkingCopy) do
0
+ run_and_verify do
0
+ @wc.expects(:exist?).returns(false)
0
+ end
0
+ end
0
+ end
0
+
0
+ def test_run_when_directory_exist_but_yml_not_exit
0
+ assert_raise(Piston::WorkingCopy::NotWorkingCopy) do
0
+ run_and_verify do
0
+ @wc.expects(:exist?).returns(true)
0
+ @wc.expects(:pistonized?).returns(false)
0
+ end
0
+ end
0
+ end
0
+
0
+ private
0
+ def run_and_verify
0
+ yield
0
+ piston_lock.run(true)
0
+ end
0
+
0
+ def piston_lock
0
+ Piston::WorkingCopy.expects(:guess).with("directory").returns(@wc)
0
+ Piston::Commands::LockUnlock.new(:wcdir => "directory", :verbose => "verbose",
0
+ :quiet => "quiet", :force => "force")
0
+ end
0
+end

Comments

    No one has commented yet.