Debian Codegraph @

tests/test-add.t

raw
1 $ hg init a
2 $ cd a
3 $ echo a > a
4 $ hg add -n
5 adding a
6 $ hg st
7 ? a
8 $ hg add
9 adding a
10 $ hg st
11 A a
12 $ hg forget a
13 $ hg add
14 adding a
15 $ hg forget a
16 $ hg add --color debug
17 [ui.addremove.added ui.status|adding a]
18 $ hg st
19 A a
20 $ mkdir dir
21 $ cd dir
22 $ hg add ../a
23 ../a already tracked!
24 $ cd ..
25
26 $ echo b > b
27 $ hg add -n b
28 $ hg st
29 A a
30 ? b
31 $ hg add b
32 $ hg st
33 A a
34 A b
35
36 should fail
37
38 $ hg add b
39 b already tracked!
40 $ hg st
41 A a
42 A b
43
44 #if no-windows
45 $ echo foo > con.xml
46 $ hg --config ui.portablefilenames=jump add con.xml
47 config error: ui.portablefilenames value is invalid ('jump')
48 [30]
49 $ hg --config ui.portablefilenames=abort add con.xml
50 abort: filename contains 'con', which is reserved on Windows: con.xml
51 [10]
52 $ hg st
53 A a
54 A b
55 ? con.xml
56 $ hg add con.xml
57 warning: filename contains 'con', which is reserved on Windows: con.xml
58 $ hg st
59 A a
60 A b
61 A con.xml
62 $ hg forget con.xml
63 $ rm con.xml
64 #endif
65
66 #if eol-in-paths
67 $ echo bla > 'hello:world'
68 $ hg --config ui.portablefilenames=abort add
69 adding hello:world
70 abort: filename contains ':', which is reserved on Windows: 'hello:world'
71 [10]
72 $ hg st
73 A a
74 A b
75 ? hello:world
76 $ hg --config ui.portablefilenames=ignore add
77 adding hello:world
78 $ hg st
79 A a
80 A b
81 A hello:world
82 #endif
83
84 $ hg ci -m 0 --traceback
85
86 $ hg log -r "heads(. or wdir() & file('**'))"
87 changeset: 0:* (glob)
88 tag: tip
89 user: test
90 date: Thu Jan 01 00:00:00 1970 +0000
91 summary: 0
92
93 should fail
94
95 $ hg add a
96 a already tracked!
97
98 $ echo aa > a
99 $ hg ci -m 1
100 $ hg up 0
101 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
102 $ echo aaa > a
103 $ hg ci -m 2
104 created new head
105
106 $ hg merge
107 merging a
108 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
109 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
110 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
111 [1]
112 $ hg st
113 M a
114 ? a.orig
115
116 wdir doesn't cause a crash, and can be dynamically selected if dirty
117
118 $ hg log -r "heads(. or wdir() & file('**'))"
119 changeset: 2147483647:ffffffffffff
120 parent: 2:* (glob)
121 parent: 1:* (glob)
122 user: test
123 date: * (glob)
124
125 should fail
126
127 $ hg add a
128 a already tracked!
129 $ hg st
130 M a
131 ? a.orig
132 $ hg resolve -m a
133 (no more unresolved files)
134 $ hg ci -m merge
135
136 Issue683: peculiarity with hg revert of an removed then added file
137
138 $ hg forget a
139 $ hg add a
140 $ hg st
141 ? a.orig
142 $ hg rm a
143 $ hg st
144 R a
145 ? a.orig
146 $ echo a > a
147 $ hg add a
148 $ hg st
149 M a
150 ? a.orig
151
152 excluded file shouldn't be added even if it is explicitly specified
153
154 $ hg add a.orig -X '*.orig'
155 $ hg st
156 M a
157 ? a.orig
158
159 Forgotten file can be added back (as either clean or modified)
160
161 $ hg forget b
162 $ hg add b
163 $ hg st -A b
164 C b
165 $ hg forget b
166 $ echo modified > b
167 $ hg add b
168 $ hg st -A b
169 M b
170 $ hg revert -qC b
171
172 $ hg add c && echo "unexpected addition of missing file"
173 c: * (glob)
174 [1]
175 $ echo c > c
176 $ hg add d c && echo "unexpected addition of missing file"
177 d: * (glob)
178 [1]
179 $ hg st
180 M a
181 A c
182 ? a.orig
183 $ hg up -C
184 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
185
186 forget and get should have the right order: added but missing dir should be
187 forgotten before file with same name is added
188
189 $ echo file d > d
190 $ hg add d
191 $ hg ci -md
192 $ hg rm d
193 $ mkdir d
194 $ echo a > d/a
195 $ hg add d/a
196 $ rm -r d
197 $ hg up -C
198 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
199 $ cat d
200 file d
201
202 Test that adding a directory doesn't require case matching (issue4578)
203 #if icasefs
204 $ mkdir -p CapsDir1/CapsDir
205 $ echo abc > CapsDir1/CapsDir/AbC.txt
206 $ mkdir CapsDir1/CapsDir/SubDir
207 $ echo def > CapsDir1/CapsDir/SubDir/Def.txt
208
209 $ hg add capsdir1/capsdir
210 adding CapsDir1/CapsDir/AbC.txt
211 adding CapsDir1/CapsDir/SubDir/Def.txt
212
213 $ hg forget capsdir1/capsdir/abc.txt
214
215 $ hg forget capsdir1/capsdir
216 removing CapsDir1/CapsDir/SubDir/Def.txt
217
218 $ hg add capsdir1
219 adding CapsDir1/CapsDir/AbC.txt
220 adding CapsDir1/CapsDir/SubDir/Def.txt
221
222 $ hg ci -m "AbCDef" capsdir1/capsdir
223
224 $ hg status -A capsdir1/capsdir
225 C CapsDir1/CapsDir/AbC.txt
226 C CapsDir1/CapsDir/SubDir/Def.txt
227
228 $ hg files capsdir1/capsdir
229 CapsDir1/CapsDir/AbC.txt
230 CapsDir1/CapsDir/SubDir/Def.txt
231
232 $ echo xyz > CapsDir1/CapsDir/SubDir/Def.txt
233 $ hg ci -m xyz capsdir1/capsdir/subdir/def.txt
234
235 $ hg revert -r '.^' capsdir1/capsdir
236 reverting CapsDir1/CapsDir/SubDir/Def.txt
237
238 The conditional tests above mean the hash on the diff line differs on Windows
239 and OS X
240 $ hg diff capsdir1/capsdir
241 diff -r * CapsDir1/CapsDir/SubDir/Def.txt (glob)
242 --- a/CapsDir1/CapsDir/SubDir/Def.txt Thu Jan 01 00:00:00 1970 +0000
243 +++ b/CapsDir1/CapsDir/SubDir/Def.txt * (glob)
244 @@ -1,1 +1,1 @@
245 -xyz
246 +def
247
248 $ hg mv CapsDir1/CapsDir/abc.txt CapsDir1/CapsDir/ABC.txt
249 $ hg ci -m "case changing rename" CapsDir1/CapsDir/AbC.txt CapsDir1/CapsDir/ABC.txt
250
251 $ hg status -A capsdir1/capsdir
252 M CapsDir1/CapsDir/SubDir/Def.txt
253 C CapsDir1/CapsDir/ABC.txt
254
255 $ hg remove -f 'glob:**.txt' -X capsdir1/capsdir
256 $ hg remove -f 'glob:**.txt' -I capsdir1/capsdir
257 removing CapsDir1/CapsDir/ABC.txt
258 removing CapsDir1/CapsDir/SubDir/Def.txt
259 #endif
260
261 $ cd ..
262
263 test --dry-run mode in forget
264
265 $ hg init testdir_forget
266 $ cd testdir_forget
267 $ echo foo > foo
268 $ hg add foo
269 $ hg commit -m "foo"
270 $ hg forget foo --dry-run -v
271 removing foo
272 $ hg diff
273 $ hg forget not_exist -n
274 not_exist: $ENOENT$
275 [1]
276
277 $ cd ..
278
279 test --interactive mode in forget
280
281 $ hg init interactiveforget
282 $ cd interactiveforget
283 $ echo foo > foo
284 $ hg commit -qAm "foo"
285 $ echo bar > bar
286 $ hg commit -qAm "bar"
287 $ hg forget foo --dry-run -i
288 abort: cannot specify both --dry-run and --interactive
289 [10]
290
291 $ hg forget foo --config ui.interactive=True -i << EOF
292 > ?
293 > n
294 > EOF
295 forget foo [Ynsa?] ?
296 y - yes, forget this file
297 n - no, skip this file
298 s - skip remaining files
299 a - include all remaining files
300 ? - ? (display help)
301 forget foo [Ynsa?] n
302
303 $ hg forget foo bar --config ui.interactive=True -i << EOF
304 > y
305 > n
306 > EOF
307 forget bar [Ynsa?] y
308 forget foo [Ynsa?] n
309 removing bar
310 $ hg status
311 R bar
312 $ hg up -qC .
313
314 $ hg forget foo bar --config ui.interactive=True -i << EOF
315 > s
316 > EOF
317 forget bar [Ynsa?] s
318 $ hg st
319 $ hg up -qC .
320
321 $ hg forget foo bar --config ui.interactive=True -i << EOF
322 > a
323 > EOF
324 forget bar [Ynsa?] a
325 removing bar
326 removing foo
327 $ hg status
328 R bar
329 R foo
330 $ hg up -qC .
331
332 $ cd ..