You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Michael Wood <mw...@its.uct.ac.za> on 2003/04/29 09:15:13 UTC

[PATCH] branches/cvs2svn-kfogel/tools/cvs2svn/cvs2svn.py

I don't know if the code in Dump.start_revision() is going to be
scrapped in favour of "back patching" as is done in
Dump.add_or_change_path().  Here's a patch in case it's not.

Fix up the format of the Revision part of the dump file written by the
new cvs2svn.py.

* branches/cvs2svn-kfogel/tools/cvs2svn/cvs2svn.py:
  (Dump.start_revision): Fix the Prop-content-length and
    Content-length calculation.  Move the code that outputs
    PROPS-END out of the loop.

Index: branches/cvs2svn-kfogel/tools/cvs2svn/cvs2svn.py
===================================================================
--- branches/cvs2svn-kfogel/tools/cvs2svn/cvs2svn.py	(revision 5755)
+++ branches/cvs2svn-kfogel/tools/cvs2svn/cvs2svn.py	(working copy)
@@ -401,12 +401,12 @@
     # are always the same for revisions.
     
     # Calculate the total length of the props section.
-    total_len = 0
+    total_len = len('PROPS-END\n')
     for pname in props.keys():
-      klen = len(pname) + 1
-      klen_len = int(math.ceil(math.log10(klen))) + 1
-      plen = len(props[pname]) + 1
-      plen_len = int(math.ceil(math.log10(plen))) + 1
+      klen = len(pname) + 1 # pname + '\n'
+      klen_len = int(math.ceil(math.log10(klen))) + 3 # 'K ' + klen + '\n'
+      plen = len(props[pname]) + 1 # prop + '\n'
+      plen_len = int(math.ceil(math.log10(plen))) + 3 # 'V ' + klen + '\n'
       total_len = total_len + klen + klen_len + plen + plen_len
         
     # Print the revision header and props
@@ -419,8 +419,8 @@
       self.dumpfile.write('%s\n' % pname)
       self.dumpfile.write('V %d\n' % len(props[pname]))
       self.dumpfile.write('%s\n' % props[pname])
-      self.dumpfile.write('PROPS-END\n')
-      self.dumpfile.write('\n')
+    self.dumpfile.write('PROPS-END\n')
+    self.dumpfile.write('\n')
 
   def end_revision(self):
     old_rev = self.revision

-- 
Michael Wood <mw...@its.uct.ac.za>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] branches/cvs2svn-kfogel/tools/cvs2svn/cvs2svn.py

Posted by Karl Fogel <kf...@newton.ch.collab.net>.
Michael Wood <mw...@its.uct.ac.za> writes:
> I don't know if the code in Dump.start_revision() is going to be
> scrapped in favour of "back patching" as is done in
> Dump.add_or_change_path().  Here's a patch in case it's not.

It's not going to backpatch, since we know all the lengths in advance.

Thanks for the patch!

-K

> Fix up the format of the Revision part of the dump file written by the
> new cvs2svn.py.
> 
> * branches/cvs2svn-kfogel/tools/cvs2svn/cvs2svn.py:
>   (Dump.start_revision): Fix the Prop-content-length and
>     Content-length calculation.  Move the code that outputs
>     PROPS-END out of the loop.
> 
> Index: branches/cvs2svn-kfogel/tools/cvs2svn/cvs2svn.py
> ===================================================================
> --- branches/cvs2svn-kfogel/tools/cvs2svn/cvs2svn.py	(revision 5755)
> +++ branches/cvs2svn-kfogel/tools/cvs2svn/cvs2svn.py	(working copy)
> @@ -401,12 +401,12 @@
>      # are always the same for revisions.
>      
>      # Calculate the total length of the props section.
> -    total_len = 0
> +    total_len = len('PROPS-END\n')
>      for pname in props.keys():
> -      klen = len(pname) + 1
> -      klen_len = int(math.ceil(math.log10(klen))) + 1
> -      plen = len(props[pname]) + 1
> -      plen_len = int(math.ceil(math.log10(plen))) + 1
> +      klen = len(pname) + 1 # pname + '\n'
> +      klen_len = int(math.ceil(math.log10(klen))) + 3 # 'K ' + klen + '\n'
> +      plen = len(props[pname]) + 1 # prop + '\n'
> +      plen_len = int(math.ceil(math.log10(plen))) + 3 # 'V ' + klen + '\n'
>        total_len = total_len + klen + klen_len + plen + plen_len
>          
>      # Print the revision header and props
> @@ -419,8 +419,8 @@
>        self.dumpfile.write('%s\n' % pname)
>        self.dumpfile.write('V %d\n' % len(props[pname]))
>        self.dumpfile.write('%s\n' % props[pname])
> -      self.dumpfile.write('PROPS-END\n')
> -      self.dumpfile.write('\n')
> +    self.dumpfile.write('PROPS-END\n')
> +    self.dumpfile.write('\n')
>  
>    def end_revision(self):
>      old_rev = self.revision
> 
> -- 
> Michael Wood <mw...@its.uct.ac.za>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org