summaryrefslogtreecommitdiffstats
path: root/apps/patchwork/bin/parsemail.py
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2008-10-29 11:21:05 +1100
committerJeremy Kerr <jk@ozlabs.org>2008-10-29 11:21:05 +1100
commit74425beba0dc641509c5268571ea5328ac8185ec (patch)
treef9033b51d3b5608f398b5ce358ba202edefb10ad /apps/patchwork/bin/parsemail.py
parent4da08a17e860b6831f9446af46b2f562efeeb461 (diff)
downloadpatchwork-74425beba0dc641509c5268571ea5328ac8185ec.tar.bz2
patchwork-74425beba0dc641509c5268571ea5328ac8185ec.tar.xz
[models] Make patches unique on (msgid, project), not just (msgid)
On patchwork.ozlabs.org, we may see multiple patches for different projects, but with the same message-id. We want these patches to show up on both projects, so we need to change the current UNIQUE contstraint on msgid. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'apps/patchwork/bin/parsemail.py')
-rwxr-xr-xapps/patchwork/bin/parsemail.py15
1 files changed, 9 insertions, 6 deletions
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))