# HG changeset patch # User FUJIWARA Katsunori # Date 2014-11-19 09:35:14 # Node ID 46265d0f0c7ba1c492985a42ef60313193d1eb17 # Parent 22e00674d17e8344abf27a0619dae371bebd9f83 vfs: add "notindexed" argument to invoke "ensuredir" with it in write mode This patch uses "False" as default value of "notindexed" argument, even though "vfs.makedir()" uses "True" for it, because "os.mkdir()" doesn't set "_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED" attribute to newly created directories. diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -197,9 +197,16 @@ 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): + '''Open ``path`` file, which is relative to vfs root. + + Newly created directories are marked as "not to be indexed by + the content indexing service", if ``notindexed`` is specified + for "write" mode access. + ''' 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') @@ -345,7 +352,14 @@ 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): + '''Open ``path`` file, which is relative to vfs root. + + Newly created directories are marked as "not to be indexed by + the content indexing service", if ``notindexed`` is specified + for "write" mode access. + ''' if self._audit: r = util.checkosfilename(path) if r: @@ -363,7 +377,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: @@ -381,7 +395,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 @@ -1088,15 +1088,20 @@ def makedirs(name, mode=None, notindexed if mode is not None: os.chmod(name, mode) -def ensuredirs(name, mode=None): - """race-safe recursive directory creation""" +def ensuredirs(name, mode=None, notindexed=False): + """race-safe recursive directory creation + + Newly created directories are marked as "not to be indexed by + the content indexing service", if ``notindexed`` is specified + for "write" mode access. + """ if os.path.isdir(name): return parent = os.path.dirname(os.path.abspath(name)) if parent != name: - ensuredirs(parent, mode) + ensuredirs(parent, mode, notindexed) try: - os.mkdir(name) + 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