Patchwork [1,of,4] scmutil: support background closing for write()

login
register
mail settings
Submitter Gregory Szorc
Date Feb. 20, 2016, 11:55 p.m.
Message ID <5f5a32bf365ee87f37c2.1456012557@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/13275/
State Accepted
Headers show

Comments

Gregory Szorc - Feb. 20, 2016, 11:55 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1456010652 28800
#      Sat Feb 20 15:24:12 2016 -0800
# Node ID 5f5a32bf365ee87f37c201df2a667a7332779653
# Parent  8449ef66f732a71008dc887ffd6efbfb6dc64ee0
scmutil: support background closing for write()

Upcoming patches will add background file closer support to
working copy update. This patch adds some plumbing to prepare
for that.

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -271,18 +271,18 @@  class abstractvfs(object):
     def read(self, path):
         with self(path, 'rb') as fp:
             return fp.read()
 
     def readlines(self, path, mode='rb'):
         with self(path, mode=mode) as fp:
             return fp.readlines()
 
-    def write(self, path, data):
-        with self(path, 'wb') as fp:
+    def write(self, path, data, backgroundclose=False):
+        with self(path, 'wb', backgroundclose=backgroundclose) as fp:
             return fp.write(data)
 
     def writelines(self, path, data, mode='wb', notindexed=False):
         with self(path, mode=mode, notindexed=notindexed) as fp:
             return fp.writelines(data)
 
     def append(self, path, data):
         with self(path, 'ab') as fp: