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
Implemented PistonCore::Repository#guess and 
PistonCore::WorkingCopy#guess.
francois (author)
Fri Mar 14 08:43:13 -0700 2008
commit  1c649fa32c3214e49c2263b94585e6d396cec0dd
tree    26b7679658bb6268b735723a9d09670592eb4d29
parent  ce4e3684bae50773af74563daa5bd61134afec32
...
2
3
4
 
 
5
6
7
...
14
15
16
17
 
 
 
 
 
 
 
 
 
 
 
 
18
19
20
...
2
3
4
5
6
7
8
9
...
16
17
18
 
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
0
@@ -2,6 +2,8 @@ require "piston_core/revision"
0
 
0
 module PistonCore
0
   class Repository
0
+ class UnhandledUrl < RuntimeError; end
0
+
0
     class << self
0
       def logger
0
         @@logger
0
@@ -14,7 +16,18 @@ module PistonCore
0
 
0
       def guess(url)
0
         logger.debug {"Guessing the repository type of #{url.inspect}"}
0
- self.new(url)
0
+
0
+ handler = self.handlers.detect do |handler|
0
+ handler.understands_url?(url)
0
+ end
0
+
0
+ raise UnhandledUrl, "No internal handlers found for #{url.inspect}. Do you want to help ?" if handler.nil?
0
+ handler.new(url)
0
+ end
0
+
0
+ @@handlers = Array.new
0
+ def handlers
0
+ @@handlers
0
       end
0
     end
0
 
...
1
2
 
 
3
4
5
...
11
12
13
14
 
 
 
 
 
 
 
 
 
 
 
15
16
17
...
1
2
3
4
5
6
7
...
13
14
15
 
16
17
18
19
20
21
22
23
24
25
26
27
28
29
0
@@ -1,5 +1,7 @@
0
 module PistonCore
0
   class WorkingCopy
0
+ class UnhandledWorkingCopy < RuntimeError; end
0
+
0
     class << self
0
       def logger=(logger)
0
         @@logger = logger
0
@@ -11,7 +13,17 @@ module PistonCore
0
 
0
       def guess(path)
0
         logger.debug {"Guessing the working copy type of #{path.inspect}"}
0
- self.new(path)
0
+ handler = self.handlers.detect do |handler|
0
+ handler.understands_dir?(path)
0
+ end
0
+
0
+ raise UnhandledWorkingCopy, "Don't know what working copy type #{path} is." if handler.nil?
0
+ handler.new(path)
0
+ end
0
+
0
+ @@handlers = Array.new
0
+ def handlers
0
+ @@handlers
0
       end
0
     end
0
 

Comments

    No one has commented yet.