source: tailor/README @ 646

Revision 646, 15.2 KB checked in by lele@…, 8 years ago (diff)

Some fixes and better explanations

Line 
1Tailor 1.0
2##########
3
4.. contents::
5
6About
7=====
8
9Tailor is a tool to migrate changesets between ArX_, `Bazaar-NG`_
10CVS_, Codeville_, Darcs_, Mercurial_, Monotone_, Tla_ and Subversion_
11[#]_ repositories.
12
13This script makes it easier to keep the upstream changes merged in
14a branch of a product, storing needed information such as the upstream
15URI and revision in special properties on the branched directory.
16
17The following ascii-art illustrates the usual scenario::
18
19                           +------------+            +------------+
20  +--------------+         | Immutable  |            | Working    |
21  | Upstream CVS |-------->| darcs      |----------->| darcs      |
22  | repository   | tailor  | repository | darcs pull | repository |
23  +--------------+         +------------+            +------------+
24                                                           |^         
25                                                           ||
26                                                           ||
27                                                           v|
28                                                          User
29
30Ideally you should be able to swap and replace "CVS server" and "darcs
31repository" with any combination of the supported systems.
32
33A more convoluted setup shows how brave people are using it to get a
34two way sync::
35
36  +----------+        +--------+        +--------+       +---------+
37  |          | -----> | hybrid | darcs  |        | ----> |   my    |
38  | upstream | tailor |  CVS   | -----> | master | darcs | working |
39  |   CVS    | <----- | darcs  | <----- | darcs  | <---- |  darcs  |
40  |          |        |  sync  | tailor |        |       |         |
41  +----------+        +--------+        +--------+       +---------+
42               (cron)            (cron)
43
44
45.. [#] ArX, Monotone, Codeville, Mercurial and Baazar-NG systems may be
46       used only as the `target` backend, since the `source` support
47       isn't coded yet. Contributions on these backends will be very
48       appreciated, since I do not use them enough to figure out the
49       best way to get pending changes and build tailor ChangeSets out
50       of them.
51
52       To the opposite, Tla is supported only as a source system.
53
54.. _arx: http://www.nongnu.org/arx/
55.. _bazaar-ng: http://www.bazaar-ng.org/
56.. _codeville: http://www.codeville.org/
57.. _cvs: http://www.nongnu.org/cvs/
58.. _darcs: http://www.darcs.net/
59.. _mercurial: http://www.selenic.com/mercurial/
60.. _monotone: http://www.venge.net/monotone/
61.. _subversion: http://subversion.tigris.org/
62.. _tla: http://www.gnuarch.org/arch/index.html
63
64
65Installation
66============
67
68tailor is written in Python, and thus Python must be installed on
69your system to use it.  It has been successfully used with Python 2.3
70and 2.4.
71
72Since it relies on external tools to do the real work such as `cvs`,
73`darcs` [#]_ and `svn`, they need to be installed as well, although only
74those you will actually use.
75
76Make tailor executable::
77
78 $ chmod +x tailor
79
80You can either run tailor where it is currently located, or move it
81along with the vcpx directory to a location in your PATH.
82
83There's even a standard setup.py that you may use to install the
84script using Python conventional distutils.
85
86.. [#] Darcs 1.0.2 is too old, 1.0.3 is good, 1.0.4 (the fourth
87       release candidate is under final testing) is recommended since
88       it's faster in most operations!
89
90
91Testing
92=======
93
94You can run the test suite with the following command line::
95
96 $ tailor test -v
97
98that runs all the tests in sequence, or::
99
100 $ tailor test -v TailorTest
101
102to trigger just a subset of them.
103
104
105Operation
106=========
107
108tailor needs now a configuration file that collects the various bits
109of information it needs to do it's job.
110
111The simplest way of starting out a new configuration is by omitting
112the --configfile command line option, and specifying the other as
113needed plus --verbose: in this situation, tailor will print out an
114equivalent configuration that you can redirect to a file, that you
115later will pass as --configfile.
116
117
118Examples
119--------
120
1211. Bootstrap a new tailored project, starting at upstream revision 10
122
123   a. First create a config file::
124   
125       $ tailor --verbose -s svn -R http://svn.server/path/to/svnrepo \
126                --module /Product/trunk -r 10 --subdir Product \
127                ~/darcs/MyProduct > myproject.tailor
128
129   b. Modify it as you like (mostly adjusting root-directories and the
130      like)::
131     
132       $ emacs myproject.tailor
133
134   c. Run tailor on it::
135   
136       $ tailor --configfile myproject.tailor
137
1382. Bootstrap a new product, fetching its whole CVS repository and
139   storing under SVN
140
141   a. First create a config file::
142
143       $ tailor --verbose --source-kind cvs --target-kind svn \
144                --repository :pserver:cvs.zope.org:/cvs-repository \
145                --module CMF/CMFCore --revision INITIAL \
146                --target-repository file:///some/where/svnrepo \
147                --target-module / cmfcore > cmfcore.tailor
148
149   b. Modify it as you like (mostly adjusting root-directories and the
150      like)::
151     
152       $ emacs cmfcore.tailor
153
154   c. Run tailor on it once, to bootstrap the project::
155   
156       $ tailor -D -v --configfile cmfcore.tailor
157
158      If the target repository is on the local filesystem (ie, it
159      starts with ``file:///``) and it does not exist, tailor
160      creates a new empty Subversion repository at the specified
161      location.
162     
163   .. note:: Before step d) below, you may want to install an
164             appropriate hook in the repository to enable the
165             propset command to operate on unversioned properties,
166             as described in the `svn manual`__. Then you can
167             specify '--use-svn-propset' option, and tailor will
168             put the original author and timestamp in the proper
169             svn metadata instead of appending them to the changelog.
170
171             Other than the annoying repository manual intervention,
172             this thread__ and this other__ explain why using
173             ``-r{DATE}`` may produce strange results with this setup.
174
175   d. Run tailor again and again, to sync up with latest changes::
176
177       $ tailor -D -v --configfile myproject.tailor
178   
179__ http://svnbook.red-bean.com/en/1.0/ch05s02.html#svn-ch-5-sect-2.1
180__ http://svn.haxx.se/users/archive-2005-07/0605.shtml
181__ http://svn.haxx.se/users/archive-2005-03/0596.shtml
182
183
1843. Given the configuration file shown below in `Config file format`_,
185   the following command::
186
187    $ tailor --configfile example.tailor
188
189   is equivalent to this one::
190
191    $ tailor --configfile example.tailor tailor
192
193   in that they operate respectively on the default project(s) or
194   the ones specified on the command line (and in this case there
195   is just a single default project, tailor).
196
197   This one instead::
198
199    $ tailor --configfile example.tailor tailor tailor-reverse
200
201   operates on both projects.
202
203
204CVS start-revision
205------------------
206
207With CVS, you can specify a particular *point in time* specifying
208a `start-revision` with a timestamp like ``2001-12-25 23:26:48 UTC``.
209
210To specify also a particular `branch`, prepend it before the
211timestamp, as in ``unstable-branch 2001-12-25 23:26:48 UTC``.
212
213
214Resolving conflicts
215===================
216
217Should one of the replayed changes generate any conflict, tailor
218will prompt the user to correct them. This is done after the upstream
219patch has been applied and before the final commit on the target
220system, so that manually tweaking the conflict can produce a clean
221patch.
222
223
224Shortcomings
225============
226
227Tailor currently suffers of the following reported problems:
228
229a) It does not handle "empty" CVS checkouts, in other words you cannot
230   bootstrap a project that has nothing in its CVS upstream
231   repository, or from a point in time where this condition was true.
232
233b) It's completely unsupported under Windows, evenif it now uses
234   2.4's subprocess_ that seems able to hide Windows crazyness...
235
236c) ArX, Monotone, Codeville and Baazar-NG are (currently) only
237   supported as *target*; Tla only as *source*.
238
239d) Specifying ``--subdir .`` may not work, in particular when dealing
240   with remote CVS repositories (it does when the CVS repository is
241   on local machine).
242   
243This list will always be incomplete, but I'll do my best to keep it
244short :-)
245
246.. _subprocess: http://www.lysator.liu.se/~astrand/popen5/
247
248
249Config file format
250==================
251
252When your project is composed by multiple upstream modules, it is
253easier to collect such information in a single file. This is done by
254specifying the `--configfile` option with a file name as argument. In
255this case, tailor will read the above information from a standard
256Python ConfigParser file.
257
258For example::
259
260    [DEFAULT]
261    verbose = True
262    projects = tailor
263
264    [tailor]
265    root-directory = /tmp/n9
266    source = darcs:tailor
267    target = svn:tailor
268    dont-refill-changelogs = True
269    state-file = tailor.state
270
271    [tailor-reverse]
272    root-directory = /tmp/n9
273    source = svn:tailor
274    target = darcs:tailor
275    state-file = reverse.state
276   
277    [svn:tailor]
278    repository = file:///tmp/testtai
279    module = /project1
280    subdir = svnside
281   
282    [darcs:tailor]
283    repository = ~/WiP/cvsync
284    subdir = darcside
285
286The configuration may hold one or more `projects` and two or more
287`repositories`: project names do not contains colons ":",
288repository names must and the first part of the name before the
289colon specify the kind of the repository.  So, the above example
290contains two projects, one that goes from `darcs` to `subversion`, the
291other in the opposite direction.
292
293The ``[DEFAULT]`` section contains the default values, that will be
294used when a specific setting is missing from the particular section.
295
296You can specify on which project tailor should operate by
297giving its name on the command line, even more than one. When not
298explicitly given, tailor will look at ``projects`` in the
299``[DEFAULT]`` section, and if its missing it will loop over all
300projects in the configuration.
301
302The following simpler config just go in one direction, for a single
303project, so no need neither for ``[DEFAULT].projects`` nor command
304line arguments::
305
306    [pxlib]
307    source = cvs:pxlib
308    target = hg:pxlib
309    root-directory = ~/mypxlib
310    start-revision = INITIAL
311    subdir = pxlib
312   
313    [cvs:pxlib]
314    repository = :pserver:anonymous@cvs.sf.net:/cvsroot/pxlib
315    module = pxlib
316
317    [hg:pxlib]
318    hg-command = /usr/local/bin/hg
319
320This will use a single directory, ``pxlib`` to contain both the source
321and the target system. If you prefer keeping the separated, you just
322need to specify a different directory for each repository, as in::
323
324    [pxlib]
325    source = cvs:pxlib
326    target = hg:pxlib
327    root-directory = ~/mypxlib
328    start-revision = INITIAL
329   
330    [cvs:pxlib]
331    repository = :pserver:anonymous@cvs.sf.net:/cvsroot/pxlib
332    module = pxlib
333    subdir = original
334
335    [hg:pxlib]
336    hg-command = /usr/local/bin/hg
337    subdir = migrated
338
339This will extract upstream CVS sources into ``~/mypxlib/original``,
340and create a new Mercurial repository in ``~/mypxlib/migrated``.
341
342
343Using a Python script as configuration file
344-------------------------------------------
345
346Instead of executing ``tailor --configfile project.tailor.conf``
347you can prepend the following signature to the config itself::
348
349  #!/usr/bin/env /path/to/tailor
350
351Giving execute mode to it will permit the launch of the tailor
352process by running the config script directly::
353
354  $ ./project.tailor.conf
355
356When a config file is signed in this way [#]_, either you pass it as
357argument to ``--configfile`` or executed as above, tailor will
358actually execute it as a full fledged Python script, that may define
359functions that alter the behaviour of tailor itself.
360
361A common usage of this functionality is to define so called `hooks`,
362sequences of functions that are executed at particular points in
363the tailorization process.
364
365Just to illustrate the functionality, consider the following example::
366
367    #!/usr/bin/env tailor
368
369    """
370    [DEFAULT]
371    debug = False
372    verbose = True
373
374    [project]
375    target = bzrng:target
376    root-directory = /tmp/prova
377    state-file = tailor.state
378    source = darcs:source
379    before-commit = before
380    after-commit = after
381    start-revision = Almost arbitrarily tagging this as version 0.8
382
383    [bzrng:target]
384    python-path = /opt/src/bzr.dev
385    subdir = bzrside
386
387    [darcs:source]
388    repository = /home/lele/WiP/cvsync
389    subdir = darcside
390    """
391
392    def before(wd, changeset):
393        print "BEFORE", changeset
394        changeset.author = "LELE"
395        return changeset
396
397    def after(wd, changeset):
398        print "AFTER", changeset
399
400With the above in a `script` called say ``tester``, just doing::
401
402    $ chmod 755 tester
403    $ ./tester
404
405will migrate the history from a darcs repository to a bazaar-ng one,
406forcing the author to a well-known name :-)
407
408.. [#] Tailor does actually read just the first two bytes from the
409       file, and compare them with "#!", so you are free to choose
410       whatever syntax works in your environment.
411
412
413State file
414----------
415
416The state file stores two things: the last upstream revision that
417has been applied to the tree, and a sequence of pending (not yet
418applied) changesets, that may be empty. In the latter case, tailor
419will fetch latest changes from the upstream repository.
420
421       
422Further help
423============
424
425See the output of ``tailor -h`` for some further tips.  There's
426also a `wiki page`_ that may give you some other hints.  The
427development of Tailor is mainly driven by user requests at this point,
428and the preferred comunication media is the dedicated `mailing list`_
429[#]_.
430
431.. _wiki page:
432   http://www.darcs.net/DarcsWiki/Tailor
433
434.. _mailing list:
435   http://lists.zooko.com/mailman/listinfo/tailor
436   
437I will be more than happy to answer any doubt, question or suggestion
438you may have on it. I'm usually hanging as "lelit" on the IRC channel
439devoted to darcs on the `freenode.net` network. Do not hesitate to
440contact me either by email or chatting there.
441
442.. [#] I wish to say a big `Thank you` to `Zooko <zooko@zooko.com>`_,
443       for hosting the ML and for supporting Tailor in several ways,
444       from suggestions to bug reporting and fixing.
445
446
447Authors
448=======
449
450Lele Gaifax <lele@nautilus.homeip.net>
451
452Since I'm not currently using all the supported systems (so little
453time, so many VCSs...) I'm not in position to test them out properly,
454but I'll do my best to keep them in sync, maybe with your support :-)
455
456ArX support
457-----------
458
459ArX_ support was contributed by `Walter Landry <wlandry@ucsd.edu>`_.
460
461Bazaar-NG support
462-----------------
463
464`Bazaar-NG`_ support was contributed by `Johan Rydberg
465<jrydberg@gnu.org>`_.
466
467Monotone support
468----------------
469
470Monotone_ support was kindly contributed by `Markus Schiltknecht
471<markus@bluegap.ch>`_ and further developed by `rghetta
472<birrachiara@tin.it>`_.
473
474Tla support
475-----------
476
477Tla_ support was contributed by `Robin Farine
478<robin.farine@terminus.org>`_.
479
480
481License
482=======
483
484Tailor is distribuited under the `GNU General Public License`__.
485
486__ http://www.fsf.org/licensing/licenses/gpl.html
487
488
489About this document
490===================
491
492This document and most of the internal documention use the
493reStructuredText format so that it can be easily converted into other
494formats, such as HTML.  For more information about this, please see:
495
496  http://docutils.sourceforge.net/rst.html
497
498
499.. vim:ft=rest
500.. Local Variables:
501.. mode: rst
502.. End:
Note: See TracBrowser for help on using the repository browser.