source: tailor/README @ 691

Revision 691, 20.1 KB checked in by tmokros@…, 8 years ago (diff)

Initial GIT target support, using Cogito

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_, Git_, 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, Codeville, Git, 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.. _git: http://git.or.cz/
60.. _mercurial: http://www.selenic.com/mercurial/
61.. _monotone: http://www.venge.net/monotone/
62.. _subversion: http://subversion.tigris.org/
63.. _tla: http://www.gnuarch.org/arch/index.html
64
65
66Installation
67============
68
69tailor is written in Python, and thus Python must be installed on
70your system to use it.  It has been successfully used with Python 2.3
71and 2.4.
72
73Since it relies on external tools to do the real work such as `cvs`,
74`darcs` [#]_ and `svn`, they need to be installed as well, although only
75those you will actually use.
76
77Make tailor executable::
78
79 $ chmod +x tailor
80
81You can either run tailor where it is currently located, or move it
82along with the vcpx directory to a location in your PATH.
83
84There's even a standard setup.py that you may use to install the
85script using Python conventional distutils.
86
87.. [#] Darcs 1.0.2 is too old, 1.0.3 is good, 1.0.4 (the fourth
88       release candidate is under final testing) is recommended since
89       it's faster in most operations!
90
91
92Testing
93=======
94
95You can run the test suite with the following command line::
96
97 $ tailor test -v
98
99that runs all the tests in sequence, or::
100
101 $ tailor test -v TailorTest
102
103to trigger just a subset of them.
104
105
106Operation
107=========
108
109tailor needs now a configuration file that collects the various bits
110of information it needs to do it's job.
111
112The simplest way of starting out a new configuration is by omitting
113the --configfile command line option, and specifying the other as
114needed plus --verbose: in this situation, tailor will print out an
115equivalent configuration that you can redirect to a file, that you
116later will pass as --configfile.
117
118
119Examples
120--------
121
1221. Bootstrap a new tailored project, starting at upstream revision 10
123
124   a. First create a config file::
125   
126       $ tailor --verbose -s svn -R http://svn.server/path/to/svnrepo \
127                --module /Product/trunk -r 10 --subdir Product \
128                ~/darcs/MyProduct > myproject.tailor
129
130   b. Modify it as you like (mostly adjusting root-directories and the
131      like)::
132     
133       $ emacs myproject.tailor
134
135   c. Run tailor on it::
136   
137       $ tailor --configfile myproject.tailor
138
1392. Bootstrap a new product, fetching its whole CVS repository and
140   storing under SVN
141
142   a. First create a config file::
143
144       $ tailor --verbose --source-kind cvs --target-kind svn \
145                --repository :pserver:cvs.zope.org:/cvs-repository \
146                --module CMF/CMFCore --revision INITIAL \
147                --target-repository file:///some/where/svnrepo \
148                --target-module / cmfcore > cmfcore.tailor
149
150   b. Modify it as you like (mostly adjusting root-directories and the
151      like)::
152     
153       $ emacs cmfcore.tailor
154
155   c. Run tailor on it once, to bootstrap the project::
156   
157       $ tailor -D -v --configfile cmfcore.tailor
158
159      If the target repository is on the local filesystem (ie, it
160      starts with ``file:///``) and it does not exist, tailor
161      creates a new empty Subversion repository at the specified
162      location.
163     
164   .. note:: Before step d) below, you may want to install an
165             appropriate hook in the repository to enable the
166             propset command to operate on unversioned properties,
167             as described in the `svn manual`__. Then you can
168             specify '--use-svn-propset' option, and tailor will
169             put the original author and timestamp in the proper
170             svn metadata instead of appending them to the changelog.
171
172             Other than the annoying repository manual intervention,
173             this thread__ and this other__ explain why using
174             ``-r{DATE}`` may produce strange results with this setup.
175
176   d. Run tailor again and again, to sync up with latest changes::
177
178       $ tailor -D -v --configfile myproject.tailor
179   
180__ http://svnbook.red-bean.com/en/1.0/ch05s02.html#svn-ch-5-sect-2.1
181__ http://svn.haxx.se/users/archive-2005-07/0605.shtml
182__ http://svn.haxx.se/users/archive-2005-03/0596.shtml
183
184
1853. Given the configuration file shown below in `Config file format`_,
186   the following command::
187
188    $ tailor --configfile example.tailor
189
190   is equivalent to this one::
191
192    $ tailor --configfile example.tailor tailor
193
194   in that they operate respectively on the default project(s) or
195   the ones specified on the command line (and in this case there
196   is just a single default project, tailor).
197
198   This one instead::
199
200    $ tailor --configfile example.tailor tailor tailor-reverse
201
202   operates on both projects.
203
204
205CVS start-revision
206------------------
207
208With CVS, you can specify a particular *point in time* specifying
209a `start-revision` with a timestamp like ``2001-12-25 23:26:48 UTC``.
210
211To specify also a particular `branch`, prepend it before the
212timestamp, as in ``unstable-branch 2001-12-25 23:26:48 UTC``.
213
214
215Resolving conflicts
216===================
217
218Should one of the replayed changes generate any conflict, tailor
219will prompt the user to correct them. This is done after the upstream
220patch has been applied and before the final commit on the target
221system, so that manually tweaking the conflict can produce a clean
222patch.
223
224
225Shortcomings
226============
227
228Tailor currently suffers of the following reported problems:
229
230a) It does not handle "empty" CVS checkouts, in other words you cannot
231   bootstrap a project that has nothing in its CVS upstream
232   repository, or from a point in time where this condition was true.
233
234b) It's completely unsupported under Windows, evenif it now uses
235   2.4's subprocess_ that seems able to hide Windows crazyness...
236
237c) ArX, Baazar-NG, Codeville, Git, and Mercurial are (currently) only
238   supported as *target*; Tla only as *source*.
239
240d) Specifying ``--subdir .`` may not work, in particular when dealing
241   with remote CVS repositories (it does when the CVS repository is
242   on local machine).
243   
244This list will always be incomplete, but I'll do my best to keep it
245short :-)
246
247.. _subprocess: http://www.lysator.liu.se/~astrand/popen5/
248
249
250Config file format
251==================
252
253When your project is composed by multiple upstream modules, it is
254easier to collect such information in a single file. This is done by
255specifying the `--configfile` option with a file name as argument. In
256this case, tailor will read the above information from a standard
257Python ConfigParser file.
258
259For example::
260
261    [DEFAULT]
262    verbose = True
263    projects = tailor
264
265    [tailor]
266    root-directory = /tmp/n9
267    source = darcs:tailor
268    target = svn:tailor
269    dont-refill-changelogs = True
270    state-file = tailor.state
271
272    [tailor-reverse]
273    root-directory = /tmp/n9
274    source = svn:tailor
275    target = darcs:tailor
276    state-file = reverse.state
277   
278    [svn:tailor]
279    repository = file:///tmp/testtai
280    module = /project1
281    subdir = svnside
282   
283    [darcs:tailor]
284    repository = ~/WiP/cvsync
285    subdir = darcside
286
287The configuration may hold one or more `projects`_ and two or more
288`repositories`_: project names do not contains colons ":",
289repository names must and the first part of the name before the
290colon specify the kind of the repository.  So, the above example
291contains two projects, one that goes from `darcs` to `subversion`, the
292other in the opposite direction.
293
294The ``[DEFAULT]`` section contains the default values, that will be
295used when a specific setting is missing from the particular section.
296
297You can specify on which project tailor should operate by
298giving its name on the command line, even more than one. When not
299explicitly given, tailor will look at ``projects`` in the
300``[DEFAULT]`` section, and if its missing it will loop over all
301projects in the configuration.
302
303The following simpler config just go in one direction, for a single
304project, so no need neither for ``[DEFAULT].projects`` nor command
305line arguments::
306
307    [pxlib]
308    source = cvs:pxlib
309    target = hg:pxlib
310    root-directory = ~/mypxlib
311    start-revision = INITIAL
312    subdir = pxlib
313   
314    [cvs:pxlib]
315    repository = :pserver:anonymous@cvs.sf.net:/cvsroot/pxlib
316    module = pxlib
317
318    [hg:pxlib]
319    hg-command = /usr/local/bin/hg
320
321This will use a single directory, ``pxlib`` to contain both the source
322and the target system. If you prefer keeping the separated, you just
323need to specify a different directory for each repository, as in::
324
325    [pxlib]
326    source = cvs:pxlib
327    target = hg:pxlib
328    root-directory = ~/mypxlib
329    start-revision = INITIAL
330   
331    [cvs:pxlib]
332    repository = :pserver:anonymous@cvs.sf.net:/cvsroot/pxlib
333    module = pxlib
334    subdir = original
335
336    [hg:pxlib]
337    hg-command = /usr/local/bin/hg
338    subdir = migrated
339
340This will extract upstream CVS sources into ``~/mypxlib/original``,
341and create a new Mercurial repository in ``~/mypxlib/migrated``.
342
343
344Configuration sections
345----------------------
346
347Default
348~~~~~~~
349
350The ``[DEFAULT]`` section in the configuration file may set the
351default value for any of the recognized options: when a value is
352missing from a specific section it is looked up in this section.
353
354One particular option, ``projects``, is meaningful only in the
355``[DEFAULT]`` section: it's a comma separated list of project names,
356the one that will be operated on by tailor when no project is
357specified on the command line.  When the there are no ``projects``
358setting nor any on the command line, tailor activates all configured
359projects, in order of appearance in the config file.
360
361
362Projects
363~~~~~~~~
364
365A project is identified by a section whose name does not contain any
366colon (":") character, and configured with the following values:
367
368root-directory
369  This is where all the fun will happen: this directory will contain
370  the source and the target working copy, and usually the state and
371  the log file. It support the conventional `~user` to indicate user's
372  home directory.
373
374subdir
375  This is the subdirectory, relative to the `root-directory`, where
376  tailor will extract the source working copy. It may be '.' for some
377  backend kinds.
378
379state-file
380  Name of the state file needed to store tailor last activity.
381
382source
383  The source repository: a repository name is something like
384  "darcs:somename", that will be loaded from the homonymous section
385  in the configuration.
386
387target
388  The counterpart of `source`, the repository that will receive the
389  changes coming from there.
390
391Non mandatory options:
392
393verbose
394  Print the commands as they are executed.
395
396debug
397  Print also their output.
398 
399before-commit
400  This is a function name, or a sequence of function names enclosed
401  by brackets, that will be executed on each changeset just before
402  it get replayed on the target system: this may be used to perform
403  any kind of alteration on the content of the changeset, or to skip
404  some of them.
405
406after-commit
407  This is a function name, or a sequence of function names enclosed
408  by brackets, that will be executed on each changeset just after
409  the commit on the target system: this may be used for example to
410  create a tag.
411
412subdir
413  The name of the subdirectory, under ``root-directory``, that will
414  contain the source and target repositories/working directories.
415
416start-revision
417  This identifies from when tailor should start the migration. It can
418  be either ``INITIAL``, to indicate the start of the history, or
419  ``HEAD`` to indicate the current latest changeset, or a backend
420  specific way of indicate a particular revision/tag in the history.
421  See also `CVS start-revision`_ above.
422
423patch-name-format
424  Some backends have a distinct notion of `patch name` and `change
425  log`, others just suggest a policy that the first line of the
426  message is a summary, the rest if present is a more detailed
427  description of the change.  With this option you can control the
428  format of the name, or of the first line of the changelog.
429
430  The prototype may contain ``%(keyword)s`` such as 'author', 'date',
431  'revision', 'firstlogline', 'remaininglog'.  It defaults to
432  `Tailorized "%(revision)s"`; setting it to the empty string means
433  that tailor will simply use the original changelog.
434
435remove-first-log-line
436  Remove the first line of the upstream changelog. This is intended to
437  go in pair with ``patch-name-format``, when using it's 'firstlogline'
438  variable to build the name of the patch.  By default is ``False``.
439
440
441Repositories
442~~~~~~~~~~~~
443
444All the section whose name contains at least one colon character
445denote a repository.  A single repository may be shared by zero, one or
446more projects.  The first part of the name up to the first colon
447indicates the `kind` of the repository, one of ``arx``, ``bzr``,
448``bzrng``, ``cdv``, ``cg``, ``cvs``, ``darcs``, ``hg``, ``monotone``,
449``svn`` and ``tla``.
450
451When a repository is used as a `source`, it must indicate its origin
452with ``repository``, and for some backends also a ``module``, but are
453not required when it's a target system, even if some backend may use
454the information to create the target repository (like ``svn`` backend
455does).
456
457Each repository may then impose a particular external binary to be
458used, as done in the example above for ``hg``. Actually only one of
459them, `bzrng`, accepts an option ``python-path``, to indicate where
460the BazaarNG Python library is located.
461
462A repository may also have it's own ``subdir``: when the `source` and
463`target` repositories use different subdirectories, tailor uses
464``rsync`` to copy the changes between the two after each applied
465changeset.
466
467CVS and CVSPS repositories may turn of automatic tagging of entries,
468that tailor does by default to prevent manual interventions in the
469CVS working copy, using ``tag_entries = False``.
470
471
472Using a Python script as configuration file
473-------------------------------------------
474
475Instead of executing ``tailor --configfile project.tailor.conf``
476you can prepend the following signature to the config itself::
477
478  #!/usr/bin/env /path/to/tailor
479
480Giving execute mode to it will permit the launch of the tailor
481process by running the config script directly::
482
483  $ ./project.tailor.conf
484
485When a config file is signed in this way [#]_, either you pass it as
486argument to ``--configfile`` or executed as above, tailor will
487actually execute it as a full fledged Python script, that may define
488functions that alter the behaviour of tailor itself.
489
490A common usage of this functionality is to define so called `hooks`,
491sequences of functions that are executed at particular points in
492the tailorization process.
493
494Just to illustrate the functionality, consider the following example::
495
496    #!/usr/bin/env tailor
497
498    """
499    [DEFAULT]
500    debug = False
501    verbose = True
502
503    [project]
504    target = bzrng:target
505    root-directory = /tmp/prova
506    state-file = tailor.state
507    source = darcs:source
508    before-commit = before
509    after-commit = after
510    start-revision = Almost arbitrarily tagging this as version 0.8
511
512    [bzrng:target]
513    python-path = /opt/src/bzr.dev
514    subdir = bzrside
515
516    [darcs:source]
517    repository = /home/lele/WiP/cvsync
518    subdir = darcside
519    """
520
521    def before(wd, changeset):
522        print "BEFORE", changeset
523        changeset.author = "LELE"
524        return changeset
525
526    def after(wd, changeset):
527        print "AFTER", changeset
528
529With the above in a `script` called say ``tester``, just doing::
530
531    $ chmod 755 tester
532    $ ./tester
533
534will migrate the history from a darcs repository to a bazaar-ng one,
535forcing the author to a well-known name :-)
536
537.. [#] Tailor does actually read just the first two bytes from the
538       file, and compare them with "#!", so you are free to choose
539       whatever syntax works in your environment.
540
541
542State file
543----------
544
545The state file stores two things: the last upstream revision that
546has been applied to the tree, and a sequence of pending (not yet
547applied) changesets, that may be empty. In the latter case, tailor
548will fetch latest changes from the upstream repository.
549
550       
551Further help
552============
553
554See the output of ``tailor -h`` for some further tips.  There's
555also a `wiki page`_ that may give you some other hints.  The
556development of Tailor is mainly driven by user requests at this point,
557and the preferred comunication media is the dedicated `mailing list`_
558[#]_.
559
560.. _wiki page:
561   http://www.darcs.net/DarcsWiki/Tailor
562
563.. _mailing list:
564   http://lists.zooko.com/mailman/listinfo/tailor
565   
566I will be more than happy to answer any doubt, question or suggestion
567you may have on it. I'm usually hanging as "lelit" on the IRC channel
568devoted to darcs on the `freenode.net` network. Do not hesitate to
569contact me either by email or chatting there.
570
571.. [#] I wish to say a big `Thank you` to `Zooko <zooko@zooko.com>`_,
572       for hosting the ML and for supporting Tailor in several ways,
573       from suggestions to bug reporting and fixing.
574
575
576Authors
577=======
578
579Lele Gaifax <lele@nautilus.homeip.net>
580
581Since I'm not currently using all the supported systems (so little
582time, so many VCSs...) I'm not in position to test them out properly,
583but I'll do my best to keep them in sync, maybe with your support :-)
584
585ArX support
586-----------
587
588ArX_ support was contributed by `Walter Landry <wlandry@ucsd.edu>`_.
589
590Bazaar-NG support
591-----------------
592
593`Bazaar-NG`_ support was contributed by `Johan Rydberg
594<jrydberg@gnu.org>`_.
595
596Git support
597-----------
598
599`Git`_ support (using Cogito) was contributed by `Todd Mokros
600<tmokros@tmokros.net>`_.
601
602Monotone support
603----------------
604
605Monotone_ support was kindly contributed by `Markus Schiltknecht
606<markus@bluegap.ch>`_ and further developed by `rghetta
607<birrachiara@tin.it>`_, that was able to linearize the multi-headed
608monotone history into something tailor groks. Kudos!
609
610Tla support
611-----------
612
613Tla_ support was contributed by `Robin Farine
614<robin.farine@terminus.org>`_.
615
616
617License
618=======
619
620Tailor is distribuited under the `GNU General Public License`__.
621
622__ http://www.fsf.org/licensing/licenses/gpl.html
623
624
625About this document
626===================
627
628This document and most of the internal documention use the
629reStructuredText format so that it can be easily converted into other
630formats, such as HTML.  For more information about this, please see:
631
632  http://docutils.sourceforge.net/rst.html
633
634
635.. vim:ft=rest
636.. Local Variables:
637.. mode: rst
638.. End:
Note: See TracBrowser for help on using the repository browser.