##// END OF EJS Templates
log: fix status template to list copy source per dest (issue5155)...
Yuya Nishihara -
r29000:2d3837a4 stable
parent child Browse files
Show More
@@ -1,25 +1,20 b''
1 1 %include map-cmdline.default
2 2
3 3 # Override base templates
4 4 changeset = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{summary}{lfiles}\n'
5 5 changeset_verbose = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{description}{lfiles}\n'
6 6 changeset_debug = '{fullcset}{branches}{bookmarks}{tags}{lphase}{parents}{manifest}{user}{ldate}{extras}{description}{lfiles}\n'
7 7
8 8 # Override the file templates
9 9 lfiles = '{if(files,
10 10 label('ui.note log.files',
11 'files:\n'))}{lfile_mods}{lfile_adds}{lfile_copies_switch}{lfile_dels}'
11 'files:\n'))}{lfile_mods}{lfile_adds}{lfile_dels}'
12 12
13 # Exclude copied files, will display those in lfile_copies_switch
14 lfile_adds = '{file_adds % "{ifcontains(file, file_copies_switch,
15 '',
16 '{lfile_add}')}"}'
13 lfile_adds = '{file_adds % "{lfile_add}{lfile_src}"}'
14 lfile_mods = '{file_mods % "{lfile_mod}{lfile_src}"}'
17 15 lfile_add = '{label("status.added", "A {file}\n")}'
18
19 lfile_copies_switch = '{file_copies_switch % "{lfile_copy_orig}{lfile_copy_dest}"}'
20 lfile_copy_orig = '{label("status.added", "A {name}\n")}'
21 lfile_copy_dest = '{label("status.copied", " {source}\n")}'
22
23 lfile_mods = '{file_mods % "{label('status.modified', 'M {file}\n')}"}'
16 lfile_mod = '{label("status.modified", "M {file}\n")}'
17 lfile_src = '{ifcontains(file, file_copies_switch,
18 label("status.copied", " {get(file_copies_switch, file)}\n"))}'
24 19
25 20 lfile_dels = '{file_dels % "{label('status.removed', 'R {file}\n')}"}'
@@ -1,524 +1,549 b''
1 1 $ hg init repo1
2 2 $ cd repo1
3 3 $ mkdir a b a/1 b/1 b/2
4 4 $ touch in_root a/in_a b/in_b a/1/in_a_1 b/1/in_b_1 b/2/in_b_2
5 5
6 6 hg status in repo root:
7 7
8 8 $ hg status
9 9 ? a/1/in_a_1
10 10 ? a/in_a
11 11 ? b/1/in_b_1
12 12 ? b/2/in_b_2
13 13 ? b/in_b
14 14 ? in_root
15 15
16 16 hg status . in repo root:
17 17
18 18 $ hg status .
19 19 ? a/1/in_a_1
20 20 ? a/in_a
21 21 ? b/1/in_b_1
22 22 ? b/2/in_b_2
23 23 ? b/in_b
24 24 ? in_root
25 25
26 26 $ hg status --cwd a
27 27 ? a/1/in_a_1
28 28 ? a/in_a
29 29 ? b/1/in_b_1
30 30 ? b/2/in_b_2
31 31 ? b/in_b
32 32 ? in_root
33 33 $ hg status --cwd a .
34 34 ? 1/in_a_1
35 35 ? in_a
36 36 $ hg status --cwd a ..
37 37 ? 1/in_a_1
38 38 ? in_a
39 39 ? ../b/1/in_b_1
40 40 ? ../b/2/in_b_2
41 41 ? ../b/in_b
42 42 ? ../in_root
43 43
44 44 $ hg status --cwd b
45 45 ? a/1/in_a_1
46 46 ? a/in_a
47 47 ? b/1/in_b_1
48 48 ? b/2/in_b_2
49 49 ? b/in_b
50 50 ? in_root
51 51 $ hg status --cwd b .
52 52 ? 1/in_b_1
53 53 ? 2/in_b_2
54 54 ? in_b
55 55 $ hg status --cwd b ..
56 56 ? ../a/1/in_a_1
57 57 ? ../a/in_a
58 58 ? 1/in_b_1
59 59 ? 2/in_b_2
60 60 ? in_b
61 61 ? ../in_root
62 62
63 63 $ hg status --cwd a/1
64 64 ? a/1/in_a_1
65 65 ? a/in_a
66 66 ? b/1/in_b_1
67 67 ? b/2/in_b_2
68 68 ? b/in_b
69 69 ? in_root
70 70 $ hg status --cwd a/1 .
71 71 ? in_a_1
72 72 $ hg status --cwd a/1 ..
73 73 ? in_a_1
74 74 ? ../in_a
75 75
76 76 $ hg status --cwd b/1
77 77 ? a/1/in_a_1
78 78 ? a/in_a
79 79 ? b/1/in_b_1
80 80 ? b/2/in_b_2
81 81 ? b/in_b
82 82 ? in_root
83 83 $ hg status --cwd b/1 .
84 84 ? in_b_1
85 85 $ hg status --cwd b/1 ..
86 86 ? in_b_1
87 87 ? ../2/in_b_2
88 88 ? ../in_b
89 89
90 90 $ hg status --cwd b/2
91 91 ? a/1/in_a_1
92 92 ? a/in_a
93 93 ? b/1/in_b_1
94 94 ? b/2/in_b_2
95 95 ? b/in_b
96 96 ? in_root
97 97 $ hg status --cwd b/2 .
98 98 ? in_b_2
99 99 $ hg status --cwd b/2 ..
100 100 ? ../1/in_b_1
101 101 ? in_b_2
102 102 ? ../in_b
103 103
104 104 combining patterns with root and patterns without a root works
105 105
106 106 $ hg st a/in_a re:.*b$
107 107 ? a/in_a
108 108 ? b/in_b
109 109
110 110 $ cd ..
111 111
112 112 $ hg init repo2
113 113 $ cd repo2
114 114 $ touch modified removed deleted ignored
115 115 $ echo "^ignored$" > .hgignore
116 116 $ hg ci -A -m 'initial checkin'
117 117 adding .hgignore
118 118 adding deleted
119 119 adding modified
120 120 adding removed
121 121 $ touch modified added unknown ignored
122 122 $ hg add added
123 123 $ hg remove removed
124 124 $ rm deleted
125 125
126 126 hg status:
127 127
128 128 $ hg status
129 129 A added
130 130 R removed
131 131 ! deleted
132 132 ? unknown
133 133
134 134 hg status modified added removed deleted unknown never-existed ignored:
135 135
136 136 $ hg status modified added removed deleted unknown never-existed ignored
137 137 never-existed: * (glob)
138 138 A added
139 139 R removed
140 140 ! deleted
141 141 ? unknown
142 142
143 143 $ hg copy modified copied
144 144
145 145 hg status -C:
146 146
147 147 $ hg status -C
148 148 A added
149 149 A copied
150 150 modified
151 151 R removed
152 152 ! deleted
153 153 ? unknown
154 154
155 155 hg status -A:
156 156
157 157 $ hg status -A
158 158 A added
159 159 A copied
160 160 modified
161 161 R removed
162 162 ! deleted
163 163 ? unknown
164 164 I ignored
165 165 C .hgignore
166 166 C modified
167 167
168 168 $ hg status -A -Tjson
169 169 [
170 170 {
171 171 "path": "added",
172 172 "status": "A"
173 173 },
174 174 {
175 175 "copy": "modified",
176 176 "path": "copied",
177 177 "status": "A"
178 178 },
179 179 {
180 180 "path": "removed",
181 181 "status": "R"
182 182 },
183 183 {
184 184 "path": "deleted",
185 185 "status": "!"
186 186 },
187 187 {
188 188 "path": "unknown",
189 189 "status": "?"
190 190 },
191 191 {
192 192 "path": "ignored",
193 193 "status": "I"
194 194 },
195 195 {
196 196 "path": ".hgignore",
197 197 "status": "C"
198 198 },
199 199 {
200 200 "path": "modified",
201 201 "status": "C"
202 202 }
203 203 ]
204 204
205 205 $ hg status -A -Tpickle > pickle
206 206 >>> import pickle
207 207 >>> print sorted((x['status'], x['path']) for x in pickle.load(open("pickle")))
208 208 [('!', 'deleted'), ('?', 'pickle'), ('?', 'unknown'), ('A', 'added'), ('A', 'copied'), ('C', '.hgignore'), ('C', 'modified'), ('I', 'ignored'), ('R', 'removed')]
209 209 $ rm pickle
210 210
211 211 $ echo "^ignoreddir$" > .hgignore
212 212 $ mkdir ignoreddir
213 213 $ touch ignoreddir/file
214 214
215 215 Test templater support:
216 216
217 217 $ hg status -AT "[{status}]\t{if(copy, '{copy} -> ')}{path}\n"
218 218 [M] .hgignore
219 219 [A] added
220 220 [A] modified -> copied
221 221 [R] removed
222 222 [!] deleted
223 223 [?] ignored
224 224 [?] unknown
225 225 [I] ignoreddir/file
226 226 [C] modified
227 227 $ hg status -AT default
228 228 M .hgignore
229 229 A added
230 230 A copied
231 231 modified
232 232 R removed
233 233 ! deleted
234 234 ? ignored
235 235 ? unknown
236 236 I ignoreddir/file
237 237 C modified
238 238 $ hg status -T compact
239 239 abort: "status" not in template map
240 240 [255]
241 241
242 242 hg status ignoreddir/file:
243 243
244 244 $ hg status ignoreddir/file
245 245
246 246 hg status -i ignoreddir/file:
247 247
248 248 $ hg status -i ignoreddir/file
249 249 I ignoreddir/file
250 250 $ cd ..
251 251
252 252 Check 'status -q' and some combinations
253 253
254 254 $ hg init repo3
255 255 $ cd repo3
256 256 $ touch modified removed deleted ignored
257 257 $ echo "^ignored$" > .hgignore
258 258 $ hg commit -A -m 'initial checkin'
259 259 adding .hgignore
260 260 adding deleted
261 261 adding modified
262 262 adding removed
263 263 $ touch added unknown ignored
264 264 $ hg add added
265 265 $ echo "test" >> modified
266 266 $ hg remove removed
267 267 $ rm deleted
268 268 $ hg copy modified copied
269 269
270 270 Specify working directory revision explicitly, that should be the same as
271 271 "hg status"
272 272
273 273 $ hg status --change "wdir()"
274 274 M modified
275 275 A added
276 276 A copied
277 277 R removed
278 278 ! deleted
279 279 ? unknown
280 280
281 281 Run status with 2 different flags.
282 282 Check if result is the same or different.
283 283 If result is not as expected, raise error
284 284
285 285 $ assert() {
286 286 > hg status $1 > ../a
287 287 > hg status $2 > ../b
288 288 > if diff ../a ../b > /dev/null; then
289 289 > out=0
290 290 > else
291 291 > out=1
292 292 > fi
293 293 > if [ $3 -eq 0 ]; then
294 294 > df="same"
295 295 > else
296 296 > df="different"
297 297 > fi
298 298 > if [ $out -ne $3 ]; then
299 299 > echo "Error on $1 and $2, should be $df."
300 300 > fi
301 301 > }
302 302
303 303 Assert flag1 flag2 [0-same | 1-different]
304 304
305 305 $ assert "-q" "-mard" 0
306 306 $ assert "-A" "-marduicC" 0
307 307 $ assert "-qA" "-mardcC" 0
308 308 $ assert "-qAui" "-A" 0
309 309 $ assert "-qAu" "-marducC" 0
310 310 $ assert "-qAi" "-mardicC" 0
311 311 $ assert "-qu" "-u" 0
312 312 $ assert "-q" "-u" 1
313 313 $ assert "-m" "-a" 1
314 314 $ assert "-r" "-d" 1
315 315 $ cd ..
316 316
317 317 $ hg init repo4
318 318 $ cd repo4
319 319 $ touch modified removed deleted
320 320 $ hg ci -q -A -m 'initial checkin'
321 321 $ touch added unknown
322 322 $ hg add added
323 323 $ hg remove removed
324 324 $ rm deleted
325 325 $ echo x > modified
326 326 $ hg copy modified copied
327 327 $ hg ci -m 'test checkin' -d "1000001 0"
328 328 $ rm *
329 329 $ touch unrelated
330 330 $ hg ci -q -A -m 'unrelated checkin' -d "1000002 0"
331 331
332 332 hg status --change 1:
333 333
334 334 $ hg status --change 1
335 335 M modified
336 336 A added
337 337 A copied
338 338 R removed
339 339
340 340 hg status --change 1 unrelated:
341 341
342 342 $ hg status --change 1 unrelated
343 343
344 344 hg status -C --change 1 added modified copied removed deleted:
345 345
346 346 $ hg status -C --change 1 added modified copied removed deleted
347 347 M modified
348 348 A added
349 349 A copied
350 350 modified
351 351 R removed
352 352
353 353 hg status -A --change 1 and revset:
354 354
355 355 $ hg status -A --change '1|1'
356 356 M modified
357 357 A added
358 358 A copied
359 359 modified
360 360 R removed
361 361 C deleted
362 362
363 363 $ cd ..
364 364
365 365 hg status with --rev and reverted changes:
366 366
367 367 $ hg init reverted-changes-repo
368 368 $ cd reverted-changes-repo
369 369 $ echo a > file
370 370 $ hg add file
371 371 $ hg ci -m a
372 372 $ echo b > file
373 373 $ hg ci -m b
374 374
375 375 reverted file should appear clean
376 376
377 377 $ hg revert -r 0 .
378 378 reverting file
379 379 $ hg status -A --rev 0
380 380 C file
381 381
382 382 #if execbit
383 383 reverted file with changed flag should appear modified
384 384
385 385 $ chmod +x file
386 386 $ hg status -A --rev 0
387 387 M file
388 388
389 389 $ hg revert -r 0 .
390 390 reverting file
391 391
392 392 reverted and committed file with changed flag should appear modified
393 393
394 394 $ hg co -C .
395 395 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
396 396 $ chmod +x file
397 397 $ hg ci -m 'change flag'
398 398 $ hg status -A --rev 1 --rev 2
399 399 M file
400 400 $ hg diff -r 1 -r 2
401 401
402 402 #endif
403 403
404 404 hg status of binary file starting with '\1\n', a separator for metadata:
405 405
406 406 $ hg init repo5
407 407 $ cd repo5
408 408 >>> open("010a", "wb").write("\1\nfoo")
409 409 $ hg ci -q -A -m 'initial checkin'
410 410 $ hg status -A
411 411 C 010a
412 412
413 413 >>> open("010a", "wb").write("\1\nbar")
414 414 $ hg status -A
415 415 M 010a
416 416 $ hg ci -q -m 'modify 010a'
417 417 $ hg status -A --rev 0:1
418 418 M 010a
419 419
420 420 $ touch empty
421 421 $ hg ci -q -A -m 'add another file'
422 422 $ hg status -A --rev 1:2 010a
423 423 C 010a
424 424
425 425 $ cd ..
426 426
427 427 test "hg status" with "directory pattern" which matches against files
428 428 only known on target revision.
429 429
430 430 $ hg init repo6
431 431 $ cd repo6
432 432
433 433 $ echo a > a.txt
434 434 $ hg add a.txt
435 435 $ hg commit -m '#0'
436 436 $ mkdir -p 1/2/3/4/5
437 437 $ echo b > 1/2/3/4/5/b.txt
438 438 $ hg add 1/2/3/4/5/b.txt
439 439 $ hg commit -m '#1'
440 440
441 441 $ hg update -C 0 > /dev/null
442 442 $ hg status -A
443 443 C a.txt
444 444
445 445 the directory matching against specified pattern should be removed,
446 446 because directory existence prevents 'dirstate.walk()' from showing
447 447 warning message about such pattern.
448 448
449 449 $ test ! -d 1
450 450 $ hg status -A --rev 1 1/2/3/4/5/b.txt
451 451 R 1/2/3/4/5/b.txt
452 452 $ hg status -A --rev 1 1/2/3/4/5
453 453 R 1/2/3/4/5/b.txt
454 454 $ hg status -A --rev 1 1/2/3
455 455 R 1/2/3/4/5/b.txt
456 456 $ hg status -A --rev 1 1
457 457 R 1/2/3/4/5/b.txt
458 458
459 459 $ hg status --config ui.formatdebug=True --rev 1 1
460 460 status = [
461 461 {*'path': '1/2/3/4/5/b.txt'*}, (glob)
462 462 ]
463 463
464 464 #if windows
465 465 $ hg --config ui.slash=false status -A --rev 1 1
466 466 R 1\2\3\4\5\b.txt
467 467 #endif
468 468
469 469 $ cd ..
470 470
471 471 Status after move overwriting a file (issue4458)
472 472 =================================================
473 473
474 474
475 475 $ hg init issue4458
476 476 $ cd issue4458
477 477 $ echo a > a
478 478 $ echo b > b
479 479 $ hg commit -Am base
480 480 adding a
481 481 adding b
482 482
483 483
484 484 with --force
485 485
486 486 $ hg mv b --force a
487 487 $ hg st --copies
488 488 M a
489 489 b
490 490 R b
491 491 $ hg revert --all
492 492 reverting a
493 493 undeleting b
494 494 $ rm *.orig
495 495
496 496 without force
497 497
498 498 $ hg rm a
499 499 $ hg st --copies
500 500 R a
501 501 $ hg mv b a
502 502 $ hg st --copies
503 503 M a
504 504 b
505 505 R b
506 506
507 507 using ui.statuscopies setting
508 508 $ hg st --config ui.statuscopies=true
509 509 M a
510 510 b
511 511 R b
512 512 $ hg st --config ui.statuscopies=false
513 513 M a
514 514 R b
515 515
516 using log status template (issue5155)
517 $ hg log -Tstatus -r 'wdir()' -C
518 changeset: 2147483647:ffffffffffff
519 parent: 0:8c55c58b4c0e
520 user: test
521 date: * (glob)
522 files:
523 M a
524 b
525 R b
526
527
516 528 Other "bug" highlight, the revision status does not report the copy information.
517 529 This is buggy behavior.
518 530
519 531 $ hg commit -m 'blah'
520 532 $ hg st --copies --change .
521 533 M a
522 534 R b
523 535
536 using log status template, the copy information is displayed correctly.
537 $ hg log -Tstatus -r. -C
538 changeset: 1:6685fde43d21
539 tag: tip
540 user: test
541 date: * (glob)
542 summary: blah
543 files:
544 M a
545 b
546 R b
547
548
524 549 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now