h3. What is monotone?
Monotone is a free distributed version control system. it provides a simple, single-file transactional version store, with fully disconnected operation and an efficient peer-to-peer synchronization protocol. it understands history-sensitive merging, lightweight branches, integrated code review and 3rd party testing. it uses cryptographic version naming and client-side RSA certificates. it has good internationalization support, has no external dependencies, runs on linux, solaris, OSX, windows, and other unixes, and is licensed under the GNU GPL.
_Taken from the monotone website_
h3. Installing monotone
Download the monotone package.
* Linux (Static): http://www.venge.net/monotone/downloads/mtn-0.26-linux-x86.bz2
* MacOSX: http://www.venge.net/monotone/downloads/mtn-0.26-osx-univ.bz2
# wget http://www.venge.net/monotone/downloads/mtn-0.26-osx-univ.bz2
# bunzip2 mtn-0.26-osx-univ.bz2
# mv mtn-0.26-osx-univ.bz2 /usr/local/bin/mtn
You should now be able to just type mtn on the command line to run the application.
h3. Setting up a project
# mkdir ~/.monotone
# mtn db init --db=~/.monotone/scrobbler.mtn
This will create the monotone database (sqlite3.3) for you.
Every user is required to have a pair of RSA keys.
# mtn genkey wnoronha@scrobbler.net
mtn: generating key-pair 'wnoronha@scrobbler.net'
enter passphrase for key ID [wnoronha@scrobbler.net] :
confirm passphrase for key ID [wnoronha@scrobbler.net]:
mtn: storing key-pair 'wnoronha@scrobbler.net' in /Users/wnoronha/.monotone/keys
Monotone will generate a key and store it for you to use it later. Initially the keys were stored in the database. The behavior was changed so that you could move the db around without being all paranoid about losing private data. Also most developers use the same keys across multiple projects. So this new method saves you a couple steps.
You can view your keys by running
# mtn list keys
[public keys]
9e9e9ef1d515ad58bfaa5cf282b4a872d8fda00c wnoronha@scrobbler.net (*)
(*) - only in /Users/wnoronha/.monotone/keys/
[private keys]
642ace046c22210a99e5fddfa99c9381260b6432 wnoronha@scrobbler.net
I do not do this because I don't like to store my passwords on any system. But this could save you a couple seconds, and may be after years of usage you would have saved 5 minutes. No telling what you could do with those extra 5 minutes. Monotone configuration files are written in LUA.
# cat >>~/.monotone/monotonerc
function get_passphrase(keypair_id)
return "greekgeek"
end
^D
h3. Setting up a new Project
A quick note about branch naming. Since monotone is distributed, and to avoid conflicts with two people having the same name; you use inverted domain names and a domain that you have control off, something like Java files. This is not a rule its just a recommendation. So in this case I use the net.scrobbler.dev.todo as my branch.
# mtn --db=~/.monotone/scrobbler.mtn --branch=net.scrobbler.dev.todo setup todo
You will now have a directory called todo. We will now setup and add a Rails project.
# rails todo
# cd todo
# cat >>.mtn-ignore
^log/.*\.log$
^config/database.yml$
^config/lighttpd.config$
^D
This will ignore all the *.log files in the log directory, the database.yml and lighttpd.config file in the config directory. You can add other files to the list, using simple regular expression.
# cp config/database.yml config/database.yml.dist
Committing the vanilla project
# mtn add .
# mtn commit -m 'Initial project import'
You can get the current version by running
# mtn status
or
# mtn log
I generally just do a "mtn log > CHANGELOG" since I am too lazy to update that file by hand.
h3. Share your changes
Developer "N" now needs access to your source code. So she creates a new monotone repo; generates a keypair, sets up a workspace and sends you her public key.
Exporting her public key
# mtn --db=~/zshack-todo.mtn pubkey z@zshack.com >~/zshack.pubkey
You now insert her public keys into your database.
# cat ~/zshack.pubkey | monotone --db=~/.monotone/scrobbler.mtn read
Granting people access to the repo
# cat >>~/.monotone/read-permissions
pattern "*"
allow "z@zshack.com"
^D
# cat >>~/.monotone/write-permissions
z@zshack.com
^D
Now you can just launch the server by running the following command. Note the system now runs on port 4691.
# mtn --db=~/.monotone/scrobbler.mtn serve "net.scrobbler.dev.**"
This will initiate the monotone syncing server.
Your developer will need to run the following to sync, push or pull from the host.
# mtn --db=~/zshack-todo.mtn sync home.scrobbler.net "net.scrobbler.dev*"
Thats about it. I will add more information on how to use SwitchTower/Cap to deploy your application using montone.

Comments
Post new comment