[PATCH] convert/mtn: Fix conversion of large files from mtn (broken in ed97955e0c04)

daniel.atallah at gmail.com daniel.atallah at gmail.com
Mon Mar 28 22:17:16 CDT 2011


# HG changeset patch
# User Daniel Atallah <daniel.atallah at gmail.com>
# Date 1301368580 14400
# Node ID 6538e67d4c08cfcc1a4429f1029b4aeab267c872
# Parent  307c72686eb0c336db0e20143a76edb211e9bba8
convert/mtn: Fix conversion of large files from mtn (broken in ed97955e0c04)

"mtn automate stdio" will break output larger than 32kB into several packets.
This ensures that we are processing all the output on the main stream and not
only the last packet.

diff --git a/hgext/convert/monotone.py b/hgext/convert/monotone.py
--- a/hgext/convert/monotone.py
+++ b/hgext/convert/monotone.py
@@ -138,7 +138,7 @@
         return (commandnbr, stream, length, read)
 
     def mtnstdioreadcommandoutput(self, command):
-        retval = ''
+        retval = []
         while True:
             commandnbr, stream, length, output = self.mtnstdioreadpacket()
             self.ui.debug('mtn: read packet %s:%s:%s\n' %
@@ -159,9 +159,9 @@
                 self.ui.debug('mtn: ' + output)
             elif stream == 'm':
                 # Main stream - command output
-                retval = output
+                retval.append(output)
 
-        return retval
+        return ''.join(retval)
 
     def mtnloadmanifest(self, rev):
         if self.manifest_rev == rev:
diff --git a/tests/test-convert-mtn.t b/tests/test-convert-mtn.t
--- a/tests/test-convert-mtn.t
+++ b/tests/test-convert-mtn.t
@@ -208,9 +208,20 @@
   mtn: beginning commit on branch 'com.selenic.test'
   mtn: committed revision 4a736634505795f17786fffdf2c9cbf5b11df6f6
 
+test large file support (> 32kB)
+
+  $ python -c 'for x in range(10000): print x' > large-file
+  $ $TESTDIR/md5sum.py large-file
+  5d6de8a95c3b6bf9e0ffb808ba5299c1  large-file
+  $ mtn add large-file
+  mtn: adding large-file to workspace manifest
+  $ mtn ci -m largefile
+  mtn: beginning commit on branch 'com.selenic.test'
+  mtn: committed revision f0a20fecd10dc4392d18fe69a03f1f4919d3387b
+
 test suspending (closing a branch)
 
-  $ mtn suspend 4a736634505795f17786fffdf2c9cbf5b11df6f6 2> /dev/null
+  $ mtn suspend f0a20fecd10dc4392d18fe69a03f1f4919d3387b 2> /dev/null
   $ cd ..
 
 convert incrementally
@@ -220,27 +231,30 @@
   scanning source...
   sorting...
   converting...
-  11 update2 "with" quotes
-  10 createdir1
-  9 movedir1
-  8 movedir
-  7 emptydir
-  6 dropdirectory
-  5 dirfilemove
-  4 dirfilemove2
-  3 dirdirmove
-  2 dirdirmove2
-  1 divergentdirmove
-  0 divergentdirmove2
+  12 update2 "with" quotes
+  11 createdir1
+  10 movedir1
+  9 movedir
+  8 emptydir
+  7 dropdirectory
+  6 dirfilemove
+  5 dirfilemove2
+  4 dirdirmove
+  3 dirdirmove2
+  2 divergentdirmove
+  1 divergentdirmove2
+  0 largefile
   $ glog()
   > {
   >     hg glog --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
   > }
   $ cd repo.mtn-hg
   $ hg up -C
-  11 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  12 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ glog
-  @  13 "divergentdirmove2" files: dir7-2/c dir7/c dir7/dir9/b dir7/dir9/dir8/a dir8-2/a dir9-2/b
+  @  14 "largefile" files: large-file
+  |
+  o  13 "divergentdirmove2" files: dir7-2/c dir7/c dir7/dir9/b dir7/dir9/dir8/a dir8-2/a dir9-2/b
   |
   o  12 "divergentdirmove" files: dir7/c dir7/dir9/b dir7/dir9/dir8/a
   |
@@ -283,6 +297,7 @@
   dir8-2/a
   dir9-2/b
   e
+  large-file
 
 contents
 
@@ -360,9 +375,14 @@
   dir9-2/b
   e
 
+test large file support (> 32kB)
+
+  $ $TESTDIR/md5sum.py large-file
+  5d6de8a95c3b6bf9e0ffb808ba5299c1  large-file
+
 check branch closing
 
   $ hg branches -a
   $ hg branches -c
-  com.selenic.test              13:* (closed) (glob)
+  com.selenic.test              14:* (closed) (glob)
 


More information about the Mercurial-devel mailing list