Improve error reporting of ValueExceptions emitted by rcsparse.
[cvs2svn.git] / cvs2svn_lib / output_option.py
blobebd7d80262366296b6e2b981d1a9ebe438220c83
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
22 class OutputOption:
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
27 # subclasses
28 name = None
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())."""
38 pass
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 control characters.
52 If any of these tests fail, raise an IllegalSVNPathError."""
54 if filename == '':
55 raise IllegalSVNPathError("Empty filename component.")
57 if filename in ['.', '..']:
58 raise IllegalSVNPathError("Illegal filename component %r." % (filename,))
60 def check(self):
61 """Check that the options stored in SELF are sensible.
63 This might including the existence of a repository on disk, etc."""
65 raise NotImplementedError()
67 def check_symbols(self, symbol_map):
68 """Check that the symbols in SYMBOL_MAP are OK for this output option.
70 SYMBOL_MAP is a map {AbstractSymbol : (Trunk|TypedSymbol)},
71 indicating how each symbol is planned to be converted. Raise a
72 FatalError if the symbol plan is not acceptable for this output
73 option."""
75 raise NotImplementedError()
77 def setup(self, svn_rev_count):
78 """Prepare this output option."""
80 raise NotImplementedError()
82 def process_initial_project_commit(self, svn_commit):
83 """Process SVN_COMMIT, which is an SVNInitialProjectCommit."""
85 raise NotImplementedError()
87 def process_primary_commit(self, svn_commit):
88 """Process SVN_COMMIT, which is an SVNPrimaryCommit."""
90 raise NotImplementedError()
92 def process_post_commit(self, svn_commit):
93 """Process SVN_COMMIT, which is an SVNPostCommit."""
95 raise NotImplementedError()
97 def process_branch_commit(self, svn_commit):
98 """Process SVN_COMMIT, which is an SVNBranchCommit."""
100 raise NotImplementedError()
102 def process_tag_commit(self, svn_commit):
103 """Process SVN_COMMIT, which is an SVNTagCommit."""
105 raise NotImplementedError()
107 def cleanup(self):
108 """Perform any required cleanup related to this output option."""
110 raise NotImplementedError()