After explaining what is the Monotone's CVS gateway, I've been asked to post a little step by step tutorial about it. I'll focus the example towards pkgsrc. Here it goes:

The first step is to create a local database for Monotone and a key for personal use:

$ monotone --db=~/pkgsrc.db db init
$ monotone --db=~/pkgsrc.db genkey user@example.com

Once this is done, we can proceed to import the CVS repository into the database. We can do this in two different ways:

  • Import the files from the repository, thus getting all the history in our local Monotone database. This might be appropriate in some cases, but may take a very long time and may not be worth it. This is done by doing:

    $ monotone --db=~/pkgsrc.db --branch=org.pkgsrc cvs_pull    :ext:anoncvs@anoncvs.NetBSD.org:/cvsroot pkgsrc
  • Import the files from a local working copy. This has the advantage of being a very fast operation, but you won't have old revision history in your database. This can be achieved issuing:

    $ cd /usr/pkgsrc
    $ monotone --db=~/pkgsrc.db --branch=org.pkgsrc cvs_takeover

After any of these two steps, you'll get an org.pkgsrc branch in your local Monotone database. So the next thing to do is to check out a copy of it (just as you'd do in CVS after an import operation):

$ cd
$ monotone --db=~/pkgsrc.db --branch=org.pkgsrc checkout pkgsrc

This will create a working copy under ~/pkgsrc; you can change the name of the directory by changing the last word of the command.

And now it's time to start working on your copy. Edit the files you want and do as many commits as you want (monotone commit). You can examine your changes by viewing the log (monotone log), examining annotated changes (monotone annotate) or any other thing you want. The interface is very similar to that of CVS.

At last, when you are ready to publish your changes to the original CVS repository, you can do so using the cvs_push command, as in:

$ cd ~/pkgsrc
$ monotone --db=~/pkgsrc.db cvs_push

Keep in mind that your Monotone repository is completely independent from the CVS one. Therefore, you may want to periodically repeat the cvs_pull operation to bring new CVS revisions into your Monotone tree, and use cvs_push to send your custom revisions to the CVS repository. I'm not sure about what will happen in case of conflicts, but I'd expect a new head in the branch that you must manually merge with the other one (using monotone merge).

Comments from the original Blogger-hosted post: