Fix importing from stdin
authorCatalin Marinas <catalin.marinas@gmail.com>
Thu, 22 Sep 2005 16:43:36 +0000 (17:43 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Thu, 22 Sep 2005 18:36:54 +0000 (19:36 +0100)
The current stdin patch importing expects two EOFs since the 'for' loop
doesn't start before one EOF is received. As suggested, this patch changes
the 'for' loop with a 'while True' loop.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/commands/imprt.py
stgit/git.py

index 24c7429..9001639 100644 (file)
@@ -87,7 +87,10 @@ def __parse_mail(filename = None):
     descr = authname = authemail = authdate = None
 
     # parse the headers
-    for line in f:
+    while True:
+        line = f.readline()
+        if not line:
+            break
         line = line.strip()
         if re.match('from:\s+', line, re.I):
             auth = re.findall('^.*?:\s+(.*)$', line)[0]
@@ -109,7 +112,10 @@ def __parse_mail(filename = None):
         raise CmdException, 'Subject: line not found'
 
     # the rest of the patch description
-    for line in f:
+    while True:
+        line = f.readline()
+        if not line:
+            break
         if re.match('---\s*$', line) or re.match('diff -', line) or \
                 re.match('^Index: ', line):
             break
@@ -134,7 +140,11 @@ def __parse_patch(filename = None):
     authname = authemail = authdate = None
 
     descr = ''
-    for line in f:
+    while True:
+        line = f.readline()
+        if not line:
+            break
+
         # the first 'Signed-of-by:' is the author
         if not authname and re.match('signed-off-by:\s+', line, re.I):
             auth = re.findall('^.*?:\s+(.*)$', line)[0]
index 293d421..7ab9aef 100644 (file)
@@ -113,7 +113,10 @@ def get_conflicts():
 
 def _input(cmd, file_desc):
     p = popen2.Popen3(cmd)
-    for line in file_desc:
+    while True:
+        line = file_desc.readline()
+        if not line:
+            break
         p.tochild.write(line)
     p.tochild.close()
     if p.wait():