source: tailor/README @ 1159

Revision 1159, 31.9 KB checked in by Yann Dirson <ydirson@…>, 7 years ago (diff)

Make changeset-threshold a cvs 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
668%%%
669
670.. no specific options
671
672hg
673%%
674
675.. no specific options
676
677monotone
678%%%%%%%%
679
680keyid : string
681  Monotone key id to use for commits. The specified key
682  must exist on keystore. Takes precedence
683  over keyfile and keygenid.
684
685keyfile : string
686  File containing a keypair to store in the repository.
687  The keypair is used for commits. Ignored if keyid is
688  specified.
689
690keygenid : string
691  Id of a new keypair to generate and store in the
692  repository.
693  The keypair is used for commits. Ignored if keyid is
694  specified.
695
696passphrase : string
697  Passphrase to use for commits. Must be specified.
698
699custom_lua : string
700  Optional custom lua script. If present, is written into MT/monotonerc.
701
702svn
703%%%
704
705filter-badchars : bool (or string)
706  Activate (with *True*) or activate and specify (with a *string*) the
707  filter on the svn log to eliminate illegal XML characters.
708
709  *False* by default, when set to *True* the following characters are
710  washed out from the upstream changes::
711
712    allbadchars = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09" \
713                  "\x0B\x0C\x0E\x0F\x10\x11\x12\x13\x14\x15" \
714                  "\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x7f"
715
716  If this is not right or enough, you can specify a string value
717  instead of the boolean flag, containing the characters to omit, as
718  in::
719
720    filter-badchars=\x00\x01
721 
722use-propset : bool
723  Indicate that tailor is allowed to properly inject the upstream
724  changeset's author and timestamp into the target repository.  As
725  stated above, this requires a manual intervention on the repository
726  itself and thus is off by default, and tailor simply appends those
727  values to the changelog.  When active at bootstrap time and the
728  repository is local, tailor creates automatically a minimal
729  ``hooks/pre-revprop-change`` script inside the repository, so no
730  other intervention is needed.
731
732  *False* by default.
733
734use-limit : bool
735  By default *True*, should be set to *False* when using old
736  Subversion clients, since ``log --limit`` was introduced with
737  version 1.2. By using this option tailor can fetch just the
738  revision it needs, instead of transfering whole history log.
739
740trust-root : bool
741  Tailor by default verifies that the specified ``repository``
742  effectively points to the root of a Subversion repository,
743  eventually splitting it and adjusting ``module`` accordingly.  This
744  is sometimes undesiderable, for example when the root isn't public
745  and cannot be listed.  Setting this option to *True* disable the
746  check and tailor takes the given ``repository`` and ``module`` as-is.
747
748ignore-externals : bool
749  By default the Subversion backend does not consider the external
750  references defined in the source repository.  This option force
751  Tailor to behave as it did up to 0.9.20.
752
753tla
754%%%
755
756.. no specific options
757
758
759.. [#] This is because when you use ``subdir = .`` tailor uses
760       ``darcs pull`` instead of ``darcs get``, and the former does
761       not accept the option ``--to-match``.
762
763
764Using a Python script as configuration file
765-------------------------------------------
766
767Instead of executing ``tailor --configfile project.tailor.conf``
768you can prepend the following signature to the config itself::
769
770  #!/usr/bin/env /path/to/tailor
771
772Giving execute mode to it will permit the launch of the tailor
773process by running the config script directly::
774
775  $ ./project.tailor.conf
776
777When a config file is signed in this way [#]_, either you pass it as
778argument to ``--configfile`` or executed as above, tailor will
779actually execute it as a full fledged Python script, that may define
780functions that alter the behaviour of tailor itself.
781
782Pre-commit and post-commit hooks
783~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
784
785A common usage of this functionality is to define so called `hooks`,
786sequences of functions that are executed at particular points in
787the tailorization process.
788
789Example 1
790%%%%%%%%%
791
792Just to illustrate the functionality, consider the following example::
793
794    #!/usr/bin/env tailor
795
796    """
797    [DEFAULT]
798    debug = False
799    verbose = True
800
801    [project]
802    target = bzr:target
803    root-directory = /tmp/prova
804    state-file = tailor.state
805    source = darcs:source
806    before-commit = before
807    after-commit = after
808    start-revision = Almost arbitrarily tagging this as version 0.8
809
810    [bzr:target]
811    python-path = /opt/src/bzr.dev
812    subdir = bzrside
813
814    [darcs:source]
815    repository = /home/lele/WiP/cvsync
816    subdir = darcside
817    """
818
819    def before(wd, changeset):
820        print "BEFORE", changeset
821        changeset.author = "LELE"
822        return changeset
823
824    def after(wd, changeset):
825        print "AFTER", changeset
826
827With the above in a `script` called say ``tester``, just doing::
828
829    $ chmod 755 tester
830    $ ./tester
831
832will migrate the history from a darcs repository to a bazaar-ng one,
833forcing the author to a well-known name :-)
834
835Example 2
836%%%%%%%%%
837
838A pre commit hook may even alter the content of the files. The
839following function replaces the DOS end-of-line convention with the
840UNIX one::
841
842    def newlinefix(wd, changeset):
843        from pyutil import lineutil
844        lineutil.lineify_all_files(wd.basedir, strip=True,
845                                   dirpruner=lineutil.darcs_metadir_dirpruner,
846                                   filepruner=lineutil.source_code_filepruner)
847        return True
848
849It uses zooko's pyutil[#]_ toolset.  Another approach would be looping
850over changeset.entries and operating only on added or changed entries.
851
852Example 3
853%%%%%%%%%
854
855This loops over the file touched by a particular changeset and tries
856to reindent it if it's a Python file::
857
858    def reindent_em(wd, changeset):
859        import reindent
860        import os
861       
862        for entry in changeset.entries:
863            fname = os.path.join(wd.basedir, entry.name)
864
865            try:
866                if fname[-3:] == '.py':
867                    reindent.check(fname)
868            except Exception, le:
869                print "got an exception from attempt to reindent" \
870                      " (maybe that file wasn't Python code?):" \
871                      " changeset entry: %s, exception:" \
872                      " %s %s %s" % (entry, type(le), repr(le),
873                                     hasattr(le, 'args') and le.args,)
874                raise le
875        return True
876
877You have to find reindent.py in your Python distribution and put it
878in your python path. **Beware** that this has some drawbacks: be sure
879to read `ticket 8`_ annotations if you use it.
880
881.. [#] Tailor does actually read just the first two bytes from the
882       file, and compare them with "#!", so you are free to choose
883       whatever syntax works in your environment.
884
885.. [#] Available either at https://yumyum.zooko.com:19144/pub/repos/pyutil
886       or http://zooko.com/repos/pyutil.
887
888.. _ticket 8: http://progetti.arstecnica.it/tailor/ticket/8
889
890
891State file
892----------
893
894The state file stores two things: the last upstream revision that
895has been applied to the tree, and a sequence of pending (not yet
896applied) changesets, that may be empty. In the latter case, tailor
897will fetch latest changes from the upstream repository.
898
899
900Logging
901-------
902
903Tailor uses the Python's logging module to emit noise. It's basic
904configuration is hardwired and correspond to the following::
905
906    [formatters]
907    keys = console
908
909    [formatter_console]
910    format =  %(asctime)s [%(levelname).1s] %(message)s
911    datefmt = %H:%M:%S
912
913    [loggers]
914    keys = root
915
916    [logger_root]
917    level = INFO
918    handlers = console
919
920    [handlers]
921    keys = console
922
923    [handler_console]
924    class = StreamHandler
925    formatter = console
926    args = (sys.stdout,)
927    level = INFO
928
929However, you can completely override the default adding a
930*supersection* ``[[logging]]`` to the configuration file, something
931like::
932
933    # ... usual tailor config ...
934    [project]
935    source = bzr:source
936    target = hg:target
937
938    # Here ends tailor config, and start the one for the logging
939    # module
940
941    [[logging]]
942
943    [logger_tailor.BzrRepository]
944    level = DEBUG
945    handlers = tailor.source
946
947    [handler_tailor.source]
948    class = SMTPHandler
949    args = ('localhost', 'from@abc', ['tailor@abc'], 'Tailor log')
950
951Further help
952============
953
954See the output of ``tailor -h`` for some further tips.  There's
955also a `wiki page`_ that may give you some other hints.  The
956development of Tailor is mainly driven by user requests at this point,
957and the preferred comunication medium is the dedicated `mailing list`_
958[#]_.
959
960.. _wiki page:
961   http://www.darcs.net/DarcsWiki/Tailor
962
963.. _mailing list:
964   http://lists.zooko.com/mailman/listinfo/tailor
965   
966I will be more than happy to answer any doubt, question or suggestion
967you may have on it. I'm usually hanging out as "lelit" on the
968``#tailor`` IRC channel on the `freenode.net` network. Do not hesitate
969to contact me either by email or chatting there.
970
971.. [#] I wish to say a big `Thank you` to `Zooko <zooko@zooko.com>`_,
972       for hosting the ML and for supporting Tailor in several ways,
973       from suggestions to bug reporting and fixing.
974
975
976Authors
977=======
978
979Lele Gaifax <lele@nautilus.homeip.net>
980
981Since I'm not currently using all the supported systems (so little
982time, so many VCSs...) I'm not in position to test them out properly,
983but I'll do my best to keep them in sync, maybe with your support :-)
984
985ArX support
986-----------
987
988ArX_ support was contributed by `Walter Landry <wlandry@ucsd.edu>`_.
989
990Bazaar-NG support
991-----------------
992
993`Bazaar-NG`_ support was contributed by `Johan Rydberg
994<jrydberg@gnu.org>`_.  Nowadays it's being maintained by `Lalo Martins
995<lalo.martins@gmail.com>`_.
996
997Git support
998-----------
999
1000`Git`_ support was contributed by `Todd Mokros
1001<tmokros@tmokros.net>`_.
1002
1003Monotone support
1004----------------
1005
1006Monotone_ support was kindly contributed by `Markus Schiltknecht
1007<markus@bluegap.ch>`_ and further developed by `rghetta
1008<birrachiara@tin.it>`_, that was able to linearize the multi-headed
1009monotone history into something tailor groks. Kudos!
1010
1011Tla support
1012-----------
1013
1014Tla_ support was contributed by `Robin Farine
1015<robin.farine@terminus.org>`_.
1016
1017
1018License
1019=======
1020
1021Tailor is distribuited under the `GNU General Public License`__.
1022
1023__ http://www.fsf.org/licensing/licenses/gpl.html
1024
1025
1026About this document
1027===================
1028
1029This document and most of the internal documentation use the
1030reStructuredText format so that it can be easily converted into other
1031formats, such as HTML.  For more information about this, please see:
1032
1033  http://docutils.sourceforge.net/rst.html
1034
1035
1036.. vim:ft=rest
1037.. Local Variables:
1038.. mode: rst
1039.. End:
Note: See TracBrowser for help on using the repository browser.