From patchwork Wed May 28 15:00:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [06, of, 10] vfs: add "notindexed" argument to invoke "ensuredir" with it in write mode From: Katsunori FUJIWARA X-Patchwork-Id: 4887 Message-Id: To: mercurial-devel@selenic.com Date: Thu, 29 May 2014 00:00:18 +0900 # HG changeset patch # User FUJIWARA Katsunori # Date 1401288802 -32400 # Wed May 28 23:53:22 2014 +0900 # Node ID e8bcf7420213eb28e5f1217fbed7fd1c69200fc5 # Parent ab38c2a1b9b3e8b80657dde6ed1f7897874d144c vfs: add "notindexed" argument to invoke "ensuredir" with it in write mode diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -144,9 +144,10 @@ class abstractvfs(object): raise return [] - def open(self, path, mode="r", text=False, atomictemp=False): + def open(self, path, mode="r", text=False, atomictemp=False, + notindexed=False): self.open = self.__call__ - return self.__call__(path, mode, text, atomictemp) + return self.__call__(path, mode, text, atomictemp, notindexed) def read(self, path): fp = self(path, 'rb') @@ -286,7 +287,8 @@ class vfs(abstractvfs): return os.chmod(name, self.createmode & 0666) - def __call__(self, path, mode="r", text=False, atomictemp=False): + def __call__(self, path, mode="r", text=False, atomictemp=False, + notindexed=False): if self._audit: r = util.checkosfilename(path) if r: @@ -304,7 +306,7 @@ class vfs(abstractvfs): # to a directory. Let the posixfile() call below raise IOError. if basename: if atomictemp: - util.ensuredirs(dirname, self.createmode) + util.ensuredirs(dirname, self.createmode, notindexed) return util.atomictempfile(f, mode, self.createmode) try: if 'w' in mode: @@ -322,7 +324,7 @@ class vfs(abstractvfs): if e.errno != errno.ENOENT: raise nlink = 0 - util.ensuredirs(dirname, self.createmode) + util.ensuredirs(dirname, self.createmode, notindexed) if nlink > 0: if self._trustnlink is None: self._trustnlink = nlink > 1 or util.checknlink(f) diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -910,15 +910,15 @@ def makedirs(name, mode=None, notindexed if mode is not None: os.chmod(name, mode) -def ensuredirs(name, mode=None): +def ensuredirs(name, mode=None, notindexed=False): """race-safe recursive directory creation""" if os.path.isdir(name): return parent = os.path.dirname(os.path.abspath(name)) if parent != name: - ensuredirs(parent, mode) - try: - os.mkdir(name) + ensuredirs(parent, mode, notindexed) + try: + makedir(name, notindexed) except OSError, err: if err.errno == errno.EEXIST and os.path.isdir(name): # someone else seems to have won a directory creation race