1 # (Be in -*- python -*- mode.)
3 # ====================================================================
4 # Copyright (c) 2000-2006 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 """Store the context (options, etc) for a cvs2svn run."""
28 """Session state for this run of cvs2svn. For example, run-time
29 options are stored here. This class is a Borg, see
30 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531."""
35 self
.__dict
__ = self
.__shared
_state
38 # Else, initialize to defaults.
40 self
.dumpfile
= config
.DUMPFILE
45 self
.existing_svnrepos
= 0
49 self
.trunk_base
= "trunk"
50 self
.tags_base
= "tags"
51 self
.branches_base
= "branches"
52 self
.encoding
= ["ascii"]
53 self
.mime_types_file
= None
54 self
.auto_props_file
= None
55 self
.auto_props_ignore_case
= False
56 self
.no_default_eol
= 0
57 self
.eol_from_mime_type
= 0
60 self
.svnadmin
= "svnadmin"
64 self
.bdb_txn_nosync
= 0
66 self
.forced_branches
= []
69 self
.symbol_transforms
= []
70 self
.svn_property_setters
= []
72 def get_temp_filename(self
, basename
):
73 return os
.path
.join(self
.tmpdir
, basename
)
75 def to_utf8(self
, value
, mode
='replace'):
76 """Encode (as Unicode) VALUE, trying the encodings in self.encoding
77 as valid source encodings. Raise UnicodeError on failure of all
80 ### FIXME: The 'replace' default mode should be an option,
81 ### like --encoding is.
82 for encoding
in self
.encoding
:
84 return unicode(value
, encoding
, mode
).encode('utf8')
86 Log().verbose("Encoding '%s' failed for string '%s'"