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/tapajos/piston.git
Fixed deletion of .piston.yml files during updates.
btakita (author)
Tue Aug 26 00:35:03 -0700 2008
commit  2a134f3bd1922cc3a344a6d21d63ced2c812c56c
tree    0c7a94d92fdcd98982f63b955a2cd1f5e69d1238
parent  eb1f01bc6a26b8b0100d256fa2d274e5d6aeb81b
...
39
40
41
42
43
44
45
46
47
48
...
39
40
41
 
 
 
 
42
43
44
0
@@ -39,10 +39,6 @@ module Piston
0
         wc.validate!
0
         wc
0
       end
0
-
0
- def temp_dir_name(working_copy)
0
- working_copy.path.parent + ".#{working_copy.path.basename}.tmp"
0
- end
0
     end
0
   end
0
 end
...
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
59
60
61
 
 
62
63
64
...
30
31
32
 
 
33
34
35
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
38
39
40
41
0
@@ -30,35 +30,12 @@ module Piston
0
         logger.debug {"repository_url: #{repository_url.inspect}, target_revision: #{target_revision.inspect}, wcdir: #{wcdir.inspect}"}
0
         working_copy = guess_wc(wcdir)
0
 
0
- tmpdir = temp_dir_name(working_copy)
0
-
0
         if working_copy.exist? && !force then
0
           logger.fatal "Path #{working_copy} already exists and --force not given. Aborting..."
0
           abort
0
         end
0
-
0
- begin
0
- logger.info {"Checking out the repository"}
0
- revision.checkout_to(tmpdir)
0
-
0
- logger.debug {"Creating the local working copy"}
0
- working_copy.create
0
-
0
- logger.info {"Copying from #{revision}"}
0
- working_copy.copy_from(revision)
0
-
0
- logger.debug {"Remembering values"}
0
- working_copy.remember({:repository_url => repository.url, :lock => options[:lock], :repository_class => repository.class.name},
0
- revision.remember_values)
0
-
0
- logger.debug {"Finalizing working copy"}
0
- working_copy.finalize
0
-
0
- logger.info {"Checked out #{repository_url.inspect} #{revision.name} to #{wcdir.inspect}"}
0
- ensure
0
- logger.debug {"Removing temporary directory: #{tmpdir}"}
0
- tmpdir.rmtree rescue nil
0
- end
0
+
0
+ working_copy.import(revision, options[:lock])
0
       end
0
     end
0
   end
...
22
23
24
25
26
27
28
29
30
31
32
33
 
34
35
36
...
22
23
24
 
 
 
 
 
 
 
 
 
25
26
27
28
0
@@ -22,15 +22,7 @@ module Piston
0
 
0
         logger.info {"Updating from #{from_revision} to #{to_revision}"}
0
 
0
- tmpdir = temp_dir_name(working_copy)
0
- to_revision.checkout_to(tmpdir)
0
-
0
- begin
0
- working_copy.update(from_revision, to_revision, tmpdir, options[:lock])
0
- ensure
0
- logger.debug {"Removing temporary directory: #{tmpdir}"}
0
- tmpdir.rmtree rescue nil
0
- end
0
+ working_copy.update(to_revision, options[:lock])
0
       end
0
     end
0
   end
...
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
79
80
...
58
59
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
0
@@ -58,23 +58,33 @@ module Piston
0
         Dir.chdir(path) { git(:add, ".") }
0
       end
0
 
0
- def update(from, to, tmpdir, lock)
0
- puts "tmpdir: #{tmpdir}"
0
- puts "exist? #{tmpdir.exist?}"
0
- puts "file? #{tmpdir.file?}"
0
- puts "directory? #{tmpdir.directory?}"
0
- path.children.reject {|item| ['.git', '.piston.yml'].include?(item.basename.to_s)}.each do |item|
0
- puts "rm -rf #{item}"
0
- FileUtils.rm_rf(item)
0
- end
0
- tmpdir.children.reject {|item| item.basename.to_s == '.git'}.each do |item|
0
- puts "cp -r #{item} #{path}"
0
- FileUtils.cp_r(item, path)
0
- end
0
- FileUtils.rm_rf(tmpdir)
0
- Dir.chdir(path) do
0
- remember(recall.merge(:lock => lock), to.remember_values)
0
- git(:add, ".")
0
+ def update(to, lock)
0
+ tmpdir = temp_dir_name
0
+ begin
0
+ to.checkout_to(tmpdir)
0
+ puts "tmpdir: #{tmpdir}"
0
+ puts "exist? #{tmpdir.exist?}"
0
+ puts "file? #{tmpdir.file?}"
0
+ puts "directory? #{tmpdir.directory?}"
0
+ path.children.reject {|item| ['.git', '.piston.yml'].include?(item.basename.to_s)}.each do |item|
0
+ puts "rm -rf #{item}"
0
+ FileUtils.rm_rf(item)
0
+ end
0
+ tmpdir.children.reject {|item| item.basename.to_s == '.git'}.each do |item|
0
+ puts "cp -r #{item} #{path}"
0
+ FileUtils.cp_r(item, path)
0
+ end
0
+ Dir.chdir(path) do
0
+ repository = to.repository
0
+ remember(
0
+ {:repository_url => repository.url, :lock => lock, :repository_class => repository.class.name},
0
+ to.remember_values
0
+ )
0
+ git(:add, ".")
0
+ end
0
+ ensure
0
+ logger.debug {"Removing temporary directory: #{tmpdir}"}
0
+ tmpdir.rmtree rescue nil
0
         end
0
       end
0
     end
...
78
79
80
81
82
83
84
85
86
 
 
 
 
 
 
 
 
 
 
 
 
 
87
88
89
 
90
91
92
...
78
79
80
 
 
 
 
 
 
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
 
96
97
98
99
0
@@ -78,15 +78,22 @@ module Piston
0
         end
0
       end
0
 
0
- def update(from, to, tmpdir, lock)
0
- logger.info "Copying new changes in place"
0
- copy_from(to)
0
- logger.info "Merging local changes into working copy"
0
- merge_changes(from, to, tmpdir)
0
- remember(recall.merge(:lock => lock), to.remember_values)
0
+ def update(to, lock)
0
+ tmpdir = temp_dir_name
0
+ begin
0
+ to.checkout_to(tmpdir)
0
+ logger.info "Copying new changes in place"
0
+ copy_from(to)
0
+ logger.info "Merging local changes into working copy"
0
+ merge_changes(to)
0
+ remember(recall.merge(:lock => lock), to.remember_values)
0
+ ensure
0
+ logger.debug {"Removing temporary directory: #{tmpdir}"}
0
+ tmpdir.rmtree rescue nil
0
+ end
0
       end
0
 
0
- def merge_changes(from, to, tmpdir)
0
+ def merge_changes(to)
0
         data = svn(:info, yaml_path)
0
         info = YAML.load(data)
0
         initial_revision = info["Last Changed Rev"].to_i
...
119
120
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
123
124
125
126
 
 
 
 
127
128
129
...
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
0
@@ -119,11 +119,44 @@ module Piston
0
       recall
0
     end
0
 
0
+ def import(revision, lock)
0
+ repository = revision.repository
0
+ tmpdir = temp_dir_name
0
+ begin
0
+ logger.info {"Checking out the repository"}
0
+ revision.checkout_to(tmpdir)
0
+
0
+ logger.debug {"Creating the local working copy"}
0
+ create
0
+
0
+ logger.info {"Copying from #{revision}"}
0
+ copy_from(revision)
0
+
0
+ logger.debug {"Remembering values"}
0
+ remember(
0
+ {:repository_url => repository.url, :lock => lock, :repository_class => repository.class.name},
0
+ revision.remember_values
0
+ )
0
+
0
+ logger.debug {"Finalizing working copy"}
0
+ finalize
0
+
0
+ logger.info {"Checked out #{repository_url.inspect} #{revision.name} to #{wcdir.inspect}"}
0
+ ensure
0
+ logger.debug {"Removing temporary directory: #{tmpdir}"}
0
+ tmpdir.rmtree rescue nil
0
+ end
0
+ end
0
+
0
     # Update this working copy from +from+ to +to+, which means merging local changes back in
0
     def update(from, to, todir)
0
       logger.debug {"Updating"}
0
     end
0
 
0
+ def temp_dir_name
0
+ path.parent + ".#{path.basename}.tmp"
0
+ end
0
+
0
     protected
0
     # The path to the piston YAML file.
0
     def yaml_path
...
18
19
20
21
 
22
23
24
25
26
27
28
 
29
30
31
...
18
19
20
 
21
22
23
24
25
26
27
 
28
29
30
31
0
@@ -18,14 +18,14 @@ class Piston::Svn::TestMerging < PistonTestCase
0
     @wc.stubs(:svn).returns()
0
     @wc.expects(:svn).with(:info, @wcdir + ".piston.yml").returns(PISTON_YML_INFO)
0
 
0
- @wc.merge_changes(@from, @to, @todir)
0
+ @wc.merge_changes(@to)
0
   end
0
 
0
   def test_merging_asks_svn_to_merge_all_changes_since_last_change_plus_one_on_dot_piston_yml_file
0
     @to.stubs(:revision).returns(9999)
0
     @wc.stubs(:svn).with(:info, anything).returns(PISTON_YML_INFO)
0
     @wc.expects(:svn).with(:merge, "--revision", "9223:#{@to.revision}", @wcdir, @wcdir).returns()
0
- @wc.merge_changes(@from, @to, @todir)
0
+ @wc.merge_changes(@to)
0
   end
0
 
0
   PISTON_YML_INFO = <<-EOF

Comments

    No one has commented yet.