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 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 a couple of
38 # 1. "hg fastimport" does not support blobs, so the contents of the
39 # revisions are output inline rather than in a separate blobs file.
40 # This increases the size of the output, because file contents that
41 # appear identically on multiple branches have to be output
44 # 2. Mercurial only allows a revsion to have two parents (not an
45 # arbitrary number, as allowed by git). This affects the way that
46 # cvs2svn handles a symbol that includes content from multiple
47 # parent branches. For output to Mercurial, files are only copied
48 # from one parent branch in each commit (therefore potentially
49 # taking multiple commits to create the symbol).
51 # Many options do not have defaults, so it is easier to copy this file
52 # and modify what you need rather than creating a new options file
53 # from scratch. This file is in Python syntax, but you don't need to
54 # know Python to modify it. But if you *do* know Python, then you
55 # will be happy to know that you can use arbitary Python constructs to
56 # do fancy configuration tricks.
58 # But please be aware of the following:
60 # * In many places, leading whitespace is significant in Python (it is
61 # used instead of curly braces to group statements together).
62 # Therefore, if you don't know what you are doing, it is best to
63 # leave the whitespace as it is.
65 # * In normal strings, Python treats a backslash ("\") as an escape
66 # character. Therefore, if you want to specify a string that
67 # contains a backslash, you need either to escape the backslash with
68 # another backslash ("\\"), or use a "raw string", as in one if the
69 # following equivalent examples:
71 # ctx.sort_executable = 'c:\\windows\\system32\\sort.exe'
72 # ctx.sort_executable = r'c:\windows\system32\sort.exe'
74 # See http://docs.python.org/tutorial/introduction.html#strings for
77 # Two identifiers will have been defined before this file is executed,
78 # and can be used freely within this file:
80 # ctx -- a Ctx object (see cvs2svn_lib/context.py), which holds
81 # many configuration options
83 # run_options -- an instance of the GitRunOptions class (see
84 # cvs2svn_lib/git_run_options.py), which holds some variables
85 # governing how cvs2git is run
88 # Import some modules that are used in setting the options:
91 from cvs2svn_lib import config
92 from cvs2svn_lib import changeset_database
93 from cvs2svn_lib.common import CVSTextDecoder
94 from cvs2svn_lib.log import Log
95 from cvs2svn_lib.project import Project
96 from cvs2svn_lib.git_revision_recorder import GitRevisionRecorder
97 from cvs2svn_lib.git_output_option import GitRevisionInlineWriter
98 from cvs2svn_lib.git_output_option import GitOutputOption
99 from cvs2svn_lib.revision_manager import NullRevisionRecorder
100 from cvs2svn_lib.revision_manager import NullRevisionExcluder
101 from cvs2svn_lib.rcs_revision_manager import RCSRevisionReader
102 from cvs2svn_lib.cvs_revision_manager import CVSRevisionReader
103 from cvs2svn_lib.checkout_internal import InternalRevisionRecorder
104 from cvs2svn_lib.checkout_internal import InternalRevisionExcluder
105 from cvs2svn_lib.checkout_internal import InternalRevisionReader
106 from cvs2svn_lib.symbol_strategy import AllBranchRule
107 from cvs2svn_lib.symbol_strategy import AllTagRule
108 from cvs2svn_lib.symbol_strategy import BranchIfCommitsRule
109 from cvs2svn_lib.symbol_strategy import ExcludeRegexpStrategyRule
110 from cvs2svn_lib.symbol_strategy import ForceBranchRegexpStrategyRule
111 from cvs2svn_lib.symbol_strategy import ForceTagRegexpStrategyRule
112 from cvs2svn_lib.symbol_strategy import ExcludeTrivialImportBranchRule
113 from cvs2svn_lib.symbol_strategy import ExcludeVendorBranchRule
114 from cvs2svn_lib.symbol_strategy import HeuristicStrategyRule
115 from cvs2svn_lib.symbol_strategy import UnambiguousUsageRule
116 from cvs2svn_lib.symbol_strategy import HeuristicPreferredParentRule
117 from cvs2svn_lib.symbol_strategy import SymbolHintsFileRule
118 from cvs2svn_lib.symbol_transform import ReplaceSubstringsSymbolTransform
119 from cvs2svn_lib.symbol_transform import RegexpSymbolTransform
120 from cvs2svn_lib.symbol_transform import NormalizePathsSymbolTransform
121 from cvs2svn_lib.property_setters import AutoPropsPropertySetter
122 from cvs2svn_lib.property_setters import CVSBinaryFileDefaultMimeTypeSetter
123 from cvs2svn_lib.property_setters import CVSBinaryFileEOLStyleSetter
124 from cvs2svn_lib.property_setters import CVSRevisionNumberSetter
125 from cvs2svn_lib.property_setters import DefaultEOLStyleSetter
126 from cvs2svn_lib.property_setters import EOLStyleFromMimeTypeSetter
127 from cvs2svn_lib.property_setters import ExecutablePropertySetter
128 from cvs2svn_lib.property_setters import KeywordsPropertySetter
129 from cvs2svn_lib.property_setters import MimeMapper
130 from cvs2svn_lib.property_setters import SVNBinaryFileKeywordsPropertySetter
132 # To choose the level of logging output, uncomment one of the
134 #Log().log_level = Log.WARN
135 #Log().log_level = Log.QUIET
136 Log().log_level = Log.NORMAL
137 #Log().log_level = Log.VERBOSE
138 #Log().log_level = Log.DEBUG
141 # cvs2hg reads the contents of file revisions during OutputPass, so no
142 # revision recorder is needed:
143 ctx.revision_recorder = NullRevisionRecorder()
145 # cvs2hg does not need to keep track of what revisions will be
146 # excluded, so leave this option unchanged:
147 ctx.revision_excluder = NullRevisionExcluder()
149 # cvs2hg's revision reader is set via the GitOutputOption constructor,
150 # so leave this option set to None.
151 ctx.revision_reader = None
153 # Set the name (and optionally the path) of some other executables
154 # required by cvs2svn:
155 ctx.sort_executable = r'sort'
157 # Change the following line to True if the conversion should only
158 # include the trunk of the repository (i.e., all branches and tags
159 # should be omitted from the conversion):
160 ctx.trunk_only = False
162 # How to convert CVS author names, log messages, and filenames to
163 # unicode. The first argument to CVSTextDecoder is a list of encoders
164 # that are tried in order in 'strict' mode until one of them succeeds.
165 # If none of those succeeds, then fallback_encoder (if it is
166 # specified) is used in lossy 'replace' mode. Setting a fallback
167 # encoder ensures that the encoder always succeeds, but it can cause
169 ctx.cvs_author_decoder = CVSTextDecoder(
175 #fallback_encoding='ascii'
177 ctx.cvs_log_decoder = CVSTextDecoder(
183 #fallback_encoding='ascii'
185 # You might want to be especially strict when converting filenames to
186 # unicode (e.g., maybe not specify a fallback_encoding).
187 ctx.cvs_filename_decoder = CVSTextDecoder(
193 #fallback_encoding='ascii'
196 # Template for the commit message to be used for initial project
198 ctx.initial_project_commit_message = (
199 'Standard project directories initialized by cvs2svn.'
202 # Template for the commit message to be used for post commits, in
203 # which modifications to a vendor branch are copied back to trunk.
204 # This message can use '%(revnum)d' to include the SVN revision number
205 # of the revision that included the change to the vendor branch
206 # (admittedly rather pointless in a cvs2hg conversion).
207 ctx.post_commit_message = (
208 'This commit was generated by cvs2svn to track changes on a CVS '
212 # Template for the commit message to be used for commits in which
213 # symbols are created. This message can use '%(symbol_type)d' to
214 # include the type of the symbol ('branch' or 'tag') or
215 # '%(symbol_name)' to include the name of the symbol.
216 ctx.symbol_commit_message = (
217 "This commit was manufactured by cvs2svn to create %(symbol_type)s "
221 # Some CVS clients for MacOS store resource fork data into CVS along
222 # with the file contents itself by wrapping it all up in a container
223 # format called "AppleSingle". Subversion currently does not support
224 # MacOS resource forks. Nevertheless, sometimes the resource fork
225 # information is not necessary and can be discarded. Set the
226 # following option to True if you would like cvs2svn to identify files
227 # whose contents are encoded in AppleSingle format, and discard all
228 # but the data fork for such files before committing them to
229 # Subversion. (Please note that AppleSingle contents are identified
230 # by the AppleSingle magic number as the first four bytes of the file.
231 # This check is not failproof, so only set this option if you think
233 ctx.decode_apple_single = False
235 # This option can be set to the name of a filename to which are stored
236 # statistics and conversion decisions about the CVS symbols.
237 ctx.symbol_info_filename = None
238 #ctx.symbol_info_filename = 'symbol-info.txt'
240 # cvs2svn uses "symbol strategy rules" to help decide how to handle
241 # CVS symbols. The rules in a project's symbol_strategy_rules are
242 # applied in order, and each rule is allowed to modify the symbol.
243 # The result (after each of the rules has been applied) is used for
246 # 1. A CVS symbol might be used as a tag in one file and as a branch
247 # in another file. cvs2svn has to decide whether to convert such a
248 # symbol as a tag or as a branch. cvs2svn uses a series of
249 # heuristic rules to decide how to convert a symbol. The user can
250 # override the default rules for specific symbols or symbols
251 # matching regular expressions.
253 # 2. cvs2svn is also capable of excluding symbols from the conversion
254 # (provided no other symbols depend on them.
256 # 3. CVS does not record unambiguously the line of development from
257 # which a symbol sprouted. cvs2svn uses a heuristic to choose a
258 # symbol's "preferred parents".
260 # The standard branch/tag/exclude StrategyRules do not change a symbol
261 # that has already been processed by an earlier rule, so in effect the
262 # first matching rule is the one that is used.
264 global_symbol_strategy_rules = [
265 # It is possible to specify manually exactly how symbols should be
266 # converted and what line of development should be used as the
267 # preferred parent. To do so, create a file containing the symbol
268 # hints and enable the following option.
270 # The format of the hints file is described in the documentation
271 # for the --symbol-hints command-line option. The file output by
272 # the --write-symbol-info (i.e., ctx.symbol_info_filename) option
273 # is in the same format. The simplest way to use this option is
274 # to run the conversion through CollateSymbolsPass with
275 # --write-symbol-info option, copy the symbol info and edit it to
276 # create a hints file, then re-start the conversion at
277 # CollateSymbolsPass with this option enabled.
278 #SymbolHintsFileRule('symbol-hints.txt'),
280 # To force all symbols matching a regular expression to be
281 # converted as branches, add rules like the following:
282 #ForceBranchRegexpStrategyRule(r'branch.*'),
284 # To force all symbols matching a regular expression to be
285 # converted as tags, add rules like the following:
286 #ForceTagRegexpStrategyRule(r'tag.*'),
288 # To force all symbols matching a regular expression to be
289 # excluded from the conversion, add rules like the following:
290 #ExcludeRegexpStrategyRule(r'unknown-.*'),
292 # Sometimes people use "cvs import" to get their own source code
293 # into CVS. This practice creates a vendor branch 1.1.1 and
294 # imports the code onto the vendor branch as 1.1.1.1, then copies
295 # the same content to the trunk as version 1.1. Normally, such
296 # vendor branches are useless and they complicate the SVN history
297 # unnecessarily. The following rule excludes any branches that
298 # only existed as a vendor branch with a single import (leaving
299 # only the 1.1 revision). If you want to retain such branches,
300 # comment out the following line. (Please note that this rule
301 # does not exclude vendor *tags*, as they are not so easy to
303 ExcludeTrivialImportBranchRule(),
305 # To exclude all vendor branches (branches that had "cvs import"s
306 # on them bug no other kinds of commits), uncomment the following
308 #ExcludeVendorBranchRule(),
310 # Usually you want this rule, to convert unambiguous symbols
311 # (symbols that were only ever used as tags or only ever used as
312 # branches in CVS) the same way they were used in CVS:
313 UnambiguousUsageRule(),
315 # If there was ever a commit on a symbol, then it cannot be
316 # converted as a tag. This rule causes all such symbols to be
317 # converted as branches. If you would like to resolve such
318 # ambiguities manually, comment out the following line:
319 BranchIfCommitsRule(),
321 # Last in the list can be a catch-all rule that is used for
322 # symbols that were not matched by any of the more specific rules
323 # above. (Assuming that BranchIfCommitsRule() was included above,
324 # then the symbols that are still indeterminate at this point can
325 # sensibly be converted as branches or tags.) Include at most one
326 # of these lines. If none of these catch-all rules are included,
327 # then the presence of any ambiguous symbols (that haven't been
328 # disambiguated above) is an error:
330 # Convert ambiguous symbols based on whether they were used more
331 # often as branches or as tags:
332 HeuristicStrategyRule(),
333 # Convert all ambiguous symbols as branches:
335 # Convert all ambiguous symbols as tags:
338 # The last rule is here to choose the preferred parent of branches
339 # and tags, that is, the line of development from which the symbol
341 HeuristicPreferredParentRule(),
344 # Specify a username to be used for commits for which CVS doesn't
345 # record the original author (for example, the creation of a branch).
346 # This should be a simple (unix-style) username, but it can be
347 # translated into a hg-style name by the author_transforms map.
348 ctx.username = 'cvs2svn'
350 # ctx.svn_property_setters contains a list of rules used to set the
351 # svn properties on files in the converted archive. For each file,
352 # the rules are tried one by one. Any rule can add or suppress one or
353 # more svn properties. Typically the rules will not overwrite
354 # properties set by a previous rule (though they are free to do so).
356 # Obviously, SVN properties per se are not interesting for a cvs2hg
357 # conversion, but some of these properties have side-effects that do
358 # affect the hg output. FIXME: Document this in more detail.
359 ctx.svn_property_setters.extend([
360 # To read auto-props rules from a file, uncomment the following line
361 # and specify a filename. The boolean argument specifies whether
362 # case should be ignored when matching filenames to the filename
363 # patterns found in the auto-props file:
364 #AutoPropsPropertySetter(
365 # r'/home/username/.subversion/config',
369 # To read mime types from a file, uncomment the following line and
370 # specify a filename:
371 #MimeMapper(r'/etc/mime.types'),
373 # Omit the svn:eol-style property from any files that are listed
374 # as binary (i.e., mode '-kb') in CVS:
375 CVSBinaryFileEOLStyleSetter(),
377 # If the file is binary and its svn:mime-type property is not yet
378 # set, set svn:mime-type to 'application/octet-stream'.
379 CVSBinaryFileDefaultMimeTypeSetter(),
381 # To try to determine the eol-style from the mime type, uncomment
382 # the following line:
383 #EOLStyleFromMimeTypeSetter(),
385 # Choose one of the following lines to set the default
386 # svn:eol-style if none of the above rules applied. The argument
387 # is the svn:eol-style that should be applied, or None if no
388 # svn:eol-style should be set (i.e., the file should be treated as
391 # The default is to treat all files as binary unless one of the
392 # previous rules has determined otherwise, because this is the
393 # safest approach. However, if you have been diligent about
394 # marking binary files with -kb in CVS and/or you have used the
395 # above rules to definitely mark binary files as binary, then you
396 # might prefer to use 'native' as the default, as it is usually
397 # the most convenient setting for text files. Other possible
398 # options: 'CRLF', 'CR', 'LF'.
399 DefaultEOLStyleSetter(None),
400 #DefaultEOLStyleSetter('native'),
402 # Prevent svn:keywords from being set on files that have
403 # svn:eol-style unset.
404 SVNBinaryFileKeywordsPropertySetter(),
406 # If svn:keywords has not been set yet, set it based on the file's
408 KeywordsPropertySetter(config.SVN_KEYWORDS_VALUE),
410 # Set the svn:executable flag on any files that are marked in CVS as
412 ExecutablePropertySetter(),
416 # The directory to use for temporary files:
417 ctx.tmpdir = r'cvs2svn-tmp'
419 # To skip the cleanup of temporary files, uncomment the following
421 #ctx.skip_cleanup = True
424 # In CVS, it is perfectly possible to make a single commit that
425 # affects more than one project or more than one branch of a single
426 # project. Subversion also allows such commits. Therefore, by
427 # default, when cvs2svn sees what looks like a cross-project or
428 # cross-branch CVS commit, it converts it into a
429 # cross-project/cross-branch Subversion commit.
431 # However, other tools and SCMs have trouble representing
432 # cross-project or cross-branch commits. (For example, Trac's Revtree
433 # plugin, http://www.trac-hacks.org/wiki/RevtreePlugin is confused by
434 # such commits.) Therefore, we provide the following two options to
435 # allow cross-project/cross-branch commits to be suppressed.
437 # cvs2hg only supports single-project conversions (multiple-project
438 # conversions wouldn't really make sense for hg anyway). So this
439 # option must be set to False:
440 ctx.cross_project_commits = False
442 # Mercurial itself doesn't allow commits that affect more than one
443 # branch, so this option must be set to False:
444 ctx.cross_branch_commits = False
446 # cvs2hg does not yet handle translating .cvsignore files into
447 # .hgignore content, so by default, the .cvsignore files are included
448 # inthe conversion output. If you would like to omit the .cvsignore
449 # files from the output, set this option to False:
450 ctx.keep_cvsignore = True
452 # By default, it is a fatal error for a CVS ",v" file to appear both
453 # inside and outside of an "Attic" subdirectory (this should never
454 # happen, but frequently occurs due to botched repository
455 # administration). If you would like to retain both versions of such
456 # files, change the following option to True, and the attic version of
457 # the file will be written to a subdirectory called "Attic" in the
459 ctx.retain_conflicting_attic_files = False
461 # CVS uses unix login names as author names whereas "hg fastimport"
462 # format requires author names to be of the form "foo <bar>". The
463 # default is to set the author to "cvsauthor <cvsauthor>".
464 # author_transforms can be used to map cvsauthor names (e.g.,
465 # "jrandom") to a true name and email address (e.g., "J. Random
466 # <jrandom@example.com>" for the example shown). All values should be
467 # either 16-bit strings (i.e., with "u" as a prefix) or 8-bit strings
468 # in the utf-8 encoding. Please substitute your own project's
469 # usernames here to use with the author_transforms option of
470 # GitOutputOption below.
472 'jrandom' : ('J. Random', 'jrandom@example.com'),
473 'mhagger' : ('Michael Haggerty', 'mhagger@alum.mit.edu'),
474 'brane' : (u'Branko Čibej', 'brane@xbc.nu'),
475 'ringstrom' : ('Tobias Ringström', 'tobias@ringstrom.mine.nu'),
476 'dionisos' : (u'Erik Hülsmann', 'e.huelsmann@gmx.net'),
478 # This one will be used for commits for which CVS doesn't record
479 # the original author, as explained above.
480 'cvs2svn' : ('cvs2svn', 'admin@example.com'),
483 # This is the main option that causes cvs2svn to output to an "hg
484 # fastimport"-format dumpfile rather than to Subversion:
485 ctx.output_option = GitOutputOption(
486 # The file in which to write the "hg fastimport" stream that
487 # contains the changesets and branch/tag information:
488 'cvs2svn-tmp/hg-dump.dat',
490 # Write the file contents inline in the "hg fastimport" stream,
491 # rather than using a separate blobs file (which "hg fastimport"
493 revision_writer=GitRevisionInlineWriter(
494 # cvs2hg uses either RCS's "co" command or CVS's "cvs co -p" to
495 # extract the content of file revisions. Here you can choose
496 # whether to use RCS (faster, but fails in some rare
497 # circumstances) or CVS (much slower, but more reliable).
498 #RCSRevisionReader(co_executable=r'co')
499 CVSRevisionReader(cvs_executable=r'cvs')
502 # This option limits the number of revisions that are merged with
503 # the main parent in any commit. For Mercurial output, this
504 # should be set to 1 (see the comment at the top of this file for
508 # Optional map from CVS author names to hg author names:
509 author_transforms=author_transforms,
512 # Change this option to True to turn on profiling of cvs2svn (for
513 # debugging purposes):
514 run_options.profiling = False
517 # Should CVSItem -> Changeset database files be memory mapped? In
518 # some tests, using memory mapping speeded up the overall conversion
519 # by about 5%. But this option can cause the conversion to fail with
520 # an out of memory error if the conversion computer runs out of
521 # virtual address space (e.g., when running a very large conversion on
522 # a 32-bit operating system). Therefore it is disabled by default.
523 # Uncomment the following line to allow these database files to be
525 #changeset_database.use_mmap_for_cvs_item_to_changeset_table = True
527 # Now set the project to be converted to hg. cvs2hg only supports
528 # single-project conversions, so this method must only be called once:
529 run_options.set_project(
530 # The filesystem path to the part of the CVS repository (*not* a
531 # CVS working copy) that should be converted. This may be a
532 # subdirectory (i.e., a module) within a larger CVS repository.
533 r'test-data/main-cvsrepos',
535 # A list of symbol transformations that can be used to rename
536 # symbols in this project.
538 # RegexpSymbolTransforms transform symbols textually using a
539 # regular expression. The first argument is a Python regular
540 # expression pattern and the second is a replacement pattern.
541 # The pattern is matched against each symbol name. If it
542 # matches the whole symbol name, then the symbol name is
543 # replaced with the corresponding replacement text. The
544 # replacement can include substitution patterns (e.g., r'\1'
545 # or r'\g<name>'). Typically you will want to use raw strings
546 # (strings with a preceding 'r', like shown in the examples)
547 # for the regexp and its replacement to avoid backslash
548 # substitution within those strings.
550 #RegexpSymbolTransform(r'release-(\d+)_(\d+)',
552 #RegexpSymbolTransform(r'release-(\d+)_(\d+)_(\d+)',
553 # r'release-\1.\2.\3'),
555 # Simple 1:1 character replacements can also be done. The
556 # following transform converts backslashes into forward
558 ReplaceSubstringsSymbolTransform('\\','/'),
560 # This last rule eliminates leading, trailing, and repeated
561 # slashes within the output symbol names:
562 NormalizePathsSymbolTransform(),
565 # See the definition of global_symbol_strategy_rules above for a
566 # description of this option:
567 symbol_strategy_rules=global_symbol_strategy_rules,