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 """This module contains classes that hold the cvs2svn output options."""
19 from cvs2svn_lib
.common
import IllegalSVNPathError
23 """Represents an output choice for a run of cvs2svn."""
25 # name of output format (for error messages), capitalized for use at
26 # the start of a sentence. This class attribute must be set by
30 def register_artifacts(self
, which_pass
):
31 """Register artifacts that will be needed for this output option.
33 WHICH_PASS is the pass that will call our callbacks, so it should
34 be used to do the registering (e.g., call
35 WHICH_PASS.register_temp_file() and/or
36 WHICH_PASS.register_temp_file_needed())."""
40 def verify_filename_legal(self
, filename
):
41 """Verify that FILENAME is a legal filename.
43 FILENAME is a path component of a CVS path. Check that it won't
44 choke the destination VCS:
46 - Check that it is not empty.
48 - Check that it is not equal to '.' or '..'.
50 - Check that the filename does not include any characters that are
51 illegal in the destination VCS.
53 If any of these tests fail, raise an IllegalSVNPathError.
55 This method should be overridden as needed by derived classes."""
58 raise IllegalSVNPathError("Empty filename component.")
60 if filename
in ['.', '..']:
61 raise IllegalSVNPathError("Illegal filename component %r." % (filename
,))
64 """Check that the options stored in SELF are sensible.
66 This might including the existence of a repository on disk, etc."""
68 raise NotImplementedError()
70 def check_symbols(self
, symbol_map
):
71 """Check that the symbols in SYMBOL_MAP are OK for this output option.
73 SYMBOL_MAP is a map {AbstractSymbol : (Trunk|TypedSymbol)},
74 indicating how each symbol is planned to be converted. Raise a
75 FatalError if the symbol plan is not acceptable for this output
78 raise NotImplementedError()
80 def setup(self
, svn_rev_count
):
81 """Prepare this output option."""
83 raise NotImplementedError()
85 def process_initial_project_commit(self
, svn_commit
):
86 """Process SVN_COMMIT, which is an SVNInitialProjectCommit."""
88 raise NotImplementedError()
90 def process_primary_commit(self
, svn_commit
):
91 """Process SVN_COMMIT, which is an SVNPrimaryCommit."""
93 raise NotImplementedError()
95 def process_post_commit(self
, svn_commit
):
96 """Process SVN_COMMIT, which is an SVNPostCommit."""
98 raise NotImplementedError()
100 def process_branch_commit(self
, svn_commit
):
101 """Process SVN_COMMIT, which is an SVNBranchCommit."""
103 raise NotImplementedError()
105 def process_tag_commit(self
, svn_commit
):
106 """Process SVN_COMMIT, which is an SVNTagCommit."""
108 raise NotImplementedError()
111 """Perform any required cleanup related to this output option."""
113 raise NotImplementedError()
116 class NullOutputOption(OutputOption
):
117 """An OutputOption that doesn't do anything."""
124 def check_symbols(self
, symbol_map
):
127 def setup(self
, svn_rev_count
):
130 def process_initial_project_commit(self
, svn_commit
):
133 def process_primary_commit(self
, svn_commit
):
136 def process_post_commit(self
, svn_commit
):
139 def process_branch_commit(self
, svn_commit
):
142 def process_tag_commit(self
, svn_commit
):