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