About
=====

tailor.py is a tool to migrate changesets between CVS, Subversion, and
darcs repositories.

This script makes it easier to keep the upstream changes merged in
a branch of a product, storing needed information such as the upstream
URI and revision in special properties on the branched directory.

The following ascii-art illustrates the usual scenario::

                           +------------+            +------------+
  +--------------+         | Immutable  |            | Working    |
  | Upstream CVS |-------->| darcs      |----------->| darcs      |
  | repository   | tailor  | repository | darcs pull | repository |
  +--------------+         +------------+            +------------+
                                                           |^         
                                                           ||
                                                           ||
                                                           v|
                                                          User

Ideally you should be able to swap and replace "CVS server" and "darcs
repository" with any combination of `CVS`, `Subversion` and `darcs`.


Installation
============

tailor.py is written in Python, and thus Python must be installed on
your system to use it.  It has been successfully used with Python 2.3
and 2.4.

Since it relays on external tools to do the real work such as `cvs`,
`darcs` and `svn`, they need to be installed as well.

Make tailor.py executable::

 $ chmod +x tailor.py

You can either run tailor.py where it is currently located, or move it
along with the vcpx directory to a location in your PATH.


Examples
========

1. Bootstrap a new tailored project, starting at upstream revision 10::

  $ tailor.py -b -s svn -R http://svn.server/Product -r 10 ~/darcs/MyProduct 

2. Bootstrap a new product, fetching from CVS and storing under SVN:
   this will create the directory "~/svnwc/cmfcore"; "~/svnwc" must be
   already under SVN::

  $ tailor.py --source-kind cvs --target-kind svn --bootstrap \
              --repository :pserver:cvs.zope.org:/cvs-repository \
              --module CMF/CMFCore ~/svnwc/cmfcore

3. Showing each command bootstrap a new DARCS repos in
   "~/darcs/cmftopic" under which the upstream module will be
   extracted as "CMFTopic" (ie, the last component of the module
   name)::

  $ tailor.py -D -b -R :pserver:anonymous@cvs.zope.org:/cvs-repository/ \
              -m CMF/CMFTopic ~/darcs/cmftopic
              
4. Merge upstream changes since last update/bootstrap::

  $ tailor.py ~/svnwc/MyProduct


Resolving conflicts
===================

Should one of the replayed changes generate any conflict, tailor.py
will prompt the user to correct them. This is done after the upstream
patch has been applied and before the final commit on the target
system, so that manually tweaking the conflict can produce a clean
patch.


Shortcomings
============

Tailor currently suffers of the following reported problems:

a) It does not handle "empty" CVS checkouts, in other words you cannot
   bootstrap a project that has nothing in its CVS upstream
   repository, or from a point in time where this condition was true.

b) It does not work under Windows (no, that's not a feature :-). Maybe
   replacing the shwrap machinery with something built on top of
   subprocess_ that seems able to hide Windows crazyness...

This list will always be incomplete, but I'll do my best to keep it
short :-)

.. _subprocess: http://www.lysator.liu.se/~astrand/popen5/


Tailor's metadata
=================

To do its work, tailor needs some information about your source tree,
such as the upstream repository URL and the current revision of the
sources on your harddisk.

In the simpler case, tailor keeps this information in a file called
`tailor.info`, one for each tailored project, that is a very simple
text document, with the following information, one per line:

1. Upstream repository kind (either "cvs", "darcs" or "svn)
2. Target repository kind (the same as above)
3. The name of the "module" that's been tailored
4. The URL of the upstream repository (that may not be an URL, for cvs...)
5. The current revision, from the upstream point of view, of the sources
6. The subdirectory that contains the checked out upstream tree,
   either that given with with the `--subdir` option or computed
   taking the last part of the module name. 

This is everything tailor needs, to be able to keep going from where it
left last time.


Config file format
------------------

When your project is composed by multiple upstream modules, it is
easier to collect such information in a single file. This is done by
specifying the `--configfile` option with a file name as argument. In
this case, tailor will read/write the above information from a
standard Python dictionary stored in the given file. 

The dictionary is keyed on the relative position of each project, and
each entry carries the same information described above.

Here's an example config file entry::

 {'plone/atcontenttypes': {'module': 'ATContentTypes',
                           'source_kind': 'cvs',
                           'subdir': 'ATContentTypes',
                           'target_kind': 'darcs',
                           'upstream_repos': ':ext:cvs.sourceforge.net:/cvsroot/collective',
                           'upstream_revision': '2004-11-24 19:42:06 by ctheune'}}

By convention, config files are named with the extension ".tailor",
but this is not enforced.

In the example above, 'plone/atcontenttypes' is a directory where the
target source will be stored. The keys such 'module', 'source_kind',
etc correspond to options of the same name.

When using a config file, tailor will perform its job on each project
contained in the dictionary.


Further help
============

See the output of tailor.py -h for some further tips.  There's also a
`wiki page`_ that may give you some other hints.

.. _wiki page:
   http://www.scannedinavian.org/DarcsWiki/ConvertingFromSubversion

I will be more than happy to answer any doubt, question or suggestion
you may have on it. I'm usually hanging as "lelit" on the IRC channel
devoted to darcs on the `freenode.net` network. Do not hesitate to
contact me either by email or chatting there.


Author
======

Lele Gaifax <lele@nautilus.homeip.net>


About this document
===================

This document and most of the internal documention use the
reStructuredText format so that it can be easily converted into other
formats, such as HTML.  For more information about this, please see:

  http://docutils.sourceforge.net/rst.html


.. vim:ft=rest
.. Local Variables:
.. mode: rst
.. End:
