[Patch] Fix marshalling in P4 convert extension to use a binary stream

Peter Ingebretson pingebre at yahoo.com
Wed Sep 23 02:16:13 CDT 2009


# HG changeset patch
# User Peter Ingebretson <pingebre at yahoo dot com>
# Date 1253689419 25200
# Node ID 4d65d096faa0d227d7c704e83b912f1d2d67ec06
# Parent  f3f400b13984d175f44943de2cc348c435c4119e
Fix marshalling in P4 convert extension to use a binary stream

The Perforce convert extension uses the p4 -G command line
option and marshal.load to obtain information about the history
of a Perforce depot.

The method marshal.load must be provided with a binary stream
(mode='rb') in order to function reliably.  Certain changelist
descriptions or other elements in a depot history could trigger
a premature EOFError, causing the conversion process to fail.

This may resolve the issue discussed in the following thread:
http://www.selenic.com/pipermail/mercurial/2009-July/026813.html

diff -r f3f400b13984 -r 4d65d096faa0 hgext/convert/p4.py
--- a/hgext/convert/p4.py	Wed Sep 23 00:23:50 2009 -0500
+++ b/hgext/convert/p4.py	Wed Sep 23 00:03:39 2009 -0700
@@ -53,7 +53,7 @@
     def _parse_view(self, path):
         "Read changes affecting the path"
         cmd = 'p4 -G changes -s submitted "%s"' % path
-        stdout = util.popen(cmd)
+        stdout = util.popen(cmd, mode='rb')
         for d in loaditer(stdout):
             c = d.get("change", None)
             if c:
@@ -72,7 +72,7 @@
                 views = {"//": ""}
         else:
             cmd = 'p4 -G client -o "%s"' % path
-            clientspec = marshal.load(util.popen(cmd))
+            clientspec = marshal.load(util.popen(cmd, mode='rb'))
 
             views = {}
             for client in clientspec:
@@ -105,7 +105,7 @@
         lastid = None
         for change in self.p4changes:
             cmd = "p4 -G describe %s" % change
-            stdout = util.popen(cmd)
+            stdout = util.popen(cmd, mode='rb')
             d = marshal.load(stdout)
 
             desc = self.recode(d["desc"])
@@ -147,7 +147,7 @@
 
     def getfile(self, name, rev):
         cmd = 'p4 -G print "%s#%s"' % (self.depotname[name], rev)
-        stdout = util.popen(cmd)
+        stdout = util.popen(cmd, mode='rb')
 
         mode = None
         contents = ""



      


More information about the Mercurial-devel mailing list