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 #!/usr/bin/env ruby 2 # 3 # Import an SVN repository into an SVN working copy. 4 require File.dirname(__FILE__) + "/common" 5 6 @root = @root + "tmp/git_git" 7 @root.rmtree rescue nil 8 @root.mkpath 9 10 @tmp = @root + "plugin.tmp" 11 12 @plugin = @root + "plugin" 13 @plugin.mkpath 14 File.open(@plugin + "README", "wb") {|f| f.puts "Hello World"} 15 File.open(@plugin + "init.rb", "wb") {|f| f.puts "# Some init code"} 16 Dir.chdir(@plugin) do 17 git :init 18 git :add, "." 19 git :commit, "-m", "initial commit" 20 end 21 22 @wc = @root + "wc" 23 @wc.mkpath 24 File.open(@wc + "README", "wb") {|f| f.puts "My local project"} 25 Dir.chdir(@wc) do 26 git :init 27 git :add, "." 28 git :commit, "-m", "initial commit" 29 end 30 31 repos = Piston::Git::Repository.new("file://" + @plugin.realpath) 32 commit = repos.at(:head) 33 commit.checkout_to(@tmp) 34 35 wc = Piston::Git::WorkingCopy.new(@wc + "vendor") 36 wc.create 37 wc.copy_from(commit) 38 wc.remember(commit.remember_values) 39 wc.finalize
samples/import_git_svn.rb
1 #!/usr/bin/env ruby 2 # 3 # Import a Git project into a Subversion working copy. 4 require File.dirname(__FILE__) + "/common" 5 6 @root = @root + "tmp/git_svn" 7 @root.rmtree rescue nil 8 @root.mkpath 9 10 @repos = @root + "repos" 11 @wc = @root + "wc" 12 13 @plugin = @root + "plugin" 14 @tmp = @root + "plugin.tmp" 15 16 svnadmin :create, @repos 17 svn :checkout, "--quiet", "file://" + @repos.realpath, @wc 18 19 @plugin.mkpath 20 File.open(@plugin + "README", "wb") {|f| f.puts "Hello World"} 21 File.open(@plugin + "init.rb", "wb") {|f| f.puts "# Some initialization code here"} 22 Dir.chdir(@plugin) do 23 logger.debug {"CWD: #{Dir.getwd}"} 24 git :init 25 git :add, "." 26 git :commit, "-m", "initial commit" 27 end 28 29 repos = Piston::Git::Repository.new("file://" + @plugin.realpath) 30 commit = repos.at(:head) 31 commit.checkout_to(@tmp) 32 wc = Piston::Svn::WorkingCopy.new(@wc + "vendor") 33 wc.create 34 wc.copy_from(commit) 35 wc.remember(commit.remember_values) 36 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.