Pull method get_content() up to AbstractRCSRevisionManager class.
[cvs2svn.git] / cvs2svn_lib / abstract_rcs_revision_manager.py
blob37579a549d533166be72d1fd994f39f1630c4738
1 # (Be in -*- python -*- mode.)
3 # ====================================================================
4 # Copyright (c) 2000-2010 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 """Base class for RCSRevisionReader and CVSRevisionReader."""
20 from cvs2svn_lib.common import canonicalize_eol
21 from cvs2svn_lib.process import get_command_output
22 from cvs2svn_lib.context import Ctx
23 from cvs2svn_lib.revision_manager import RevisionReader
24 from cvs2svn_lib.apple_single_filter import get_maybe_apple_single
27 class AbstractRCSRevisionReader(RevisionReader):
28 """A base class for RCSRevisionReader and CVSRevisionReader."""
30 def get_pipe_command(self, cvs_rev):
31 """Return the command that is needed to get the contents for CVS_REV."""
33 raise NotImplementedError()
35 def select_k_option(self, cvs_rev):
36 """Return the '-k' option to be used for CVS_REV.
38 Return a list containing any '-k' option that should be used when
39 checking out content for CVS_REV. If no option is needed, return
40 an empty list."""
42 if cvs_rev.get_property('_keyword_handling') == 'collapsed':
43 return ['-kk']
44 else:
45 return []
47 def get_content(self, cvs_rev):
48 data = get_command_output(self.get_pipe_command(cvs_rev))
50 if Ctx().decode_apple_single:
51 # Insert a filter to decode any files that are in AppleSingle
52 # format:
53 data = get_maybe_apple_single(data)
55 eol_fix = cvs_rev.get_property('_eol_fix')
56 if eol_fix:
57 data = canonicalize_eol(data, eol_fix)
59 return data