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
Miscellaneous minor changes to make everything work 'for real'
francois (author)
Sat Mar 15 11:22:42 -0700 2008
commit  9a5e41d717eb202c76908efeed3a90d284d2844f
tree    11a2d2d4f921964b5f1b87e612d35961332b44d3
parent  0cc3d9a48f776ee1f3ccf40f35afcd8f5262c868
...
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
...
9
10
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
13
14
15
16
17
 
18
19
20
0
@@ -9,30 +9,12 @@ module Piston
0
         working_copy.path.parent + ".#{working_copy.path.basename}.tmp"
0
       end
0
 
0
- def create_tmpdir(tmpdir)
0
- tmpdir_create_attempted = false
0
- begin
0
- debug {"Creating temporary directory: #{tmpdir}"}
0
- raise Errno::EEXIST if tmpdir.directory?
0
- tmpdir.mkpath
0
- rescue Errno::EEXIST
0
- if tmpdir_create_attempted then
0
- raise
0
- else
0
- tmpdir.rmtree
0
- tmpdir_create_attempted = true
0
- retry
0
- end
0
- end
0
- end
0
-
0
       def run(revision, working_copy)
0
         tmpdir = temp_dir_name(working_copy)
0
 
0
         abort("Path #{working_copy} already exists and --force not given. Aborting...") if working_copy.exist? && !force
0
 
0
         begin
0
- create_tmpdir(tmpdir)
0
           revision.checkout_to(tmpdir)
0
           working_copy.create
0
           working_copy.copy_from(revision)
...
44
45
46
 
47
48
49
 
 
 
50
51
52
...
44
45
46
47
48
49
 
50
51
52
53
54
55
0
@@ -44,9 +44,12 @@ module Piston
0
 
0
         def run_real(cmd)
0
           begin
0
+ debug {"> #{cmd.inspect}"}
0
             pid, stdin, stdout, stderr = Open4::popen4(cmd)
0
             _, cmdstatus = Process.waitpid2(pid)
0
- raise CommandError, "#{cmd.inspect} exited with status: #{cmdstatus.exitstatus}\n#{stderr.read}" unless cmdstatus.success? || cmdstatus.exitstatus == 1
0
+ debug {"> #{cmdstatus.inspect}, success? #{cmdstatus.success?}, status: #{cmdstatus.exitstatus}"}
0
+ return stdout.read if cmd =~ /status/ && cmdstatus.exitstatus == 1
0
+ raise CommandError, "#{cmd.inspect} exited with status: #{cmdstatus.exitstatus}\n#{stderr.read}" unless cmdstatus.success?
0
             return stdout.read
0
           rescue Errno::ENOENT
0
             raise BadCommand, cmd.inspect
...
1
2
 
3
4
5
...
13
14
15
 
16
17
18
...
28
29
30
 
31
32
33
 
 
 
 
34
35
36
...
1
2
3
4
5
6
...
14
15
16
17
18
19
20
...
30
31
32
33
34
35
36
37
38
39
40
41
42
43
0
@@ -1,5 +1,6 @@
0
 require "piston/git/client"
0
 require "piston/revision"
0
+require "fileutils"
0
 
0
 module Piston
0
   module Git
0
@@ -13,6 +14,7 @@ module Piston
0
         @dir = dir
0
         git(:clone, repository.url, @dir)
0
         Dir.chdir(@dir) do
0
+ logger.debug {"in dir #{@dir}"}
0
           git(:checkout, "-b", "my-#{revision}", revision)
0
           if revision == "HEAD" then
0
             response = git(:log, "-n", "1")
0
@@ -28,9 +30,14 @@ module Piston
0
           raise ArgumentError, "Never cloned + checked out" if @dir.nil?
0
           @dir.find do |path|
0
             Find.prune if path.to_s =~ %r{/[.]git}
0
+ next if @dir == path
0
             yield path.relative_path_from(@dir)
0
           end
0
         end
0
+
0
+ def copy_to(relpath, abspath)
0
+ FileUtils.cp(@dir + relpath, abspath)
0
+ end
0
       end
0
     end
0
   end
...
21
22
23
24
 
 
 
 
 
 
25
26
27
...
21
22
23
 
24
25
26
27
28
29
30
31
32
0
@@ -21,7 +21,12 @@ module Piston
0
       end
0
 
0
       def at(commit)
0
- Piston::Git::Commit.new(self, commit)
0
+ case commit
0
+ when :head
0
+ Piston::Git::Commit.new(self, "HEAD")
0
+ else
0
+ Piston::Git::Commit.new(self, commit)
0
+ end
0
       end
0
     end
0
   end
...
49
50
51
52
 
53
54
55
...
49
50
51
 
52
53
54
55
0
@@ -49,7 +49,7 @@ module Piston
0
         end
0
       end
0
 
0
- def remember_values(values)
0
+ def remember(values)
0
         File.open(path + ".piston.yml", "wb") do |f|
0
           f.write({"format" => 1, "handler" => values}.to_yaml)
0
         end
...
9
10
11
 
 
 
 
 
12
...
9
10
11
12
13
14
15
16
17
0
@@ -9,4 +9,9 @@ class TestGitRepositoryAt < Test::Unit::TestCase
0
     Piston::Git::Commit.expects(:new).with(@repos, "a93029").returns(commit = mock("commit"))
0
     assert_equal commit, @repos.at("a93029")
0
   end
0
+
0
+ def test_returns_a_piston_git_commit_at_head_when_appropriate
0
+ Piston::Git::Commit.expects(:new).with(@repos, "HEAD").returns(commit = mock("commit"))
0
+ assert_equal commit, @repos.at(:head)
0
+ end
0
 end
...
12
13
14
15
 
16
17
18
19
20
21
 
22
23
24
...
12
13
14
 
15
16
17
18
19
20
 
21
22
23
24
0
@@ -12,13 +12,13 @@ class TestGitWorkingCopyRememberance < Test::Unit::TestCase
0
   end
0
 
0
   def test_creates_dot_piston_dot_yml_file
0
- @wc.remember_values("a" => "b")
0
+ @wc.remember("a" => "b")
0
     assert((@wcdir + ".piston.yml").exist?)
0
   end
0
 
0
   def test_writes_values_as_yaml_under_handler_key
0
     expected = {"a" => "b"}
0
- @wc.remember_values(expected)
0
+ @wc.remember(expected)
0
     actual = YAML.load((@wcdir + ".piston.yml").read)
0
     assert_equal expected, actual["handler"]
0
   end
...
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
...
15
16
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
0
@@ -15,32 +15,4 @@ class TestImport < Test::Unit::TestCase
0
     @wc.stubs(:path).returns(Pathname.new("tmp/a/dir"))
0
     assert_equal Pathname.new("tmp/a/.dir.tmp"), @cmd.temp_dir_name(@wc)
0
   end
0
-
0
- def test_create_tmpdir_creates_specified_dir
0
- tmpdir = Pathname.new("tmp/newdir")
0
- begin
0
- tmpdir.rmtree rescue nil
0
- @cmd.create_tmpdir(tmpdir)
0
- assert tmpdir.exist?, "#{tmpdir} doesn't exist"
0
- assert tmpdir.directory?, "#{tmpdir} isn't a directory"
0
- ensure
0
- tmpdir.rmtree
0
- end
0
- end
0
-
0
- def test_create_tmpdir_removes_existing_dir_and_creates_again
0
- tmpdir = Pathname.new("tmp/newdir")
0
- begin
0
- tmpdir.rmtree rescue nil
0
- tmpdir.mkpath
0
- file = tmpdir + "a.rb"
0
- File.open(file, "wb") {|f| f.write "bla" }
0
- @cmd.create_tmpdir(tmpdir)
0
- assert tmpdir.exist?, "#{tmpdir} doesn't exist"
0
- assert tmpdir.directory?, "#{tmpdir} isn't a directory"
0
- deny file.exist?, "#{file} still exists"
0
- ensure
0
- tmpdir.rmtree
0
- end
0
- end
0
 end

Comments

    No one has commented yet.