Patchwork [hglib,b] ignore close() on non-open clients (issue5751)

login
register
mail settings
Submitter Gábor Stefanik
Date Feb. 12, 2018, 1:55 p.m.
Message ID <fe38aeeb1586464769ca.1518443757@GSTEFANIK.NavnGo.local>
Download mbox | patch
Permalink /patch/27660/
State New
Headers show

Comments

Gábor Stefanik - Feb. 12, 2018, 1:55 p.m.
# HG changeset patch
# User Gábor Stefanik <gabor.stefanik@nng.com>
# Date 1518443649 -3600
#      Mon Feb 12 14:54:09 2018 +0100
# Node ID fe38aeeb1586464769caa6e9bb819078028fc858
# Parent  1085c904d8c04d51c6897027fe9c7bae0964b64b
[b] ignore close() on non-open clients (issue5751)

Closing a client twice currently triggers a rather confusing exception.
Instead, follow the convention set by Python's file objects, and ignore close()
commands on non-open clients.

________________________________
 This message, including its attachments, is confidential and the property of NNG Llc. For more information please read NNG's email policy here:
https://www.nng.com/email-policy/
By responding to this email you accept the email policy.
Yuya Nishihara - Feb. 12, 2018, 2:50 p.m.
On Mon, 12 Feb 2018 14:55:57 +0100, Gábor Stefanik wrote:
> # HG changeset patch
> # User Gábor Stefanik <gabor.stefanik@nng.com>
> # Date 1518443649 -3600
> #      Mon Feb 12 14:54:09 2018 +0100
> # Node ID fe38aeeb1586464769caa6e9bb819078028fc858
> # Parent  1085c904d8c04d51c6897027fe9c7bae0964b64b
> [b] ignore close() on non-open clients (issue5751)
  ^^^
  what's [b]?

Thanks, this looks good, except the patch is malformed because of a corporate
mail server?

> diff -r 1085c904d8c0 -r fe38aeeb1586 hglib/client.py
> --- a/hglib/client.py   Thu Feb 01 15:10:02 2018 -0500
> +++ b/hglib/client.py   Mon Feb 12 14:54:09 2018 +0100
> @@ -294,6 +294,8 @@
>          return self._close()[0]
> 
>      def _close(self):
> +        if not self.server:
> +            return 0, ''

I slight prefer moving this to close() so _close() stays as a low-level
helper, but that doesn't matter in practice.

>          _sout, serr = self.server.communicate()
>          ret = self.server.returncode
>          self.server = None
Gábor Stefanik - Feb. 12, 2018, 5:09 p.m.
> -----Original Message-----

> From: Yuya Nishihara [mailto:youjah@gmail.com] On Behalf Of Yuya

> Nishihara

> Sent: Monday, February 12, 2018 3:50 PM

> To: Gábor STEFANIK <Gabor.STEFANIK@nng.com>

> Cc: mercurial-devel@mercurial-scm.org

> Subject: Re: [PATCH hglib] [b] ignore close() on non-open clients (issue5751)

>

> On Mon, 12 Feb 2018 14:55:57 +0100, Gábor Stefanik wrote:

> > # HG changeset patch

> > # User Gábor Stefanik <gabor.stefanik@nng.com> # Date 1518443649 -3600

> > #      Mon Feb 12 14:54:09 2018 +0100

> > # Node ID fe38aeeb1586464769caa6e9bb819078028fc858

> > # Parent  1085c904d8c04d51c6897027fe9c7bae0964b64b

> > [b] ignore close() on non-open clients (issue5751)

>   ^^^

>   what's [b]?


Ouch... our internal notation for a bugfix commit.

>

> Thanks, this looks good, except the patch is malformed because of a

> corporate mail server?

>

> > diff -r 1085c904d8c0 -r fe38aeeb1586 hglib/client.py

> > --- a/hglib/client.py   Thu Feb 01 15:10:02 2018 -0500

> > +++ b/hglib/client.py   Mon Feb 12 14:54:09 2018 +0100

> > @@ -294,6 +294,8 @@

> >          return self._close()[0]

> >

> >      def _close(self):

> > +        if not self.server:

> > +            return 0, ''

>

> I slight prefer moving this to close() so _close() stays as a low-level helper,

> but that doesn't matter in practice.

>

> >          _sout, serr = self.server.communicate()

> >          ret = self.server.returncode

> >          self.server = None

________________________________
 This message, including its attachments, is confidential and the property of NNG Llc. For more information please read NNG's email policy here:
https://www.nng.com/email-policy/
By responding to this email you accept the email policy.

Patch

diff -r 1085c904d8c0 -r fe38aeeb1586 hglib/client.py

--- a/hglib/client.py   Thu Feb 01 15:10:02 2018 -0500

+++ b/hglib/client.py   Mon Feb 12 14:54:09 2018 +0100

@@ -294,6 +294,8 @@ 

         return self._close()[0]

     def _close(self):
+        if not self.server:

+            return 0, ''

         _sout, serr = self.server.communicate()
         ret = self.server.returncode
         self.server = None