From 6fe6b1bd5137323248b696989c41ebb7b98514cc Mon Sep 17 00:00:00 2001 Message-Id: <6fe6b1bd5137323248b696989c41ebb7b98514cc.1746708761.git.mdw@distorted.org.uk> From: Mark Wooding Date: Thu, 22 Sep 2005 17:43:36 +0100 Subject: [PATCH] Fix importing from stdin Organization: Straylight/Edgeware From: Catalin Marinas 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 --- stgit/commands/imprt.py | 16 +++++++++++++--- stgit/git.py | 5 ++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py index 24c7429..9001639 100644 --- a/stgit/commands/imprt.py +++ b/stgit/commands/imprt.py @@ -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] diff --git a/stgit/git.py b/stgit/git.py index 293d421..7ab9aef 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -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(): -- [mdw]