Patchwork [hglib] client: connect to repo if necessary when using "with" statement

login
register
mail settings
Submitter Paul Tonelli
Date June 17, 2014, 1:17 p.m.
Message ID <5c1dd855444a8210f564.1403011023@crater1.logilab.fr>
Download mbox | patch
Permalink /patch/5012/
State Superseded
Headers show

Comments

Paul Tonelli - June 17, 2014, 1:17 p.m.
# HG changeset patch
# User Paul Tonelli <paul.tonelli@logilab.fr>
# Date 1402936146 -7200
#      Mon Jun 16 18:29:06 2014 +0200
# Node ID 5c1dd855444a8210f56431cd0eed4c1d6c2ddb1f
# Parent  861583ceca0bea2a4f692b1e247af7a21c176dcc
client: connect to repo if necessary when using "with" statement

While the '__exit__' closes the connection to the server, the __enter__ method
does not open it. Without this patch, a disconnected repo cannot be used with a
context managed unless you explicitely call the "open" method.
Matt Mackall - July 10, 2014, 10:17 p.m.
On Tue, 2014-06-17 at 15:17 +0200, Paul Tonelli wrote:
> # HG changeset patch
> # User Paul Tonelli <paul.tonelli@logilab.fr>
> # Date 1402936146 -7200
> #      Mon Jun 16 18:29:06 2014 +0200
> # Node ID 5c1dd855444a8210f56431cd0eed4c1d6c2ddb1f
> # Parent  861583ceca0bea2a4f692b1e247af7a21c176dcc
> client: connect to repo if necessary when using "with" statement

Ok, I've gone ahead and queued this, thanks. We'll deal with the test
suite problem later.
Paul Tonelli - Sept. 10, 2014, 2:09 p.m.
Thanks for correcting the tests, the 1.3 has all I need, would it be 
possible to push the new version to pypi ?

Le 11/07/2014 00:17, Matt Mackall a écrit :
> On Tue, 2014-06-17 at 15:17 +0200, Paul Tonelli wrote:
>> # HG changeset patch
>> # User Paul Tonelli <paul.tonelli@logilab.fr>
>> # Date 1402936146 -7200
>> #      Mon Jun 16 18:29:06 2014 +0200
>> # Node ID 5c1dd855444a8210f56431cd0eed4c1d6c2ddb1f
>> # Parent  861583ceca0bea2a4f692b1e247af7a21c176dcc
>> client: connect to repo if necessary when using "with" statement
> Ok, I've gone ahead and queued this, thanks. We'll deal with the test
> suite problem later.
>
Matt Mackall - Sept. 10, 2014, 8:25 p.m.
On Wed, 2014-09-10 at 16:09 +0200, Paul Tonelli wrote:
> Thanks for correcting the tests, the 1.3 has all I need, would it be 
> possible to push the new version to pypi ?

Idan, can you update this? I've also got a pypi account now, so you can
hand it off to me if you want.
Idan Kamara - Sept. 11, 2014, 1:50 a.m.
On Wed, Sep 10, 2014 at 1:25 PM, Matt Mackall <mpm@selenic.com> wrote:
>
> On Wed, 2014-09-10 at 16:09 +0200, Paul Tonelli wrote:
> > Thanks for correcting the tests, the 1.3 has all I need, would it be
> > possible to push the new version to pypi ?
>
> Idan, can you update this? I've also got a pypi account now, so you can
> hand it off to me if you want.

I uploaded 1.3. I can add you, what's your username (mpm doesn't work)?
Matt Mackall - Sept. 11, 2014, 3:54 p.m.
On Wed, 2014-09-10 at 18:50 -0700, Idan Kamara wrote:
> On Wed, Sep 10, 2014 at 1:25 PM, Matt Mackall <mpm@selenic.com> wrote:
> >
> > On Wed, 2014-09-10 at 16:09 +0200, Paul Tonelli wrote:
> > > Thanks for correcting the tests, the 1.3 has all I need, would it be
> > > possible to push the new version to pypi ?
> >
> > Idan, can you update this? I've also got a pypi account now, so you can
> > hand it off to me if you want.
> 
> I uploaded 1.3. I can add you, what's your username (mpm doesn't work)?

mpmselenic
Idan Kamara - Sept. 11, 2014, 4:54 p.m.
On Thu, Sep 11, 2014 at 8:54 AM, Matt Mackall <mpm@selenic.com> wrote:
> On Wed, 2014-09-10 at 18:50 -0700, Idan Kamara wrote:
>> On Wed, Sep 10, 2014 at 1:25 PM, Matt Mackall <mpm@selenic.com> wrote:
>> >
>> > On Wed, 2014-09-10 at 16:09 +0200, Paul Tonelli wrote:
>> > > Thanks for correcting the tests, the 1.3 has all I need, would it be
>> > > possible to push the new version to pypi ?
>> >
>> > Idan, can you update this? I've also got a pypi account now, so you can
>> > hand it off to me if you want.
>>
>> I uploaded 1.3. I can add you, what's your username (mpm doesn't work)?
>
> mpmselenic

added

Patch

diff -r 861583ceca0b -r 5c1dd855444a hglib/client.py
--- a/hglib/client.py	Wed May 21 15:19:19 2014 +0200
+++ b/hglib/client.py	Mon Jun 16 18:29:06 2014 +0200
@@ -61,6 +61,8 @@ 
             self.open()
 
     def __enter__(self):
+        if self.server is None:
+            self.open()
         return self
 
     def __exit__(self, exc_type, exc_val, exc_tb):