##// END OF EJS Templates
tests: don't run test-update-atomic.t on chg...
Pulkit Goyal -
r45110:1bc345d4 default
parent child Browse files
Show More
@@ -1,147 +1,147 b''
1 #require execbit unix-permissions
1 #require execbit unix-permissions no-chg
2 2
3 3 Checking that experimental.atomic-file works.
4 4
5 5 $ cat > $TESTTMP/show_mode.py <<EOF
6 6 > from __future__ import print_function
7 7 > import os
8 8 > import stat
9 9 > import sys
10 10 > ST_MODE = stat.ST_MODE
11 11 >
12 12 > for file_path in sys.argv[1:]:
13 13 > file_stat = os.stat(file_path)
14 14 > octal_mode = oct(file_stat[ST_MODE] & 0o777).replace('o', '')
15 15 > print("%s:%s" % (file_path, octal_mode))
16 16 >
17 17 > EOF
18 18
19 19 $ hg init repo
20 20 $ cd repo
21 21
22 22 $ cat > .hg/showwrites.py <<EOF
23 23 > from __future__ import print_function
24 24 > from mercurial import pycompat
25 25 > from mercurial.utils import stringutil
26 26 > def uisetup(ui):
27 27 > from mercurial import vfs
28 28 > class newvfs(vfs.vfs):
29 29 > def __call__(self, *args, **kwargs):
30 30 > print(pycompat.sysstr(stringutil.pprint(
31 31 > ('vfs open', args, sorted(list(kwargs.items()))))))
32 32 > return super(newvfs, self).__call__(*args, **kwargs)
33 33 > vfs.vfs = newvfs
34 34 > EOF
35 35
36 36 $ for v in a1 a2 b1 b2 c ro; do echo $v > $v; done
37 37 $ chmod +x b*
38 38 $ hg commit -Aqm _
39 39
40 40 # We check that
41 41 # - the changes are actually atomic
42 42 # - that permissions are correct (all 4 cases of (executable before) * (executable after))
43 43 # - that renames work, though they should be atomic anyway
44 44 # - that it works when source files are read-only (but directories are read-write still)
45 45
46 46 $ for v in a1 a2 b1 b2 ro; do echo changed-$v > $v; done
47 47 $ chmod -x *1; chmod +x *2
48 48 $ hg rename c d
49 49 $ hg commit -qm _
50 50
51 51 Check behavior without update.atomic-file
52 52
53 53 $ hg update -r 0 -q
54 54 $ hg update -r 1 --config extensions.showwrites=.hg/showwrites.py 2>&1 | grep "a1'.*wb"
55 55 ('vfs open', ('a1', 'wb'), [('atomictemp', False), ('backgroundclose', True)])
56 56
57 57 $ python $TESTTMP/show_mode.py *
58 58 a1:0644
59 59 a2:0755
60 60 b1:0644
61 61 b2:0755
62 62 d:0644
63 63 ro:0644
64 64
65 65 Add a second revision for the ro file so we can test update when the file is
66 66 present or not
67 67
68 68 $ echo "ro" > ro
69 69
70 70 $ hg commit -qm _
71 71
72 72 Check behavior without update.atomic-file first
73 73
74 74 $ hg update -C -r 0 -q
75 75
76 76 $ hg update -r 1
77 77 6 files updated, 0 files merged, 1 files removed, 0 files unresolved
78 78
79 79 $ python $TESTTMP/show_mode.py *
80 80 a1:0644
81 81 a2:0755
82 82 b1:0644
83 83 b2:0755
84 84 d:0644
85 85 ro:0644
86 86
87 87 Manually reset the mode of the read-only file
88 88
89 89 $ chmod a-w ro
90 90
91 91 $ python $TESTTMP/show_mode.py ro
92 92 ro:0444
93 93
94 94 Now the file is present, try to update and check the permissions of the file
95 95
96 96 $ hg up -r 2
97 97 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
98 98
99 99 $ python $TESTTMP/show_mode.py ro
100 100 ro:0644
101 101
102 102 # The file which was read-only is now writable in the default behavior
103 103
104 104 Check behavior with update.atomic-files
105 105
106 106
107 107 $ cat >> .hg/hgrc <<EOF
108 108 > [experimental]
109 109 > update.atomic-file = true
110 110 > EOF
111 111
112 112 $ hg update -C -r 0 -q
113 113 $ hg update -r 1 --config extensions.showwrites=.hg/showwrites.py 2>&1 | grep "a1'.*wb"
114 114 ('vfs open', ('a1', 'wb'), [('atomictemp', True), ('backgroundclose', True)])
115 115 $ hg st -A --rev 1
116 116 C a1
117 117 C a2
118 118 C b1
119 119 C b2
120 120 C d
121 121 C ro
122 122
123 123 Check the file permission after update
124 124 $ python $TESTTMP/show_mode.py *
125 125 a1:0644
126 126 a2:0755
127 127 b1:0644
128 128 b2:0755
129 129 d:0644
130 130 ro:0644
131 131
132 132 Manually reset the mode of the read-only file
133 133
134 134 $ chmod a-w ro
135 135
136 136 $ python $TESTTMP/show_mode.py ro
137 137 ro:0444
138 138
139 139 Now the file is present, try to update and check the permissions of the file
140 140
141 141 $ hg update -r 2 --traceback
142 142 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
143 143
144 144 $ python $TESTTMP/show_mode.py ro
145 145 ro:0644
146 146
147 147 # The behavior is the same as without atomic update
General Comments 0
You need to be logged in to leave comments. Login now