convert: fix marshalling in P4 convert extension to use a binary stream
authorPeter Ingebretson <pingebre@yahoo.com>
Wed, 23 Sep 2009 15:36:51 +0200
changeset 9474 6ea653272c09
parent 9470 ba75830d17a9
child 9475 c295a82a020b
convert: 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
hgext/convert/p4.py
--- a/hgext/convert/p4.py	Sat Sep 19 13:52:54 2009 +0200
+++ b/hgext/convert/p4.py	Wed Sep 23 15:36:51 2009 +0200
@@ -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 = ""