make the journal/undo files from transactions inherit the mode from .hg/store
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Sat, 09 Feb 2008 18:38:54 -0200
changeset 6065 53ed9b40cfc4
parent 6064 c608f67a87c0
child 6066 f3a8b5360100
make the journal/undo files from transactions inherit the mode from .hg/store
mercurial/localrepo.py
mercurial/transaction.py
tests/test-inherit-mode
tests/test-inherit-mode.out
--- a/mercurial/localrepo.py	Sat Feb 09 18:38:54 2008 -0200
+++ b/mercurial/localrepo.py	Sat Feb 09 18:38:54 2008 -0200
@@ -78,6 +78,7 @@
         except OSError:
             mode = None
 
+        self._createmode = mode
         self.opener.createmode = mode
         sopener = util.opener(self.spath)
         sopener.createmode = mode
@@ -563,8 +564,9 @@
                    (self.join("journal.dirstate"), self.join("undo.dirstate")),
                    (self.join("journal.branch"), self.join("undo.branch"))]
         tr = transaction.transaction(self.ui.warn, self.sopener,
-                                       self.sjoin("journal"),
-                                       aftertrans(renames))
+                                     self.sjoin("journal"),
+                                     aftertrans(renames),
+                                     self._createmode)
         self._transref = weakref.ref(tr)
         return tr
 
--- a/mercurial/transaction.py	Sat Feb 09 18:38:54 2008 -0200
+++ b/mercurial/transaction.py	Sat Feb 09 18:38:54 2008 -0200
@@ -15,7 +15,7 @@
 import os
 
 class transaction(object):
-    def __init__(self, report, opener, journal, after=None):
+    def __init__(self, report, opener, journal, after=None, createmode=None):
         self.journal = None
 
         self.count = 1
@@ -27,6 +27,8 @@
         self.journal = journal
 
         self.file = open(self.journal, "w")
+        if createmode is not None:
+            os.chmod(self.journal, createmode & 0666)
 
     def __del__(self):
         if self.journal:
--- a/tests/test-inherit-mode	Sat Feb 09 18:38:54 2008 -0200
+++ b/tests/test-inherit-mode	Sat Feb 09 18:38:54 2008 -0200
@@ -48,7 +48,7 @@
 echo '% after commit'
 echo '% working dir files can only be written by the owner'
 echo '% files created in .hg can be written by the group'
-echo '% (in particular, store/**, dirstate, branch.cache)'
+echo '% (in particular, store/**, dirstate, branch.cache, undo files)'
 echo '% new directories are setgid'
 python ../printmodes.py .
 
--- a/tests/test-inherit-mode.out	Sat Feb 09 18:38:54 2008 -0200
+++ b/tests/test-inherit-mode.out	Sat Feb 09 18:38:54 2008 -0200
@@ -9,7 +9,7 @@
 % after commit
 % working dir files can only be written by the owner
 % files created in .hg can be written by the group
-% (in particular, store/**, dirstate, branch.cache)
+% (in particular, store/**, dirstate, branch.cache, undo files)
 % new directories are setgid
 00700 ./.hg/
 00600 ./.hg/00changelog.i
@@ -22,7 +22,7 @@
 02770 ./.hg/store/data/dir/
 00660 ./.hg/store/data/dir/bar.i
 00660 ./.hg/store/data/foo.i
-00600 ./.hg/store/undo
+00660 ./.hg/store/undo
 00660 ./.hg/undo.branch
 00660 ./.hg/undo.dirstate
 00700 ./dir/
@@ -49,6 +49,6 @@
 00770 ../push/.hg/store/data/dir/
 00660 ../push/.hg/store/data/dir/bar.i
 00660 ../push/.hg/store/data/foo.i
-00600 ../push/.hg/store/undo
+00660 ../push/.hg/store/undo
 00660 ../push/.hg/undo.branch
 00660 ../push/.hg/undo.dirstate