public
Fork of francois/piston
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/technicalpickles/piston.git
Search Repo:
Merge branch 'master' of git://github.com/francois/piston
Fri May 09 08:35:46 -0700 2008
commit  faac9131bd254adba48a1e37a626d919665467c5
tree    58422820ac65d01791da3f8b2dbab3385433db4d
parent  f169b317fd270f6b5b05b1440309f8767f339542 parent  29185f5c30acfc9ab36f661bd44d1429e0e8d336
...
1
2
3
 
 
 
...
1
2
3
4
5
6
0
@@ -1,4 +1,7 @@
0
 *.swp
0
 *.log
0
 pkg
0
+*.iml
0
+*.ipr
0
+*.iws
...
12
13
14
 
15
16
17
...
26
27
28
 
29
30
31
32
...
47
48
49
50
51
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
...
12
13
14
15
16
17
18
...
27
28
29
30
31
32
33
34
...
49
50
51
 
 
 
 
 
 
 
 
 
 
 
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
0
@@ -12,6 +12,7 @@
0
 lib/piston/commands.rb
0
 lib/piston/commands/base.rb
0
 lib/piston/commands/import.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
0
@@ -26,6 +27,7 @@
0
 lib/piston/svn/working_copy.rb
0
 lib/piston/version.rb
0
 lib/piston/working_copy.rb
0
+lib/subclass_responsibility_error.rb
0
 log/.gitignore
0
 samples/common.rb
0
 samples/import_git_git.rb
0
0
@@ -47,33 +49,33 @@
0
 test/integration/test_import_svn_svn.rb
0
 test/integration_helpers.rb
0
 test/test_helper.rb
0
-test/unit/test_git_commit_checkout.rb
0
-test/unit/test_git_commit_each.rb
0
-test/unit/test_git_commit_rememberance.rb
0
-test/unit/test_git_repository_at.rb
0
-test/unit/test_git_repository_guessing.rb
0
-test/unit/test_git_working_copy_copying.rb
0
-test/unit/test_git_working_copy_creation.rb
0
-test/unit/test_git_working_copy_existence.rb
0
-test/unit/test_git_working_copy_finalization.rb
0
-test/unit/test_git_working_copy_guessing.rb
0
-test/unit/test_git_working_copy_rememberance.rb
0
+test/unit/git/commit/test_checkout.rb
0
+test/unit/git/commit/test_each.rb
0
+test/unit/git/commit/test_rememberance.rb
0
+test/unit/git/repository/test_at.rb
0
+test/unit/git/repository/test_basename.rb
0
+test/unit/git/repository/test_guessing.rb
0
+test/unit/git/working_copy/test_copying.rb
0
+test/unit/git/working_copy/test_creation.rb
0
+test/unit/git/working_copy/test_existence.rb
0
+test/unit/git/working_copy/test_finalization.rb
0
+test/unit/git/working_copy/test_guessing.rb
0
+test/unit/git/working_copy/test_rememberance.rb
0
+test/unit/svn/repository/test_at.rb
0
+test/unit/svn/repository/test_basename.rb
0
+test/unit/svn/repository/test_guessing.rb
0
+test/unit/svn/revision/test_checkout.rb
0
+test/unit/svn/revision/test_each.rb
0
+test/unit/svn/revision/test_rememberance.rb
0
+test/unit/svn/working_copy/test_copying.rb
0
+test/unit/svn/working_copy/test_creation.rb
0
+test/unit/svn/working_copy/test_existence.rb
0
+test/unit/svn/working_copy/test_finalization.rb
0
+test/unit/svn/working_copy/test_guessing.rb
0
+test/unit/svn/working_copy/test_rememberance.rb
0
 test/unit/test_import.rb
0
-test/unit/test_piston.rb
0
-test/unit/test_repository_guessing.rb
0
-test/unit/test_svn_repository_at.rb
0
-test/unit/test_svn_repository_guessing.rb
0
-test/unit/test_svn_revision_checkout.rb
0
-test/unit/test_svn_revision_each.rb
0
-test/unit/test_svn_revision_rememberance.rb
0
-test/unit/test_svn_working_copy_copying.rb
0
-test/unit/test_svn_working_copy_creation.rb
0
-test/unit/test_svn_working_copy_existence.rb
0
-test/unit/test_svn_working_copy_finalization.rb
0
-test/unit/test_svn_working_copy_guessing.rb
0
-test/unit/test_svn_working_copy_rememberance.rb
0
-test/unit/test_working_copy_guessing.rb
0
-test/unit/test_working_copy_rememberance.rb
0
+test/unit/working_copy/test_guessing.rb
0
+test/unit/working_copy/test_rememberance.rb
0
 tmp/.gitignore
0
 website/index.html
0
 website/index.txt
...
 
 
1
2
3
...
1
2
3
4
5
0
@@ -1,3 +1,5 @@
0
+require "subclass_responsibility_error"
0
+
0
 require "piston/repository"
0
 require "piston/revision"
0
 require "piston/working_copy"
...
80
81
82
83
84
 
85
86
87
88
89
...
101
102
103
 
 
 
 
 
 
 
104
105
 
 
 
 
 
 
 
 
 
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
108
109
...
80
81
82
 
 
83
84
85
86
87
88
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
0
@@ -80,8 +80,7 @@
0
         raise ArgumentError, "Only one of --revision or --commit can be given. Received both."
0
       end
0
 
0
- cmd = Piston::Commands::Import.new(:lock => params["lock"].value,
0
- :verbose => params["verbose"].value,
0
+ cmd = Piston::Commands::Import.new(:verbose => params["verbose"].value,
0
                                          :quiet => params["quiet"].value,
0
                                          :force => params["force"].value,
0
                                          :dry_run => params["dry-run"].value,
0
0
0
@@ -101,9 +100,68 @@
0
         end
0
         exit_failure!
0
       end
0
+
0
+ # Lock the working copy, if the user asked for it
0
+ cmd = Piston::Commands::LockUnlock.new(:verbose => params["verbose"].value,
0
+ :quiet => params["quiet"].value,
0
+ :force => params["force"].value,
0
+ :dry_run => params["dry-run"].value)
0
+ cmd.run(params["directory"].value, true) if params["lock"].value
0
     end
0
   end
0
+
0
+ mode "lock" do
0
+ mixin :standard_options
0
+
0
+ argument "directory" do
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
+
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
+ rescue Piston::WorkingCopy::NotWorkingCopy
0
+ puts "The #{params["directory"].value} is not Pistonized"
0
+ end
0
+ end
0
+ end
0
+
0
+ mode "unlock" do
0
+ mixin :standard_options
0
+
0
+ argument "directory" do
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
+
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"
0
+ rescue Piston::WorkingCopy::NotWorkingCopy
0
+ puts "The #{params["directory"].value} is not Pistonized"
0
+ end
0
+ end
0
+ end
0
+
0
   option("version", "v")
0
 
0
   def run
...
1
 
...
1
2
0
@@ -1,2 +1,3 @@
0
 require "piston/commands/import"
0
+require "piston/commands/lock_unlock"
...
13
14
15
16
17
 
 
18
19
20
21
 
22
23
24
 
25
26
27
28
29
30
 
31
32
33
...
67
68
69
70
 
71
72
73
...
75
76
77
78
79
80
81
...
13
14
15
 
 
16
17
18
19
20
 
21
22
23
 
24
25
 
26
27
28
 
29
30
31
32
...
66
67
68
 
69
70
71
72
...
74
75
76
 
77
78
79
0
@@ -13,21 +13,20 @@
0
         options[:repository_type]
0
       end
0
       
0
- def determine_repository(repository_url)
0
- if repository_type
0
+ def select_repository(repository_url)
0
+ if repository_type then
0
           logger.info {"Forced repository type to #{repository_type}"}
0
           repository_class_name = "Piston::#{repository_type.downcase.capitalize}::Repository"
0
           repository_class = constantize(repository_class_name)
0
- repository = repository_class.new(repository_url)
0
+ repository repository_class.new(repository_url)
0
         else
0
           logger.info {"Guessing the repository type"}
0
- repository = Piston::Repository.guess(repository_url)
0
+ Piston::Repository.guess(repository_url)
0
         end
0
- repository
0
       end
0
 
0
       def run(repository_url, target_revision, wcdir)
0
- repository = determine_repository(repository_url)
0
+ repository = select_repository(repository_url)
0
         revision = repository.at(target_revision)
0
 
0
         wcdir = wcdir.nil? ? repository.basename : wcdir
0
@@ -67,7 +66,7 @@
0
       end
0
       
0
       protected
0
- # riped out of activesupport
0
+ # Copied from ActiveSupport
0
       def constantize(camel_cased_word)
0
         unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ camel_cased_word
0
           raise NameError, "#{camel_cased_word.inspect} is not a valid constant name!"
0
@@ -75,7 +74,6 @@
0
       
0
         Object.module_eval("::#{$1}", __FILE__, __LINE__)
0
       end
0
-
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
20
21
0
@@ -1 +1,22 @@
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(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
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
0
@@ -1 +1,29 @@
0
+require "piston/commands/base"
0
+
0
+module Piston
0
+ module Commands
0
+ class Update < Piston::Commands::Base
0
+ # +wcdir+ is the working copy we're going to change.
0
+ # +to+ is the new target revision we want to be at after update returns.
0
+ def run(wcdir, to)
0
+ working_copy = Piston::WorkingCopy.guess(wcdir)
0
+
0
+ logger.debug {"Recalling previously saved values"}
0
+ values = working_copy.recall
0
+
0
+ repository_class = values["repository_class"]
0
+ repository_url = values["repository_url"]
0
+ repository = repository_class.constantize.new(repository_url)
0
+ from_revision = repository.at(values["handler"])
0
+ to_revision = repository.at(to)
0
+
0
+ logger.debug {"Validating that #{from_revision} exists and is capable of performing the update"}
0
+ from_revision.validate!
0
+
0
+ logger.info {"Updating from #{from_revision} to #{to_revision}"}
0
+ working_copy.apply_differences(from_revision.differences_with(to_revision))
0
+ end
0
+ end
0
+ end
0
+end
...
11
12
13
14
 
15
16
17
18
...
43
44
45
46
47
 
48
49
50
51
 
 
 
 
52
53
54
...
11
12
13
 
14
15
16
17
18
...
43
44
45
 
 
46
47
48
49
50
51
52
53
54
55
56
57
0
@@ -11,7 +11,7 @@
0
 
0
       def guess(url)
0
         logger.info {"Guessing the repository type of #{url.inspect}"}
0
-
0
+
0
         handler = handlers.detect do |handler|
0
           logger.debug {"Asking #{handler}"}
0
           handler.understands_url?(url)
0
0
@@ -43,12 +43,15 @@
0
     end
0
 
0
     def at(revision)
0
- logger.info {"Targeting #{self} at #{revision.inspect}"}
0
- Piston::Revision.new(self, revision)
0
+ raise SubclassResponsibilityError, "Piston::Repository#at should be implemented by a subclass."
0
     end
0
 
0
     def to_s
0
       "Piston::Repository(#{@url})"
0
+ end
0
+
0
+ def ==(other)
0
+ url == other.url
0
     end
0
   end
0
 end
...
13
14
15
16
 
17
18
19
...
37
38
39
40
 
41
42
43
...
13
14
15
 
16
17
18
19
...
37
38
39
 
40
41
42
43
0
@@ -13,7 +13,7 @@
0
     def initialize(repository, revision)
0
       @repository, @revision = repository, revision
0
     end
0
-
0
+
0
     def name
0
       @revision
0
     end
0
@@ -37,7 +37,7 @@
0
       {}
0
     end
0
 
0
- # Yields each file of this revision in turn to our callers.
0
+ # Yields each file of this revision in turn to our caller.
0
     def each
0
     end
0
 
...
1
2
3
 
4
5
6
...
46
47
48
 
 
 
 
 
49
50
51
...
1
2
3
4
5
6
7
...
47
48
49
50
51
52
53
54
55
56
57
0
@@ -1,6 +1,7 @@
0
 module Piston
0
   class WorkingCopy
0
     class UnhandledWorkingCopy < RuntimeError; end
0
+ class NotWorkingCopy < RuntimeError; end
0
 
0
     class << self
0
       def logger
0
@@ -46,6 +47,11 @@
0
     end
0
 
0
     def exist?
0
+ @path.exist? && @path.directory?
0
+ end
0
+
0
+ def pistonized?
0
+ yaml_path.exist? && yaml_path.file?
0
     end
0
 
0
     # Creates the initial working copy for pistonizing a new repository.
...
 
 
...
1
2
0
@@ -1 +1,3 @@
0
+class SubclassResponsibilityError < RuntimeError
0
+end
...
5
6
7
8
 
9
10
11
12
13
14
15
 
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
...
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
0
@@ -5,14 +5,35 @@
0
     t.libs << "test"
0
     t.test_files = FileList['test/unit/**/test_*.rb']
0
     t.verbose = true
0
- t.warning = true
0
+ t.warning = false
0
   end
0
 
0
   Rake::TestTask.new("integration") do |t|
0
     t.libs << "test"
0
     t.test_files = FileList['test/integration/**/test_*.rb']
0
     t.verbose = true
0
- t.warning = true
0
+ t.warning = false
0
   end
0
+
0
+ Rake::TestTask.new("recent") do |t|
0
+ t.libs << "test"
0
+ t.verbose = true
0
+ t.warning = false
0
+
0
+ # 10 minutes ago
0
+ cutoff_at = Time.now - 10 * 60
0
+
0
+ t.test_files = FileList["test/integration/**/test_*.rb", "test/unit/**/test_*.rb"].select do |path|
0
+ File.mtime(path) > cutoff_at
0
+ end
0
+ end
0
+end
0
+
0
+Rake::TestTask.new("test") do |t|
0
+ Rake::Task["test:units"].invoke
0
+ Rake::Task["test:integration"].invoke
0
+
0
+ # Don't run the default test task
0
+ exit 0
0
 end
...
2
3
4
 
5
6
7
...
30
31
32
33
 
34
35
36
...
41
42
43
 
44
45
46
...
2
3
4
5
6
7
8
...
31
32
33
 
34
35
36
37
...
42
43
44
45
46
47
48
0
@@ -2,6 +2,7 @@
0
 require "rubygems"
0
 require "mocha"
0
 require "log4r"
0
+require "fileutils"
0
 
0
 require File.dirname(__FILE__) + "/../config/requirements"
0
 
0
@@ -30,7 +31,7 @@
0
   end
0
 end
0
 
0
-LOG_DIR = Pathname.new(File.dirname(__FILE__) + "/../log"))
0
+LOG_DIR = Pathname.new(File.dirname(__FILE__) + "/../log") unless Object::const_defined?(:LOG_DIR)
0
 LOG_DIR.mkdir rescue nil
0
 
0
 Log4r::Logger.root.level = Log4r::DEBUG
0
@@ -41,6 +42,7 @@
0
 Log4r::Logger.new("handler::client::out")
0
 Log4r::Logger.new("test")
0
 
0
+FileUtils.touch("#{LOG_DIR}/test.log")
0
 Log4r::FileOutputter.new("log", :trunc => true, :filename => (LOG_DIR + "test.log").realpath.to_s)
0
 
0
 Log4r::Logger["main"].add "log"
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
53
54
55
56
57
58
0
@@ -1 +1,59 @@
0
+require File.dirname(__FILE__) + "/../test_helper"
0
+
0
+class TestLockUnlock < Test::Unit::TestCase
0
+ def setup
0
+ @values = {"lock" => false}
0
+ @wcdir = "tmp/wcdir"
0
+ @wc = mock("WorkingCopy")
0
+ end
0
+
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.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
+ 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(lock=true)
0
+ yield
0
+ lock_unlock_command.run(@wcdir, lock)
0
+ end
0
+
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
...
1
2
3
4
5
6
7
8
9
10
11
...
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,12 +1 @@
0
-require File.dirname(__FILE__) + '/../test_helper.rb'
0
-
0
-class TestPiston < Test::Unit::TestCase
0
-
0
- def setup
0
- end
0
-
0
- def test_truth
0
- assert true
0
- end
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
48
49
50
0
@@ -1 +1,51 @@
0
+require File.dirname(__FILE__) + "/../test_helper"
0
+
0
+class TestRepository < Test::Unit::TestCase
0
+ def setup
0
+ Piston::Repository.send(:handlers).clear
0
+ end
0
+
0
+ def test_guess_asks_each_handler_in_turn
0
+ Piston::Repository.add_handler(handler = mock("handler"))
0
+ handler.expects(:understands_url?).with("http://a.repos.com/trunk").returns(false)
0
+ assert_raise Piston::Repository::UnhandledUrl do
0
+ Piston::Repository.guess("http://a.repos.com/trunk")
0
+ end
0
+ end
0
+
0
+ def test_guess_returns_first_handler_that_understands_the_url
0
+ url = "svn://a.repos.com/projects/libcalc/trunk"
0
+
0
+ handler = mock("handler")
0
+ handler.expects(:understands_url?).with(url).returns(true)
0
+ handler_instance = mock("handler_instance")
0
+ handler.expects(:new).with(url).returns(handler_instance)
0
+
0
+ Piston::Repository.add_handler handler
0
+ assert_equal handler_instance, Piston::Repository.guess(url)
0
+ end
0
+
0
+ def test_guess_raises_unhandled_url_exception_when_no_repository_handler_found
0
+ assert_raise(Piston::Repository::UnhandledUrl) do
0
+ Piston::Repository.guess("invalid")
0
+ end
0
+ end
0
+
0
+ def test_add_handler
0
+ Piston::Repository.add_handler(handler = mock("handler"))
0
+ assert_equal [handler], Piston::Repository.send(:handlers)
0
+ end
0
+
0
+ def test_initialize_stores_url_parameter_in_url_accessor
0
+ @repository = Piston::Repository.new("url")
0
+ assert_equal "url", @repository.url
0
+ end
0
+
0
+ def test_at_is_a_subclass_responsibility
0
+ @repository = Piston::Repository.new("url")
0
+ assert_raise(SubclassResponsibilityError) do
0
+ @repository.at(:any)
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
20
21
22
23
24
25
26
27
28
29
30
31
32
33
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,34 +1 @@
0
-require File.dirname(__FILE__) + "/../test_helper"
0
-
0
-class TestRepositoryGuessing < Test::Unit::TestCase
0
- def setup
0
- Piston::Repository.send(:handlers).clear
0
- end
0
-
0
- def test_guess_when_no_handlers_raises
0
- assert_raise Piston::Repository::UnhandledUrl do
0
- Piston::Repository.guess("http://")
0
- end
0
- end
0
-
0
- def test_guess_asks_each_handler_in_turn
0
- Piston::Repository.add_handler(handler = mock("handler"))
0
- handler.expects(:understands_url?).with("http://a.repos.com/trunk").returns(false)
0
- assert_raise Piston::Repository::UnhandledUrl do
0
- Piston::Repository.guess("http://a.repos.com/trunk")
0
- end
0
- end
0
-
0
- def test_guess_returns_first_handler_that_understands_the_url
0
- url = "svn://a.repos.com/projects/libcalc/trunk"
0
-
0
- handler = mock("handler")
0
- handler.expects(:understands_url?).with(url).returns(true)
0
- handler_instance = mock("handler_instance")
0
- handler.expects(:new).with(url).returns(handler_instance)
0
-
0
- Piston::Repository.add_handler handler
0
- assert_equal handler_instance, Piston::Repository.guess(url)
0
- end
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
0
@@ -1 +1,27 @@
0
+require File.dirname(__FILE__) + "/../test_helper"
0
+
0
+class TestRevision < Test::Unit::TestCase
0
+ def setup
0
+ @repository = mock("repository")
0
+ @revision_number = "1"
0
+ @revision = Piston::Revision.new(@repository, @revision_number)
0
+ end
0
+
0
+ def test_initialize
0
+ assert_equal @repository, @revision.repository
0
+ assert_equal @revision_number, @revision.revision
0
+ end
0
+
0
+ def test_repository
0
+ assert_equal @repository, @revision.repository
0
+ end
0
+
0
+ def test_revision
0
+ assert_equal @revision_number, @revision.revision
0
+ end
0
+
0
+ def test_name
0
+ assert_equal @revision_number, @revision.name
0
+ end
0
+end

Comments

    No one has commented yet.