Monotone Distributed Version Control

More Information

Monotone Home Page

Create a database

mtn db init --db=~/mt.db

Generate a key

Skip this step if you are importing a monotone key from somewhere else.

# Generate a key bound to your email address.
mtn --db=~/mt.db genkey jim@juicebot.co.jp

Importing a key from another system

Skip this step if you just generated a key above.

# Export the key from the other system.
mtn --db=~/othermt.db privkey jim@juicebot.co.jp > abe-privkey

# Import the key into new database.
mtn --db=~/mt.db read < abe-privkey

Pushing a key to a host

Use this when you need to propagate a key that hasn't signed anything yet.

mtn --db=~/mt.db push --key-to-push jim@juicebot.co.jp

Setup config to skip typing password

Definitely don't do this unless your machine is unshared and secured! If you skip this step you will be prompted for your password at various points.

# Append some stuff your monotone config.
cat >> $HOME/.monotone/monotonerc <<EOF
function get_passphrase(keypair_id)
   return "yourpassword"
end
EOF

# Make sure your config file is private.
chmod 0600 $HOME/.monotone/monotonerc

# Replace "yourpassword" with your password.

Sync RadHoc namespace from the public server

mtn --db=~/mt.db sync mtn.bonsai.com org.radhoc.*

Send me your public key

If you send me your public key I can enable write permission. You can fetch copies of the tree before this step is completed; you just can't write modifications back to the network server.

# Export the public key data.
mtn pubkey jim@juicebot.co.jp

# Email the output to me.

Checkout a source tree from network repository

Since the network server has anonymous read enabled you don't need write permission to obtain the source.

cd /good/place/for/source
mtn --db=~/mt.db --branch=org.radhoc.radhoc checkout radhoc

# Hack away ...
cd radhoc

# Show diffs (anywhere in source tree ...)
mtn diff

Commit changes

You don't need write permission on the network server to do this either. You can commit into your local db without anyone's permission. You can sync the mods with other folks directly if they give you permission.

# Make sure your EDITOR or VISUAL env variables are set.

# Commit the whole tree. (partial below)
# Anywhere in the source tree ...
mtn commit

# Commit specific files instead.
mtn commit foo.cpp foo.h README.txt

Merge your changes back into network repository

You'll need write permission on the network server to propogate modifications back. You can always sync from the server to you, however.

# Synchronize with server.
mtn sync

# List the heads (You're done if the result is already merged).
mtn heads

# Merge the results.
mtn merge

# Update your working tree.
mtn up

Some tips for Windows and Cygwin users

I use cygwin and have found monotone gets confused about where my home directory is. It probably depends on how you use cygwin as well. I use a home directory in cygwin, and for command line options, like --db=~/mt.db, monotone looks looks in my cygwin home. But for other paths, like looking for keys, and the monotone scripts, it looks in my windows home directory.

Side note: Lately I have been using the cygwin monotone distribution which does not have this problem, so consider this suggestion for those that use cygwin with a non-cygwin monotone distribution.

So for the purposes of the instructions above, I have:

# In my cygwin environment I have HOME=/home/chris, therefore mt.db here:

    /cygdrive/c/cygwin/home/chris ( C:\cygwin\home\chris ) 

# The keys are generated here ( this occurs automatically ):

    C:\Documents and Settings\chris\Application Data\monotone\keys\

# I had to put my monotonerc file here ( note there is no
# .monotone directory ):

    C:\Documents and Settings\chris\Application Data\monotone\

So now when I work in cygwin, I can use the --db=~/mt.db and not worry about the keys or rc file.

Using Inodeprints

When running in inodeprints mode, monotone does not read the whole workspace; rather, it keeps a cache of interesting information about each file (its size, its last modification time, and so on), and skips reading any file for which these values have not changed. This is inherently somewhat less safe, and unnecessary for most projects, so it is disabled by default.

To turn on inodeprints:

mtn refresh_inodeprints

To turn off inodeprints:

rm _MTN/inodeprints

Grant a developer write permission on the network server

IMPORTANT - don't execute these commands until you have already inserted the key in the database. There is a exploit if you do this before inserting the key and syncing to the network server.

These commands must be executed as root on the network server itself:

cat >> /etc/monotone/write-permissions <<EOF
jim@juicebot.co.jp
EOF

Restart the monotone server (not sure if this is neccessary). service monotone restart

Replace another persons key in your database

WARNING - Think about possible exploits here; make sure you don't execute this command unless you are sure that the source of the key is the intended person.

Drop the key from the database:

mtn --db=~/mtn/myproj.mtn dropkey KEYID

Insert their replacement key -OR see next ...

mtn --db=~/mtn/myproj.mtn read < pubkey.txt

... OR sync key from other datbase.

mtn --db=~/mtn/myproj.mtn sync

Monotone Documentation

Consult the full monotone online documentation.