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