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