December 12, 2006
Managing Rails Plugins with Piston
Post by Chris Wanstrath of ErrTheBlog
Piston is a tool for keeping bits and pieces of your Subversion repository in sync with a remote repository. Like svn:externals, but better. How?
With Piston, you import a remote repository and check it into your local repository. You can then go nuts modifying it or periodically sync it up with its remote origin using piston update.
There's an advent calendar full of reasons why you'd want to manage Rails plugins with Piston rather than using svn:externals. For one thing, it makes checkouts and updates faster -- code is all kept in the same repository so you don't need to query foreign repositories on every svn up. It also gives you simple control over which reversion of a plugin you keep around -- it's really not ideal to have your plugins updating to the bleeding edge all the time. You could set your external to a tag, but what plugin author uses tags? Seriously. Piston makes life easier.
Install it:
$ gem install piston -y Successfully installed piston-1.2.1
Import a plugin (from your Rails app's root directory):
$ piston import http://dev.rubyonrails.org/svn/rails/plugins/simply_helpful/ vendor/plugins/simply_helpful Exported r5630 from 'http://dev.rubyonrails.org/svn/rails/plugins/simply_helpful/' to 'vendor/plugins/simply_helpful'
Convert an existing svn:externals directory into Piston-style:
$ piston convert Importing 'http://dev.rubyonrails.org/svn/rails/trunk' to vendor/rails (-r 4720) Exported r4720 from 'http://dev.rubyonrails.org/svn/rails/trunk' to 'vendor/rails' Done converting existing svn:externals to Piston
Grab remote updates (plugin was updated, you want the updates):
$ piston update vendor/plugins/simply_helpful/ Updated to r5710 (4 changes)
See directories under Piston's watch in your project:
$ piston status vendor/plugins/simply_helpful (http://dev.rubyonrails.org/svn/rails/plugins/simply_helpful) vendor/plugins/annotate_models (http://svn.pragprog.com/Public/plugins/annotate_models) M vendor/plugins/acts_as_attachment (http://svn.techno-weenie.net/projects/plugins/acts_as_attachment/) vendor/plugins/acts_as_textiled (svn://errtheblog.com/svn/plugins/acts_as_textiled) vendor/plugins/mocha (svn://rubyforge.org/var/svn/mocha/trunk) vendor/plugins/has_many_polymorphs (svn://rubyforge.org/var/svn/polymorphs/has_many_polymorphs)
Make sure a directory can't be updated:
$ piston lock vendor/plugins/simply_helpful/ 'vendor/plugins/simply_helpful/' locked at revision 5710
Predictably, unlock:
$ piston unlock vendor/plugins/simply_helpful/ 'vendor/plugins/simply_helpful/' unlocked.
Check out Piston's daily usage page or developer François Beausoleil's blog for more slickness.