aboutsummaryrefslogtreecommitdiff
blob: 2b4e22818f5de9d2172c0182f79ffc68db2aa950 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# (Be in -*- python -*- mode.)
#
# ====================================================================
# Copyright (c) 2000-2008 CollabNet.  All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution.  The terms
# are also available at http://subversion.tigris.org/license-1.html.
# If newer versions of this license are posted there, you may use a
# newer version instead, at your option.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://cvs2svn.tigris.org/.
# ====================================================================

"""This module contains database facilities used by cvs2svn."""


from cvs2svn_lib.log import Log
from cvs2svn_lib.svn_repository_delegate import SVNRepositoryDelegate


class StdoutDelegate(SVNRepositoryDelegate):
  """Makes no changes to the disk, but writes out information to
  STDOUT about what is happening in the SVN output.  Of course, our
  print statements will state that we're doing something, when in
  reality, we aren't doing anything other than printing out that we're
  doing something.  Kind of zen, really."""

  def __init__(self, total_revs):
    self.total_revs = total_revs

  def start_commit(self, revnum, revprops):
    """Prints out the Subversion revision number of the commit that is
    being started."""

    Log().verbose("=" * 60)
    Log().normal("Starting Subversion r%d / %d" % (revnum, self.total_revs))

  def end_commit(self):
    pass

  def initialize_project(self, project):
    Log().verbose("  Initializing project %s" % (project,))

  def initialize_lod(self, lod):
    Log().verbose("  Initializing %s" % (lod,))

  def mkdir(self, lod, cvs_directory):
    Log().verbose(
        "  New Directory %s" % (lod.get_path(cvs_directory.cvs_path),)
        )

  def add_path(self, s_item):
    """Print a line stating what path we are 'adding'."""

    Log().verbose("  Adding %s" % (s_item.cvs_rev.get_svn_path(),))

  def change_path(self, s_item):
    """Print a line stating what path we are 'changing'."""

    Log().verbose("  Changing %s" % (s_item.cvs_rev.get_svn_path(),))

  def delete_lod(self, lod):
    """Print a line stating that we are 'deleting' LOD."""

    Log().verbose("  Deleting %s" % (lod.get_path(),))

  def delete_path(self, lod, cvs_path):
    """Print a line stating that we are 'deleting' PATH."""

    Log().verbose("  Deleting %s" % (lod.get_path(cvs_path.cvs_path),))

  def _show_copy(self, src_path, dest_path, src_revnum):
    """Print a line stating that we are 'copying' revision SRC_REVNUM
    of SRC_PATH to DEST_PATH."""

    Log().verbose(
        "  Copying revision %d of %s\n"
        "                to %s\n"
        % (src_revnum, src_path, dest_path,)
        )

  def copy_lod(self, src_lod, dest_lod, src_revnum):
    """Print a line stating that we are 'copying' revision SRC_REVNUM
    of SRC_PATH to DEST_PATH."""

    self._show_copy(src_lod.get_path(), dest_lod.get_path(), src_revnum)

  def copy_path(self, cvs_path, src_lod, dest_lod, src_revnum):
    """Print a line stating that we are 'copying' revision SRC_REVNUM
    of CVS_PATH from SRC_LOD to DEST_LOD."""

    self._show_copy(
        src_lod.get_path(cvs_path.cvs_path),
        dest_lod.get_path(cvs_path.cvs_path),
        src_revnum,
        )

  def finish(self):
    """State that we are done creating our repository."""

    Log().verbose("Finished creating Subversion repository.")
    Log().quiet("Done.")