Piston 2.0 Progress: Piston can import all four cases
As I outlined in Piston will get Git support, the four cases below are now supported (at least for importing):
| Repository | Working Copy | Strategy |
|---|---|---|
| Subversion | Subversion | Use current strategy of storing data in Subversion properties |
| Subversion | Git | Clone the Git repository, copy the files over and store the metadata as Subversion properties. Use Git to handle the merging for Piston (Yay!) |
| Git | Subversion | svn export the data and use a hidden YAML file to store the metadata in the pistonized directory |
| Git | Subversion | Use Git submodules perhaps ? Or git clone + copy + YAML |
I’m not in fact using git submodules, or anything fancy. I’m cloning the repository, and copying manually from there. So, nothing fancy. But adding new repository and working copy handlers is so easy:
samples/import_svn_svn.rb
1 2 3 4 5 6 7 8 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 39 |
#!/usr/bin/env ruby # # Import an SVN repository into an SVN working copy. require File.dirname(__FILE__) + "/common" @root = @root + "tmp/git_git" @root.rmtree rescue nil @root.mkpath @tmp = @root + "plugin.tmp" @plugin = @root + "plugin" @plugin.mkpath File.open(@plugin + "README", "wb") {|f| f.puts "Hello World"} File.open(@plugin + "init.rb", "wb") {|f| f.puts "# Some init code"} Dir.chdir(@plugin) do git :init git :add, "." git :commit, "-m", "initial commit" end @wc = @root + "wc" @wc.mkpath File.open(@wc + "README", "wb") {|f| f.puts "My local project"} Dir.chdir(@wc) do git :init git :add, "." git :commit, "-m", "initial commit" end repos = Piston::Git::Repository.new("file://" + @plugin.realpath) commit = repos.at(:head) commit.checkout_to(@tmp) wc = Piston::Git::WorkingCopy.new(@wc + "vendor") wc.create wc.copy_from(commit) wc.remember(commit.remember_values) wc.finalize |
samples/import_git_svn.rb
1 2 3 4 5 6 7 8 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 |
#!/usr/bin/env ruby # # Import a Git project into a Subversion working copy. require File.dirname(__FILE__) + "/common" @root = @root + "tmp/git_svn" @root.rmtree rescue nil @root.mkpath @repos = @root + "repos" @wc = @root + "wc" @plugin = @root + "plugin" @tmp = @root + "plugin.tmp" svnadmin :create, @repos svn :checkout, "--quiet", "file://" + @repos.realpath, @wc @plugin.mkpath File.open(@plugin + "README", "wb") {|f| f.puts "Hello World"} File.open(@plugin + "init.rb", "wb") {|f| f.puts "# Some initialization code here"} Dir.chdir(@plugin) do logger.debug {"CWD: #{Dir.getwd}"} git :init git :add, "." git :commit, "-m", "initial commit" end repos = Piston::Git::Repository.new("file://" + @plugin.realpath) commit = repos.at(:head) commit.checkout_to(@tmp) wc = Piston::Svn::WorkingCopy.new(@wc + "vendor") wc.create wc.copy_from(commit) wc.remember(commit.remember_values) wc.finalize |
Do you see the differences ? They’re all in the setup code. Once we hit commit.checkout_to, everything else is the same.
I’m almost ready to release a release candidate. This will be 1.9.0, and only support the import subcommand. It will at least expose the code to more testing than just what I have.
Oh, and no more Piston 1.3.3: Now with specifications. This version of Piston was tested right from the start.
April 23rd, 2008 at 11:09 AM
Hi,
The link “Piston 1.3.3: Now with specifications” goes to an admin edit page that is password protected.