X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=apps%2Fpatchwork%2Fbin%2Fparsemail.py;h=7f6727fc79c9d7e7efaf36f303e8f3c2ee188a4d;hb=74425beba0dc641509c5268571ea5328ac8185ec;hp=772728e41e82ffbba9e2d42a54ca17004652e3bf;hpb=4da08a17e860b6831f9446af46b2f562efeeb461;p=patchwork diff --git a/apps/patchwork/bin/parsemail.py b/apps/patchwork/bin/parsemail.py index 772728e..7f6727f 100755 --- a/apps/patchwork/bin/parsemail.py +++ b/apps/patchwork/bin/parsemail.py @@ -173,7 +173,7 @@ def find_content(project, mail): if patch: cpatch = patch else: - cpatch = find_patch_for_comment(mail) + cpatch = find_patch_for_comment(project, mail) if not cpatch: return (None, None) comment = Comment(patch = cpatch, date = mail_date(mail), @@ -182,7 +182,7 @@ def find_content(project, mail): return (patch, comment) -def find_patch_for_comment(mail): +def find_patch_for_comment(project, mail): # construct a list of possible reply message ids refs = [] if 'In-Reply-To' in mail: @@ -200,14 +200,14 @@ def find_patch_for_comment(mail): # first, check for a direct reply try: - patch = Patch.objects.get(msgid = ref) + patch = Patch.objects.get(project = project, msgid = ref) return patch except Patch.DoesNotExist: pass # see if we have comments that refer to a patch try: - comment = Comment.objects.get(msgid = ref) + comment = Comment.objects.get(patch__project = project, msgid = ref) return comment.patch except Comment.DoesNotExist: pass @@ -319,8 +319,7 @@ def clean_content(str): str = sig_re.sub('', str) return str.strip() -def main(args): - mail = message_from_file(sys.stdin) +def parse_mail(mail): # some basic sanity checks if 'From' not in mail: @@ -376,5 +375,9 @@ def main(args): return 0 +def main(args): + mail = message_from_file(sys.stdin) + return parse_mail(mail) + if __name__ == '__main__': sys.exit(main(sys.argv))