Commit 685915ab99ad28b71d6b61300d88a8b231cc97d6

Finished implementing Piston::Commands::Import

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

Commit diff

lib/piston.rb

 
1111 super "The working copy rooted at #{path} has pending changes. Please run 'svn update' before running Piston again"
1212 end
1313 end
14
15 REMOTE_UUID = "piston:remote-uuid"
16 REMOTE_REVISION = "piston:remote-revision"
17 LOCAL_REVISION = "piston:local-revision"
18 LOCKED = "piston:locked"
1419end
1520
1621require 'piston/version'
toggle raw diff

lib/piston/commands/import.rb

 
1212
1313 @wc = Piston::WorkingCopy.new(@path, :logger => options[:logger])
1414 @root = @wc.parent
15 debug {"
16#{@root.status(true).to_yaml}
17#{@wc.path.to_s}
18#{@root.status(true).grep(/#{@wc.path.to_s}/).to_yaml}
19"}
2015 raise Piston::LocalChangesPending.new(@root.dir) unless @root.status(true).grep(/#{@wc.path}/).empty?
2116 end
2217
2318 def run
2419 @wc.export(@repos.url)
2520 @root.add(@wc.path)
21 @wc.propset(Piston::REMOTE_UUID, @repos.uuid)
22 @wc.propset(Piston::REMOTE_REVISION, @repos.youngest)
23 @wc.propset(Piston::LOCAL_REVISION, @wc.last_changed_revision || 0)
2624 end
2725
2826 def debug(&block)
toggle raw diff

spec/import_spec.rb

 
2424 @wc.status.should include("A #{@wc.path + "vendor"}")
2525 end
2626
27 it "should have copied the upstream repository's UUID as a property on the import path"
28 it "should have copied the upstream revision as a property on the import path"
29 it "should have copied the local revision as a property on the import path"
27 it "should have copied the upstream repository's UUID as a property on the import path" do
28 @wc.propget(Piston::REMOTE_UUID, "vendor").should == @upstream.uuid
29 end
30
31 it "should have copied the upstream revision as a property on the import path" do
32 @wc.propget(Piston::REMOTE_REVISION, "vendor").should == @upstream.youngest
33 end
34
35 it "should NOT have locked the folder" do
36 @wc.propget(Piston::LOCKED, "vendor").should be_nil
37 end
38
39 it "should have copied the last changed revision of the local working copy as a property on the import path" do
40 @wc.propget(Piston::LOCAL_REVISION, "vendor").should == 0
41 end
3042end
3143
3244describe Piston::Commands::Import, "#run(upstream_url, 'vendor/') with pending changes" do
6969 end
7070end
7171
72describe Piston::Commands::Import, "#run(upstream_url, 'vendor/') with an unrelated pending changes" do
72describe Piston::Commands::Import, "#run(upstream_url, 'vendor/') with an unrelated pending change" do
7373 it_should_behave_like "An upstream repository with no copies/renames"
7474
7575 before do
toggle raw diff