Patchwork [3,of,9] vfs: add "open()" for newly added code paths which open files via vfs

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Oct. 14, 2013, 4:16 p.m.
Message ID <2e396a54482df124d5d4.1381767363@juju>
Download mbox | patch
Permalink /patch/2760/
State Accepted
Commit 896a4568def7e8ac61660cf72ca92235fbcef4a6
Headers show

Comments

Katsunori FUJIWARA - Oct. 14, 2013, 4:16 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1381765864 -32400
#      Tue Oct 15 00:51:04 2013 +0900
# Node ID 2e396a54482df124d5d4cb58be2398a143edefe7
# Parent  661c03d3bd9642203a8543b534237fa474e5bc06
vfs: add "open()" for newly added code paths which open files via vfs

This patch replaces "open()" by own "__call__()" defined in derived
classes at the first invocation, for efficiency of succeeding
invocations.

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -217,6 +217,10 @@ 
                 raise
         return ""
 
+    def open(self, path, mode="r", text=False, atomictemp=False):
+        self.open = self.__call__
+        return self.__call__(path, mode, text, atomictemp)
+
     def read(self, path):
         fp = self(path, 'rb')
         try: