Normalize and cache the paths returned by CVSFile.get_filename().
[cvs2svn.git] / cvs2bzr-example.options
blobec68accd8facd70b14d9263b50ac5873e4602340
1 # (Be in -*- mode: python; coding: utf-8 -*- mode.)
3 # ====================================================================
4 # Copyright (c) 2006-2009 CollabNet.  All rights reserved.
6 # This software is licensed as described in the file COPYING, which
7 # you should have received as part of this distribution.  The terms
8 # are also available at http://subversion.tigris.org/license-1.html.
9 # If newer versions of this license are posted there, you may use a
10 # newer version instead, at your option.
12 # This software consists of voluntary contributions made by many
13 # individuals.  For exact contribution history, see the revision
14 # history and logs, available at http://cvs2svn.tigris.org/.
15 # ====================================================================
17 #                  #####################
18 #                  ## PLEASE READ ME! ##
19 #                  #####################
21 # This is a template for an options file that can be used to configure
22 # cvs2svn to convert to Bazaar rather than to Subversion.  See
23 # www/cvs2bzr.html and www/cvs2svn.html for general information, and
24 # see the comments in this file for information about what options are
25 # available and how they can be set.
27 # The program that is run to convert from CVS to Bazaar is called
28 # cvs2bzr.  Run it with the --options option, passing it this file
29 # like this:
31 #     cvs2bzr --options=cvs2bzr-example.options
33 # The output of cvs2bzr is a dump file that can be loaded into Bazaar
34 # using the "bzr fast-import" command.  Please read www/cvs2bzr.html
35 # for more information.
37 # Many options do not have defaults, so it is easier to copy this file
38 # and modify what you need rather than creating a new options file
39 # from scratch.  This file is in Python syntax, but you don't need to
40 # know Python to modify it.  But if you *do* know Python, then you
41 # will be happy to know that you can use arbitary Python constructs to
42 # do fancy configuration tricks.
44 # But please be aware of the following:
46 # * In many places, leading whitespace is significant in Python (it is
47 #   used instead of curly braces to group statements together).
48 #   Therefore, if you don't know what you are doing, it is best to
49 #   leave the whitespace as it is.
51 # * In normal strings, Python treats a backslash ("\") as an escape
52 #   character.  Therefore, if you want to specify a string that
53 #   contains a backslash, you need either to escape the backslash with
54 #   another backslash ("\\"), or use a "raw string", as in one if the
55 #   following equivalent examples:
57 #       cvs_executable = 'c:\\windows\\system32\\cvs.exe'
58 #       cvs_executable = r'c:\windows\system32\cvs.exe'
60 #   See http://docs.python.org/tutorial/introduction.html#strings for
61 #   more information.
63 # Two identifiers will have been defined before this file is executed,
64 # and can be used freely within this file:
66 #     ctx -- a Ctx object (see cvs2svn_lib/context.py), which holds
67 #         many configuration options
69 #     run_options -- an instance of the BzrRunOptions class (see
70 #         cvs2svn_lib/bzr_run_options.py), which holds some variables
71 #         governing how cvs2bzr is run
74 # Import some modules that are used in setting the options:
75 import os
77 from cvs2svn_lib import config
78 from cvs2svn_lib import changeset_database
79 from cvs2svn_lib.common import CVSTextDecoder
80 from cvs2svn_lib.log import Log
81 from cvs2svn_lib.project import Project
82 from cvs2svn_lib.git_output_option import GitRevisionInlineWriter
83 from cvs2svn_lib.bzr_output_option import BzrOutputOption
84 from cvs2svn_lib.revision_manager import NullRevisionCollector
85 from cvs2svn_lib.rcs_revision_manager import RCSRevisionReader
86 from cvs2svn_lib.cvs_revision_manager import CVSRevisionReader
87 from cvs2svn_lib.checkout_internal import InternalRevisionCollector
88 from cvs2svn_lib.checkout_internal import InternalRevisionReader
89 from cvs2svn_lib.symbol_strategy import AllBranchRule
90 from cvs2svn_lib.symbol_strategy import AllTagRule
91 from cvs2svn_lib.symbol_strategy import BranchIfCommitsRule
92 from cvs2svn_lib.symbol_strategy import ExcludeRegexpStrategyRule
93 from cvs2svn_lib.symbol_strategy import ForceBranchRegexpStrategyRule
94 from cvs2svn_lib.symbol_strategy import ForceTagRegexpStrategyRule
95 from cvs2svn_lib.symbol_strategy import ExcludeTrivialImportBranchRule
96 from cvs2svn_lib.symbol_strategy import ExcludeVendorBranchRule
97 from cvs2svn_lib.symbol_strategy import HeuristicStrategyRule
98 from cvs2svn_lib.symbol_strategy import UnambiguousUsageRule
99 from cvs2svn_lib.symbol_strategy import HeuristicPreferredParentRule
100 from cvs2svn_lib.symbol_strategy import SymbolHintsFileRule
101 from cvs2svn_lib.symbol_transform import ReplaceSubstringsSymbolTransform
102 from cvs2svn_lib.symbol_transform import RegexpSymbolTransform
103 from cvs2svn_lib.symbol_transform import IgnoreSymbolTransform
104 from cvs2svn_lib.symbol_transform import NormalizePathsSymbolTransform
105 from cvs2svn_lib.property_setters import AutoPropsPropertySetter
106 from cvs2svn_lib.property_setters import CVSBinaryFileDefaultMimeTypeSetter
107 from cvs2svn_lib.property_setters import CVSBinaryFileEOLStyleSetter
108 from cvs2svn_lib.property_setters import DefaultEOLStyleSetter
109 from cvs2svn_lib.property_setters import EOLStyleFromMimeTypeSetter
110 from cvs2svn_lib.property_setters import ExecutablePropertySetter
111 from cvs2svn_lib.property_setters import KeywordsPropertySetter
112 from cvs2svn_lib.property_setters import MimeMapper
113 from cvs2svn_lib.property_setters import SVNBinaryFileKeywordsPropertySetter
115 # To choose the level of logging output, uncomment one of the
116 # following lines:
117 #Log().log_level = Log.WARN
118 #Log().log_level = Log.QUIET
119 Log().log_level = Log.NORMAL
120 #Log().log_level = Log.VERBOSE
121 #Log().log_level = Log.DEBUG
124 # The directory to use for temporary files:
125 ctx.tmpdir = r'cvs2svn-tmp'
127 # cvs2bzr does not need to keep track of what revisions will be
128 # excluded, so leave this option unchanged:
129 ctx.revision_collector = NullRevisionCollector()
131 # cvs2bzr's revision reader is set via the BzrOutputOption constructor,
132 # so leave this option set to None.
133 ctx.revision_reader = None
135 # Change the following line to True if the conversion should only
136 # include the trunk of the repository (i.e., all branches and tags
137 # should be omitted from the conversion):
138 ctx.trunk_only = False
140 # How to convert CVS author names, log messages, and filenames to
141 # Unicode.  The first argument to CVSTextDecoder is a list of encoders
142 # that are tried in order in 'strict' mode until one of them succeeds.
143 # If none of those succeeds, then fallback_encoder (if it is
144 # specified) is used in lossy 'replace' mode.  Setting a fallback
145 # encoder ensures that the encoder always succeeds, but it can cause
146 # information loss.
147 ctx.cvs_author_decoder = CVSTextDecoder(
148     [
149         #'latin1',
150         #'utf8',
151         'ascii',
152         ],
153     #fallback_encoding='ascii'
154     )
155 ctx.cvs_log_decoder = CVSTextDecoder(
156     [
157         #'latin1',
158         #'utf8',
159         'ascii',
160         ],
161     #fallback_encoding='ascii'
162     )
163 # You might want to be especially strict when converting filenames to
164 # Unicode (e.g., maybe not specify a fallback_encoding).
165 ctx.cvs_filename_decoder = CVSTextDecoder(
166     [
167         #'latin1',
168         #'utf8',
169         'ascii',
170         ],
171     #fallback_encoding='ascii'
172     )
174 # Template for the commit message to be used for initial project
175 # commits.
176 ctx.initial_project_commit_message = (
177     'Standard project directories initialized by cvs2svn.'
178     )
180 # Template for the commit message to be used for post commits, in
181 # which modifications to a vendor branch are copied back to trunk.
182 # This message can use '%(revnum)d' to include the SVN revision number
183 # of the revision that included the change to the vendor branch
184 # (admittedly rather pointless in a cvs2bzr conversion).
185 ctx.post_commit_message = (
186     'This commit was generated by cvs2svn to track changes on a CVS '
187     'vendor branch.'
188     )
190 # Template for the commit message to be used for commits in which
191 # symbols are created.  This message can use '%(symbol_type)s' to
192 # include the type of the symbol ('branch' or 'tag') or
193 # '%(symbol_name)s' to include the name of the symbol.
194 ctx.symbol_commit_message = (
195     "This commit was manufactured by cvs2svn to create %(symbol_type)s "
196     "'%(symbol_name)s'."
197     )
199 # Template for the commit message to be used for commits in which
200 # tags are pseudo-merged back to their source branch.  This message can
201 # use '%(symbol_name)s' to include the name of the symbol.
202 # (Not used by default unless you enable tie_tag_fixup_branches on
203 # GitOutputOption.)
204 ctx.tie_tag_ancestry_message = (
205     "This commit was manufactured by cvs2svn to tie ancestry for "
206     "tag '%(symbol_name)s' back to the source branch."
207     )
209 # Some CVS clients for MacOS store resource fork data into CVS along
210 # with the file contents itself by wrapping it all up in a container
211 # format called "AppleSingle".  Subversion currently does not support
212 # MacOS resource forks.  Nevertheless, sometimes the resource fork
213 # information is not necessary and can be discarded.  Set the
214 # following option to True if you would like cvs2svn to identify files
215 # whose contents are encoded in AppleSingle format, and discard all
216 # but the data fork for such files before committing them to
217 # Subversion.  (Please note that AppleSingle contents are identified
218 # by the AppleSingle magic number as the first four bytes of the file.
219 # This check is not failproof, so only set this option if you think
220 # you need it.)
221 ctx.decode_apple_single = False
223 # This option can be set to the name of a filename to which are stored
224 # statistics and conversion decisions about the CVS symbols.
225 ctx.symbol_info_filename = None
226 #ctx.symbol_info_filename = 'symbol-info.txt'
228 # cvs2svn uses "symbol strategy rules" to help decide how to handle
229 # CVS symbols.  The rules in a project's symbol_strategy_rules are
230 # applied in order, and each rule is allowed to modify the symbol.
231 # The result (after each of the rules has been applied) is used for
232 # the conversion.
234 # 1. A CVS symbol might be used as a tag in one file and as a branch
235 #    in another file.  cvs2svn has to decide whether to convert such a
236 #    symbol as a tag or as a branch.  cvs2svn uses a series of
237 #    heuristic rules to decide how to convert a symbol.  The user can
238 #    override the default rules for specific symbols or symbols
239 #    matching regular expressions.
241 # 2. cvs2svn is also capable of excluding symbols from the conversion
242 #    (provided no other symbols depend on them.
244 # 3. CVS does not record unambiguously the line of development from
245 #    which a symbol sprouted.  cvs2svn uses a heuristic to choose a
246 #    symbol's "preferred parents".
248 # The standard branch/tag/exclude StrategyRules do not change a symbol
249 # that has already been processed by an earlier rule, so in effect the
250 # first matching rule is the one that is used.
252 global_symbol_strategy_rules = [
253     # It is possible to specify manually exactly how symbols should be
254     # converted and what line of development should be used as the
255     # preferred parent.  To do so, create a file containing the symbol
256     # hints and enable the following option.
257     #
258     # The format of the hints file is described in the documentation
259     # for the --symbol-hints command-line option.  The file output by
260     # the --write-symbol-info (i.e., ctx.symbol_info_filename) option
261     # is in the same format.  The simplest way to use this option is
262     # to run the conversion through CollateSymbolsPass with
263     # --write-symbol-info option, copy the symbol info and edit it to
264     # create a hints file, then re-start the conversion at
265     # CollateSymbolsPass with this option enabled.
266     #SymbolHintsFileRule('symbol-hints.txt'),
268     # To force all symbols matching a regular expression to be
269     # converted as branches, add rules like the following:
270     #ForceBranchRegexpStrategyRule(r'branch.*'),
272     # To force all symbols matching a regular expression to be
273     # converted as tags, add rules like the following:
274     #ForceTagRegexpStrategyRule(r'tag.*'),
276     # To force all symbols matching a regular expression to be
277     # excluded from the conversion, add rules like the following:
278     #ExcludeRegexpStrategyRule(r'unknown-.*'),
280     # Sometimes people use "cvs import" to get their own source code
281     # into CVS.  This practice creates a vendor branch 1.1.1 and
282     # imports the code onto the vendor branch as 1.1.1.1, then copies
283     # the same content to the trunk as version 1.1.  Normally, such
284     # vendor branches are useless and they complicate the SVN history
285     # unnecessarily.  The following rule excludes any branches that
286     # only existed as a vendor branch with a single import (leaving
287     # only the 1.1 revision).  If you want to retain such branches,
288     # comment out the following line.  (Please note that this rule
289     # does not exclude vendor *tags*, as they are not so easy to
290     # identify.)
291     ExcludeTrivialImportBranchRule(),
293     # To exclude all vendor branches (branches that had "cvs import"s
294     # on them but no other kinds of commits), uncomment the following
295     # line:
296     #ExcludeVendorBranchRule(),
298     # Usually you want this rule, to convert unambiguous symbols
299     # (symbols that were only ever used as tags or only ever used as
300     # branches in CVS) the same way they were used in CVS:
301     UnambiguousUsageRule(),
303     # If there was ever a commit on a symbol, then it cannot be
304     # converted as a tag.  This rule causes all such symbols to be
305     # converted as branches.  If you would like to resolve such
306     # ambiguities manually, comment out the following line:
307     BranchIfCommitsRule(),
309     # Last in the list can be a catch-all rule that is used for
310     # symbols that were not matched by any of the more specific rules
311     # above.  (Assuming that BranchIfCommitsRule() was included above,
312     # then the symbols that are still indeterminate at this point can
313     # sensibly be converted as branches or tags.)  Include at most one
314     # of these lines.  If none of these catch-all rules are included,
315     # then the presence of any ambiguous symbols (that haven't been
316     # disambiguated above) is an error:
318     # Convert ambiguous symbols based on whether they were used more
319     # often as branches or as tags:
320     HeuristicStrategyRule(),
321     # Convert all ambiguous symbols as branches:
322     #AllBranchRule(),
323     # Convert all ambiguous symbols as tags:
324     #AllTagRule(),
326     # The last rule is here to choose the preferred parent of branches
327     # and tags, that is, the line of development from which the symbol
328     # sprouts.
329     HeuristicPreferredParentRule(),
330     ]
332 # Specify a username to be used for commits for which CVS doesn't
333 # record the original author (for example, the creation of a branch).
334 # This should be a simple (unix-style) username, but it can be
335 # translated into a Bazaar-style name by the author_transforms map.
336 ctx.username = 'cvs2svn'
338 # ctx.svn_property_setters contains a list of rules used to set the
339 # svn properties on files in the converted archive.  For each file,
340 # the rules are tried one by one.  Any rule can add or suppress one or
341 # more svn properties.  Typically the rules will not overwrite
342 # properties set by a previous rule (though they are free to do so).
344 # Obviously, SVN properties per se are not interesting for a cvs2bzr
345 # conversion, but some of these properties have side-effects that do
346 # affect the Bazaar output.  FIXME: Document this in more detail.
347 ctx.svn_property_setters.extend([
348     # To read auto-props rules from a file, uncomment the following line
349     # and specify a filename.  The boolean argument specifies whether
350     # case should be ignored when matching filenames to the filename
351     # patterns found in the auto-props file:
352     #AutoPropsPropertySetter(
353     #    r'/home/username/.subversion/config',
354     #    ignore_case=True,
355     #    ),
357     # To read mime types from a file, uncomment the following line and
358     # specify a filename:
359     #MimeMapper(r'/etc/mime.types', ignore_case=False),
361     # Omit the svn:eol-style property from any files that are listed
362     # as binary (i.e., mode '-kb') in CVS:
363     CVSBinaryFileEOLStyleSetter(),
365     # If the file is binary and its svn:mime-type property is not yet
366     # set, set svn:mime-type to 'application/octet-stream'.
367     CVSBinaryFileDefaultMimeTypeSetter(),
369     # To try to determine the eol-style from the mime type, uncomment
370     # the following line:
371     #EOLStyleFromMimeTypeSetter(),
373     # Choose one of the following lines to set the default
374     # svn:eol-style if none of the above rules applied.  The argument
375     # is the svn:eol-style that should be applied, or None if no
376     # svn:eol-style should be set (i.e., the file should be treated as
377     # binary).
378     #
379     # The default is to treat all files as binary unless one of the
380     # previous rules has determined otherwise, because this is the
381     # safest approach.  However, if you have been diligent about
382     # marking binary files with -kb in CVS and/or you have used the
383     # above rules to definitely mark binary files as binary, then you
384     # might prefer to use 'native' as the default, as it is usually
385     # the most convenient setting for text files.  Other possible
386     # options: 'CRLF', 'CR', 'LF'.
387     DefaultEOLStyleSetter(None),
388     #DefaultEOLStyleSetter('native'),
390     # Prevent svn:keywords from being set on files that have
391     # svn:eol-style unset.
392     SVNBinaryFileKeywordsPropertySetter(),
394     # If svn:keywords has not been set yet, set it based on the file's
395     # CVS mode:
396     KeywordsPropertySetter(config.SVN_KEYWORDS_VALUE),
398     # Set the svn:executable flag on any files that are marked in CVS as
399     # being executable:
400     ExecutablePropertySetter(),
402     ])
404 # To skip the cleanup of temporary files, uncomment the following
405 # option:
406 #ctx.skip_cleanup = True
409 # In CVS, it is perfectly possible to make a single commit that
410 # affects more than one project or more than one branch of a single
411 # project.  Subversion also allows such commits.  Therefore, by
412 # default, when cvs2svn sees what looks like a cross-project or
413 # cross-branch CVS commit, it converts it into a
414 # cross-project/cross-branch Subversion commit.
416 # However, other tools and SCMs have trouble representing
417 # cross-project or cross-branch commits.  (For example, Trac's Revtree
418 # plugin, http://www.trac-hacks.org/wiki/RevtreePlugin is confused by
419 # such commits.)  Therefore, we provide the following two options to
420 # allow cross-project/cross-branch commits to be suppressed.
422 # cvs2bzr only supports single-project conversions (multiple-project
423 # conversions wouldn't really make sense for Bazaar anyway).  So this
424 # option must be set to False:
425 ctx.cross_project_commits = False
427 # Bazaar itself doesn't allow commits that affect more than one branch,
428 # so this option must be set to False:
429 ctx.cross_branch_commits = False
431 # cvs2bzr does not yet handle translating .cvsignore files into
432 # .bzrignore content, so by default, the .cvsignore files are included
433 # in the conversion output.  If you would like to omit the .cvsignore
434 # files from the output, set this option to False:
435 ctx.keep_cvsignore = True
437 # By default, it is a fatal error for a CVS ",v" file to appear both
438 # inside and outside of an "Attic" subdirectory (this should never
439 # happen, but frequently occurs due to botched repository
440 # administration).  If you would like to retain both versions of such
441 # files, change the following option to True, and the attic version of
442 # the file will be written to a subdirectory called "Attic" in the
443 # output repository:
444 ctx.retain_conflicting_attic_files = False
446 # CVS uses unix login names as author names whereas Bazaar requires
447 # author names to be of the form "foo <bar>".  The default is to set
448 # the Bazaar author to "cvsauthor <cvsauthor>".  author_transforms can
449 # be used to map cvsauthor names (e.g., "jrandom") to a true name and
450 # email address (e.g., "J. Random <jrandom@example.com>" for the
451 # example shown).  All strings should be either Unicode strings (i.e.,
452 # with "u" as a prefix) or 8-bit strings in the utf-8 encoding.  The
453 # values can either be strings in the form "name <email>" or tuples
454 # (name, email).  Please substitute your own project's usernames here
455 # to use with the author_transforms option of BzrOutputOption below.
456 author_transforms={
457     'jrandom' : ('J. Random', 'jrandom@example.com'),
458     'mhagger' : 'Michael Haggerty <mhagger@alum.mit.edu>',
459     'brane' : (u'Branko Čibej', 'brane@xbc.nu'),
460     'ringstrom' : 'Tobias Ringström <tobias@ringstrom.mine.nu>',
461     'dionisos' : (u'Erik Hülsmann', 'e.huelsmann@gmx.net'),
463     # This one will be used for commits for which CVS doesn't record
464     # the original author, as explained above.
465     'cvs2svn' : 'cvs2svn <admin@example.com>',
466     }
468 # This is the main option that causes cvs2svn to output to a
469 # "fastimport"-format dumpfile rather than to Subversion:
470 ctx.output_option = BzrOutputOption(
471     # The file in which to write the "fastimport" stream:
472     os.path.join(ctx.tmpdir, 'dumpfile.fi'),
474     # Write the file contents inline in the "fastimport" stream,
475     # rather than using a separate blobs file (which "bzr fastimport"
476     # can't handle as easily).
477     revision_writer=GitRevisionInlineWriter(
478         # cvs2bzr uses either RCS's "co" command or CVS's "cvs co -p" to
479         # extract the content of file revisions.  Here you can choose
480         # whether to use RCS (faster, but fails in some rare
481         # circumstances) or CVS (much slower, but more reliable).
482         #RCSRevisionReader(co_executable=r'co')
483         CVSRevisionReader(cvs_executable=r'cvs')
484         ),
486     # Optional map from CVS author names to Bazaar author names:
487     author_transforms=author_transforms,
488     )
490 # Change this option to True to turn on profiling of cvs2svn (for
491 # debugging purposes):
492 run_options.profiling = False
495 # Should CVSItem -> Changeset database files be memory mapped?  In
496 # some tests, using memory mapping speeded up the overall conversion
497 # by about 5%.  But this option can cause the conversion to fail with
498 # an out of memory error if the conversion computer runs out of
499 # virtual address space (e.g., when running a very large conversion on
500 # a 32-bit operating system).  Therefore it is disabled by default.
501 # Uncomment the following line to allow these database files to be
502 # memory mapped.
503 #changeset_database.use_mmap_for_cvs_item_to_changeset_table = True
505 # Now set the project to be converted to Bazaar.  cvs2bzr only supports
506 # single-project conversions, so this method must only be called
507 # once:
508 run_options.set_project(
509     # The filesystem path to the part of the CVS repository (*not* a
510     # CVS working copy) that should be converted.  This may be a
511     # subdirectory (i.e., a module) within a larger CVS repository.
512     r'test-data/main-cvsrepos',
514     # A list of symbol transformations that can be used to rename
515     # symbols in this project.
516     symbol_transforms=[
517         # Use IgnoreSymbolTransforms like the following to completely
518         # ignore symbols matching a regular expression when parsing
519         # the CVS repository, for example to avoid warnings about
520         # branches with two names and to choose the preferred name.
521         # It is *not* recommended to use this instead of
522         # ExcludeRegexpStrategyRule; though more efficient,
523         # IgnoreSymbolTransforms are less flexible and don't exclude
524         # branches correctly.  The argument is a Python-style regular
525         # expression that has to match the *whole* CVS symbol name:
526         #IgnoreSymbolTransform(r'nightly-build-tag-.*')
528         # RegexpSymbolTransforms transform symbols textually using a
529         # regular expression.  The first argument is a Python regular
530         # expression pattern and the second is a replacement pattern.
531         # The pattern is matched against each symbol name.  If it
532         # matches the whole symbol name, then the symbol name is
533         # replaced with the corresponding replacement text.  The
534         # replacement can include substitution patterns (e.g., r'\1'
535         # or r'\g<name>').  Typically you will want to use raw strings
536         # (strings with a preceding 'r', like shown in the examples)
537         # for the regexp and its replacement to avoid backslash
538         # substitution within those strings.
539         #RegexpSymbolTransform(r'release-(\d+)_(\d+)',
540         #                      r'release-\1.\2'),
541         #RegexpSymbolTransform(r'release-(\d+)_(\d+)_(\d+)',
542         #                      r'release-\1.\2.\3'),
544         # Simple 1:1 character replacements can also be done.  The
545         # following transform, which converts backslashes into forward
546         # slashes, should usually be included:
547         ReplaceSubstringsSymbolTransform('\\','/'),
549         # This last rule eliminates leading, trailing, and repeated
550         # slashes within the output symbol names:
551         NormalizePathsSymbolTransform(),
552         ],
554     # See the definition of global_symbol_strategy_rules above for a
555     # description of this option:
556     symbol_strategy_rules=global_symbol_strategy_rules,
557     )