source: tailor/README @ 635

Revision 635, 16.1 KB checked in by lele@…, 8 years ago (diff)

Re-fixed (sigh) bazaar spelling and credits to Johan Rydberg

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