Finished implementing Piston::Commands::Import
git-svn-id: svn+ssh://rubyforge.org/var/svn/piston/trunk@124 d6c2ea82-c31b-0410-8381-e9c44f9824c5
| |   |
| 12 | 12 | |
| 13 | 13 | @wc = Piston::WorkingCopy.new(@path, :logger => options[:logger]) |
| 14 | 14 | @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 | | "} |
| 20 | 15 | raise Piston::LocalChangesPending.new(@root.dir) unless @root.status(true).grep(/#{@wc.path}/).empty? |
| 21 | 16 | end |
| 22 | 17 | |
| 23 | 18 | def run |
| 24 | 19 | @wc.export(@repos.url) |
| 25 | 20 | @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) |
| 26 | 24 | end |
| 27 | 25 | |
| 28 | 26 | def debug(&block) |
| toggle raw diff |
--- a/lib/piston/commands/import.rb
+++ b/lib/piston/commands/import.rb
@@ -12,17 +12,15 @@ module Piston
@wc = Piston::WorkingCopy.new(@path, :logger => options[:logger])
@root = @wc.parent
- debug {"
-#{@root.status(true).to_yaml}
-#{@wc.path.to_s}
-#{@root.status(true).grep(/#{@wc.path.to_s}/).to_yaml}
-"}
raise Piston::LocalChangesPending.new(@root.dir) unless @root.status(true).grep(/#{@wc.path}/).empty?
end
def run
@wc.export(@repos.url)
@root.add(@wc.path)
+ @wc.propset(Piston::REMOTE_UUID, @repos.uuid)
+ @wc.propset(Piston::REMOTE_REVISION, @repos.youngest)
+ @wc.propset(Piston::LOCAL_REVISION, @wc.last_changed_revision || 0)
end
def debug(&block) |
| |   |
| 24 | 24 | @wc.status.should include("A #{@wc.path + "vendor"}") |
| 25 | 25 | end |
| 26 | 26 | |
| 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 |
| 30 | 42 | end |
| 31 | 43 | |
| 32 | 44 | describe Piston::Commands::Import, "#run(upstream_url, 'vendor/') with pending changes" do |
| … | … | |
| 69 | 69 | end |
| 70 | 70 | end |
| 71 | 71 | |
| 72 | | describe Piston::Commands::Import, "#run(upstream_url, 'vendor/') with an unrelated pending changes" do |
| 72 | describe Piston::Commands::Import, "#run(upstream_url, 'vendor/') with an unrelated pending change" do |
| 73 | 73 | it_should_behave_like "An upstream repository with no copies/renames" |
| 74 | 74 | |
| 75 | 75 | before do |
| toggle raw diff |
--- a/spec/import_spec.rb
+++ b/spec/import_spec.rb
@@ -24,9 +24,21 @@ describe Piston::Commands::Import, "#run(upstream_url, 'vendor/')" do
@wc.status.should include("A #{@wc.path + "vendor"}")
end
- it "should have copied the upstream repository's UUID as a property on the import path"
- it "should have copied the upstream revision as a property on the import path"
- it "should have copied the local revision as a property on the import path"
+ it "should have copied the upstream repository's UUID as a property on the import path" do
+ @wc.propget(Piston::REMOTE_UUID, "vendor").should == @upstream.uuid
+ end
+
+ it "should have copied the upstream revision as a property on the import path" do
+ @wc.propget(Piston::REMOTE_REVISION, "vendor").should == @upstream.youngest
+ end
+
+ it "should NOT have locked the folder" do
+ @wc.propget(Piston::LOCKED, "vendor").should be_nil
+ end
+
+ it "should have copied the last changed revision of the local working copy as a property on the import path" do
+ @wc.propget(Piston::LOCAL_REVISION, "vendor").should == 0
+ end
end
describe Piston::Commands::Import, "#run(upstream_url, 'vendor/') with pending changes" do
@@ -57,7 +69,7 @@ describe Piston::Commands::Import, "#run(upstream_url, 'vendor/') with pending c
end
end
-describe Piston::Commands::Import, "#run(upstream_url, 'vendor/') with an unrelated pending changes" do
+describe Piston::Commands::Import, "#run(upstream_url, 'vendor/') with an unrelated pending change" do
it_should_behave_like "An upstream repository with no copies/renames"
before do
|