Commit 8b8847ec authored by Aurelien Campeas's avatar Aurelien Campeas
Browse files

ccplugin: use cnx as a context manager

parent 50a81bdcd68a
......@@ -76,19 +76,16 @@ class MBOXImportCommand(Command):
def run(self, args):
"""run the command with its specific arguments"""
cnx = self.connect(args.pop(0))
importer = self.create_importer(cnx)
try:
self.import_mbox_files(importer, args)
except:
# without a correct connection handling we exhaust repository's
# connections pool.
# the repository should be more resilient against bad clients !
cnx.rollback()
cnx.close()
raise
if not self.autocommit:
with self.connect(args.pop(0)) as cnx:
importer = self.create_importer(cnx)
try:
self.import_mbox_files(importer, args)
except:
# without a correct connection handling we exhaust repository's
# connections pool.
# the repository should be more resilient against bad clients !
cnx.rollback()
raise
cnx.commit()
cnx.close()
CWCTL.register(MBOXImportCommand)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment