[PATCH stable] convert.cvs: Initialize state variable and abort on cvs error
Mads Kiilerich
mads at kiilerich.com
Mon Mar 29 19:43:07 CDT 2010
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1269909741 -7200
# Branch stable
# Node ID 2837acc6e4fe44ca9584737e1a51e2fcd5b2c27e
# Parent 4cee900210bcaa2b0cdc2c2fca999274e2ee7e49
convert.cvs: Initialize state variable and abort on cvs error
Fix as proposed by Frank Kingswood.
Avoids
UnboundLocalError: local variable 'mode' referenced before assignment
when cvs fails.
This alsa partially fixes issue1592.
diff --git a/hgext/convert/cvs.py b/hgext/convert/cvs.py
--- a/hgext/convert/cvs.py
+++ b/hgext/convert/cvs.py
@@ -227,6 +227,7 @@
self.writep.flush()
data = ""
+ mode = None
while 1:
line = self.readp.readline()
if line.startswith("Created ") or line.startswith("Updated "):
@@ -244,6 +245,8 @@
data = chunkedread(self.readp, count)
else:
if line == "ok\n":
+ if mode is None:
+ raise util.Abort(_('malformed response from CVS'))
return (data, "x" in mode and "x" or "")
elif line.startswith("E "):
self.ui.warn(_("cvs server: %s\n") % line[2:])
More information about the Mercurial-devel
mailing list