source: tailor/README @ 1398

Revision 1398, 37.9 KB checked in by henry@…, 6 years ago (diff)

Henry's mail address

Line 
1.. Hey! This is reStructuredText, where "*this*" notation means an
2.. italic "this" and similar oddities. See the notes at the end of
3.. this file for details.
4
5Tailor 1.0
6##########
7
8.. contents::
9
10About
11=====
12
13Tailor is a tool to migrate changesets between ArX_, Baz_,
14`Bazaar`_, CVS_, Codeville_, Darcs_, Git_, Mercurial_, Monotone_,
15Perforce_, Subversion_ and Tla_ [#]_ repositories.
16
17This script makes it easier to keep the upstream changes merged in
18a branch of a product, storing needed information such as the upstream
19URI and revision in special properties on the branched directory.
20
21The following ascii-art illustrates the usual scenario::
22
23                           +------------+            +------------+
24  +--------------+         | Immutable  |            | Working    |
25  | Upstream CVS |-------->| darcs      |----------->| darcs      |
26  | repository   | tailor  | repository | darcs pull | repository |
27  +--------------+         +------------+            +------------+
28                                                           |^         
29                                                           ||
30                                                           ||
31                                                           v|
32                                                          User
33
34Ideally you should be able to swap and replace "CVS server" and "darcs
35repository" with any combination of the supported systems.
36
37A more convoluted setup shows how brave people are using it to get a
38`two way sync`_::
39
40  +----------+        +--------+        +--------+       +---------+
41  |          | -----> | hybrid | darcs  |        | ----> |   my    |
42  | upstream | tailor |  CVS   | -----> | master | darcs | working |
43  |   CVS    | <----- | darcs  | <----- | darcs  | <---- |  darcs  |
44  |          |        |  sync  | tailor |        |       |         |
45  +----------+        +--------+        +--------+       +---------+
46               (cron)            (cron)
47
48
49.. [#] ArX and Codeville systems may be used only as the `target`
50       backend, since the `source` support isn't coded yet.
51       Contributions on these backends will be very appreciated,
52       since I do not use them enough to figure out the best way to
53       get pending changes and build tailor ChangeSets out of them.
54
55       To the opposite, Baz (1.0, not Bazaar), Perforce and Tla
56       are supported only as source systems.
57
58.. _arx: http://www.nongnu.org/arx/
59.. _baz: http://bazaar-vcs.org/Baz1x
60.. _bazaar: http://bazaar-vcs.org/
61.. _codeville: http://www.codeville.org/
62.. _cvs: http://www.nongnu.org/cvs/
63.. _darcs: http://www.darcs.net/
64.. _git: http://git.or.cz/
65.. _mercurial: http://www.selenic.com/mercurial/
66.. _monotone: http://www.monotone.ca/
67.. _perforce: http://www.perforce.com/
68.. _subversion: http://subversion.tigris.org/
69.. _tla: http://www.gnuarch.org/arch/index.html
70.. _two way sync: http://progetti.arstecnica.it/tailor/wiki/TwoWaySync
71
72
73Installation
74============
75
76tailor is written in Python, and thus Python must be installed on
77your system to use it.  It has been successfully used with Python 2.3
78and 2.4.
79
80Since it relies on external tools to do the real work such as `cvs`,
81`darcs` [#]_ and `svn`, they need to be installed as well, although only
82those you will actually use.
83
84Make tailor executable::
85
86 $ chmod +x tailor
87
88You can either run tailor where it is currently located, or move it
89along with the vcpx directory to a location in your PATH.
90
91There's even a standard setup.py that you may use to install the
92script using Python's conventional distutils.
93
94.. [#] Darcs 1.0.2 is too old, 1.0.3 is good, 1.0.4 (the fourth
95       release candidate is under final testing) is recommended since
96       it's faster in most operations!
97
98
99Testing
100=======
101
102Tailor has more than 50 unit and operational tests, that you can
103run with the following command line::
104
105 $ tailor test -v
106
107Since some tests take very long to complete, in particular the
108operational tests, you may prefer the execution of a single suite::
109
110 $ tailor test -v Darcs
111
112or even a single test within a suite::
113
114 $ tailor test StateFile.testJournal
115
116To obtain a list of the test, use ``--list`` option.  As usual with::
117
118 $ tailor test --help
119
120you will get some more details.
121
122
123Operation
124=========
125
126tailor needs now a configuration file that collects the various bits
127of information it needs to do its job.
128
129The simplest way of starting out a new configuration is by omitting
130the ``--configfile`` command line option, and specifying the other as
131needed plus ``--verbose``: in this situation, tailor will print out an
132equivalent configuration that you can redirect to a file, that you
133later will pass as ``--configfile`` (or simply ``-c``).
134
135
136Examples
137--------
138
1391. Bootstrap a new tailored project, starting at upstream revision 10
140
141   a. First create a config file::
142   
143       $ tailor --verbose -s svn -R http://svn.server/path/to/svnrepo \
144                --module /Product/trunk -r 10 --subdir Product \
145                ~/darcs/MyProduct > myproject.tailor
146
147   b. Modify it as you like (mostly adjusting root-directories and the
148      like)::
149     
150       $ emacs myproject.tailor
151
152   c. Run tailor on it::
153   
154       $ tailor --configfile myproject.tailor
155
1562. Bootstrap a new product, fetching its whole CVS repository and
157   storing under SVN
158
159   a. First create a config file::
160
161       $ tailor --verbose --source-kind cvs --target-kind svn \
162                --repository :pserver:cvs.zope.org:/cvs-repository \
163                --module CMF/CMFCore --revision INITIAL \
164                --target-repository file:///some/where/svnrepo \
165                --target-module / cmfcore > cmfcore.tailor
166
167   b. Modify it as you like (mostly adjusting root-directories and the
168      like)::
169
170       $ emacs cmfcore.tailor
171
172   .. note:: By default, tailor uses "." as ``subdir``, to mean that
173             it will extract upstream source directly inside the
174             ``root-directory``.
175
176             This is known to cause problems with CVS as source, with
177             which you could see some wierd error like
178
179             ::
180
181               $ cvs -q -d ...:/cvsroot/mymodule checkout -d . ... mymodule
182               cvs checkout: existing repository /cvsroot/mymodule does not match /cvsroot/mymodule/mymodule
183               cvs checkout: ignoring module mymodule
184
185             When this is the case, the culprit may be a CVS
186             shortcoming not being able to handle ``-d .`` in the
187             right way.  Specify a different ``subdir`` option to
188             avoid the problem.
189
190   c. Run tailor on it once, to bootstrap the project::
191   
192       $ tailor -D -v -c cmfcore.tailor
193
194      If the target repository is on the local filesystem (ie, it
195      starts with ``file:///``) and it does not exist, tailor
196      creates a new empty Subversion repository at the specified
197      location.
198     
199   .. note:: Before step d) below, you may want to install an
200             appropriate hook in the repository to enable the
201             propset command to operate on unversioned properties,
202             as described in the `svn manual`__. Then you can
203             specify '--use-propset' option, and tailor will
204             put the original author and timestamp in the proper
205             svn metadata instead of appending them to the changelog.
206
207             Other than the annoying repository manual intervention,
208             this thread__ and this other__ explain why using
209             ``-r{DATE}`` may produce strange results with this setup.
210
211   d. Run tailor again and again, to sync up with latest changes::
212
213       $ tailor -v --configfile cmfcore.tailor
214   
215__ http://svnbook.red-bean.com/en/1.0/ch05s02.html#svn-ch-5-sect-2.1
216__ http://svn.haxx.se/users/archive-2005-07/0605.shtml
217__ http://svn.haxx.se/users/archive-2005-03/0596.shtml
218
219
2203. Given the configuration file shown below in `Config file format`_,
221   the following command::
222
223    $ tailor --configfile example.tailor
224
225   is equivalent to this one::
226
227    $ tailor --configfile example.tailor tailor
228
229   in that they operate respectively on the default project(s) or
230   the ones specified on the command line (and in this case there
231   is just a single default project, tailor).
232
233   This one instead::
234
235    $ tailor -c example.tailor tailor tailor-reverse
236
237   operates on both projects.
238
239
240CVS start-revision
241------------------
242
243With CVS, you can specify a particular *point in time* specifying
244a `start-revision` with a timestamp like ``2001-12-25 23:26:48 UTC``.
245
246To specify also a particular `branch`, prepend it before the
247timestamp, as in ``unstable-branch 2001-12-25 23:26:48 UTC``.
248
249To migrate the whole history of a specific `branch`, use something
250like ``somebranch INITIAL``.
251
252
253Resolving conflicts
254===================
255
256Should one of the replayed changes generate any conflict, tailor
257will prompt the user to correct them. This is done after the upstream
258patch has been applied and before the final commit on the target
259system, so that manually tweaking the conflict can produce a clean
260patch.
261
262
263Shortcomings
264============
265
266Tailor currently suffers of the following reported problems:
267
268a) It does not handle "empty" CVS checkouts, in other words you cannot
269   bootstrap a project that has nothing in its CVS upstream
270   repository, or from a point in time where this condition was true.
271
272b) It's completely unsupported under Windows, evenif it now uses
273   2.4's subprocess_ that seems able to hide Windows crazyness...
274
275c) ArX and Codeville are (currently) only supported as *target*;
276   Baz and Tla only as *source*.
277
278d) Specifying ``--subdir .`` may not work, in particular when dealing
279   with remote CVS repositories (it does when the CVS repository is
280   on local machine).
281   
282This list will always be incomplete, but I'll do my best to keep it
283short :-)
284
285.. _subprocess: http://www.lysator.liu.se/~astrand/popen5/
286
287
288Config file format
289==================
290
291When your project is composed by multiple upstream modules, it is
292easier to collect such information in a single file. This is done by
293specifying the `--configfile` option with a file name as argument. In
294this case, tailor will read the above information from a standard
295Python ConfigParser file.
296
297For example::
298
299    [DEFAULT]
300    verbose = True
301    projects = tailor
302
303    [tailor]
304    root-directory = /tmp/n9
305    source = darcs:tailor
306    target = svn:tailor
307    state-file = tailor.state
308
309    [tailor-reverse]
310    root-directory = /tmp/n9
311    source = svn:tailor
312    target = darcs:tailor
313    state-file = reverse.state
314   
315    [svn:tailor]
316    repository = file:///tmp/testtai
317    module = /project1
318    subdir = svnside
319   
320    [darcs:tailor]
321    repository = ~/WiP/cvsync
322    subdir = darcside
323
324The configuration may hold one or more `projects`_ and two or more
325`repositories`_: project names do not contains colons ":",
326repository names must and the first part of the name before the
327colon specify the kind of the repository.  So, the above example
328contains two projects, one that goes from `darcs` to `subversion`, the
329other in the opposite direction.
330
331The ``[DEFAULT]`` section contains the default values, that will be
332used when a specific setting is missing from the particular section.
333
334You can specify on which project tailor should operate by
335giving its name on the command line, even more than one. When not
336explicitly given, tailor will look at ``projects`` in the
337``[DEFAULT]`` section, and if its missing it will loop over all
338projects in the configuration.
339
340The following simpler config just go in one direction, for a single
341project, so no need neither for ``[DEFAULT].projects`` nor command
342line arguments. Also, notice the usage of the repository short cut:
343the ``source`` and ``target`` will be implicitly loaded from
344`cvs:pxlib` and `hg:pxlib` respectively::
345
346    [pxlib]
347    source = cvs:
348    target = hg:
349    root-directory = ~/mypxlib
350    start-revision = INITIAL
351    subdir = pxlib
352   
353    [cvs:pxlib]
354    repository = :pserver:anonymous@cvs.sf.net:/cvsroot/pxlib
355    module = pxlib
356
357    [hg:pxlib]
358    hg-command = /usr/local/bin/hg
359
360This will use a single directory, ``pxlib`` to contain both the source
361and the target system. If you prefer keeping them separated, you just
362need to specify a different directory for each repository [#]_, as in::
363
364    [pxlib]
365    source = cvs:pxlib
366    target = hg:pxlib
367    root-directory = ~/mypxlib
368    start-revision = INITIAL
369   
370    [cvs:pxlib]
371    repository = :pserver:anonymous@cvs.sf.net:/cvsroot/pxlib
372    module = pxlib
373    subdir = original
374    delay-before-apply = 10
375
376    [hg:pxlib]
377    hg-command = /usr/local/bin/hg
378    subdir = migrated
379
380This will extract upstream CVS sources into ``~/mypxlib/original``,
381and create a new Mercurial repository in ``~/mypxlib/migrated``.
382
383On final example to show the syntax of Baz sources::
384
385    [project]
386    target = hg:target
387    start-revision = base-0
388    root-directory = /tmp/calife
389    state-file = hidden
390    source = baz:source
391
392    [baz:source]
393    module = calife--pam--3.0
394    repository = roberto@keltia.net--2003-depot
395    subdir = tla
396
397    [hg:target]
398    repository = /tmp/HG/calife-pam
399    subdir = hg
400
401Note the usage of ``hidden`` for the state file name: given the
402importance of this file, that at the same time is of no interest by
403the user, this will store that information `inside` the same directory
404used by the target repository for its metadata, with the name
405``tailor.state``.  In this particular example, it will end up as
406``/tmp/calife/hg/.hg/tailor.state``.
407
408.. [#] NB: when the source and the target repositories specify
409       different directories with the ``subdir`` option, tailor
410       uses ``rsync`` to keep them in sync, so that tool needs
411       to be installed.
412
413
414Configuration sections
415----------------------
416
417Default
418~~~~~~~
419
420The ``[DEFAULT]`` section in the configuration file may set the
421default value for any of the recognized options: when a value is
422missing from a specific section it is looked up in this section.
423
424One particular option, ``projects``, is meaningful only in the
425``[DEFAULT]`` section: it's a comma separated list of project names,
426the one that will be operated on by tailor when no project is
427specified on the command line.  When the there are no ``projects``
428setting nor any on the command line, tailor activates all configured
429projects, in order of appearance in the config file.
430
431
432Projects
433~~~~~~~~
434
435A project is identified by a section whose name does not contain any
436colon (":") character, and configured with the following values:
437
438.. note:: If a particular option is missing from the project section,
439          its value is obtained looking up the same option in the
440          ``[DEFAULT]`` section.
441
442root-directory : string
443  This is where all the fun will happen: this directory will contain
444  the source and the target working copy, and usually the state and
445  the log file. It supports the conventional `~user` to indicate user's
446  home directory and defaults to the current working directory.
447
448subdir : string
449  This is the subdirectory, relative to the `root-directory`, where
450  tailor will extract the source working copy. It may be '.' for some
451  backend kinds. The source and target backends will use this value
452  if they don't explicitly override it.
453
454state-file : string
455  Name of the state file needed to store tailor last activity. When
456  this is set to ``hidden``, the state file will be named
457  ``tailor.state``, possibly under the target's ``METADIR``.
458
459source : string
460  The source repository: a repository name is something like
461  "darcs:somename", that will be loaded from the homonymous section
462  in the configuration. As a short cut, the "somename" part may be
463  omitted: in that case, the project name will be appended to the
464  specified prefix.
465
466target : string
467  The counterpart of `source`, the repository that will receive the
468  changes coming from there.
469
470Non mandatory options:
471
472verbose : bool
473  Print the commands as they are executed.
474
475debug : bool
476  Print also their output.
477 
478before-commit : tuple
479  This is a function name, or a sequence of function names enclosed
480  by brackets, that will be executed on each changeset just before
481  it get replayed on the target system: this may be used to perform
482  any kind of alteration on the content of the changeset, or to skip
483  some of them.
484
485after-commit : tuple
486  This is a function name, or a sequence of function names enclosed
487  by brackets, that will be executed on each changeset just after
488  the commit on the target system: this may be used for example to
489  create a tag.
490
491subdir : string
492  The name of the subdirectory, under ``root-directory``, that will
493  contain the source and target repositories/working directories.
494
495start-revision : string
496  This identifies from when tailor should start the migration. It can
497  be either ``INITIAL``, to indicate the start of the history, or
498  ``HEAD`` to indicate the current latest changeset, or a backend
499  specific way of indicate a particular revision/tag in the history.
500  See also `CVS start-revision`_ above.
501
502patch-name-format : string
503  Some backends have a distinct notion of `patch name` and `change
504  log`, others just suggest a policy that the first line of the
505  message is a summary, the rest if present is a more detailed
506  description of the change.  With this option you can control the
507  format of the name, or of the first line of the changelog.
508
509  The prototype may contain ``%(keyword)s`` such as 'author', 'date',
510  'revision', 'firstlogline', 'remaininglog' or 'project'.  It
511  defaults to ``[%(project)s @ %(revision)s]``; setting it to the
512  empty string means that tailor will simply use the original
513  changelog.
514
515  When you set it empty, as in
516
517  ::
518
519    [project]
520    patch-name-format =
521
522  tailor will keep the original changelog as is.
523
524remove-first-log-line : bool
525  Remove the first line of the upstream changelog. This is intended to
526  go in pair with ``patch-name-format``, when using its 'firstlogline'
527  variable to build the name of the patch.  The default is ``False``.
528 
529  A reasonable usage is::
530
531    [DEFAULT]
532    patch-name-format=[%(project)s @ %(revision)s]: %(firstlogline)s
533    remove-first-log-line=True
534
535refill-changelogs : bool
536  Off by default, when active tailor reformats every changelog before
537  committing on the target system.
538
539
540Repositories
541~~~~~~~~~~~~
542
543All the section whose name contains at least one colon character
544denote a repository.  A single repository may be shared by zero, one or
545more projects.  The first part of the name up to the first colon
546indicates the `kind` of the repository, one of ``arx``, ``baz``, ``bzr``,
547``cdv``, ``cvs``, ``darcs``, ``git``, ``hg``, ``monotone``, ``p4``,
548``svn`` and ``tla``.
549
550.. note:: If a particular option is missing from the repository section,
551          its value is obtained looking up the same option in the
552          section of the project *currently* using the repository,
553          falling back to the ``[DEFAULT]`` section.
554
555Some options may be shared with others repositories, like in the
556following example, where the common settings for the target monotone
557repository are set just once::
558
559  [DEFAULT]
560  target-repository = /bigdisk/my-huge-repository.mtn
561  target-keyid = test@example.com
562  target-passphrase = lala
563  source-repository = http://svn.someserver.com
564 
565  [productA]
566  target = monotone:productA
567  source = svn:sourceA
568
569  [productB]
570  target = monotone:productB
571  source = darcs:sourceB
572
573  [productC]
574  target = monotone:productC
575  source = svn:sourceC
576
577  [productC_darcs]
578  target = darcs:
579  source = svn:sourceC
580 
581  ...
582
583  [monotone:productA]
584  module = every.thing.productA
585
586  [monotone:productB]
587  module = every.thing.productB
588
589  [monotone:productC]
590  module = every.thing.productC
591 
592  [svn:sourceA]
593  module = /productA
594
595  [darcs:sourceB]
596  repository = http://some.server.com/darcs/productB
597
598  [svn:sourceC]
599  module = /productC
600
601For some backends, for example for those that like ``darcs`` do not
602make a distinction between `repository` and `working copy` and thus
603the former may be assumed by ``root-directory`` (and possibly
604``subdir``), the config section may be completely omitted, as done for
605`productC_darcs` above.
606
607
608Common options
609%%%%%%%%%%%%%%
610
611repository : string
612  When a repository is used as a `source`, it must indicate its origin
613  with ``repository``, and for some backends also a ``module``, but
614  are not required when it's a target system, even if some backend may
615  use the information to create the target repository (like ``svn``
616  backend does).
617
618subdir : string
619  When the `source` and `target` repositories use different
620  subdirectories, tailor uses ``rsync`` to copy the changes between
621  the two after each applied changeset.  When the source repository
622  basedir is a subdirectory of target basedir tailor prefixes all
623  paths coming from upstream to match the relative position.
624
625  This defaults to the project's setting.
626
627command : string
628  Backends based on external command line tool such as *svn* or
629  *darcs* offers this option to impose a particular external binary to
630  be used, as done in the example above for ``hg``.
631
632python-path : string
633  For pythonique backends such as *bzr* and *hg* this indicates
634  where the respective library is located.
635
636encoding : string
637  States the charset encoding the particular repository uses, and it's
638  particularly important when it differs from local system setup, that
639  you may inspect executing::
640
641    python -m locale
642
643encoding-errors-policy : string
644  By default is *strict*, that means that Python will raise an
645  exception on Unicode conversion errors. Valid options are *ignore*
646  that simply skips offending glyphs and *replace* where unrecognized
647  entities are replaced with a place holder.
648
649delay-before-apply : integer
650  Sometime the migration is fast enough to put the upstream server
651  under an excessive load. When this is the case, you may specify
652  ``delay-before-apply = 5``, that is the number of seconds tailor
653  will wait before applying each changeset.
654
655  It defaults to *None*, ie no delay at all.
656
657arx
658%%%
659
660.. no specific options
661
662baz
663%%%
664
665.. no specific options
666
667bzr
668%%%
669
670.. no specific options
671
672cdv
673%%%
674
675.. no specific options
676
677cvs
678%%%
679
680changeset-threshold : integer
681  Maximum number of seconds allowed to separated commits to different
682  files for them to be considered part of the same changeset.
683
684  180 by default.
685
686freeze-keywords : bool
687  With this enabled (it is off by default) tailor will use ``-kk`` flag
688  on `checkouts` and `updates` to turn off the keyword expansion. This
689  may help minimizing the chance of spurious conflicts with later
690  merges between different branches.
691
692  *False* by default.
693
694tag-entries : bool
695  CVS and CVSPS repositories may turn off automatic tagging of
696  entries, that tailor does by default to prevent manual interventions
697  in the CVS working copy, using ``tag_entries = False``.
698
699  *True* by default.
700
701cvsps
702%%%%%
703
704freeze-keywords : bool
705  With this enabled (it is off by default) tailor will use ``-kk`` flag
706  on `checkouts` and `updates` to turn off the keyword expansion. This
707  may help minimizing the chance of spurious conflicts with later
708  merges between different branches.
709
710  *False* by default.
711
712tag-entries : bool
713  CVS and CVSPS repositories may turn off automatic tagging of
714  entries, that tailor does by default to prevent manual interventions
715  in the CVS working copy, using ``tag_entries = False``.
716
717  *True* by default.
718 
719darcs
720%%%%%
721
722look-for-adds : bool
723  By default tailor commits only the entries explicitly mentioned by
724  the upstream changeset. Sometimes this is not desiderable, maybe
725  even as a quick workaround to a tailor bug. This option allows a
726  more relaxed view of life using ``record --look-for-adds``.
727
728replace-badchars : string
729  Apparently some darcs repo contains some characters that are illegal
730  in an XML stream. This is the case when one uses non-utf8
731  accents. To be safe, you can replace them with their xml-safe
732  equivalent. The given string must be a regular and valid Python
733  dictionary, with each substitution keyed on the character to be
734  replaced. By default it's::
735
736    {
737      '\xc1': '&#193;',
738      '\xc9': '&#201;',
739      '\xcd': '&#205;',
740      '\xd3': '&#211;',
741      '\xd6': '&#214;',
742      '\xd5': '&#336;',
743      '\xda': '&#218;',
744      '\xdc': '&#220;',
745      '\xdb': '&#368;',
746      '\xe1': '&#225;',
747      '\xe9': '&#233;',
748      '\xed': '&#237;',
749      '\xf3': '&#243;',
750      '\xf6': '&#246;',
751      '\xf5': '&#337;',
752      '\xfa': '&#250;',
753      '\xfc': '&#252;',
754      '\xfb': '&#369;',
755      '\xf1': '&#241;',
756      '\xdf': '&#223;',
757      '\xe5': '&#229;'
758    }
759   
760start-revision : string
761  Under darcs this may be either the name of a tag or the hash of an
762  arbitrary patch in the repository, plus the ordinary ``INITIAL`` or
763  ``HEAD`` symbols.
764
765  .. note:: If you want to start from a particular patch, giving its
766            hash value as ``start-revision``, you **must** use a
767            ``subdir`` different from ``.``. [#]_
768
769git target
770%%%%%%%%%%
771
772parent-repo : string
773  Relative path to a git directory to use as a parent.  This is one
774  way to import branches into a git repository, which creates a new
775  git repository borrowing ancestry from the parent-repo.  It is quite
776  a simple way, and thus believed to be quite robust, but spreads
777  branches across several git repositories. If this parameter is
778  not set, and ``repository`` is not set either, the branch has no
779  parent.
780
781  The alternative is to specify a ``repository`` parameter, to contain
782  all git branches.  The .git directory in the working copy for each
783  branch will then only contain the ``.git/index`` file.
784
785branch : string
786  The name of the branch to which to commit.  It is only used in
787  single-repository mode (using ``repository``, see above).  The
788  default is to use the "master" branch.
789
790branchpoint : string
791  A reference to the git commit which is the parent for the first
792  revision on the branch to be imported.  It can be a tag name or any
793  syntax acceptable by git (eg. something like "tag~2", if you want to
794  correct the idea of where the branchpoint is).
795
796  Since tailor generates mostly-stable SHA-1 revisions, you can
797  usually also use a SHA-1 as branchpoint.  Just import your trunk
798  first, find the correct SHA-1, and setup and import your branch.
799  This is especially useful since the current cvs source
800  implementation misses many tags.
801
802hg
803%%
804
805.. no specific options
806
807monotone
808%%%%%%%%
809
810keyid : string
811  Monotone key id to use for commits. The specified key
812  must exist on keystore. Takes precedence
813  over keygenid.
814
815keygenid : string
816  Id of a new keypair to generate and store in the
817  repository.
818  The keypair is used for commits. Ignored if keyid is
819  specified.
820
821passphrase : string
822  Passphrase to use for commits. Must be specified unless you have one
823  on your .monotonerc file
824
825custom-lua : string
826  Optional custom lua script. If present, is written into _MTN/monotonerc.
827
828p4
829%%
830
831depot-path : string
832  The path within the depot indicating the root of all files that will be
833  replicated.
834 
835  This is used both for determining changes as well as mapping
836  file locations from changesets to the filesystem.
837
838  Example:  ``//depot/project/main/``
839
840p4-client : string
841  The perforce client spec to use.
842
843  Example:  ``myhostname-tailor``
844
845p4-port : string
846  The address of the perforce server.
847
848  Example: ``perforce.mycompany.com:1666``
849
850svn
851%%%
852
853filter-badchars : bool (or string)
854  Activate (with *True*) or activate and specify (with a *string*) the
855  filter on the svn log to eliminate illegal XML characters.
856
857  *False* by default, when set to *True* the following characters are
858  washed out from the upstream changes::
859
860    allbadchars = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09" \
861                  "\x0B\x0C\x0E\x0F\x10\x11\x12\x13\x14\x15" \
862                  "\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x7f"
863
864  If this is not right or enough, you can specify a string value
865  instead of the boolean flag, containing the characters to omit, as
866  in::
867
868    filter-badchars=\x00\x01
869 
870use-propset : bool
871  Indicate that tailor is allowed to properly inject the upstream
872  changeset's author and timestamp into the target repository.  As
873  stated above, this requires a manual intervention on the repository
874  itself and thus is off by default, and tailor simply appends those
875  values to the changelog.  When active at bootstrap time and the
876  repository is local, tailor creates automatically a minimal
877  ``hooks/pre-revprop-change`` script inside the repository, so no
878  other intervention is needed.
879
880  *False* by default.
881
882propset-date : bool
883  By default *True*, can be used to avoid setting the ``svn:date``
884  property on the Subversion revision, and thus problem with
885  ``-r{DATE}`` mentioned above.  When this is *False*, the original
886  timestamp gets appended to the revision log.
887
888use-limit : bool
889  By default *True*, should be set to *False* when using old
890  Subversion clients, since ``log --limit`` was introduced with
891  version 1.2. By using this option tailor can fetch just the
892  revision it needs, instead of transfering whole history log.
893
894commit-all-files : bool
895  By default *True*, commits all files from current changeset. Lets
896  Subversion check the changes self.
897  Set it to *False*, then whish to commits only changed files, that
898  tailor detects, perhaps a network speedup.  But a  *False* can be
899  insert an extra revision on long dep paths with lot of files. You
900  would see two revisions on target, where the source have only one.
901  For a true convert should leave it *True*.
902
903trust-root : bool
904  Tailor by default verifies that the specified ``repository``
905  effectively points to the root of a Subversion repository,
906  eventually splitting it and adjusting ``module`` accordingly.  This
907  is sometimes undesiderable, for example when the root isn't public
908  and cannot be listed.  Setting this option to *True* disable the
909  check and tailor takes the given ``repository`` and ``module`` as-is.
910
911ignore-externals : bool
912  By default the Subversion backend does not consider the external
913  references defined in the source repository.  This option force
914  Tailor to behave as it did up to 0.9.20.
915
916svn-tags : string
917  Name of the directory used for tags: tailor will copy tagged
918  revisions under this directory.
919
920  ``/tags`` by default.
921
922svn-branches : string
923  Name of the directory used for branches: tailor will copy branches
924  under that directory.
925
926  ``/branches`` by default.
927
928  .. note:: Target module for branches **must** start with ``branches/``.
929            Every branch must configure in a single-repository mode.
930
931            Example: ``module = branches/branch.name``
932
933tla
934%%%
935
936.. no specific options
937
938
939.. [#] This is because when you use ``subdir = .`` tailor uses
940       ``darcs pull`` instead of ``darcs get``, and the former does
941       not accept the option ``--to-match``.
942
943
944Using a Python script as configuration file
945-------------------------------------------
946
947Instead of executing ``tailor --configfile project.tailor.conf``
948you can prepend the following signature to the config itself::
949
950  #!/usr/bin/env /path/to/tailor
951
952Giving execute mode to it will permit the launch of the tailor
953process by running the config script directly::
954
955  $ ./project.tailor.conf
956
957When a config file is signed in this way [#]_, either you pass it as
958argument to ``--configfile`` or executed as above, tailor will
959actually execute it as a full fledged Python script, that may define
960functions that alter the behaviour of tailor itself.
961
962Pre-commit and post-commit hooks
963~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
964
965A common usage of this functionality is to define so called `hooks`,
966sequences of functions that are executed at particular points in
967the tailorization process.
968
969Example 1
970%%%%%%%%%
971
972Just to illustrate the functionality, consider the following example::
973
974    #!/usr/bin/env tailor
975
976    """
977    [DEFAULT]
978    debug = False
979    verbose = True
980
981    [project]
982    target = bzr:target
983    root-directory = /tmp/prova
984    state-file = tailor.state
985    source = darcs:source
986    before-commit = before
987    after-commit = after
988    start-revision = Almost arbitrarily tagging this as version 0.8
989
990    [bzr:target]
991    python-path = /opt/src/bzr.dev
992    subdir = bzrside
993
994    [darcs:source]
995    repository = /home/lele/WiP/cvsync
996    subdir = darcside
997    """
998
999    def before(wd, changeset):
1000        print "BEFORE", changeset
1001        changeset.author = "LELE"
1002        return changeset
1003
1004    def after(wd, changeset):
1005        print "AFTER", changeset
1006
1007With the above in a `script` called say ``tester``, just doing::
1008
1009    $ chmod 755 tester
1010    $ ./tester
1011
1012will migrate the history from a darcs repository to a Bazaar one,
1013forcing the author to a well-known name :-)
1014
1015Example 2
1016%%%%%%%%%
1017
1018A pre commit hook may even alter the content of the files. The
1019following function replaces the DOS end-of-line convention with the
1020UNIX one::
1021
1022    def newlinefix(wd, changeset):
1023        from pyutil import lineutil
1024        lineutil.lineify_all_files(wd.basedir, strip=True,
1025                                   dirpruner=lineutil.darcs_metadir_dirpruner,
1026                                   filepruner=lineutil.source_code_filepruner)
1027        return True
1028
1029It uses zooko's pyutil[#]_ toolset.  Another approach would be looping
1030over changeset.entries and operating only on added or changed entries.
1031
1032Example 3
1033%%%%%%%%%
1034
1035This loops over the file touched by a particular changeset and tries
1036to reindent it if it's a Python file::
1037
1038    def reindent_em(wd, changeset):
1039        import reindent
1040        import os
1041       
1042        for entry in changeset.entries:
1043            fname = os.path.join(wd.basedir, entry.name)
1044
1045            try:
1046                if fname[-3:] == '.py':
1047                    reindent.check(fname)
1048            except Exception, le:
1049                print "got an exception from attempt to reindent" \
1050                      " (maybe that file wasn't Python code?):" \
1051                      " changeset entry: %s, exception:" \
1052                      " %s %s %s" % (entry, type(le), repr(le),
1053                                     hasattr(le, 'args') and le.args,)
1054                raise le
1055        return True
1056
1057You have to find reindent.py in your Python distribution and put it
1058in your python path. **Beware** that this has some drawbacks: be sure
1059to read `ticket 8`_ annotations if you use it.
1060
1061.. [#] Tailor does actually read just the first two bytes from the
1062       file, and compare them with "#!", so you are free to choose
1063       whatever syntax works in your environment.
1064
1065.. [#] Available either at https://yumyum.zooko.com:19144/pub/repos/pyutil
1066       or http://zooko.com/repos/pyutil.
1067
1068.. _ticket 8: http://progetti.arstecnica.it/tailor/ticket/8
1069
1070
1071State file
1072----------
1073
1074The state file stores two things: the last upstream revision that
1075has been applied to the tree, and a sequence of pending (not yet
1076applied) changesets, that may be empty. In the latter case, tailor
1077will fetch latest changes from the upstream repository.
1078
1079
1080Logging
1081-------
1082
1083Tailor uses the Python's logging module to emit noise. Its basic
1084configuration is hardwired and corresponds to the following::
1085
1086    [formatters]
1087    keys = console
1088
1089    [formatter_console]
1090    format =  %(asctime)s [%(levelname).1s] %(message)s
1091    datefmt = %H:%M:%S
1092
1093    [loggers]
1094    keys = root
1095
1096    [logger_root]
1097    level = INFO
1098    handlers = console
1099
1100    [handlers]
1101    keys = console
1102
1103    [handler_console]
1104    class = StreamHandler
1105    formatter = console
1106    args = (sys.stdout,)
1107    level = INFO
1108
1109However, you can completely override the default adding a
1110*supersection* ``[[logging]]`` to the configuration file, something
1111like::
1112
1113    # ... usual tailor config ...
1114    [project]
1115    source = bzr:source
1116    target = hg:target
1117
1118    # Here ends tailor config, and start the one for the logging
1119    # module
1120
1121    [[logging]]
1122
1123    [logger_tailor.BzrRepository]
1124    level = DEBUG
1125    handlers = tailor.source
1126
1127    [handler_tailor.source]
1128    class = SMTPHandler
1129    args = ('localhost', 'from@abc', ['tailor@abc'], 'Tailor log')
1130
1131Further help
1132============
1133
1134See the output of ``tailor -h`` for some further tips.  There's
1135also a `wiki page`_ that may give you some other hints.  The
1136development of Tailor is mainly driven by user requests at this point,
1137and the preferred comunication medium is the dedicated `mailing list`_
1138[#]_.
1139
1140.. _wiki page:
1141   http://www.darcs.net/DarcsWiki/Tailor
1142
1143.. _mailing list:
1144   http://lists.zooko.com/mailman/listinfo/tailor
1145   
1146I will be more than happy to answer any doubt, question or suggestion
1147you may have on it. I'm usually hanging out as "lelit" on the
1148``#tailor`` IRC channel on the `freenode.net` network. Do not hesitate
1149to contact me either by email or chatting there.
1150
1151.. [#] I wish to say a big `Thank you` to `Zooko <zooko@zooko.com>`_,
1152       for hosting the ML and for supporting Tailor in several ways,
1153       from suggestions to bug reporting and fixing.
1154
1155
1156Authors
1157=======
1158
1159Lele Gaifax <lele@nautilus.homeip.net>
1160
1161Since I'm not currently using all the supported systems (so little
1162time, so many VCSs...) I'm not in position to test them out properly,
1163but I'll do my best to keep them in sync, maybe with your support :-)
1164
1165ArX support
1166-----------
1167
1168ArX_ support was contributed by `Walter Landry <wlandry@ucsd.edu>`_.
1169
1170Bazaar support
1171-----------------
1172
1173`Bazaar`_ support was contributed by `Johan Rydberg
1174<jrydberg@gnu.org>`_.  Nowadays it's being maintained by `Lalo Martins
1175<lalo.martins@gmail.com>`_.
1176
1177Git support
1178-----------
1179
1180`Git`_ support was contributed by `Todd Mokros
1181<tmokros@tmokros.net>`_.
1182
1183Monotone support
1184----------------
1185
1186Monotone_ support was kindly contributed by `Markus Schiltknecht
1187<markus@bluegap.ch>`_ and further developed by `rghetta
1188<birrachiara@tin.it>`_, that was able to linearize the multi-headed
1189monotone history into something tailor groks. Kudos!
1190More recently, `Henry Nestler <henry@bigfoot.de>`_ contributed
1191various enhancements, like using ``automate`` instead ``list`` and tag
1192support.
1193
1194Perforce support
1195----------------
1196
1197Perforce_ support was kindly contributed by `Dustin Sallings
1198<dustin@spy.net>`_.
1199
1200Tla support
1201-----------
1202
1203Tla_ support was contributed by `Robin Farine
1204<robin.farine@terminus.org>`_.
1205
1206
1207License
1208=======
1209
1210Tailor is distribuited under the `GNU General Public License`__.
1211
1212__ http://www.fsf.org/licensing/licenses/gpl.html
1213
1214
1215About this document
1216===================
1217
1218This document and most of the internal documentation use the
1219reStructuredText format so that it can be easily converted into other
1220formats, such as HTML.  For more information about this, please see:
1221
1222  http://docutils.sourceforge.net/rst.html
1223
1224
1225.. vim:ft=rest
1226.. Local Variables:
1227.. mode: rst
1228.. End:
Note: See TracBrowser for help on using the repository browser.