Mercurial > hg
comparison tests/test-inherit-mode @ 6064:c608f67a87c0
add test-inherit-mode
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Sat, 09 Feb 2008 18:38:54 -0200 |
parents | |
children | 53ed9b40cfc4 |
comparison
equal
deleted
inserted
replaced
6063:b74a0c4bfb30 | 6064:c608f67a87c0 |
---|---|
1 #!/bin/sh | |
2 | |
3 # test that new files created in .hg inherit the permissions from .hg/store | |
4 | |
5 "$TESTDIR/hghave" unix-permissions || exit 80 | |
6 | |
7 mkdir dir | |
8 # just in case somebody has a strange $TMPDIR | |
9 chmod g-s dir | |
10 cd dir | |
11 | |
12 cat >printmodes.py <<EOF | |
13 import os, sys | |
14 | |
15 allnames = [] | |
16 isdir = {} | |
17 for root, dirs, files in os.walk(sys.argv[1]): | |
18 for d in dirs: | |
19 name = os.path.join(root, d) | |
20 isdir[name] = 1 | |
21 allnames.append(name) | |
22 for f in files: | |
23 name = os.path.join(root, f) | |
24 allnames.append(name) | |
25 allnames.sort() | |
26 for name in allnames: | |
27 suffix = name in isdir and '/' or '' | |
28 print '%05o %s%s' % (os.lstat(name).st_mode & 07777, name, suffix) | |
29 EOF | |
30 | |
31 umask 077 | |
32 | |
33 hg init repo | |
34 cd repo | |
35 | |
36 chmod 02770 .hg/store | |
37 | |
38 echo '% before commit' | |
39 echo '% store can be written by the group, other files cannot' | |
40 echo '% store is setgid' | |
41 python ../printmodes.py . | |
42 | |
43 mkdir dir | |
44 touch foo dir/bar | |
45 hg ci -qAm 'add files' | |
46 | |
47 echo | |
48 echo '% after commit' | |
49 echo '% working dir files can only be written by the owner' | |
50 echo '% files created in .hg can be written by the group' | |
51 echo '% (in particular, store/**, dirstate, branch.cache)' | |
52 echo '% new directories are setgid' | |
53 python ../printmodes.py . | |
54 | |
55 umask 007 | |
56 hg init ../push | |
57 echo | |
58 echo '% before push' | |
59 echo '% group can write everything' | |
60 python ../printmodes.py ../push | |
61 | |
62 umask 077 | |
63 hg -q push ../push | |
64 echo | |
65 echo '% after push' | |
66 echo '% group can still write everything' | |
67 python ../printmodes.py ../push |