repoapi.py
changeset 9111 9c867d852067
parent 9105 55738c9dc26f
child 9116 57387c6482e5
--- a/repoapi.py	Wed Jun 26 14:46:24 2013 +0200
+++ b/repoapi.py	Wed Jun 26 15:11:22 2013 +0200
@@ -149,7 +149,6 @@
         self._session = session # XXX there is no real reason to keep the
                                 # session around function still using it should
                                 # be rewritten and migrated.
-        self._cnxid = None
         self._cnx = None
         self._open = None
         self._web_request = False
@@ -160,15 +159,14 @@
     def __enter__(self):
         assert self._open is None
         self._open = True
-        self._cnxid = '%s-%s' % (self._session.id, uuid4().hex)
-        self._cnx = self._session.get_cnx(self._cnxid)
+        self._cnx = self._session.new_cnx()
+        self._cnx.__enter__()
         self._cnx.ctx_count += 1
 
     def __exit__(self, exc_type, exc_val, exc_tb):
         self._open = False
-        self._cnxid = None
         self._cnx.ctx_count -= 1
-        self._session.close_cnx(self._cnx)
+        self._cnx.__exit__(exc_type, exc_val, exc_tb)
         self._cnx = None
         if self._autoclose_session:
             # we have to call repo.close to unsure the repo properly forget the