set NOT_CONTENT_INDEXED on .hg dir (issue2694)
authorAdrian Buehlmann <adrian@cadifra.com>
Mon, 28 Mar 2011 15:54:22 +0200
changeset 13795 43b5fe18ea6c
parent 13793 ba58c5a61503
child 13796 6337149fc07c
set NOT_CONTENT_INDEXED on .hg dir (issue2694) when running on Windows
mercurial/hg.py
mercurial/localrepo.py
mercurial/util.py
mercurial/win32.py
--- a/mercurial/hg.py	Tue Mar 29 16:25:48 2011 +0200
+++ b/mercurial/hg.py	Mon Mar 28 15:54:22 2011 +0200
@@ -143,7 +143,7 @@
 
     if not os.path.isdir(root):
         os.mkdir(root)
-    os.mkdir(roothg)
+    util.makedir(roothg, notindexed=True)
 
     requirements = ''
     try:
@@ -281,7 +281,7 @@
                 dir_cleanup.dir_ = hgdir
             try:
                 dest_path = hgdir
-                os.mkdir(dest_path)
+                util.makedir(dest_path, notindexed=True)
             except OSError, inst:
                 if inst.errno == errno.EEXIST:
                     dir_cleanup.close()
--- a/mercurial/localrepo.py	Tue Mar 29 16:25:48 2011 +0200
+++ b/mercurial/localrepo.py	Mon Mar 28 15:54:22 2011 +0200
@@ -47,7 +47,7 @@
             if create:
                 if not os.path.exists(path):
                     util.makedirs(path)
-                os.mkdir(self.path)
+                util.makedir(self.path, notindexed=True)
                 requirements = ["revlogv1"]
                 if self.ui.configbool('format', 'usestore', True):
                     os.mkdir(os.path.join(self.path, "store"))
--- a/mercurial/util.py	Tue Mar 29 16:25:48 2011 +0200
+++ b/mercurial/util.py	Mon Mar 28 15:54:22 2011 +0200
@@ -438,6 +438,9 @@
 
     return check
 
+def makedir(path, notindexed):
+    os.mkdir(path)
+
 def unlinkpath(f):
     """unlink and remove the directory if it is empty"""
     os.unlink(f)
--- a/mercurial/win32.py	Tue Mar 29 16:25:48 2011 +0200
+++ b/mercurial/win32.py	Mon Mar 28 15:54:22 2011 +0200
@@ -58,6 +58,7 @@
 
 # SetFileAttributes
 _FILE_ATTRIBUTE_NORMAL = 0x80
+_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x2000
 
 # Process Security and Access Rights
 _PROCESS_QUERY_INFORMATION = 0x0400
@@ -365,3 +366,8 @@
             # Leaking a tempfile is the lesser evil than aborting here and
             # leaving some potentially serious inconsistencies.
             pass
+
+def makedir(path, notindexed):
+    os.mkdir(path)
+    if notindexed:
+        _kernel32.SetFileAttributesA(path, _FILE_ATTRIBUTE_NOT_CONTENT_INDEXED)