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 Mercurial rather than to Subversion. See
23 # www/cvs2git.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 # "cvs2hg" is shorthand for "cvs2git in the mode where it is
28 # outputting to Mercurial instead of git". But the program that needs
29 # to be run is still called "cvs2git". Run it with the --options
30 # option, passing it this file as argument:
32 # cvs2git --options=cvs2hg-example.options
34 # Mercurial can (experimentally at this time) read git-fast-import
35 # format via its "hg fastimport" extension, with exceptions:
37 # 1. "hg fastimport" does not support blobs, so the contents of the
38 # revisions are output inline rather than in a separate blobs file.
39 # This increases the size of the output, because file contents that
40 # appear identically on multiple branches have to be output
43 # Many options do not have defaults, so it is easier to copy this file
44 # and modify what you need rather than creating a new options file
45 # from scratch. This file is in Python syntax, but you don't need to
46 # know Python to modify it. But if you *do* know Python, then you
47 # will be happy to know that you can use arbitary Python constructs to
48 # do fancy configuration tricks.
50 # But please be aware of the following:
52 # * In many places, leading whitespace is significant in Python (it is
53 # used instead of curly braces to group statements together).
54 # Therefore, if you don't know what you are doing, it is best to
55 # leave the whitespace as it is.
57 # * In normal strings, Python treats a backslash ("\") as an escape
58 # character. Therefore, if you want to specify a string that
59 # contains a backslash, you need either to escape the backslash with
60 # another backslash ("\\"), or use a "raw string", as in one if the
61 # following equivalent examples:
63 # cvs_executable = 'c:\\windows\\system32\\cvs.exe'
64 # cvs_executable = r'c:\windows\system32\cvs.exe'
66 # See http://docs.python.org/tutorial/introduction.html#strings for
69 # Two identifiers will have been defined before this file is executed,
70 # and can be used freely within this file:
72 # ctx -- a Ctx object (see cvs2svn_lib/context.py), which holds
73 # many configuration options
75 # run_options -- an instance of the GitRunOptions class (see
76 # cvs2svn_lib/git_run_options.py), which holds some variables
77 # governing how cvs2git is run
80 # Import some modules that are used in setting the options:
83 from cvs2svn_lib import config
84 from cvs2svn_lib import changeset_database
85 from cvs2svn_lib.common import CVSTextDecoder
86 from cvs2svn_lib.log import logger
87 from cvs2svn_lib.project import Project
88 from cvs2svn_lib.git_output_option import GitRevisionInlineWriter
89 from cvs2svn_lib.git_output_option import GitOutputOption
90 from cvs2svn_lib.dvcs_common import KeywordHandlingPropertySetter
91 from cvs2svn_lib.revision_manager import NullRevisionCollector
92 from cvs2svn_lib.rcs_revision_manager import RCSRevisionReader
93 from cvs2svn_lib.cvs_revision_manager import CVSRevisionReader
94 from cvs2svn_lib.checkout_internal import InternalRevisionCollector
95 from cvs2svn_lib.checkout_internal import InternalRevisionReader
96 from cvs2svn_lib.symbol_strategy import AllBranchRule
97 from cvs2svn_lib.symbol_strategy import AllTagRule
98 from cvs2svn_lib.symbol_strategy import BranchIfCommitsRule
99 from cvs2svn_lib.symbol_strategy import ExcludeRegexpStrategyRule
100 from cvs2svn_lib.symbol_strategy import ForceBranchRegexpStrategyRule
101 from cvs2svn_lib.symbol_strategy import ForceTagRegexpStrategyRule
102 from cvs2svn_lib.symbol_strategy import ExcludeTrivialImportBranchRule
103 from cvs2svn_lib.symbol_strategy import ExcludeVendorBranchRule
104 from cvs2svn_lib.symbol_strategy import HeuristicStrategyRule
105 from cvs2svn_lib.symbol_strategy import UnambiguousUsageRule
106 from cvs2svn_lib.symbol_strategy import HeuristicPreferredParentRule
107 from cvs2svn_lib.symbol_strategy import SymbolHintsFileRule
108 from cvs2svn_lib.symbol_transform import ReplaceSubstringsSymbolTransform
109 from cvs2svn_lib.symbol_transform import RegexpSymbolTransform
110 from cvs2svn_lib.symbol_transform import IgnoreSymbolTransform
111 from cvs2svn_lib.symbol_transform import NormalizePathsSymbolTransform
112 from cvs2svn_lib.property_setters import AutoPropsPropertySetter
113 from cvs2svn_lib.property_setters import ConditionalPropertySetter
114 from cvs2svn_lib.property_setters import cvs_file_is_binary
115 from cvs2svn_lib.property_setters import CVSBinaryFileDefaultMimeTypeSetter
116 from cvs2svn_lib.property_setters import CVSBinaryFileEOLStyleSetter
117 from cvs2svn_lib.property_setters import DefaultEOLStyleSetter
118 from cvs2svn_lib.property_setters import EOLStyleFromMimeTypeSetter
119 from cvs2svn_lib.property_setters import ExecutablePropertySetter
120 from cvs2svn_lib.property_setters import KeywordsPropertySetter
121 from cvs2svn_lib.property_setters import MimeMapper
122 from cvs2svn_lib.property_setters import SVNBinaryFileKeywordsPropertySetter
124 # To choose the level of logging output, uncomment one of the
126 #logger.log_level = logger.WARN
127 #logger.log_level = logger.QUIET
128 logger.log_level = logger.NORMAL
129 #logger.log_level = logger.VERBOSE
130 #logger.log_level = logger.DEBUG
133 # The directory to use for temporary files:
134 ctx.tmpdir = r'cvs2svn-tmp'
136 # cvs2hg does not need to keep track of what revisions will be
137 # excluded, so leave this option unchanged:
138 ctx.revision_collector = NullRevisionCollector()
140 # cvs2hg's revision reader is set via the GitOutputOption constructor,
141 # so leave this option set to None.
142 ctx.revision_reader = None
144 # Change the following line to True if the conversion should only
145 # include the trunk of the repository (i.e., all branches and tags
146 # should be omitted from the conversion):
147 ctx.trunk_only = False
149 # How to convert CVS author names, log messages, and filenames to
150 # Unicode. The first argument to CVSTextDecoder is a list of encoders
151 # that are tried in order in 'strict' mode until one of them succeeds.
152 # If none of those succeeds, then fallback_encoder (if it is
153 # specified) is used in lossy 'replace' mode. Setting a fallback
154 # encoder ensures that the encoder always succeeds, but it can cause
156 ctx.cvs_author_decoder = CVSTextDecoder(
162 #fallback_encoding='ascii'
164 ctx.cvs_log_decoder = CVSTextDecoder(
170 #fallback_encoding='ascii'
172 # You might want to be especially strict when converting filenames to
173 # Unicode (e.g., maybe not specify a fallback_encoding).
174 ctx.cvs_filename_decoder = CVSTextDecoder(
180 #fallback_encoding='ascii'
183 # Template for the commit message to be used for initial project
185 ctx.initial_project_commit_message = (
186 'Standard project directories initialized by cvs2svn.'
189 # Template for the commit message to be used for post commits, in
190 # which modifications to a vendor branch are copied back to trunk.
191 # This message can use '%(revnum)d' to include the SVN revision number
192 # of the revision that included the change to the vendor branch
193 # (admittedly rather pointless in a cvs2hg conversion).
194 ctx.post_commit_message = (
195 'This commit was generated by cvs2svn to track changes on a CVS '
199 # Template for the commit message to be used for commits in which
200 # symbols are created. This message can use '%(symbol_type)s' to
201 # include the type of the symbol ('branch' or 'tag') or
202 # '%(symbol_name)s' to include the name of the symbol.
203 ctx.symbol_commit_message = (
204 "This commit was manufactured by cvs2svn to create %(symbol_type)s "
208 # Some CVS clients for MacOS store resource fork data into CVS along
209 # with the file contents itself by wrapping it all up in a container
210 # format called "AppleSingle". Subversion currently does not support
211 # MacOS resource forks. Nevertheless, sometimes the resource fork
212 # information is not necessary and can be discarded. Set the
213 # following option to True if you would like cvs2svn to identify files
214 # whose contents are encoded in AppleSingle format, and discard all
215 # but the data fork for such files before committing them to
216 # Subversion. (Please note that AppleSingle contents are identified
217 # by the AppleSingle magic number as the first four bytes of the file.
218 # This check is not failproof, so only set this option if you think
220 ctx.decode_apple_single = False
222 # This option can be set to the name of a filename to which are stored
223 # statistics and conversion decisions about the CVS symbols.
224 ctx.symbol_info_filename = None
225 #ctx.symbol_info_filename = 'symbol-info.txt'
227 # cvs2svn uses "symbol strategy rules" to help decide how to handle
228 # CVS symbols. The rules in a project's symbol_strategy_rules are
229 # applied in order, and each rule is allowed to modify the symbol.
230 # The result (after each of the rules has been applied) is used for
233 # 1. A CVS symbol might be used as a tag in one file and as a branch
234 # in another file. cvs2svn has to decide whether to convert such a
235 # symbol as a tag or as a branch. cvs2svn uses a series of
236 # heuristic rules to decide how to convert a symbol. The user can
237 # override the default rules for specific symbols or symbols
238 # matching regular expressions.
240 # 2. cvs2svn is also capable of excluding symbols from the conversion
241 # (provided no other symbols depend on them.
243 # 3. CVS does not record unambiguously the line of development from
244 # which a symbol sprouted. cvs2svn uses a heuristic to choose a
245 # symbol's "preferred parents".
247 # The standard branch/tag/exclude StrategyRules do not change a symbol
248 # that has already been processed by an earlier rule, so in effect the
249 # first matching rule is the one that is used.
251 global_symbol_strategy_rules = [
252 # It is possible to specify manually exactly how symbols should be
253 # converted and what line of development should be used as the
254 # preferred parent. To do so, create a file containing the symbol
255 # hints and enable the following option.
257 # The format of the hints file is described in the documentation
258 # for the --symbol-hints command-line option. The file output by
259 # the --write-symbol-info (i.e., ctx.symbol_info_filename) option
260 # is in the same format. The simplest way to use this option is
261 # to run the conversion through CollateSymbolsPass with
262 # --write-symbol-info option, copy the symbol info and edit it to
263 # create a hints file, then re-start the conversion at
264 # CollateSymbolsPass with this option enabled.
265 #SymbolHintsFileRule('symbol-hints.txt'),
267 # To force all symbols matching a regular expression to be
268 # converted as branches, add rules like the following:
269 #ForceBranchRegexpStrategyRule(r'branch.*'),
271 # To force all symbols matching a regular expression to be
272 # converted as tags, add rules like the following:
273 #ForceTagRegexpStrategyRule(r'tag.*'),
275 # To force all symbols matching a regular expression to be
276 # excluded from the conversion, add rules like the following:
277 #ExcludeRegexpStrategyRule(r'unknown-.*'),
279 # Sometimes people use "cvs import" to get their own source code
280 # into CVS. This practice creates a vendor branch 1.1.1 and
281 # imports the code onto the vendor branch as 1.1.1.1, then copies
282 # the same content to the trunk as version 1.1. Normally, such
283 # vendor branches are useless and they complicate the SVN history
284 # unnecessarily. The following rule excludes any branches that
285 # only existed as a vendor branch with a single import (leaving
286 # only the 1.1 revision). If you want to retain such branches,
287 # comment out the following line. (Please note that this rule
288 # does not exclude vendor *tags*, as they are not so easy to
290 ExcludeTrivialImportBranchRule(),
292 # To exclude all vendor branches (branches that had "cvs import"s
293 # on them but no other kinds of commits), uncomment the following
295 #ExcludeVendorBranchRule(),
297 # Usually you want this rule, to convert unambiguous symbols
298 # (symbols that were only ever used as tags or only ever used as
299 # branches in CVS) the same way they were used in CVS:
300 UnambiguousUsageRule(),
302 # If there was ever a commit on a symbol, then it cannot be
303 # converted as a tag. This rule causes all such symbols to be
304 # converted as branches. If you would like to resolve such
305 # ambiguities manually, comment out the following line:
306 BranchIfCommitsRule(),
308 # Last in the list can be a catch-all rule that is used for
309 # symbols that were not matched by any of the more specific rules
310 # above. (Assuming that BranchIfCommitsRule() was included above,
311 # then the symbols that are still indeterminate at this point can
312 # sensibly be converted as branches or tags.) Include at most one
313 # of these lines. If none of these catch-all rules are included,
314 # then the presence of any ambiguous symbols (that haven't been
315 # disambiguated above) is an error:
317 # Convert ambiguous symbols based on whether they were used more
318 # often as branches or as tags:
319 HeuristicStrategyRule(),
320 # Convert all ambiguous symbols as branches:
322 # Convert all ambiguous symbols as tags:
325 # The last rule is here to choose the preferred parent of branches
326 # and tags, that is, the line of development from which the symbol
328 HeuristicPreferredParentRule(),
331 # Specify a username to be used for commits for which CVS doesn't
332 # record the original author (for example, the creation of a branch).
333 # This should be a simple (unix-style) username, but it can be
334 # translated into a hg-style name by the author_transforms map.
335 ctx.username = 'cvs2svn'
337 # ctx.file_property_setters and ctx.revision_property_setters contain
338 # rules used to set the svn properties on files in the converted
339 # archive. For each file, the rules are tried one by one. Any rule
340 # can add or suppress one or more svn properties. Typically the rules
341 # will not overwrite properties set by a previous rule (though they
342 # are free to do so). ctx.file_property_setters should be used for
343 # properties that remain the same for the life of the file; these
344 # should implement FilePropertySetter. ctx.revision_property_setters
345 # should be used for properties that are allowed to vary from revision
346 # to revision; these should implement RevisionPropertySetter.
348 # Obviously, SVN properties per se are not interesting for a cvs2hg
349 # conversion, but some of these properties have side-effects that do
350 # affect the hg output. FIXME: Document this in more detail.
351 ctx.file_property_setters.extend([
352 # To read auto-props rules from a file, uncomment the following line
353 # and specify a filename. The boolean argument specifies whether
354 # case should be ignored when matching filenames to the filename
355 # patterns found in the auto-props file:
356 #AutoPropsPropertySetter(
357 # r'/home/username/.subversion/config',
361 # To read mime types from a file and use them to set svn:mime-type
362 # based on the filename extensions, uncomment the following line
363 # and specify a filename (see
364 # http://en.wikipedia.org/wiki/Mime.types for information about
366 #MimeMapper(r'/etc/mime.types', ignore_case=False),
368 # Omit the svn:eol-style property from any files that are listed
369 # as binary (i.e., mode '-kb') in CVS:
370 CVSBinaryFileEOLStyleSetter(),
372 # If the file is binary and its svn:mime-type property is not yet
373 # set, set svn:mime-type to 'application/octet-stream'.
374 CVSBinaryFileDefaultMimeTypeSetter(),
376 # To try to determine the eol-style from the mime type, uncomment
377 # the following line:
378 #EOLStyleFromMimeTypeSetter(),
380 # Choose one of the following lines to set the default
381 # svn:eol-style if none of the above rules applied. The argument
382 # is the svn:eol-style that should be applied, or None if no
383 # svn:eol-style should be set (i.e., the file should be treated as
386 # The default is to treat all files as binary unless one of the
387 # previous rules has determined otherwise, because this is the
388 # safest approach. However, if you have been diligent about
389 # marking binary files with -kb in CVS and/or you have used the
390 # above rules to definitely mark binary files as binary, then you
391 # might prefer to use 'native' as the default, as it is usually
392 # the most convenient setting for text files. Other possible
393 # options: 'CRLF', 'CR', 'LF'.
394 DefaultEOLStyleSetter(None),
395 #DefaultEOLStyleSetter('native'),
397 # Prevent svn:keywords from being set on files that have
398 # svn:eol-style unset.
399 SVNBinaryFileKeywordsPropertySetter(),
401 # If svn:keywords has not been set yet, set it based on the file's
403 KeywordsPropertySetter(config.SVN_KEYWORDS_VALUE),
405 # Set the svn:executable flag on any files that are marked in CVS as
407 ExecutablePropertySetter(),
409 # The following causes keywords to be untouched in binary files and
410 # collapsed in all text to be committed:
411 ConditionalPropertySetter(
412 cvs_file_is_binary, KeywordHandlingPropertySetter('untouched'),
414 KeywordHandlingPropertySetter('collapsed'),
417 ctx.revision_property_setters.extend([
420 # To skip the cleanup of temporary files, uncomment the following
422 #ctx.skip_cleanup = True
425 # In CVS, it is perfectly possible to make a single commit that
426 # affects more than one project or more than one branch of a single
427 # project. Subversion also allows such commits. Therefore, by
428 # default, when cvs2svn sees what looks like a cross-project or
429 # cross-branch CVS commit, it converts it into a
430 # cross-project/cross-branch Subversion commit.
432 # However, other tools and SCMs have trouble representing
433 # cross-project or cross-branch commits. (For example, Trac's Revtree
434 # plugin, http://www.trac-hacks.org/wiki/RevtreePlugin is confused by
435 # such commits.) Therefore, we provide the following two options to
436 # allow cross-project/cross-branch commits to be suppressed.
438 # cvs2hg only supports single-project conversions (multiple-project
439 # conversions wouldn't really make sense for hg anyway). So this
440 # option must be set to False:
441 ctx.cross_project_commits = False
443 # Mercurial itself doesn't allow commits that affect more than one
444 # branch, so this option must be set to False:
445 ctx.cross_branch_commits = False
447 # cvs2hg does not yet handle translating .cvsignore files into
448 # .hgignore content, so by default, the .cvsignore files are included
449 # inthe conversion output. If you would like to omit the .cvsignore
450 # files from the output, set this option to False:
451 ctx.keep_cvsignore = True
453 # By default, it is a fatal error for a CVS ",v" file to appear both
454 # inside and outside of an "Attic" subdirectory (this should never
455 # happen, but frequently occurs due to botched repository
456 # administration). If you would like to retain both versions of such
457 # files, change the following option to True, and the attic version of
458 # the file will be written to a subdirectory called "Attic" in the
460 ctx.retain_conflicting_attic_files = False
462 # CVS uses unix login names as author names whereas "hg fastimport"
463 # format requires author names to be of the form "foo <bar>". The
464 # default is to set the author to "cvsauthor <cvsauthor>".
465 # author_transforms can be used to map cvsauthor names (e.g.,
466 # "jrandom") to a true name and email address (e.g., "J. Random
467 # <jrandom@example.com>" for the example shown). All strings should
468 # be either Unicode strings (i.e., with "u" as a prefix) or 8-bit
469 # strings in the utf-8 encoding. The values can either be strings in
470 # the form "name <email>" or tuples (name, email). Please substitute
471 # your own project's usernames here to use with the author_transforms
472 # option of GitOutputOption below.
474 'jrandom' : ('J. Random', 'jrandom@example.com'),
475 'mhagger' : 'Michael Haggerty <mhagger@alum.mit.edu>',
476 'brane' : (u'Branko Čibej', 'brane@xbc.nu'),
477 'ringstrom' : 'Tobias Ringström <tobias@ringstrom.mine.nu>',
478 'dionisos' : (u'Erik Hülsmann', 'e.huelsmann@gmx.net'),
480 # This one will be used for commits for which CVS doesn't record
481 # the original author, as explained above.
482 'cvs2svn' : 'cvs2svn <admin@example.com>',
485 # This is the main option that causes cvs2svn to output to an "hg
486 # fastimport"-format dumpfile rather than to Subversion:
487 ctx.output_option = GitOutputOption(
488 # The file in which to write the "hg fastimport" stream that
489 # contains the changesets and branch/tag information:
490 os.path.join(ctx.tmpdir, 'hg-dump.dat'),
492 # Write the file contents inline in the "hg fastimport" stream,
493 # rather than using a separate blobs file (which "hg fastimport"
495 revision_writer=GitRevisionInlineWriter(
496 # cvs2hg uses either RCS's "co" command or CVS's "cvs co -p" to
497 # extract the content of file revisions. Here you can choose
498 # whether to use RCS (faster, but fails in some rare
499 # circumstances) or CVS (much slower, but more reliable).
500 #RCSRevisionReader(co_executable=r'co')
501 CVSRevisionReader(cvs_executable=r'cvs')
504 # Optional map from CVS author names to hg author names:
505 author_transforms=author_transforms,
508 # Change this option to True to turn on profiling of cvs2svn (for
509 # debugging purposes):
510 run_options.profiling = False
513 # Should CVSItem -> Changeset database files be memory mapped? In
514 # some tests, using memory mapping speeded up the overall conversion
515 # by about 5%. But this option can cause the conversion to fail with
516 # an out of memory error if the conversion computer runs out of
517 # virtual address space (e.g., when running a very large conversion on
518 # a 32-bit operating system). Therefore it is disabled by default.
519 # Uncomment the following line to allow these database files to be
521 #changeset_database.use_mmap_for_cvs_item_to_changeset_table = True
523 # Now set the project to be converted to hg. cvs2hg only supports
524 # single-project conversions, so this method must only be called once:
525 run_options.set_project(
526 # The filesystem path to the part of the CVS repository (*not* a
527 # CVS working copy) that should be converted. This may be a
528 # subdirectory (i.e., a module) within a larger CVS repository.
529 r'test-data/main-cvsrepos',
531 # A list of symbol transformations that can be used to rename
532 # symbols in this project.
534 # Use IgnoreSymbolTransforms like the following to completely
535 # ignore symbols matching a regular expression when parsing
536 # the CVS repository, for example to avoid warnings about
537 # branches with two names and to choose the preferred name.
538 # It is *not* recommended to use this instead of
539 # ExcludeRegexpStrategyRule; though more efficient,
540 # IgnoreSymbolTransforms are less flexible and don't exclude
541 # branches correctly. The argument is a Python-style regular
542 # expression that has to match the *whole* CVS symbol name:
543 #IgnoreSymbolTransform(r'nightly-build-tag-.*')
545 # RegexpSymbolTransforms transform symbols textually using a
546 # regular expression. The first argument is a Python regular
547 # expression pattern and the second is a replacement pattern.
548 # The pattern is matched against each symbol name. If it
549 # matches the whole symbol name, then the symbol name is
550 # replaced with the corresponding replacement text. The
551 # replacement can include substitution patterns (e.g., r'\1'
552 # or r'\g<name>'). Typically you will want to use raw strings
553 # (strings with a preceding 'r', like shown in the examples)
554 # for the regexp and its replacement to avoid backslash
555 # substitution within those strings.
556 #RegexpSymbolTransform(r'release-(\d+)_(\d+)',
558 #RegexpSymbolTransform(r'release-(\d+)_(\d+)_(\d+)',
559 # r'release-\1.\2.\3'),
561 # Simple 1:1 character replacements can also be done. The
562 # following transform, which converts backslashes into forward
563 # slashes, should usually be included:
564 ReplaceSubstringsSymbolTransform('\\','/'),
566 # This last rule eliminates leading, trailing, and repeated
567 # slashes within the output symbol names:
568 NormalizePathsSymbolTransform(),
571 # See the definition of global_symbol_strategy_rules above for a
572 # description of this option:
573 symbol_strategy_rules=global_symbol_strategy_rules,