changeset 10800:49c109d037dd stable

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.
author Mads Kiilerich <mads@kiilerich.com>
date Tue, 30 Mar 2010 02:42:21 +0200
parents e46c19c586fa
children fcfe2e50faab
files hgext/convert/cvs.py
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/cvs.py	Thu Apr 01 00:02:12 2010 +0200
+++ b/hgext/convert/cvs.py	Tue Mar 30 02:42:21 2010 +0200
@@ -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:])