# (Be in -*- python -*- mode.) # # ==================================================================== # Copyright (c) 2006-2007 CollabNet. All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://subversion.tigris.org/license-1.html. # If newer versions of this license are posted there, you may use a # newer version instead, at your option. # # This software consists of voluntary contributions made by many # individuals. For exact contribution history, see the revision # history and logs, available at http://cvs2svn.tigris.org/. # ==================================================================== # ##################### # ## PLEASE READ ME! ## # ##################### # # This is a template for an options file that can be used to configure # cvs2svn. Many options do not have defaults, so it is easier to copy # this file and modify what you need rather than creating a new # options file from scratch. # # This file is in Python syntax, but you don't need to know Python to # modify it. But if you *do* know Python, then you will be happy to # know that you can use arbitary Python constructs to do fancy # configuration tricks. # # But please be aware of the following: # # * In many places, leading whitespace is significant in Python (it is # used instead of curly braces to group statements together). # Therefore, if you don't know what you are doing, it is best to # leave the whitespace as it is. # # * In normal strings, Python uses backslashes ("\") are used as an # escape character. Therefore you need to be careful, especially # when specifying regular expressions or Windows filenames. It is # recommended that you use "raw strings" for these cases. # Backslashes in raw strings are treated literally. A raw string is # written by prefixing an "r" character to a string. Example: # # ctx.sort_executable = r'c:\windows\system32\sort.exe' # # Two identifiers will have been defined before this file is executed, # and can be used freely within this file: # # ctx -- a Ctx object (see cvs2svn_lib/context.py), which holds # many configuration options # # run_options -- an instance of the OptionsFileRunOptions class # (see cvs2svn_lib/run_options.py), which holds some variables # governing how cvs2svn is run # Import some modules that are used in setting the options: import re from cvs2svn_lib.boolean import * from cvs2svn_lib import config from cvs2svn_lib.common import UTF8Encoder from cvs2svn_lib.log import Log from cvs2svn_lib.project import Project from cvs2svn_lib.output_option import DumpfileOutputOption from cvs2svn_lib.output_option import ExistingRepositoryOutputOption from cvs2svn_lib.output_option import NewRepositoryOutputOption from cvs2svn_lib.revision_reader import RCSRevisionReader from cvs2svn_lib.revision_reader import CVSRevisionReader from cvs2svn_lib.checkout_internal import InternalRevisionReader from cvs2svn_lib.symbol_strategy import AllBranchRule from cvs2svn_lib.symbol_strategy import AllTagRule from cvs2svn_lib.symbol_strategy import BranchIfCommitsRule from cvs2svn_lib.symbol_strategy import ExcludeRegexpStrategyRule from cvs2svn_lib.symbol_strategy import ForceBranchRegexpStrategyRule from cvs2svn_lib.symbol_strategy import ForceTagRegexpStrategyRule from cvs2svn_lib.symbol_strategy import HeuristicStrategyRule from cvs2svn_lib.symbol_strategy import RuleBasedSymbolStrategy from cvs2svn_lib.symbol_strategy import UnambiguousUsageRule from cvs2svn_lib.symbol_transform import RegexpSymbolTransform from cvs2svn_lib.property_setters import AutoPropsPropertySetter from cvs2svn_lib.property_setters import CVSBinaryFileDefaultMimeTypeSetter from cvs2svn_lib.property_setters import CVSBinaryFileEOLStyleSetter from cvs2svn_lib.property_setters import CVSRevisionNumberSetter from cvs2svn_lib.property_setters import DefaultEOLStyleSetter from cvs2svn_lib.property_setters import EOLStyleFromMimeTypeSetter from cvs2svn_lib.property_setters import ExecutablePropertySetter from cvs2svn_lib.property_setters import KeywordsPropertySetter from cvs2svn_lib.property_setters import MimeMapper from cvs2svn_lib.property_setters import SVNBinaryFileKeywordsPropertySetter # To choose the level of logging output, uncomment one of the # following lines: #Log().log_level = Log.WARN #Log().log_level = Log.QUIET Log().log_level = Log.NORMAL #Log().log_level = Log.VERBOSE #Log().log_level = Log.DEBUG # There are several possible options for where to put the output of a # cvs2svn conversion. Please choose one of the following and adjust # the parameters as necessary: # Use this output option if you would like cvs2svn to create a new SVN # repository and store the converted repository there. The first # argument is the path to which the repository should be written (this # repository must not already exist). The second (optional) argument # allows a --fs-type option to be passed to "svnadmin create". The # third (optional) argument can be specified to set the # --bdb-txn-nosync option on a bdb repository: ctx.output_option = NewRepositoryOutputOption( r'/path/to/svnrepo', # Path to repository #fs_type='fsfs', # Type of repository to create #bdb_txn_nosync=False, # For bsd repositories, this option can be added ) # Use this output option if you would like cvs2svn to store the # converted CVS repository into an SVN repository that already exists. # The argument is the filesystem path of an existing local SVN # repository (this repository must already exist): #ctx.output_option = ExistingRepositoryOutputOption( # r'/path/to/svnrepo', # Path to repository # ) # Use this type of output option if you want the output of the # conversion to be written to a SVN dumpfile instead of committing # them into an actual repository: #ctx.output_option = DumpfileOutputOption( # dumpfile_path=r'/path/to/cvs2svn-dump', # Name of dumpfile to create # ) # Independent of the ctx.output_option selected, the following option # can be set to True to suppress cvs2svn output altogether: ctx.dry_run = False # The following option specifies how the revision contents of the RCS # files should be read. # # The default selection is InternalRevisionReader, which uses built-in # code that reads the RCS deltas while parsing the files in # CollectRevsPass. This method is very fast but requires lots of # temporary disk space. The disk space is required for (1) storing # all of the RCS deltas, and (2) during OutputPass, keeping a copy of # the full text of every revision that still has a descendant that # hasn't yet been committed. Since this can includes multiple # revisions of each file (i.e., on multiple branches), the required # amount of temporary space can potentially be many times the size of # a checked out copy of the whole repository. Setting compress=True # cuts the disk space requirements by about 50% at the price of # increased CPU usage. Using compression usually speeds up the # conversion due to the reduced I/O pressure, unless --tmpdir is on a # RAM disk. This method does not expand CVS's "Log" keywords. # # The second possibility is RCSRevisionReader, which uses RCS's "co" # program to extract the revision contents of the RCS files during # OutputPass. This option doesn't require any temporary space, but it # is relatively slow because (1) "co" has to be executed very many # times; and (2) "co" itself has to assemble many file deltas to # compute the contents of a particular revision. The constructor # argument specifies how to invoke the "co" executable. # # The third possibility is CVSRevisionReader, which uses the "cvs" # program to extract the revision contents out of the RCS files during # OutputPass. This option doesn't require any temporary space, but it # is the slowest of all, because "cvs" is considerably slower than # "co". However, it works in some situations where RCSRevisionReader # fails; see the HTML documentation of the "--use-cvs" option for # details. The constructor argument specifies how to invoke the "co" # executable. ctx.revision_reader = InternalRevisionReader(compress=True) #ctx.revision_reader = RCSRevisionReader(co_executable=r'co') #ctx.revision_reader = CVSRevisionReader(cvs_executable=r'cvs') # Set the name (and optionally the path) of some other executables # required by cvs2svn: ctx.svnadmin_executable = r'svnadmin' ctx.sort_executable = r'sort' # Change the following line to True if the conversion should only # include the trunk of the repository (i.e., all branches and tags # should be ignored): ctx.trunk_only = False # Change the following line to True if cvs2svn should delete a # directory once the last file has been deleted from it: ctx.prune = False # How to converting author names and log messages to UTF8. The first # argument is a list of encoders that are tried in order in 'strict' # mode until one of them succeeds. If none of those succeeds, then # fallback_encoding is used in lossy 'replace' mode (if it is # specified). Setting a fallback encoder ensures that the encoder # always succeeds, but it can cause information loss. ctx.utf8_encoder = UTF8Encoder( [ #'latin1', #'utf8', 'ascii', ], #fallback_encoder='ascii' ) # The following encoder is used to convert filenames to UTF8. See the # documentation for ctx.utf8_encoder for more information. You might # want to set this encoder stricter than ctx.utf8_encoder. ctx.filename_utf8_encoder = UTF8Encoder( [ #'latin1', #'utf8', 'ascii', ], #fallback_encoder='ascii' ) # The basic strategy for converting symbols (this should usually be # left unchanged). A CVS symbol might be used as a tag in one file # and as a branch in another file. The purpose of ctx.symbol_strategy # is to determine whether to convert a particular symbol as a tag or # as a branch. # A RuleBasedSymbolStrategy decides about each symbol based on a list # of rules. Rules can be added to this object. The rules are tried # one by one in order; the first rule that matches a given symbol is # used. It is a fatal error if no rule matches a symbol. ctx.symbol_strategy = RuleBasedSymbolStrategy() # To force all symbols matching a regular expression to be converted # as branches, add rules like the following: #ctx.symbol_strategy.add_rule(ForceBranchRegexpStrategyRule(r'branch.*')) # To force all symbols matching a regular expression to be converted # as tags, add rules like the following: #ctx.symbol_strategy.add_rule(ForceTagRegexpStrategyRule(r'tag.*')) # To force all symbols matching a regular expression to be excluded # from the conversion, add rules like the following: #ctx.symbol_strategy.add_rule(ExcludeRegexpStrategyRule(r'unknown-.*')) # Usually you want this rule, to convert unambiguous symbols (symbols # that were only ever used as tags or only ever used as branches in # CVS) the same way they were used in CVS: ctx.symbol_strategy.add_rule(UnambiguousUsageRule()) # If there was ever a commit on a symbol, then it cannot be converted # as a tag. Uncomment the following line to convert such symbols # automatically as branches: #ctx.symbol_strategy.add_rule(BranchIfCommitsRule()) # Last in the list can be a catch-all rule that is used for symbols # that were not matched by any of the more specific rules above. # Include at most one of these lines. If none of these are included, # then the presence of any ambiguous symbols (that haven't been # disambiguated above) is an error: # Convert all ambiguous symbols as branches: #ctx.symbol_strategy.add_rule(AllBranchRule()) # Convert all ambiguous symbols as tags: #ctx.symbol_strategy.add_rule(AllTagRule()) # Convert ambiguous symbols based on whether they were used more # often as branches or tags: #ctx.symbol_strategy.add_rule(HeuristicStrategyRule()) # Specify a username to be used for commits generated by cvs2svn. If # this options is set to None then no username will be used for such # commits: ctx.username = None #ctx.username = 'cvs2svn' # ctx.svn_property_setters contains a list of rules used to set the # svn properties on files in the converted archive. For each file, # the rules are tried one by one. Any rule can add or suppress one or # more svn properties. Typically the rules will not overwrite # properties set by a previous rule (though they are free to do so). ctx.svn_property_setters.extend([ # To read auto-props rules from a file, uncomment the following line # and specify a filename. The boolean argument specifies whether # case should be ignored when matching filenames to the filename # patterns found in the auto-props file: #AutoPropsPropertySetter( # r'/home/username/.subversion/config', # ignore_case=True, # ), # To read mime types from a file, uncomment the following line and # specify a filename: #MimeMapper(r'/etc/mime.types'), # Omit the svn:eol-style property from any files that are listed # as binary (i.e., mode '-kb') in CVS: CVSBinaryFileEOLStyleSetter(), # If the file is binary and its svn:mime-type property is not yet # set, set svn:mime-type to 'application/octet-stream'. CVSBinaryFileDefaultMimeTypeSetter(), # To try to determine the eol-style from the mime type, uncomment # the following line: #EOLStyleFromMimeTypeSetter(), # Choose one of the following lines to set the default # svn:eol-style if none of the above rules applied. The argument # is the svn:eol-style that should be applied, or None if no # svn:eol-style should be set (i.e., the file should be treated as # binary). # # The default is to treat all files as binary unless one of the # previous rules has determined otherwise, because this is the # safest approach. However, if you have been diligent about # marking binary files with -kb in CVS and/or you have used the # above rules to definitely mark binary files as binary, then you # might prefer to use 'native' as the default, as it is usually # the most convenient setting for text files. Other possible # options: 'CRLF', 'CR', 'LF'. DefaultEOLStyleSetter(None), #DefaultEOLStyleSetter('native'), # Prevent svn:keywords from being set on files that have # svn:eol-style unset. SVNBinaryFileKeywordsPropertySetter(), # If svn:keywords has not been set yet, set it based on the file's # CVS mode: KeywordsPropertySetter(config.SVN_KEYWORDS_VALUE), # Set the svn:executable flag on any files that are marked in CVS as # being executable: ExecutablePropertySetter(), # Uncomment the following line to include the original CVS revision # numbers as file properties in the SVN archive: #CVSRevisionNumberSetter(), ]) # The directory to use for temporary files: ctx.tmpdir = r'cvs2svn-tmp' # To skip the cleanup of temporary files, uncomment the following # option: #ctx.skip_cleanup = True # In CVS, it is perfectly possible to make a single commit that # affects more than one project or more than one branch of a single # project. Subversion also allows such commits. Therefore, by # default, when cvs2svn sees what looks like a cross-project or # cross-branch CVS commit, it converts it into a # cross-project/cross-branch Subversion commit. # # However, other tools and SCMs have trouble representing # cross-project or cross-branch commits. (For example, Trac's Revtree # plugin, http://www.trac-hacks.org/wiki/RevtreePlugin is confused by # such commits.) Therefore, we provide the following two options to # allow cross-project/cross-branch commits to be suppressed. # To prevent CVS commits from different projects from being merged # into single SVN commits, change this option to False: ctx.cross_project_commits = True # To prevent CVS commits on different branches from being merged into # single SVN commits, change this option to False: ctx.cross_branch_commits = True # By default, it is a fatal error for a CVS ",v" file to appear both # inside and outside of an "Attic" subdirectory (this should never # happen, but frequently occurs due to botched repository # administration). If you would like to retain both versions of such # files, change the following option to True, and the attic version of # the file will be left in an SVN subdirectory called "Attic": ctx.retain_conflicting_attic_files = False # Now use stanzas like the following to define CVS projects that # should be converted. The arguments are: # # - The filesystem path of the project within the CVS repository. # # - The path that should be used for the "trunk" directory of this # project within the SVN repository. This is an SVN path, so it # should always use forward slashes ("/"). # # - The path that should be used for the "branches" directory of this # project within the SVN repository. This is an SVN path, so it # should always use forward slashes ("/"). # # - The path that should be used for the "tags" directory of this # project within the SVN repository. This is an SVN path, so it # should always use forward slashes ("/"). # # - A list of symbol transformations that can be used to rename # symbols in this project. Each entry is a tuple (pattern, # replacement), where pattern is a Python regular expression pattern # and replacement is the text that should replace the pattern. Each # pattern is matched against each symbol name. If the pattern # matches, then it is replaced with the corresponding replacement # text. The replacement can include substitution patterns (e.g., # r'\1' or r'\g'). Typically you will want to use raw strings # (strings with a preceding 'r', like shown in the examples) for the # regexp and its replacement to avoid backslash substitution within # those strings. # Create the default project (using ctx.trunk, ctx.branches, and ctx.tags): ctx.add_project( Project( r'test-data/main-cvsrepos', 'trunk', 'branches', 'tags', symbol_transforms=[ #RegexpSymbolTransform(r'release-(\d+)_(\d+)', # r'release-\1.\2'), #RegexpSymbolTransform(r'release-(\d+)_(\d+)_(\d+)', # r'release-\1.\2.\3'), ], ) ) # Add a second project, to be stored to projA/trunk, projA/branches, # and projA/tags: #ctx.add_project( # Project( # r'my/cvsrepo/projA', # 'projA/trunk', # 'projA/branches', # 'projA/tags', # symbol_transforms=[ # #RegexpSymbolTransform(r'release-(\d+)_(\d+)', # # r'release-\1.\2'), # #RegexpSymbolTransform(r'release-(\d+)_(\d+)_(\d+)', # # r'release-\1.\2.\3'), # ], # ) # ) # Change this option to True to turn on profiling of cvs2svn (for # debugging purposes): run_options.profiling = False