public this repo is viewable by everyone
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
Repo Search:
Piston::Commands::LockUnlock#run accepts both the wcdir and lock/unlock 
state as parameters.

Wrote a new test to ensure unlock does the right thing.
francois (author)
12 days ago
commit  3fa9e41332db8efbbe44942aec704f024ee13e7f
tree    524a406427481ea63145146ffa74dca3036c43c1
parent  c00108bd71f25457ad0ab5a7a92a25647cba7eff
...
5
6
7
8
9
 
 
10
11
12
13
14
15
 
 
16
17
18
...
5
6
7
 
 
8
9
10
11
12
13
14
15
16
17
18
19
20
0
@@ -5,14 +5,16 @@ module Piston
0
     class LockUnlock < Piston::Commands::Base
0
       attr_reader :options
0
 
0
- def run(lock)
0
- working_copy = Piston::WorkingCopy.guess(options[:wcdir])
0
+ def run(wcdir, lock)
0
+ working_copy = Piston::WorkingCopy.guess(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
+
0
+ logger.info "Locked #{working_copy} against automatic updates"
0
       end
0
     end
0
   end
...
2
3
4
5
 
 
6
7
8
9
10
 
 
11
12
13
14
15
 
 
 
 
 
 
 
 
 
 
 
16
17
18
...
34
35
36
37
 
38
39
 
40
41
42
43
44
 
 
 
45
46
47
...
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
...
45
46
47
 
48
49
 
50
51
52
 
 
 
53
54
55
56
57
58
0
@@ -2,17 +2,28 @@ require File.dirname(__FILE__) + "/../test_helper"
0
 
0
 class TestLockUnlock < Test::Unit::TestCase
0
   def setup
0
- @values = {:lock => "false", "handler" => { :repository => "repository" }}
0
+ @values = {"lock" => false}
0
+ @wcdir = "tmp/wcdir"
0
     @wc = mock("WorkingCopy")
0
   end
0
   
0
- def test_run
0
- run_and_verify do
0
+ def test_lock_working_copy
0
+ run_and_verify(true) 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
+ @wc.expects(:remember).with(@values.merge("lock" => true), @values["handler"]).returns(@values)
0
+ end
0
+ end
0
+
0
+ def test_unlock_working_copy
0
+ run_and_verify(false) 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.merge("lock" => false), @values["handler"]).returns(@values)
0
     end
0
   end
0
   
0
@@ -34,14 +45,14 @@ class TestLockUnlock < Test::Unit::TestCase
0
   end
0
 
0
   private
0
- def run_and_verify
0
+ def run_and_verify(lock=true)
0
     yield
0
- piston_lock.run(true)
0
+ lock_unlock_command.run(@wcdir, lock)
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
+ def lock_unlock_command
0
+ Piston::WorkingCopy.expects(:guess).with(@wcdir).returns(@wc)
0
+ Piston::Commands::LockUnlock.new(:verbose => "verbose",
0
                                      :quiet => "quiet", :force => "force")
0
   end
0
 end

Comments

    No one has commented yet.