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