Em Thu, 24 Dec 2015 13:57:08 +0000
"Finucane, Stephen" <[email protected]> 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 <[email protected]>
> > ---
> >  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
> [email protected]
> https://lists.ozlabs.org/listinfo/patchwork
_______________________________________________
Patchwork mailing list
[email protected]
https://lists.ozlabs.org/listinfo/patchwork

Reply via email to