From e96455d25b9471b2e898742c48e7e12f8808acc7 Mon Sep 17 00:00:00 2001 From: mhagger Date: Sun, 18 Jul 2010 14:45:51 +0000 Subject: [PATCH] Simplify dumpfile output code. Now that we don't pretent to handle files streamily, there is no need to seek back and forth in the dumpfile output to fix up the content lengths and md5 sums; they can all be written correctly the first time. git-svn-id: http://cvs2svn.tigris.org/svn/cvs2svn/trunk@5222 be7e6eca-30d4-0310-a8e5-ac0d63af7087 --- cvs2svn_lib/dumpfile_delegate.py | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/cvs2svn_lib/dumpfile_delegate.py b/cvs2svn_lib/dumpfile_delegate.py index 080e4543..d9c3f00a 100644 --- a/cvs2svn_lib/dumpfile_delegate.py +++ b/cvs2svn_lib/dumpfile_delegate.py @@ -274,46 +274,30 @@ class DumpfileDelegate(SVNRepositoryDelegate): if not Ctx().keep_cvsignore: return + checksum = md5() + checksum.update(data) + + # The content length is the length of property data, text data, + # and any metadata around/inside around them: self.dumpfile.write( 'Node-path: %s\n' 'Node-kind: file\n' 'Node-action: %s\n' '%s' # no property header if no props - % (self._utf8_path(cvs_rev.get_svn_path()), op, props_header) - ) - - pos = self.dumpfile.tell() - - content_header_fmt = ( 'Text-content-length: %16d\n' 'Text-content-md5: %32s\n' 'Content-length: %16d\n' - '\n' + '\n' % ( + self._utf8_path(cvs_rev.get_svn_path()), op, props_header, + len(data), checksum.hexdigest(), len(data) + len(prop_contents), + ) ) - self.dumpfile.write(content_header_fmt % (0, '', 0,)) - if prop_contents: self.dumpfile.write(prop_contents) - # Insert the rev contents, calculating length and checksum. - checksum = md5() - checksum.update(data) - length = len(data) self.dumpfile.write(data) - # Go back to overwrite the length and checksum headers with the - # correct values. The content length is the length of property - # data, text data, and any metadata around/inside around them: - self.dumpfile.seek(pos, 0) - self.dumpfile.write( - content_header_fmt - % (length, checksum.hexdigest(), length + len(prop_contents),) - ) - - # Jump back to the end of the stream - self.dumpfile.seek(0, 2) - # This record is done (write two newlines -- one to terminate # contents that weren't themselves newline-termination, one to # provide a blank line for readability. -- 2.11.4.GIT