From 9075c6de095d4e70b3d34e319e3f7b31eeded728 Mon Sep 17 00:00:00 2001 From: mhagger Date: Sat, 16 Oct 2010 19:18:01 +0000 Subject: [PATCH] Inline StdoutDelegate. It was always used, so the flexibility was not needed. git-svn-id: http://cvs2svn.tigris.org/svn/cvs2svn/trunk@5296 be7e6eca-30d4-0310-a8e5-ac0d63af7087 --- cvs2svn_lib/stdout_delegate.py | 107 --------------------------------- cvs2svn_lib/svn_output_option.py | 43 +++++++++++-- cvs2svn_lib/svn_repository_delegate.py | 6 +- 3 files changed, 41 insertions(+), 115 deletions(-) delete mode 100644 cvs2svn_lib/stdout_delegate.py diff --git a/cvs2svn_lib/stdout_delegate.py b/cvs2svn_lib/stdout_delegate.py deleted file mode 100644 index 2feb4784..00000000 --- a/cvs2svn_lib/stdout_delegate.py +++ /dev/null @@ -1,107 +0,0 @@ -# (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 logger -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.""" - - logger.verbose("=" * 60) - logger.normal("Starting Subversion r%d / %d" % (revnum, self.total_revs)) - - def end_commit(self): - pass - - def initialize_project(self, project): - logger.verbose(" Initializing project %s" % (project,)) - - def initialize_lod(self, lod): - logger.verbose(" Initializing %s" % (lod,)) - - def mkdir(self, lod, cvs_directory): - logger.verbose( - " New Directory %s" % (lod.get_path(cvs_directory.cvs_path),) - ) - - def add_path(self, cvs_rev): - """Print a line stating what path we are 'adding'.""" - - logger.verbose(" Adding %s" % (cvs_rev.get_svn_path(),)) - - def change_path(self, cvs_rev): - """Print a line stating what path we are 'changing'.""" - - logger.verbose(" Changing %s" % (cvs_rev.get_svn_path(),)) - - def delete_lod(self, lod): - """Print a line stating that we are 'deleting' LOD.""" - - logger.verbose(" Deleting %s" % (lod.get_path(),)) - - def delete_path(self, lod, cvs_path): - """Print a line stating that we are 'deleting' PATH.""" - - logger.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.""" - - logger.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.""" - - logger.verbose("Finished creating Subversion repository.") - logger.quiet("Done.") - - diff --git a/cvs2svn_lib/svn_output_option.py b/cvs2svn_lib/svn_output_option.py index 9bb6d9dc..7eb417da 100644 --- a/cvs2svn_lib/svn_output_option.py +++ b/cvs2svn_lib/svn_output_option.py @@ -46,7 +46,6 @@ from cvs2svn_lib.repository_mirror import RepositoryMirror from cvs2svn_lib.repository_mirror import PathExistsError from cvs2svn_lib.openings_closings import SymbolingsReader from cvs2svn_lib.fill_source import get_source_set -from cvs2svn_lib.stdout_delegate import StdoutDelegate from cvs2svn_lib.svn_dump import DumpstreamDelegate from cvs2svn_lib.svn_dump import LoaderPipe from cvs2svn_lib.output_option import OutputOption @@ -145,7 +144,7 @@ class SVNOutputOption(OutputOption): self._mirror.open() self._delegates = [] Ctx().revision_reader.start() - self.add_delegate(StdoutDelegate(svn_rev_count)) + self.svn_rev_count = svn_rev_count def _get_author(self, svn_commit): author = svn_commit.get_author() @@ -164,6 +163,11 @@ class SVNOutputOption(OutputOption): def start_commit(self, revnum, revprops): """Start a new commit.""" + logger.verbose("=" * 60) + logger.normal( + "Starting Subversion r%d / %d" % (revnum, self.svn_rev_count) + ) + self._mirror.start_commit(revnum) self._invoke_delegates('start_commit', revnum, revprops) @@ -186,6 +190,7 @@ class SVNOutputOption(OutputOption): # Never delete a Trunk path. return + logger.verbose(" Deleting %s" % (lod.get_path(),)) self._mirror.get_current_lod_directory(lod).delete() self._invoke_delegates('delete_lod', lod) @@ -196,6 +201,7 @@ class SVNOutputOption(OutputOption): self.delete_lod(lod) return + logger.verbose(" Deleting %s" % (lod.get_path(cvs_path.cvs_path),)) parent_node = self._mirror.get_current_path( cvs_path.parent_directory, lod ) @@ -215,11 +221,13 @@ class SVNOutputOption(OutputOption): else: parent_node = node.parent_mirror_dir node.delete() + logger.verbose(" Deleting %s" % (lod.get_path(cvs_path.cvs_path),)) self._invoke_delegates('delete_path', lod, cvs_path) def initialize_project(self, project): """Create the basic structure for PROJECT.""" + logger.verbose(" Initializing project %s" % (project,)) self._invoke_delegates('initialize_project', project) # Don't invoke delegates. @@ -232,6 +240,7 @@ class SVNOutputOption(OutputOption): def change_path(self, cvs_rev): """Register a change in self._youngest for the CVS_REV's svn_path.""" + logger.verbose(" Changing %s" % (cvs_rev.get_svn_path(),)) # We do not have to update the nodes because our mirror is only # concerned with the presence or absence of paths, and a file # content change does not cause any path changes. @@ -242,6 +251,9 @@ class SVNOutputOption(OutputOption): for empty_subdirectory_id in cvs_directory.empty_subdirectory_ids: empty_subdirectory = Ctx()._cvs_path_db.get_path(empty_subdirectory_id) + logger.verbose( + " New Directory %s" % (lod.get_path(empty_subdirectory.cvs_path),) + ) # There is no need to record the empty subdirectories in the # mirror, since they live and die with their parent directories. self._invoke_delegates('mkdir', lod, empty_subdirectory) @@ -258,6 +270,7 @@ class SVNOutputOption(OutputOption): try: node = self._mirror.get_current_lod_directory(lod) except KeyError: + logger.verbose(" Initializing %s" % (lod,)) node = self._mirror.add_lod(lod) self._invoke_delegates('initialize_lod', lod) if ancestry and Ctx().include_empty_directories: @@ -267,6 +280,9 @@ class SVNOutputOption(OutputOption): try: node = node[sub_path] except KeyError: + logger.verbose( + " New Directory %s" % (lod.get_path(sub_path.cvs_path),) + ) node = node.mkdir(sub_path) self._invoke_delegates('mkdir', lod, sub_path) if Ctx().include_empty_directories: @@ -287,9 +303,20 @@ class SVNOutputOption(OutputOption): parent_path = cvs_file.parent_directory lod = cvs_rev.lod parent_node = self._mkdir_p(parent_path, lod) + logger.verbose(" Adding %s" % (cvs_rev.get_svn_path(),)) parent_node.add_file(cvs_file) self._invoke_delegates('add_path', cvs_rev) + 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.""" + + logger.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): """Copy all of SRC_LOD at SRC_REVNUM to DST_LOD. @@ -299,6 +326,7 @@ class SVNOutputOption(OutputOption): Return the new node at DEST_LOD. Note that this node is not necessarily writable, though its parent node necessarily is.""" + self._show_copy(src_lod.get_path(), dest_lod.get_path(), src_revnum) node = self._mirror.copy_lod(src_lod, dest_lod, src_revnum) self._invoke_delegates('copy_lod', src_lod, dest_lod, src_revnum) return node @@ -343,10 +371,14 @@ class SVNOutputOption(OutputOption): % (dest_lod.get_path(cvs_path.cvs_path),) ) + self._show_copy( + src_lod.get_path(cvs_path.cvs_path), + dest_lod.get_path(cvs_path.cvs_path), + src_revnum, + ) dest_parent_node[cvs_path] = src_node self._invoke_delegates( - 'copy_path', - cvs_path, src_lod, dest_lod, src_revnum + 'copy_path', cvs_path, src_lod, dest_lod, src_revnum ) return dest_parent_node[cvs_path] @@ -521,6 +553,7 @@ class SVNOutputOption(OutputOption): # order: delete_list.sort() for cvs_path in delete_list: + logger.verbose(" Deleting %s" % (symbol.get_path(cvs_path.cvs_path),)) del dest_node[cvs_path] self._invoke_delegates('delete_path', symbol, cvs_path) @@ -642,6 +675,8 @@ class SVNOutputOption(OutputOption): def cleanup(self): self._invoke_delegates('finish') + logger.verbose("Finished creating Subversion repository.") + logger.quiet("Done.") self._mirror.close() self._mirror = None Ctx().revision_reader.finish() diff --git a/cvs2svn_lib/svn_repository_delegate.py b/cvs2svn_lib/svn_repository_delegate.py index 9e96decc..3463f5b3 100644 --- a/cvs2svn_lib/svn_repository_delegate.py +++ b/cvs2svn_lib/svn_repository_delegate.py @@ -24,10 +24,8 @@ class SVNRepositoryDelegate: For each method, a subclass implements, in its own way, the Subversion operation implied by the method's name. For example, for - the add_path method, the DumpstreamDelegate would write out a - 'Node-add:' command to a Subversion dumpfile, whereas the - StdoutDelegate would merely print that the path is being added to - the repository.""" + the add_path method, the DumpstreamDelegate writes out a 'Node-add:' + command to a Subversion dumpfile.""" def start_commit(self, revnum, revprops): """An SVN commit is starting. -- 2.11.4.GIT