1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# (Be in -*- python -*- mode.)
#
# ====================================================================
# Copyright (c) 2000-2009 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/.
# ====================================================================
"""Store the context (options, etc) for a cvs2svn run."""
import os
from cvs2svn_lib import config
from cvs2svn_lib.common import CVSTextDecoder
class Ctx:
"""Session state for this run of cvs2svn. For example, run-time
options are stored here. This class is a Borg (see
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531)."""
__shared_state = { }
def __init__(self):
self.__dict__ = self.__shared_state
if self.__dict__:
return
# Else, initialize to defaults.
self.set_defaults()
def set_defaults(self):
"""Set all parameters to their default values."""
self.output_option = None
self.dry_run = False
self.revision_recorder = None
self.revision_excluder = None
self.revision_reader = None
self.svnadmin_executable = config.SVNADMIN_EXECUTABLE
self.sort_executable = config.SORT_EXECUTABLE
self.trunk_only = False
self.prune = True
self.cvs_author_decoder = CVSTextDecoder(['ascii'])
self.cvs_log_decoder = CVSTextDecoder(['ascii'])
self.cvs_filename_decoder = CVSTextDecoder(['ascii'])
self.decode_apple_single = False
self.symbol_info_filename = None
self.username = None
self.svn_property_setters = []
self.tmpdir = 'cvs2svn-tmp'
self.skip_cleanup = False
self.keep_cvsignore = False
self.cross_project_commits = True
self.cross_branch_commits = True
self.retain_conflicting_attic_files = False
self.initial_project_commit_message = (
'Standard project directories initialized by cvs2svn.'
)
self.post_commit_message = (
'This commit was generated by cvs2svn to compensate for '
'changes in r%(revnum)d, which included commits to RCS files '
'with non-trunk default branches.'
)
self.symbol_commit_message = (
"This commit was manufactured by cvs2svn to create %(symbol_type)s "
"'%(symbol_name)s'."
)
def get_temp_filename(self, basename):
return os.path.join(self.tmpdir, basename)
def clean(self):
"""Dispose of items in our dictionary that are not intended to
live past the end of a pass (identified by exactly one leading
underscore)."""
for attr in self.__dict__.keys():
if (attr.startswith('_') and not attr.startswith('__')
and not attr.startswith('_Ctx__')):
delattr(self, attr)
|