1 # (Be in -*- mode: python; coding: utf-8 -*- mode.)
3 # ====================================================================
4 # Copyright (c) 2006-2008 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
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 # ctx.sort_executable = 'c:\\windows\\system32\\sort.exe'
58 # ctx.sort_executable = r'c:\windows\system32\sort.exe'
60 # See http://docs.python.org/tutorial/introduction.html#strings for
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:
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_revision_recorder import GitRevisionRecorder
83 from cvs2svn_lib.git_output_option import GitRevisionInlineWriter
84 from cvs2svn_lib.git_output_option import GitOutputOption
85 from cvs2svn_lib.revision_manager import NullRevisionRecorder
86 from cvs2svn_lib.revision_manager import NullRevisionExcluder
87 from cvs2svn_lib.fulltext_revision_recorder \
88 import SimpleFulltextRevisionRecorderAdapter
89 from cvs2svn_lib.rcs_revision_manager import RCSRevisionReader
90 from cvs2svn_lib.cvs_revision_manager import CVSRevisionReader
91 from cvs2svn_lib.checkout_internal import InternalRevisionRecorder
92 from cvs2svn_lib.checkout_internal import InternalRevisionExcluder
93 from cvs2svn_lib.checkout_internal import InternalRevisionReader
94 from cvs2svn_lib.symbol_strategy import AllBranchRule
95 from cvs2svn_lib.symbol_strategy import AllTagRule
96 from cvs2svn_lib.symbol_strategy import BranchIfCommitsRule
97 from cvs2svn_lib.symbol_strategy import ExcludeRegexpStrategyRule
98 from cvs2svn_lib.symbol_strategy import ForceBranchRegexpStrategyRule
99 from cvs2svn_lib.symbol_strategy import ForceTagRegexpStrategyRule
100 from cvs2svn_lib.symbol_strategy import ExcludeTrivialImportBranchRule
101 from cvs2svn_lib.symbol_strategy import ExcludeVendorBranchRule
102 from cvs2svn_lib.symbol_strategy import HeuristicStrategyRule
103 from cvs2svn_lib.symbol_strategy import UnambiguousUsageRule
104 from cvs2svn_lib.symbol_strategy import HeuristicPreferredParentRule
105 from cvs2svn_lib.symbol_strategy import SymbolHintsFileRule
106 from cvs2svn_lib.symbol_transform import ReplaceSubstringsSymbolTransform
107 from cvs2svn_lib.symbol_transform import RegexpSymbolTransform
108 from cvs2svn_lib.symbol_transform import IgnoreSymbolTransform
109 from cvs2svn_lib.symbol_transform import NormalizePathsSymbolTransform
110 from cvs2svn_lib.property_setters import AutoPropsPropertySetter
111 from cvs2svn_lib.property_setters import CVSBinaryFileDefaultMimeTypeSetter
112 from cvs2svn_lib.property_setters import CVSBinaryFileEOLStyleSetter
113 from cvs2svn_lib.property_setters import CVSRevisionNumberSetter
114 from cvs2svn_lib.property_setters import DefaultEOLStyleSetter
115 from cvs2svn_lib.property_setters import EOLStyleFromMimeTypeSetter
116 from cvs2svn_lib.property_setters import ExecutablePropertySetter
117 from cvs2svn_lib.property_setters import KeywordsPropertySetter
118 from cvs2svn_lib.property_setters import MimeMapper
119 from cvs2svn_lib.property_setters import SVNBinaryFileKeywordsPropertySetter
121 # To choose the level of logging output, uncomment one of the
123 #Log().log_level = Log.WARN
124 #Log().log_level = Log.QUIET
125 Log().log_level = Log.NORMAL
126 #Log().log_level = Log.VERBOSE
127 #Log().log_level = Log.DEBUG
130 # cvs2bzr reads the contents of file revisions during OutputPass, so no
131 # revision recorder is needed:
132 ctx.revision_recorder = NullRevisionRecorder()
134 # cvs2bzr does not need to keep track of what revisions will be
135 # excluded, so leave this option unchanged:
136 ctx.revision_excluder = NullRevisionExcluder()
138 # cvs2bzr's revision reader is set via the GitOutputOption constructor,
139 # so leave this option set to None.
140 ctx.revision_reader = None
142 # Set the name (and optionally the path) of some other executables
143 # required by cvs2svn:
144 ctx.sort_executable = r'sort'
146 # Change the following line to True if the conversion should only
147 # include the trunk of the repository (i.e., all branches and tags
148 # should be omitted from the conversion):
149 ctx.trunk_only = False
151 # How to convert CVS author names, log messages, and filenames to
152 # Unicode. The first argument to CVSTextDecoder is a list of encoders
153 # that are tried in order in 'strict' mode until one of them succeeds.
154 # If none of those succeeds, then fallback_encoder (if it is
155 # specified) is used in lossy 'replace' mode. Setting a fallback
156 # encoder ensures that the encoder always succeeds, but it can cause
158 ctx.cvs_author_decoder = CVSTextDecoder(
164 #fallback_encoding='ascii'
166 ctx.cvs_log_decoder = CVSTextDecoder(
172 #fallback_encoding='ascii'
174 # You might want to be especially strict when converting filenames to
175 # Unicode (e.g., maybe not specify a fallback_encoding).
176 ctx.cvs_filename_decoder = CVSTextDecoder(
182 #fallback_encoding='ascii'
185 # Template for the commit message to be used for initial project
187 ctx.initial_project_commit_message = (
188 'Standard project directories initialized by cvs2svn.'
191 # Template for the commit message to be used for post commits, in
192 # which modifications to a vendor branch are copied back to trunk.
193 # This message can use '%(revnum)d' to include the SVN revision number
194 # of the revision that included the change to the vendor branch
195 # (admittedly rather pointless in a cvs2bzr conversion).
196 ctx.post_commit_message = (
197 'This commit was generated by cvs2svn to track changes on a CVS '
201 # Template for the commit message to be used for commits in which
202 # symbols are created. This message can use '%(symbol_type)d' to
203 # include the type of the symbol ('branch' or 'tag') or
204 # '%(symbol_name)' to include the name of the symbol.
205 ctx.symbol_commit_message = (
206 "This commit was manufactured by cvs2svn to create %(symbol_type)s "
210 # Some CVS clients for MacOS store resource fork data into CVS along
211 # with the file contents itself by wrapping it all up in a container
212 # format called "AppleSingle". Subversion currently does not support
213 # MacOS resource forks. Nevertheless, sometimes the resource fork
214 # information is not necessary and can be discarded. Set the
215 # following option to True if you would like cvs2svn to identify files
216 # whose contents are encoded in AppleSingle format, and discard all
217 # but the data fork for such files before committing them to
218 # Subversion. (Please note that AppleSingle contents are identified
219 # by the AppleSingle magic number as the first four bytes of the file.
220 # This check is not failproof, so only set this option if you think
222 ctx.decode_apple_single = False
224 # This option can be set to the name of a filename to which are stored
225 # statistics and conversion decisions about the CVS symbols.
226 ctx.symbol_info_filename = None
227 #ctx.symbol_info_filename = 'symbol-info.txt'
229 # cvs2svn uses "symbol strategy rules" to help decide how to handle
230 # CVS symbols. The rules in a project's symbol_strategy_rules are
231 # applied in order, and each rule is allowed to modify the symbol.
232 # The result (after each of the rules has been applied) is used for
235 # 1. A CVS symbol might be used as a tag in one file and as a branch
236 # in another file. cvs2svn has to decide whether to convert such a
237 # symbol as a tag or as a branch. cvs2svn uses a series of
238 # heuristic rules to decide how to convert a symbol. The user can
239 # override the default rules for specific symbols or symbols
240 # matching regular expressions.
242 # 2. cvs2svn is also capable of excluding symbols from the conversion
243 # (provided no other symbols depend on them.
245 # 3. CVS does not record unambiguously the line of development from
246 # which a symbol sprouted. cvs2svn uses a heuristic to choose a
247 # symbol's "preferred parents".
249 # The standard branch/tag/exclude StrategyRules do not change a symbol
250 # that has already been processed by an earlier rule, so in effect the
251 # first matching rule is the one that is used.
253 global_symbol_strategy_rules = [
254 # It is possible to specify manually exactly how symbols should be
255 # converted and what line of development should be used as the
256 # preferred parent. To do so, create a file containing the symbol
257 # hints and enable the following option.
259 # The format of the hints file is described in the documentation
260 # for the --symbol-hints command-line option. The file output by
261 # the --write-symbol-info (i.e., ctx.symbol_info_filename) option
262 # is in the same format. The simplest way to use this option is
263 # to run the conversion through CollateSymbolsPass with
264 # --write-symbol-info option, copy the symbol info and edit it to
265 # create a hints file, then re-start the conversion at
266 # CollateSymbolsPass with this option enabled.
267 #SymbolHintsFileRule('symbol-hints.txt'),
269 # To force all symbols matching a regular expression to be
270 # converted as branches, add rules like the following:
271 #ForceBranchRegexpStrategyRule(r'branch.*'),
273 # To force all symbols matching a regular expression to be
274 # converted as tags, add rules like the following:
275 #ForceTagRegexpStrategyRule(r'tag.*'),
277 # To force all symbols matching a regular expression to be
278 # excluded from the conversion, add rules like the following:
279 #ExcludeRegexpStrategyRule(r'unknown-.*'),
281 # Sometimes people use "cvs import" to get their own source code
282 # into CVS. This practice creates a vendor branch 1.1.1 and
283 # imports the code onto the vendor branch as 1.1.1.1, then copies
284 # the same content to the trunk as version 1.1. Normally, such
285 # vendor branches are useless and they complicate the SVN history
286 # unnecessarily. The following rule excludes any branches that
287 # only existed as a vendor branch with a single import (leaving
288 # only the 1.1 revision). If you want to retain such branches,
289 # comment out the following line. (Please note that this rule
290 # does not exclude vendor *tags*, as they are not so easy to
292 ExcludeTrivialImportBranchRule(),
294 # To exclude all vendor branches (branches that had "cvs import"s
295 # on them bug no other kinds of commits), uncomment the following
297 #ExcludeVendorBranchRule(),
299 # Usually you want this rule, to convert unambiguous symbols
300 # (symbols that were only ever used as tags or only ever used as
301 # branches in CVS) the same way they were used in CVS:
302 UnambiguousUsageRule(),
304 # If there was ever a commit on a symbol, then it cannot be
305 # converted as a tag. This rule causes all such symbols to be
306 # converted as branches. If you would like to resolve such
307 # ambiguities manually, comment out the following line:
308 BranchIfCommitsRule(),
310 # Last in the list can be a catch-all rule that is used for
311 # symbols that were not matched by any of the more specific rules
312 # above. (Assuming that BranchIfCommitsRule() was included above,
313 # then the symbols that are still indeterminate at this point can
314 # sensibly be converted as branches or tags.) Include at most one
315 # of these lines. If none of these catch-all rules are included,
316 # then the presence of any ambiguous symbols (that haven't been
317 # disambiguated above) is an error:
319 # Convert ambiguous symbols based on whether they were used more
320 # often as branches or as tags:
321 HeuristicStrategyRule(),
322 # Convert all ambiguous symbols as branches:
324 # Convert all ambiguous symbols as tags:
327 # The last rule is here to choose the preferred parent of branches
328 # and tags, that is, the line of development from which the symbol
330 HeuristicPreferredParentRule(),
333 # Specify a username to be used for commits for which CVS doesn't
334 # record the original author (for example, the creation of a branch).
335 # This should be a simple (unix-style) username, but it can be
336 # translated into a Bazaar-style name by the author_transforms map.
337 ctx.username = 'cvs2svn'
339 # ctx.svn_property_setters contains a list of rules used to set the
340 # svn properties on files in the converted archive. For each file,
341 # the rules are tried one by one. Any rule can add or suppress one or
342 # more svn properties. Typically the rules will not overwrite
343 # properties set by a previous rule (though they are free to do so).
345 # Obviously, SVN properties per se are not interesting for a cvs2bzr
346 # conversion, but some of these properties have side-effects that do
347 # affect the Bazaar output. FIXME: Document this in more detail.
348 ctx.svn_property_setters.extend([
349 # To read auto-props rules from a file, uncomment the following line
350 # and specify a filename. The boolean argument specifies whether
351 # case should be ignored when matching filenames to the filename
352 # patterns found in the auto-props file:
353 #AutoPropsPropertySetter(
354 # r'/home/username/.subversion/config',
358 # To read mime types from a file, uncomment the following line and
359 # specify a filename:
360 #MimeMapper(r'/etc/mime.types'),
362 # Omit the svn:eol-style property from any files that are listed
363 # as binary (i.e., mode '-kb') in CVS:
364 CVSBinaryFileEOLStyleSetter(),
366 # If the file is binary and its svn:mime-type property is not yet
367 # set, set svn:mime-type to 'application/octet-stream'.
368 CVSBinaryFileDefaultMimeTypeSetter(),
370 # To try to determine the eol-style from the mime type, uncomment
371 # the following line:
372 #EOLStyleFromMimeTypeSetter(),
374 # Choose one of the following lines to set the default
375 # svn:eol-style if none of the above rules applied. The argument
376 # is the svn:eol-style that should be applied, or None if no
377 # svn:eol-style should be set (i.e., the file should be treated as
380 # The default is to treat all files as binary unless one of the
381 # previous rules has determined otherwise, because this is the
382 # safest approach. However, if you have been diligent about
383 # marking binary files with -kb in CVS and/or you have used the
384 # above rules to definitely mark binary files as binary, then you
385 # might prefer to use 'native' as the default, as it is usually
386 # the most convenient setting for text files. Other possible
387 # options: 'CRLF', 'CR', 'LF'.
388 DefaultEOLStyleSetter(None),
389 #DefaultEOLStyleSetter('native'),
391 # Prevent svn:keywords from being set on files that have
392 # svn:eol-style unset.
393 SVNBinaryFileKeywordsPropertySetter(),
395 # If svn:keywords has not been set yet, set it based on the file's
397 KeywordsPropertySetter(config.SVN_KEYWORDS_VALUE),
399 # Set the svn:executable flag on any files that are marked in CVS as
401 ExecutablePropertySetter(),
405 # The directory to use for temporary files:
406 ctx.tmpdir = r'cvs2svn-tmp'
408 # To skip the cleanup of temporary files, uncomment the following
410 #ctx.skip_cleanup = True
413 # In CVS, it is perfectly possible to make a single commit that
414 # affects more than one project or more than one branch of a single
415 # project. Subversion also allows such commits. Therefore, by
416 # default, when cvs2svn sees what looks like a cross-project or
417 # cross-branch CVS commit, it converts it into a
418 # cross-project/cross-branch Subversion commit.
420 # However, other tools and SCMs have trouble representing
421 # cross-project or cross-branch commits. (For example, Trac's Revtree
422 # plugin, http://www.trac-hacks.org/wiki/RevtreePlugin is confused by
423 # such commits.) Therefore, we provide the following two options to
424 # allow cross-project/cross-branch commits to be suppressed.
426 # cvs2bzr only supports single-project conversions (multiple-project
427 # conversions wouldn't really make sense for Bazaar anyway). So this
428 # option must be set to False:
429 ctx.cross_project_commits = False
431 # Bazaar itself doesn't allow commits that affect more than one branch,
432 # so this option must be set to False:
433 ctx.cross_branch_commits = False
435 # cvs2bzr does not yet handle translating .cvsignore files into
436 # .bzrignore content, so by default, the .cvsignore files are included
437 # in the conversion output. If you would like to omit the .cvsignore
438 # files from the output, set this option to False:
439 ctx.keep_cvsignore = True
441 # By default, it is a fatal error for a CVS ",v" file to appear both
442 # inside and outside of an "Attic" subdirectory (this should never
443 # happen, but frequently occurs due to botched repository
444 # administration). If you would like to retain both versions of such
445 # files, change the following option to True, and the attic version of
446 # the file will be written to a subdirectory called "Attic" in the
448 ctx.retain_conflicting_attic_files = False
450 # CVS uses unix login names as author names whereas Bazaar requires
451 # author names to be of the form "foo <bar>". The default is to set
452 # the Bazaar author to "cvsauthor <cvsauthor>". author_transforms can be
453 # used to map cvsauthor names (e.g., "jrandom") to a true name and
454 # email address (e.g., "J. Random <jrandom@example.com>" for the
455 # example shown). All values should be either Unicode strings (i.e.,
456 # with "u" as a prefix) or 8-bit strings in the utf-8 encoding.
457 # Please substitute your own project's usernames here to use with the
458 # author_transforms option of GitOutputOption below.
460 'jrandom' : ('J. Random', 'jrandom@example.com'),
461 'mhagger' : ('Michael Haggerty', 'mhagger@alum.mit.edu'),
462 'brane' : (u'Branko Čibej', 'brane@xbc.nu'),
463 'ringstrom' : ('Tobias Ringström', 'tobias@ringstrom.mine.nu'),
464 'dionisos' : (u'Erik Hülsmann', 'e.huelsmann@gmx.net'),
466 # This one will be used for commits for which CVS doesn't record
467 # the original author, as explained above.
468 'cvs2svn' : ('cvs2svn', 'admin@example.com'),
471 # This is the main option that causes cvs2svn to output to a
472 # "fastimport"-format dumpfile rather than to Subversion:
473 ctx.output_option = GitOutputOption(
474 # The file in which to write the "fastimport" stream:
475 'cvs2svn-tmp/dumpfile.fi',
477 # Write the file contents inline in the "fastimport" stream,
478 # rather than using a separate blobs file (which "bzr fastimport"
479 # can't handle as easily).
480 revision_writer=GitRevisionInlineWriter(
481 # cvs2bzr uses either RCS's "co" command or CVS's "cvs co -p" to
482 # extract the content of file revisions. Here you can choose
483 # whether to use RCS (faster, but fails in some rare
484 # circumstances) or CVS (much slower, but more reliable).
485 #RCSRevisionReader(co_executable=r'co')
486 CVSRevisionReader(cvs_executable=r'cvs')
489 # This option can be set to an integer to limit the number of
490 # revisions that are merged with the main parent in any commit.
491 # For Bazaar output, this can be set to None (unlimited), though due
492 # to the limitations of other tools you might want to set it to a
493 # smaller number (e.g., 16). For Mercurial output, this should be
498 # Optional map from CVS author names to Bazaar author names:
499 author_transforms=author_transforms,
502 # Change this option to True to turn on profiling of cvs2svn (for
503 # debugging purposes):
504 run_options.profiling = False
507 # Should CVSItem -> Changeset database files be memory mapped? In
508 # some tests, using memory mapping speeded up the overall conversion
509 # by about 5%. But this option can cause the conversion to fail with
510 # an out of memory error if the conversion computer runs out of
511 # virtual address space (e.g., when running a very large conversion on
512 # a 32-bit operating system). Therefore it is disabled by default.
513 # Uncomment the following line to allow these database files to be
515 #changeset_database.use_mmap_for_cvs_item_to_changeset_table = True
517 # Now set the project to be converted to Bazaar. cvs2bzr only supports
518 # single-project conversions, so this method must only be called
520 run_options.set_project(
521 # The filesystem path to the part of the CVS repository (*not* a
522 # CVS working copy) that should be converted. This may be a
523 # subdirectory (i.e., a module) within a larger CVS repository.
524 r'test-data/main-cvsrepos',
526 # A list of symbol transformations that can be used to rename
527 # symbols in this project.
529 # Use IgnoreSymbolTransforms like the following to completely
530 # ignore symbols matching a regular expression when parsing
531 # the CVS repository, for example to avoid warnings about
532 # branches with two names and to choose the preferred name.
533 # It is *not* recommended to use this instead of
534 # ExcludeRegexpStrategyRule; though more efficient,
535 # IgnoreSymbolTransforms are less flexible and don't exclude
536 # branches correctly. The argument is a Python-style regular
537 # expression that has to match the *whole* CVS symbol name:
538 #IgnoreSymbolTransform(r'nightly-build-tag-.*')
540 # RegexpSymbolTransforms transform symbols textually using a
541 # regular expression. The first argument is a Python regular
542 # expression pattern and the second is a replacement pattern.
543 # The pattern is matched against each symbol name. If it
544 # matches the whole symbol name, then the symbol name is
545 # replaced with the corresponding replacement text. The
546 # replacement can include substitution patterns (e.g., r'\1'
547 # or r'\g<name>'). Typically you will want to use raw strings
548 # (strings with a preceding 'r', like shown in the examples)
549 # for the regexp and its replacement to avoid backslash
550 # substitution within those strings.
551 #RegexpSymbolTransform(r'release-(\d+)_(\d+)',
553 #RegexpSymbolTransform(r'release-(\d+)_(\d+)_(\d+)',
554 # r'release-\1.\2.\3'),
556 # Simple 1:1 character replacements can also be done. The
557 # following transform, which converts backslashes into forward
558 # slashes, should usually be included:
559 ReplaceSubstringsSymbolTransform('\\','/'),
561 # This last rule eliminates leading, trailing, and repeated
562 # slashes within the output symbol names:
563 NormalizePathsSymbolTransform(),
566 # See the definition of global_symbol_strategy_rules above for a
567 # description of this option:
568 symbol_strategy_rules=global_symbol_strategy_rules,