Add a way to specify the MimeMapper mappings to its constructor directly.
[cvs2svn.git] / cvs2svn_lib / revision_manager.py
blobea0b552dfbb825a346123715142046421fe350c6
1 # (Be in -*- python -*- mode.)
3 # ====================================================================
4 # Copyright (c) 2000-2008 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 describes the interface to the CVS repository."""
20 class RevisionCollector(object):
21 """Optionally collect revision information for CVS files."""
23 def __init__(self):
24 """Initialize the RevisionCollector.
26 Please note that a RevisionCollector is instantiated in every
27 program run, even if the data-collection pass will not be
28 executed. (This is to allow it to register the artifacts that it
29 produces.) Therefore, the __init__() method should not do much,
30 and more substantial preparation for use (like actually creating
31 the artifacts) should be done in start()."""
33 pass
35 def register_artifacts(self, which_pass):
36 """Register artifacts that will be needed while collecting data.
38 WHICH_PASS is the pass that will call our callbacks, so it should
39 be used to do the registering (e.g., call
40 WHICH_PASS.register_temp_file() and/or
41 WHICH_PASS.register_temp_file_needed())."""
43 pass
45 def start(self):
46 """Data will soon start being collected.
48 Any non-idempotent initialization should be done here."""
50 pass
52 def process_file(self, cvs_file_items):
53 """Collect data for the file described by CVS_FILE_ITEMS.
55 CVS_FILE_ITEMS has already been transformed into the logical
56 representation of the file's history as it should be output.
57 Therefore it is not necessarily identical to the history as
58 recorded in the RCS file."""
60 raise NotImplementedError()
62 def finish(self):
63 """All recording is done; clean up."""
65 pass
68 class NullRevisionCollector(RevisionCollector):
69 """A do-nothing variety of RevisionCollector."""
71 def process_file(self, cvs_file_items):
72 pass
75 class RevisionReader(object):
76 """An object that can read the contents of CVSRevisions."""
78 def register_artifacts(self, which_pass):
79 """Register artifacts that will be needed during branch exclusion.
81 WHICH_PASS is the pass that will call our callbacks, so it should
82 be used to do the registering (e.g., call
83 WHICH_PASS.register_temp_file() and/or
84 WHICH_PASS.register_temp_file_needed())."""
86 pass
88 def start(self):
89 """Prepare for calls to get_content_stream."""
91 pass
93 def get_content_stream(self, cvs_rev, suppress_keyword_substitution=False):
94 """Return a file-like object from which the contents of CVS_REV
95 can be read.
97 CVS_REV is a CVSRevision. If SUPPRESS_KEYWORD_SUBSTITUTION is
98 True, then suppress the substitution of RCS/CVS keywords in the
99 output."""
101 raise NotImplementedError
103 def finish(self):
104 """Inform the reader that all calls to get_content_stream are done.
105 Start may be called again at a later point."""
107 pass