source: tailor/README @ 1195

Revision 1195, 33.3 KB checked in by ydirson@…, 7 years ago (diff)

[git] add support for "repository" parameter

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