Bill de hÓra:
It occurred to me that by setting up a local hg, I had in fact branched, but without the overhead and ceremony associated with branches. Driving the cost of branches to zero is transformational.
Indeed.
I've been experimenting with Bazaar for a little while and had a strange idea: why not use branches as a project template mechanism?
$ bzr branch http://tomayko.com/src/ruby-project devel/hello-bill
$ cd devel/hello-bill
$ cat <<. > lib/hello.rb
#!/usr/bin/env ruby
puts 'Hello, Bill'"
.
$ chmod +x bin/hello
$ bzr add && bzr commit -m "say hi to bill"
added bin/hello-bill
added lib/hello.rb
Committed revision 23.
$ cat < Rakefile
load 'misc/asciidoc.rake'
load 'misc/project.rake'
Project.new 'Hello, Bill' do |p|
p.package_name = 'hello-bill'
p.version = '3.14159'
p.summary = 'Just saying hi'
p.author = 'Ryan Tomayko '
p.description = <<-end
A program that writes "Hello, Bill" to STDOUT and exits.
Just because.
end
p.project_url = "http://tomayko.com/src/#{p.package_name}"
p.remote_dist_location = "tomayko.com:/dist/#{p.package_name}"
p.remote_doc_location = "tomayko.com:/src/#{p.package_name}"
p.remote_branch_location = "tomayko.com:/src/#{p.package_name}"
end
EOF
$ cat < doc/index.txt
= Hello, Bill {package-version}
The +hello-bill+ program writes "Hello, Bill" to STDOUT and exits.
EOF
$ bzr ci -m "update project info and docs"
$ rake doc package publish
asciidoc -d article -o ./index.html ./index.txt
asciidoc -d article -o ./license.html ./license.txt
source-highlight -s ruby --line-number-ref='' ...
Processing 'lib/hello.rb' ... created doc/src/lib/hello.rb.html
Generating RDoc API Documentation.
tar zcvf hello-bill-3.14159.tar.gz hello-bill-3.14159 ...
zip -r hello-bill-3.14159.zip hello-bill-3.14159
rsync -aP ... rtomayko@tomayko.com:/dist/hello-bill
rsync -azP --delete --hard-links .bzr rtomayko@tomayko.com:/src/hello-bill
rsync -azP doc/ rtomayko@tomayko.com:/src/hello-bill
$ sudo gem install hello-bill --source=http://tomayko.com
$ hello-bill
Hello, Bill
Project documentation and bzr branch now here.
Cool, eh?
I've thought through the downside a bit and most of what I come up with is made irrelevant by cheap, distributed branches. For instance, if you want a different doc / test / package / distribution tool, fine: create a branch and make it do whatever you want; then, branch from there instead for your new projects.
I've only merged upstream changes from the template project into a downstream project once or twice but I'm expecting to run into silly and potentially annoying conflicts. So far it's been smooth sailing but we'll see.