[PATCH 07/10] Report if a patch is delagated and to whom
Mauro Carvalho Chehab
mchehab at osg.samsung.com
Fri Dec 25 07:31:18 AEDT 2015
Em Thu, 24 Dec 2015 13:57:08 +0000
"Finucane, Stephen" <stephen.finucane at intel.com> escreveu:
> On 28 Nov 10:14, Mauro Carvalho Chehab wrote:
> > When a patch is delegated, it can be important to report it via
> > pwclient, as handing delegated patches may be different. So, add
> > an optional field at the email's body if this is happening.
> >
> > Signed-off-by: Mauro Carvalho Chehab <mchehab at osg.samsung.com>
> > ---
> > patchwork/models.py | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 54 insertions(+)
> >
> > diff --git a/patchwork/models.py b/patchwork/models.py
> > index e552217a3cbc..024ff4d8d5e1 100644
> > --- a/patchwork/models.py
> > +++ b/patchwork/models.py
> > @@ -323,6 +323,60 @@ class Patch(models.Model):
> > str = fname_re.sub('-', self.name)
> > return str.strip('-') + '.patch'
> >
> > + def mbox(self):
> > + postscript_re = re.compile('\n-{2,3} ?\n')
> > +
> > + comment = None
> > + try:
> > + comment = Comment.objects.get(patch = self, msgid = self.msgid)
> > + except Exception:
> > + pass
> > +
> > + body = ''
> > + if comment:
> > + body = comment.content.strip() + "\n"
> > +
> > + parts = postscript_re.split(body, 1)
> > + if len(parts) == 2:
> > + (body, postscript) = parts
> > + body = body.strip() + "\n"
> > + postscript = postscript.strip() + "\n"
> > + else:
> > + postscript = ''
> > +
> > + for comment in Comment.objects.filter(patch = self) \
> > + .exclude(msgid = self.msgid):
> > + body += comment.patch_responses()
> > +
> > + if body:
> > + body += '\n'
> > +
> > + if postscript:
> > + body += '---\n' + postscript.strip() + '\n'
> > +
> > + if self.content:
> > + body += '\n' + self.content
> > +
> > + mail = PatchMbox(body)
> > + mail['Subject'] = self.name
> > + mail['Date'] = email.utils.formatdate(
> > + time.mktime(self.date.utctimetuple()))
> > + mail['From'] = unicode(self.submitter)
> > + mail['X-Patchwork-Id'] = str(self.id)
> > + if self.delegate:
> > + mail['X-Patchwork-Delegate'] = str(self.delegate.email)
>
> [snip]
>
> You seem to be missing a couple of dependencies here: it fails to run
> because of missing imports and the code looks like a minor modification
> of functionality found in 'patchwork/views/__init__.py'.
Hmm.. it runs fine at patchwork, but perhaps due to some other
locale changes I did there, for patchwork to find the dependencies.
> Is there any
> reason we can't just include the above 'X-Patchwork-Delegate' lines in
> the 'patch_to_mbox' function found in the aforementioned file?
I remember I tried to add it on some other place (don't remember where
anymore, as it was done several years ago). It didn't work when the
patch were obtained via XMLRPC.
I need to receive this tag via pwclient, as my local scripts use it
to remove patches delegated to other developers from my own work
queue.
Anyway, feel free to either modify this patch or do to something else
that would provide the same functionality. I'm not a Pyhton expert.
So, I'm probably not taking the best approach ;)
>
> Stephen
> _______________________________________________
> Patchwork mailing list
> Patchwork at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork
More information about the Patchwork
mailing list