Commit d2c7b7236e1c5cff44be820132884d2507e3e45a

Added a couple more specificiations for the import command.

git-svn-id: svn+ssh://rubyforge.org/var/svn/piston/trunk@127 d6c2ea82-c31b-0410-8381-e9c44f9824c5

Commit diff

lib/piston/commands/import.rb

 
1111 raise Piston::UnknownRepository, @repos.url unless @repos.exists?
1212
1313 @wc = Piston::WorkingCopy.new(@path, :logger => options[:logger])
14 @root = @wc.parent
14 @root = @wc.up
1515 raise Piston::LocalChangesPending.new(@root.dir) unless @root.status(true).grep(/#{@wc.path}/).empty?
1616 end
1717
1818 def run
19 @wc.export(@repos.url)
19 @revision = @options[:revision] || @repos.youngest
20 @wc.export(@repos.url, @revision)
2021 @root.add(@wc.path)
22
23 @wc.propset(Piston::REMOTE_ROOT, @repos.url)
2124 @wc.propset(Piston::REMOTE_UUID, @repos.uuid)
22 @wc.propset(Piston::REMOTE_REVISION, @repos.youngest)
25 @wc.propset(Piston::REMOTE_REVISION, @revision)
2326 @wc.propset(Piston::LOCAL_REVISION, @wc.last_changed_revision || 0)
27 @wc.propset(Piston::LOCKED, "*") if @options[:lock]
2428 end
2529
2630 def debug(&block)
toggle raw diff

spec/import_spec.rb

 
2828 @wc.propget(Piston::REMOTE_UUID, "vendor").should == @upstream.uuid
2929 end
3030
31 it "should have copied the upstream repository's URL as a property on the import path" do
32 @wc.propget(Piston::REMOTE_ROOT, "vendor").should == @upstream.url
33 end
34
3135 it "should have copied the upstream revision as a property on the import path" do
3236 @wc.propget(Piston::REMOTE_REVISION, "vendor").should == @upstream.youngest
3337 end
104104 raise_error(Piston::UnknownRepository)
105105 end
106106end
107
108describe Piston::Commands::Import, "#run(upstream_url, 'vendor/', :lock => true)" do
109 it_should_behave_like "An upstream repository with no copies/renames"
110
111 before do
112 @repos = Piston::Repository.new("file://" + self.tmppath(:repos)).create!
113 @wc = Piston::WorkingCopy.new(self.tmppath(:wc))
114 @wc.checkout(@repos.url)
115
116 Piston::Commands::Import.new(@upstream.url, @wc.path + "vendor", :logger => self.logger, :lock => true).run
117 end
118
119 it "should have locked the folder" do
120 @wc.propget(Piston::LOCKED, "vendor").should == "*"
121 end
122end
123
124describe Piston::Commands::Import, "#run(upstream_url, 'vendor/', :revision => 1)" do
125 it_should_behave_like "An upstream repository with no copies/renames"
126
127 before do
128 @repos = Piston::Repository.new("file://" + self.tmppath(:repos)).create!
129 @wc = Piston::WorkingCopy.new(self.tmppath(:wc))
130 @wc.checkout(@repos.url)
131
132 Piston::Commands::Import.new(@upstream.url, @wc.path + "vendor", :logger => self.logger, :revision => 1).run
133 @wc = @wc.down("vendor")
134 end
135
136 it "should have exported revision 1" do
137 lambda { @wc.cat("LICENSE") }.should raise_error(Piston::WorkingCopy::FileNotFound)
138 end
139
140 it "should remember the remote revision was 1, not HEAD" do
141 @wc.propget(Piston::REMOTE_REVISION).should == 1
142 end
143end
144
145describe Piston::Commands::Import, "#run(upstream_url, 'vendor/', :revision => 2, :lock => true)" do
146 it_should_behave_like "An upstream repository with no copies/renames"
147
148 before do
149 @repos = Piston::Repository.new("file://" + self.tmppath(:repos)).create!
150 @wc = Piston::WorkingCopy.new(self.tmppath(:wc))
151 @wc.checkout(@repos.url)
152
153 Piston::Commands::Import.new(@upstream.url, @wc.path + "vendor", :logger => self.logger, :revision => 2, :lock => true).run
154 @wc = @wc.down("vendor")
155 end
156
157 it "should have exported revision 2" do
158 lambda { @wc.cat("LICENSE") }.should_not raise_error(Piston::WorkingCopy::FileNotFound)
159 lambda { @wc.cat("README") }.should raise_error(Piston::WorkingCopy::FileNotFound)
160 end
161
162 it "should have locked the folder" do
163 @wc.propget(Piston::LOCKED).should == "*"
164 end
165
166 it "should remember the remote revision was 2, not HEAD" do
167 @wc.propget(Piston::REMOTE_REVISION).should == 2
168 end
169end
toggle raw diff