# HG changeset patch # User Peter Ingebretson # Date 2009-09-23 13:36:51 # Node ID 6ea653272c095bb39c2fda62d1f21c505d8daabe # Parent ba75830d17a9e685251563dff123b350413d6347 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 diff --git a/hgext/convert/p4.py b/hgext/convert/p4.py --- a/hgext/convert/p4.py +++ b/hgext/convert/p4.py @@ -53,7 +53,7 @@ class p4_source(converter_source): 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 @@ class p4_source(converter_source): 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 @@ class p4_source(converter_source): 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 @@ class p4_source(converter_source): 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 = ""