Break out of loop correctly when the first file difference is found.
[cvs2svn.git] / cvs2svn_lib / rcs_revision_manager.py
blobbf795da785b11fcea11e5bb390ddeccca0aed3d4
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 """Access the CVS repository via RCS's 'co' command."""
20 from cvs2svn_lib.common import FatalError
21 from cvs2svn_lib.common import canonicalize_eol
22 from cvs2svn_lib.process import check_command_runs
23 from cvs2svn_lib.process import get_command_output
24 from cvs2svn_lib.process import CommandFailedException
25 from cvs2svn_lib.context import Ctx
26 from cvs2svn_lib.revision_manager import RevisionReader
27 from cvs2svn_lib.apple_single_filter import get_maybe_apple_single
30 class RCSRevisionReader(RevisionReader):
31 """A RevisionReader that reads the contents via RCS."""
33 def __init__(self, co_executable):
34 self.co_executable = co_executable
35 try:
36 check_command_runs([self.co_executable, '-V'], self.co_executable)
37 except CommandFailedException, e:
38 raise FatalError('%s\n'
39 'Please check that co is installed and in your PATH\n'
40 '(it is a part of the RCS software).' % (e,))
42 def get_content(self, cvs_rev):
43 pipe_cmd = [
44 self.co_executable,
45 '-q',
46 '-x,v',
47 '-p%s' % (cvs_rev.rev,)
49 if cvs_rev.get_property('_keyword_handling') == 'collapsed':
50 pipe_cmd.append('-kk')
51 pipe_cmd.append(cvs_rev.cvs_file.filename)
52 data = get_command_output(pipe_cmd)
54 if Ctx().decode_apple_single:
55 # Insert a filter to decode any files that are in AppleSingle
56 # format:
57 data = get_maybe_apple_single(data)
59 eol_fix = cvs_rev.get_property('_eol_fix')
60 if eol_fix:
61 data = canonicalize_eol(data, eol_fix)
63 return data