##// END OF EJS Templates
test-removeemptydirs: clarify the state of things in the `histedit` case...
marmoute -
r48379:f2846abd default
parent child Browse files
Show More
@@ -1,260 +1,281 b''
1 Tests for experimental.removeemptydirs
1 Tests for experimental.removeemptydirs
2
2
3 $ NO_RM=--config=experimental.removeemptydirs=0
3 $ NO_RM=--config=experimental.removeemptydirs=0
4 $ DO_RM=--config=experimental.removeemptydirs=1
4 $ isdir() { if [ -d $1 ]; then echo yes; else echo no; fi }
5 $ isdir() { if [ -d $1 ]; then echo yes; else echo no; fi }
5 $ isfile() { if [ -f $1 ]; then echo yes; else echo no; fi }
6 $ isfile() { if [ -f $1 ]; then echo yes; else echo no; fi }
6
7
7 `hg rm` of the last file in a directory:
8 `hg rm` of the last file in a directory:
8 $ hg init hgrm
9 $ hg init hgrm
9 $ cd hgrm
10 $ cd hgrm
10 $ mkdir somedir
11 $ mkdir somedir
11 $ echo hi > somedir/foo
12 $ echo hi > somedir/foo
12 $ hg ci -qAm foo
13 $ hg ci -qAm foo
13 $ isdir somedir
14 $ isdir somedir
14 yes
15 yes
15 $ hg rm somedir/foo
16 $ hg rm somedir/foo
16 $ isdir somedir
17 $ isdir somedir
17 no
18 no
18 $ hg revert -qa
19 $ hg revert -qa
19 $ isdir somedir
20 $ isdir somedir
20 yes
21 yes
21 $ hg $NO_RM rm somedir/foo
22 $ hg $NO_RM rm somedir/foo
22 $ isdir somedir
23 $ isdir somedir
23 yes
24 yes
24 $ ls somedir
25 $ ls somedir
25 $ cd $TESTTMP
26 $ cd $TESTTMP
26
27
27 `hg mv` of the last file in a directory:
28 `hg mv` of the last file in a directory:
28 $ hg init hgmv
29 $ hg init hgmv
29 $ cd hgmv
30 $ cd hgmv
30 $ mkdir somedir
31 $ mkdir somedir
31 $ mkdir destdir
32 $ mkdir destdir
32 $ echo hi > somedir/foo
33 $ echo hi > somedir/foo
33 $ hg ci -qAm foo
34 $ hg ci -qAm foo
34 $ isdir somedir
35 $ isdir somedir
35 yes
36 yes
36 $ hg mv somedir/foo destdir/foo
37 $ hg mv somedir/foo destdir/foo
37 $ isdir somedir
38 $ isdir somedir
38 no
39 no
39 $ hg revert -qa
40 $ hg revert -qa
40 (revert doesn't get rid of destdir/foo?)
41 (revert doesn't get rid of destdir/foo?)
41 $ rm destdir/foo
42 $ rm destdir/foo
42 $ isdir somedir
43 $ isdir somedir
43 yes
44 yes
44 $ hg $NO_RM mv somedir/foo destdir/foo
45 $ hg $NO_RM mv somedir/foo destdir/foo
45 $ isdir somedir
46 $ isdir somedir
46 yes
47 yes
47 $ ls somedir
48 $ ls somedir
48 $ cd $TESTTMP
49 $ cd $TESTTMP
49
50
50 Updating to a commit that doesn't have the directory:
51 Updating to a commit that doesn't have the directory:
51 $ hg init hgupdate
52 $ hg init hgupdate
52 $ cd hgupdate
53 $ cd hgupdate
53 $ echo hi > r0
54 $ echo hi > r0
54 $ hg ci -qAm r0
55 $ hg ci -qAm r0
55 $ mkdir somedir
56 $ mkdir somedir
56 $ echo hi > somedir/foo
57 $ echo hi > somedir/foo
57 $ hg ci -qAm r1
58 $ hg ci -qAm r1
58 $ isdir somedir
59 $ isdir somedir
59 yes
60 yes
60 $ hg co -q -r ".^"
61 $ hg co -q -r ".^"
61 $ isdir somedir
62 $ isdir somedir
62 no
63 no
63 $ hg co -q tip
64 $ hg co -q tip
64 $ isdir somedir
65 $ isdir somedir
65 yes
66 yes
66 $ hg $NO_RM co -q -r ".^"
67 $ hg $NO_RM co -q -r ".^"
67 $ isdir somedir
68 $ isdir somedir
68 yes
69 yes
69 $ ls somedir
70 $ ls somedir
70 $ cd $TESTTMP
71 $ cd $TESTTMP
71
72
72 Rebasing across a commit that doesn't have the directory, from inside the
73 Rebasing across a commit that doesn't have the directory, from inside the
73 directory:
74 directory:
74 $ hg init hgrebase
75 $ hg init hgrebase
75 $ cd hgrebase
76 $ cd hgrebase
76 $ echo hi > r0
77 $ echo hi > r0
77 $ hg ci -qAm r0
78 $ hg ci -qAm r0
78 $ mkdir somedir
79 $ mkdir somedir
79 $ echo hi > somedir/foo
80 $ echo hi > somedir/foo
80 $ hg ci -qAm first_rebase_source
81 $ hg ci -qAm first_rebase_source
81 $ hg $NO_RM co -q -r ".^"
82 $ hg $NO_RM co -q -r ".^"
82 $ echo hi > somedir/bar
83 $ echo hi > somedir/bar
83 $ hg ci -qAm first_rebase_dest
84 $ hg ci -qAm first_rebase_dest
84 $ hg $NO_RM co -q -r ".^"
85 $ hg $NO_RM co -q -r ".^"
85 $ echo hi > somedir/baz
86 $ echo hi > somedir/baz
86 $ hg ci -qAm second_rebase_dest
87 $ hg ci -qAm second_rebase_dest
87 $ hg co -qr 'desc(first_rebase_source)'
88 $ hg co -qr 'desc(first_rebase_source)'
88 $ cd $TESTTMP/hgrebase/somedir
89 $ cd $TESTTMP/hgrebase/somedir
89 $ hg --config extensions.rebase= rebase -qr . -d 'desc(first_rebase_dest)'
90 $ hg --config extensions.rebase= rebase -qr . -d 'desc(first_rebase_dest)'
90 current directory was removed (rmcwd !)
91 current directory was removed (rmcwd !)
91 (consider changing to repo root: $TESTTMP/hgrebase) (rmcwd !)
92 (consider changing to repo root: $TESTTMP/hgrebase) (rmcwd !)
92 $ cd $TESTTMP/hgrebase/somedir
93 $ cd $TESTTMP/hgrebase/somedir
93 (The current node is the rebased first_rebase_source on top of
94 (The current node is the rebased first_rebase_source on top of
94 first_rebase_dest)
95 first_rebase_dest)
95 This should not output anything about current directory being removed:
96 This should not output anything about current directory being removed:
96 $ hg $NO_RM --config extensions.rebase= rebase -qr . -d 'desc(second_rebase_dest)'
97 $ hg $NO_RM --config extensions.rebase= rebase -qr . -d 'desc(second_rebase_dest)'
97 $ cd $TESTTMP
98 $ cd $TESTTMP
98
99
99 Histediting across a commit that doesn't have the directory, from inside the
100 Histediting across a commit that doesn't have the directory, from inside the
100 directory (reordering nodes):
101 directory (reordering nodes):
102
103 A directory with the right pass exists at the end of the run, but it is a
104 different directory than the current one.
105
101 $ hg init hghistedit
106 $ hg init hghistedit
102 $ cd hghistedit
107 $ cd hghistedit
103 $ echo hi > r0
108 $ echo hi > r0
104 $ hg ci -qAm r0
109 $ hg ci -qAm r0
105 $ echo hi > r1
110 $ echo hi > r1
106 $ hg ci -qAm r1
111 $ hg ci -qAm r1
107 $ echo hi > r2
112 $ echo hi > r2
108 $ hg ci -qAm r2
113 $ hg ci -qAm r2
109 $ mkdir somedir
114 $ mkdir somedir
110 $ echo hi > somedir/foo
115 $ echo hi > somedir/foo
111 $ hg ci -qAm migrating_revision
116 $ hg ci -qAm migrating_revision
112 $ cat > histedit_commands <<EOF
117 $ cat > histedit_commands <<EOF
113 > pick 89079fab8aee 0 r0
118 > pick 89079fab8aee 0 r0
114 > pick e6d271df3142 1 r1
119 > pick e6d271df3142 1 r1
115 > pick 89e25aa83f0f 3 migrating_revision
120 > pick 89e25aa83f0f 3 migrating_revision
116 > pick b550aa12d873 2 r2
121 > pick b550aa12d873 2 r2
117 > EOF
122 > EOF
118 $ cd $TESTTMP/hghistedit/somedir
123 $ cd $TESTTMP/hghistedit/somedir
119 $ hg --config extensions.histedit= histedit -q --commands ../histedit_commands
124 $ hg $DO_RM --config extensions.histedit= histedit -q --commands ../histedit_commands
120 current directory was removed
125 current directory was removed
121 (consider changing to repo root: $TESTTMP/hghistedit)
126 (consider changing to repo root: $TESTTMP/hghistedit)
127 $ ls -1 $TESTTMP/hghistedit/
128 histedit_commands
129 r0
130 r1
131 r2
132 somedir
133 $ pwd
134 $TESTTMP/hghistedit/somedir
135 $ ls -1 $TESTTMP/hghistedit/somedir
136 foo
137 $ ls -1
138
139 Get out of the doomed directory
140
141 $ cd $TESTTMP/hghistedit
142 $ hg files --rev . | grep somedir/
143 somedir/foo
122
144
123
145
124 $ cd $TESTTMP/hghistedit
125 $ cat > histedit_commands <<EOF
146 $ cat > histedit_commands <<EOF
126 > pick 89079fab8aee 0 r0
147 > pick 89079fab8aee 0 r0
127 > pick 7c7a22c6009f 3 migrating_revision
148 > pick 7c7a22c6009f 3 migrating_revision
128 > pick e6d271df3142 1 r1
149 > pick e6d271df3142 1 r1
129 > pick 40a53c2d4276 2 r2
150 > pick 40a53c2d4276 2 r2
130 > EOF
151 > EOF
131 $ cd $TESTTMP/hghistedit/somedir
152 $ cd $TESTTMP/hghistedit/somedir
132 $ hg $NO_RM --config extensions.histedit= histedit -q --commands ../histedit_commands
153 $ hg $NO_RM --config extensions.histedit= histedit -q --commands ../histedit_commands
133 Regardless of system, we should always get a 'yes' here.
154 Regardless of system, we should always get a 'yes' here.
134 $ isfile foo
155 $ isfile foo
135 yes
156 yes
136 $ cd $TESTTMP
157 $ cd $TESTTMP
137
158
138 This is essentially the exact test from issue5826, just cleaned up a little:
159 This is essentially the exact test from issue5826, just cleaned up a little:
139
160
140 $ hg init issue5826_withrm
161 $ hg init issue5826_withrm
141 $ cd issue5826_withrm
162 $ cd issue5826_withrm
142
163
143 Let's only turn this on for this repo so that we don't contaminate later tests.
164 Let's only turn this on for this repo so that we don't contaminate later tests.
144 $ cat >> .hg/hgrc <<EOF
165 $ cat >> .hg/hgrc <<EOF
145 > [extensions]
166 > [extensions]
146 > histedit =
167 > histedit =
147 > EOF
168 > EOF
148 Commit three revisions that each create a directory:
169 Commit three revisions that each create a directory:
149
170
150 $ mkdir foo
171 $ mkdir foo
151 $ touch foo/bar
172 $ touch foo/bar
152 $ hg commit -qAm "add foo"
173 $ hg commit -qAm "add foo"
153
174
154 $ mkdir bar
175 $ mkdir bar
155 $ touch bar/bar
176 $ touch bar/bar
156 $ hg commit -qAm "add bar"
177 $ hg commit -qAm "add bar"
157
178
158 $ mkdir baz
179 $ mkdir baz
159 $ touch baz/bar
180 $ touch baz/bar
160 $ hg commit -qAm "add baz"
181 $ hg commit -qAm "add baz"
161
182
162 Enter the first directory:
183 Enter the first directory:
163
184
164 $ cd foo
185 $ cd foo
165
186
166 Histedit doing 'pick, pick, fold':
187 Histedit doing 'pick, pick, fold':
167
188
168 #if rmcwd
189 #if rmcwd
169
190
170 $ hg histedit --commands - <<EOF
191 $ hg histedit --commands - <<EOF
171 > pick 6274c77c93c3 1 add bar
192 > pick 6274c77c93c3 1 add bar
172 > pick ff70a87b588f 0 add foo
193 > pick ff70a87b588f 0 add foo
173 > fold 9992bb0ac0db 2 add baz
194 > fold 9992bb0ac0db 2 add baz
174 > EOF
195 > EOF
175 current directory was removed
196 current directory was removed
176 (consider changing to repo root: $TESTTMP/issue5826_withrm)
197 (consider changing to repo root: $TESTTMP/issue5826_withrm)
177 abort: $ENOENT$
198 abort: $ENOENT$
178 [255]
199 [255]
179
200
180 Go back to the repo root after losing it as part of that operation:
201 Go back to the repo root after losing it as part of that operation:
181 $ cd $TESTTMP/issue5826_withrm
202 $ cd $TESTTMP/issue5826_withrm
182
203
183 Note the lack of a non-zero exit code from this function - it exits
204 Note the lack of a non-zero exit code from this function - it exits
184 successfully, but doesn't really do anything.
205 successfully, but doesn't really do anything.
185 $ hg histedit --continue
206 $ hg histedit --continue
186 9992bb0ac0db: cannot fold - working copy is not a descendant of previous commit 5c806432464a
207 9992bb0ac0db: cannot fold - working copy is not a descendant of previous commit 5c806432464a
187 saved backup bundle to $TESTTMP/issue5826_withrm/.hg/strip-backup/ff70a87b588f-e94f9789-histedit.hg
208 saved backup bundle to $TESTTMP/issue5826_withrm/.hg/strip-backup/ff70a87b588f-e94f9789-histedit.hg
188
209
189 $ hg log -T '{rev}:{node|short} {desc}\n'
210 $ hg log -T '{rev}:{node|short} {desc}\n'
190 2:94e3f9fae1d6 fold-temp-revision 9992bb0ac0db
211 2:94e3f9fae1d6 fold-temp-revision 9992bb0ac0db
191 1:5c806432464a add foo
212 1:5c806432464a add foo
192 0:d17db4b0303a add bar
213 0:d17db4b0303a add bar
193
214
194 #else
215 #else
195
216
196 $ cd $TESTTMP/issue5826_withrm
217 $ cd $TESTTMP/issue5826_withrm
197
218
198 $ hg histedit --commands - <<EOF
219 $ hg histedit --commands - <<EOF
199 > pick 6274c77c93c3 1 add bar
220 > pick 6274c77c93c3 1 add bar
200 > pick ff70a87b588f 0 add foo
221 > pick ff70a87b588f 0 add foo
201 > fold 9992bb0ac0db 2 add baz
222 > fold 9992bb0ac0db 2 add baz
202 > EOF
223 > EOF
203 saved backup bundle to $TESTTMP/issue5826_withrm/.hg/strip-backup/5c806432464a-cd4c8d86-histedit.hg
224 saved backup bundle to $TESTTMP/issue5826_withrm/.hg/strip-backup/5c806432464a-cd4c8d86-histedit.hg
204
225
205 $ hg log -T '{rev}:{node|short} {desc}\n'
226 $ hg log -T '{rev}:{node|short} {desc}\n'
206 1:b9eddaa97cbc add foo
227 1:b9eddaa97cbc add foo
207 ***
228 ***
208 add baz
229 add baz
209 0:d17db4b0303a add bar
230 0:d17db4b0303a add bar
210
231
211 #endif
232 #endif
212
233
213 Now test that again with experimental.removeemptydirs=false:
234 Now test that again with experimental.removeemptydirs=false:
214 $ hg init issue5826_norm
235 $ hg init issue5826_norm
215 $ cd issue5826_norm
236 $ cd issue5826_norm
216
237
217 Let's only turn this on for this repo so that we don't contaminate later tests.
238 Let's only turn this on for this repo so that we don't contaminate later tests.
218 $ cat >> .hg/hgrc <<EOF
239 $ cat >> .hg/hgrc <<EOF
219 > [extensions]
240 > [extensions]
220 > histedit =
241 > histedit =
221 > [experimental]
242 > [experimental]
222 > removeemptydirs = false
243 > removeemptydirs = false
223 > EOF
244 > EOF
224 Commit three revisions that each create a directory:
245 Commit three revisions that each create a directory:
225
246
226 $ mkdir foo
247 $ mkdir foo
227 $ touch foo/bar
248 $ touch foo/bar
228 $ hg commit -qAm "add foo"
249 $ hg commit -qAm "add foo"
229
250
230 $ mkdir bar
251 $ mkdir bar
231 $ touch bar/bar
252 $ touch bar/bar
232 $ hg commit -qAm "add bar"
253 $ hg commit -qAm "add bar"
233
254
234 $ mkdir baz
255 $ mkdir baz
235 $ touch baz/bar
256 $ touch baz/bar
236 $ hg commit -qAm "add baz"
257 $ hg commit -qAm "add baz"
237
258
238 Enter the first directory:
259 Enter the first directory:
239
260
240 $ cd foo
261 $ cd foo
241
262
242 Histedit doing 'pick, pick, fold':
263 Histedit doing 'pick, pick, fold':
243
264
244 $ hg histedit --commands - <<EOF
265 $ hg histedit --commands - <<EOF
245 > pick 6274c77c93c3 1 add bar
266 > pick 6274c77c93c3 1 add bar
246 > pick ff70a87b588f 0 add foo
267 > pick ff70a87b588f 0 add foo
247 > fold 9992bb0ac0db 2 add baz
268 > fold 9992bb0ac0db 2 add baz
248 > EOF
269 > EOF
249 saved backup bundle to $TESTTMP/issue5826_withrm/issue5826_norm/.hg/strip-backup/5c806432464a-cd4c8d86-histedit.hg
270 saved backup bundle to $TESTTMP/issue5826_withrm/issue5826_norm/.hg/strip-backup/5c806432464a-cd4c8d86-histedit.hg
250
271
251 Note the lack of a 'cd' being necessary here, and we don't need to 'histedit
272 Note the lack of a 'cd' being necessary here, and we don't need to 'histedit
252 --continue'
273 --continue'
253
274
254 $ hg log -T '{rev}:{node|short} {desc}\n'
275 $ hg log -T '{rev}:{node|short} {desc}\n'
255 1:b9eddaa97cbc add foo
276 1:b9eddaa97cbc add foo
256 ***
277 ***
257 add baz
278 add baz
258 0:d17db4b0303a add bar
279 0:d17db4b0303a add bar
259
280
260 $ cd $TESTTMP
281 $ cd $TESTTMP
General Comments 0
You need to be logged in to leave comments. Login now