Patchwork [7,of,9] bundlerepo: treat temporarily extracted bundle file via vfs

login
register
mail settings
Submitter Katsunori FUJIWARA
Date March 8, 2014, 4:07 p.m.
Message ID <29bb3f593d2ed2f8eadd.1394294832@juju>
Download mbox | patch
Permalink /patch/3897/
State Accepted
Commit 4fdd1172d37e505de657ebd5e5a9f2db9f2fa990
Headers show

Comments

Katsunori FUJIWARA - March 8, 2014, 4:07 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1394294608 -32400
#      Sun Mar 09 01:03:28 2014 +0900
# Node ID 29bb3f593d2ed2f8eadd724db31d26509f5a99db
# Parent  478805e9633b292ce1734dded800b9c4f42cd96f
bundlerepo: treat temporarily extracted bundle file via vfs

Patch

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -204,8 +204,8 @@ 
         f = util.posixfile(bundlename, "rb")
         self.bundle = changegroup.readbundle(f, bundlename)
         if self.bundle.compressed():
-            fdtemp, temp = tempfile.mkstemp(prefix="hg-bundle-",
-                                            suffix=".hg10un", dir=self.path)
+            fdtemp, temp = self.vfs.mkstemp(prefix="hg-bundle-",
+                                            suffix=".hg10un")
             self.tempfile = temp
             fptemp = os.fdopen(fdtemp, 'wb')
 
@@ -219,8 +219,8 @@ 
             finally:
                 fptemp.close()
 
-            f = util.posixfile(self.tempfile, "rb")
-            self.bundle = changegroup.readbundle(f, bundlename)
+            f = self.vfs.open(self.tempfile, mode="rb")
+            self.bundle = changegroup.readbundle(f, bundlename, self.vfs)
 
         # dict with the mapping 'filename' -> position in the bundle
         self.bundlefilespos = {}
@@ -280,7 +280,7 @@ 
         """Close assigned bundle file immediately."""
         self.bundle.close()
         if self.tempfile is not None:
-            os.unlink(self.tempfile)
+            self.vfs.unlink(self.tempfile)
         if self._tempparent:
             shutil.rmtree(self._tempparent, True)