Patchwork [3,of,4] bundlerepo: keep track of the original bundle object

login
register
mail settings
Submitter Eric Sumner
Date Feb. 6, 2015, 7:47 p.m.
Message ID <85768b6246cbeada0e13.1423252053@waste.org>
Download mbox | patch
Permalink /patch/7718/
State Accepted
Commit 145b823f5ce7230ab054a61c2ec2caf64fcf5321
Headers show

Comments

Eric Sumner - Feb. 6, 2015, 7:47 p.m.
# HG changeset patch
# User Eric Sumner <ericsumner@fb.com>
# Date 1423181006 28800
#      Thu Feb 05 16:03:26 2015 -0800
# Node ID 85768b6246cbeada0e13e8fa69ceff23a6c00286
# Parent  53207724988e8c5948fd0ed1835f55763180beaa
bundlerepo: keep track of the original bundle object

Bundlerepo should always close() the object that it receives from
exchange.readbundle().  When bundle2 support is added in a later diff,
self.bundle will be overwritten to be the changegroup part instead of the
entire bundle unpacker.

Patch

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -216,7 +216,7 @@ 
 
         self.tempfile = None
         f = util.posixfile(bundlename, "rb")
-        self.bundle = exchange.readbundle(ui, f, bundlename)
+        self.bundlefile = self.bundle = exchange.readbundle(ui, f, bundlename)
         if self.bundle.compressed():
             fdtemp, temp = self.vfs.mkstemp(prefix="hg-bundle-",
                                             suffix=".hg10un")
@@ -234,7 +234,9 @@ 
                 fptemp.close()
 
             f = self.vfs.open(self.tempfile, mode="rb")
-            self.bundle = exchange.readbundle(ui, f, bundlename, self.vfs)
+            self.bundlefile = self.bundle = exchange.readbundle(ui, f,
+                                                                bundlename,
+                                                                self.vfs)
 
         # dict with the mapping 'filename' -> position in the bundle
         self.bundlefilespos = {}
@@ -300,7 +302,7 @@ 
 
     def close(self):
         """Close assigned bundle file immediately."""
-        self.bundle.close()
+        self.bundlefile.close()
         if self.tempfile is not None:
             self.vfs.unlink(self.tempfile)
         if self._tempparent: