##// END OF EJS Templates
tests: don't use dates before epoch in test-keyword.t...
Mads Kiilerich -
r17098:09305d77 default
parent child Browse files
Show More
@@ -1,1133 +1,1133 b''
1 1 $ "$TESTDIR/hghave" unix-permissions serve || exit 80
2 2
3 3 $ cat <<EOF >> $HGRCPATH
4 4 > [extensions]
5 5 > keyword =
6 6 > mq =
7 7 > notify =
8 8 > record =
9 9 > transplant =
10 10 > [ui]
11 11 > interactive = true
12 12 > EOF
13 13
14 14 hide outer repo
15 15 $ hg init
16 16
17 17 Run kwdemo before [keyword] files are set up
18 18 as it would succeed without uisetup otherwise
19 19
20 20 $ hg --quiet kwdemo
21 21 [extensions]
22 22 keyword =
23 23 [keyword]
24 24 demo.txt =
25 25 [keywordset]
26 26 svn = False
27 27 [keywordmaps]
28 28 Author = {author|user}
29 29 Date = {date|utcdate}
30 30 Header = {root}/{file},v {node|short} {date|utcdate} {author|user}
31 31 Id = {file|basename},v {node|short} {date|utcdate} {author|user}
32 32 RCSFile = {file|basename},v
33 33 RCSfile = {file|basename},v
34 34 Revision = {node|short}
35 35 Source = {root}/{file},v
36 36 $Author: test $
37 37 $Date: ????/??/?? ??:??:?? $ (glob)
38 38 $Header: */demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob)
39 39 $Id: demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob)
40 40 $RCSFile: demo.txt,v $
41 41 $RCSfile: demo.txt,v $
42 42 $Revision: ???????????? $ (glob)
43 43 $Source: */demo.txt,v $ (glob)
44 44
45 45 $ hg --quiet kwdemo "Branch = {branches}"
46 46 [extensions]
47 47 keyword =
48 48 [keyword]
49 49 demo.txt =
50 50 [keywordset]
51 51 svn = False
52 52 [keywordmaps]
53 53 Branch = {branches}
54 54 $Branch: demobranch $
55 55
56 56 $ cat <<EOF >> $HGRCPATH
57 57 > [keyword]
58 58 > ** =
59 59 > b = ignore
60 60 > i = ignore
61 61 > [hooks]
62 62 > EOF
63 63 $ cp $HGRCPATH $HGRCPATH.nohooks
64 64 > cat <<EOF >> $HGRCPATH
65 65 > commit=
66 66 > commit.test=cp a hooktest
67 67 > EOF
68 68
69 69 $ hg init Test-bndl
70 70 $ cd Test-bndl
71 71
72 72 kwshrink should exit silently in empty/invalid repo
73 73
74 74 $ hg kwshrink
75 75
76 76 Symlinks cannot be created on Windows.
77 77 A bundle to test this was made with:
78 78 hg init t
79 79 cd t
80 80 echo a > a
81 81 ln -s a sym
82 82 hg add sym
83 83 hg ci -m addsym -u mercurial
84 84 hg bundle --base null ../test-keyword.hg
85 85
86 86 $ hg pull -u "$TESTDIR"/bundles/test-keyword.hg
87 87 pulling from *test-keyword.hg (glob)
88 88 requesting all changes
89 89 adding changesets
90 90 adding manifests
91 91 adding file changes
92 92 added 1 changesets with 1 changes to 1 files
93 93 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
94 94
95 95 $ echo 'expand $Id$' > a
96 96 $ echo 'do not process $Id:' >> a
97 97 $ echo 'xxx $' >> a
98 98 $ echo 'ignore $Id$' > b
99 99
100 100 Output files as they were created
101 101
102 102 $ cat a b
103 103 expand $Id$
104 104 do not process $Id:
105 105 xxx $
106 106 ignore $Id$
107 107
108 108 no kwfiles
109 109
110 110 $ hg kwfiles
111 111
112 112 untracked candidates
113 113
114 114 $ hg -v kwfiles --unknown
115 115 k a
116 116
117 117 Add files and check status
118 118
119 119 $ hg addremove
120 120 adding a
121 121 adding b
122 122 $ hg status
123 123 A a
124 124 A b
125 125
126 126
127 127 Default keyword expansion including commit hook
128 128 Interrupted commit should not change state or run commit hook
129 129
130 130 $ hg --debug commit
131 131 abort: empty commit message
132 132 [255]
133 133 $ hg status
134 134 A a
135 135 A b
136 136
137 137 Commit with several checks
138 138
139 139 $ hg --debug commit -mabsym -u 'User Name <user@example.com>'
140 140 a
141 141 b
142 142 overwriting a expanding keywords
143 143 running hook commit.test: cp a hooktest
144 144 committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
145 145 $ hg status
146 146 ? hooktest
147 147 $ hg debugrebuildstate
148 148 $ hg --quiet identify
149 149 ef63ca68695b
150 150
151 151 cat files in working directory with keywords expanded
152 152
153 153 $ cat a b
154 154 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
155 155 do not process $Id:
156 156 xxx $
157 157 ignore $Id$
158 158
159 159 hg cat files and symlink, no expansion
160 160
161 161 $ hg cat sym a b && echo
162 162 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
163 163 do not process $Id:
164 164 xxx $
165 165 ignore $Id$
166 166 a
167 167
168 168 $ diff a hooktest
169 169
170 170 $ cp $HGRCPATH.nohooks $HGRCPATH
171 171 $ rm hooktest
172 172
173 173 hg status of kw-ignored binary file starting with '\1\n'
174 174
175 175 >>> open("i", "wb").write("\1\nfoo")
176 176 $ hg -q commit -Am metasep i
177 177 $ hg status
178 178 >>> open("i", "wb").write("\1\nbar")
179 179 $ hg status
180 180 M i
181 181 $ hg -q commit -m "modify metasep" i
182 182 $ hg status --rev 2:3
183 183 M i
184 184 $ touch empty
185 185 $ hg -q commit -A -m "another file"
186 186 $ hg status -A --rev 3:4 i
187 187 C i
188 188
189 189 $ hg -q strip -n 2
190 190
191 191 Test hook execution
192 192
193 193 bundle
194 194
195 195 $ hg bundle --base null ../kw.hg
196 196 2 changesets found
197 197 $ cd ..
198 198 $ hg init Test
199 199 $ cd Test
200 200
201 201 Notify on pull to check whether keywords stay as is in email
202 202 ie. if patch.diff wrapper acts as it should
203 203
204 204 $ cat <<EOF >> $HGRCPATH
205 205 > [hooks]
206 206 > incoming.notify = python:hgext.notify.hook
207 207 > [notify]
208 208 > sources = pull
209 209 > diffstat = False
210 210 > maxsubject = 15
211 211 > [reposubs]
212 212 > * = Test
213 213 > EOF
214 214
215 215 Pull from bundle and trigger notify
216 216
217 217 $ hg pull -u ../kw.hg
218 218 pulling from ../kw.hg
219 219 requesting all changes
220 220 adding changesets
221 221 adding manifests
222 222 adding file changes
223 223 added 2 changesets with 3 changes to 3 files
224 224 Content-Type: text/plain; charset="us-ascii"
225 225 MIME-Version: 1.0
226 226 Content-Transfer-Encoding: 7bit
227 227 Date: * (glob)
228 228 Subject: changeset in...
229 229 From: mercurial
230 230 X-Hg-Notification: changeset a2392c293916
231 231 Message-Id: <hg.a2392c293916*> (glob)
232 232 To: Test
233 233
234 234 changeset a2392c293916 in $TESTTMP/Test (glob)
235 235 details: $TESTTMP/Test?cmd=changeset;node=a2392c293916
236 236 description:
237 237 addsym
238 238
239 239 diffs (6 lines):
240 240
241 241 diff -r 000000000000 -r a2392c293916 sym
242 242 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
243 243 +++ b/sym Sat Feb 09 20:25:47 2008 +0100
244 244 @@ -0,0 +1,1 @@
245 245 +a
246 246 \ No newline at end of file
247 247 Content-Type: text/plain; charset="us-ascii"
248 248 MIME-Version: 1.0
249 249 Content-Transfer-Encoding: 7bit
250 250 Date:* (glob)
251 251 Subject: changeset in...
252 252 From: User Name <user@example.com>
253 253 X-Hg-Notification: changeset ef63ca68695b
254 254 Message-Id: <hg.ef63ca68695b*> (glob)
255 255 To: Test
256 256
257 257 changeset ef63ca68695b in $TESTTMP/Test (glob)
258 258 details: $TESTTMP/Test?cmd=changeset;node=ef63ca68695b
259 259 description:
260 260 absym
261 261
262 262 diffs (12 lines):
263 263
264 264 diff -r a2392c293916 -r ef63ca68695b a
265 265 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
266 266 +++ b/a Thu Jan 01 00:00:00 1970 +0000
267 267 @@ -0,0 +1,3 @@
268 268 +expand $Id$
269 269 +do not process $Id:
270 270 +xxx $
271 271 diff -r a2392c293916 -r ef63ca68695b b
272 272 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
273 273 +++ b/b Thu Jan 01 00:00:00 1970 +0000
274 274 @@ -0,0 +1,1 @@
275 275 +ignore $Id$
276 276 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
277 277
278 278 $ cp $HGRCPATH.nohooks $HGRCPATH
279 279
280 280 Touch files and check with status
281 281
282 282 $ touch a b
283 283 $ hg status
284 284
285 285 Update and expand
286 286
287 287 $ rm sym a b
288 288 $ hg update -C
289 289 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
290 290 $ cat a b
291 291 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
292 292 do not process $Id:
293 293 xxx $
294 294 ignore $Id$
295 295
296 296 Check whether expansion is filewise and file mode is preserved
297 297
298 298 $ echo '$Id$' > c
299 299 $ echo 'tests for different changenodes' >> c
300 300 $ chmod 600 c
301 301 $ ls -l c | cut -b 1-10
302 302 -rw-------
303 303
304 304 commit file c
305 305
306 306 $ hg commit -A -mcndiff -d '1 0' -u 'User Name <user@example.com>'
307 307 adding c
308 308 $ ls -l c | cut -b 1-10
309 309 -rw-------
310 310
311 311 force expansion
312 312
313 313 $ hg -v kwexpand
314 314 overwriting a expanding keywords
315 315 overwriting c expanding keywords
316 316
317 317 compare changenodes in a and c
318 318
319 319 $ cat a c
320 320 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
321 321 do not process $Id:
322 322 xxx $
323 323 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
324 324 tests for different changenodes
325 325
326 326 record
327 327
328 328 $ echo '$Id$' > r
329 329 $ hg add r
330 330
331 331 record chunk
332 332
333 333 >>> lines = open('a').readlines()
334 334 >>> lines.insert(1, 'foo\n')
335 335 >>> lines.append('bar\n')
336 336 >>> open('a', 'w').writelines(lines)
337 $ hg record -d '1 10' -m rectest a<<EOF
337 $ hg record -d '10 1' -m rectest a<<EOF
338 338 > y
339 339 > y
340 340 > n
341 341 > EOF
342 342 diff --git a/a b/a
343 343 2 hunks, 2 lines changed
344 344 examine changes to 'a'? [Ynesfdaq?]
345 345 @@ -1,3 +1,4 @@
346 346 expand $Id$
347 347 +foo
348 348 do not process $Id:
349 349 xxx $
350 350 record change 1/2 to 'a'? [Ynesfdaq?]
351 351 @@ -2,2 +3,3 @@
352 352 do not process $Id:
353 353 xxx $
354 354 +bar
355 355 record change 2/2 to 'a'? [Ynesfdaq?]
356 356
357 357 $ hg identify
358 d17e03c92c97+ tip
358 5f5eb23505c3+ tip
359 359 $ hg status
360 360 M a
361 361 A r
362 362
363 363 Cat modified file a
364 364
365 365 $ cat a
366 expand $Id: a,v d17e03c92c97 1970/01/01 00:00:01 test $
366 expand $Id: a,v 5f5eb23505c3 1970/01/01 00:00:10 test $
367 367 foo
368 368 do not process $Id:
369 369 xxx $
370 370 bar
371 371
372 372 Diff remaining chunk
373 373
374 374 $ hg diff a
375 diff -r d17e03c92c97 a
376 --- a/a Wed Dec 31 23:59:51 1969 -0000
375 diff -r 5f5eb23505c3 a
376 --- a/a Thu Jan 01 00:00:09 1970 -0000
377 377 +++ b/a * (glob)
378 378 @@ -2,3 +2,4 @@
379 379 foo
380 380 do not process $Id:
381 381 xxx $
382 382 +bar
383 383
384 384 $ hg rollback
385 385 repository tip rolled back to revision 2 (undo commit)
386 386 working directory now based on revision 2
387 387
388 388 Record all chunks in file a
389 389
390 390 $ echo foo > msg
391 391
392 392 - do not use "hg record -m" here!
393 393
394 394 $ hg record -l msg -d '1 11' a<<EOF
395 395 > y
396 396 > y
397 397 > y
398 398 > EOF
399 399 diff --git a/a b/a
400 400 2 hunks, 2 lines changed
401 401 examine changes to 'a'? [Ynesfdaq?]
402 402 @@ -1,3 +1,4 @@
403 403 expand $Id$
404 404 +foo
405 405 do not process $Id:
406 406 xxx $
407 407 record change 1/2 to 'a'? [Ynesfdaq?]
408 408 @@ -2,2 +3,3 @@
409 409 do not process $Id:
410 410 xxx $
411 411 +bar
412 412 record change 2/2 to 'a'? [Ynesfdaq?]
413 413
414 414 File a should be clean
415 415
416 416 $ hg status -A a
417 417 C a
418 418
419 419 rollback and revert expansion
420 420
421 421 $ cat a
422 expand $Id: a,v 59f969a3b52c 1970/01/01 00:00:01 test $
422 expand $Id: a,v 78e0a02d76aa 1970/01/01 00:00:11 test $
423 423 foo
424 424 do not process $Id:
425 425 xxx $
426 426 bar
427 427 $ hg --verbose rollback
428 428 repository tip rolled back to revision 2 (undo commit)
429 429 working directory now based on revision 2
430 430 overwriting a expanding keywords
431 431 $ hg status a
432 432 M a
433 433 $ cat a
434 434 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
435 435 foo
436 436 do not process $Id:
437 437 xxx $
438 438 bar
439 439 $ echo '$Id$' > y
440 440 $ echo '$Id$' > z
441 441 $ hg add y
442 442 $ hg commit -Am "rollback only" z
443 443 $ cat z
444 444 $Id: z,v 45a5d3adce53 1970/01/01 00:00:00 test $
445 445 $ hg --verbose rollback
446 446 repository tip rolled back to revision 2 (undo commit)
447 447 working directory now based on revision 2
448 448 overwriting z shrinking keywords
449 449
450 450 Only z should be overwritten
451 451
452 452 $ hg status a y z
453 453 M a
454 454 A y
455 455 A z
456 456 $ cat z
457 457 $Id$
458 458 $ hg forget y z
459 459 $ rm y z
460 460
461 461 record added file alone
462 462
463 $ hg -v record -l msg -d '1 12' r<<EOF
463 $ hg -v record -l msg -d '12 2' r<<EOF
464 464 > y
465 465 > EOF
466 466 diff --git a/r b/r
467 467 new file mode 100644
468 468 examine changes to 'r'? [Ynesfdaq?]
469 469 r
470 committed changeset 3:899491280810
470 committed changeset 3:82a2f715724d
471 471 overwriting r expanding keywords
472 472 - status call required for dirstate.normallookup() check
473 473 $ hg status r
474 474 $ hg --verbose rollback
475 475 repository tip rolled back to revision 2 (undo commit)
476 476 working directory now based on revision 2
477 477 overwriting r shrinking keywords
478 478 $ hg forget r
479 479 $ rm msg r
480 480 $ hg update -C
481 481 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
482 482
483 483 record added keyword ignored file
484 484
485 485 $ echo '$Id$' > i
486 486 $ hg add i
487 $ hg --verbose record -d '1 13' -m recignored<<EOF
487 $ hg --verbose record -d '13 1' -m recignored<<EOF
488 488 > y
489 489 > EOF
490 490 diff --git a/i b/i
491 491 new file mode 100644
492 492 examine changes to 'i'? [Ynesfdaq?]
493 493 i
494 committed changeset 3:5f40fe93bbdc
494 committed changeset 3:9f40ceb5a072
495 495 $ cat i
496 496 $Id$
497 497 $ hg -q rollback
498 498 $ hg forget i
499 499 $ rm i
500 500
501 501 amend
502 502
503 503 $ echo amend >> a
504 504 $ echo amend >> b
505 $ hg -q commit -d '1 14' -m 'prepare amend'
505 $ hg -q commit -d '14 1' -m 'prepare amend'
506 506
507 $ hg --debug commit --amend -d '1 15' -m 'amend without changes' | grep keywords
507 $ hg --debug commit --amend -d '15 1' -m 'amend without changes' | grep keywords
508 508 overwriting a expanding keywords
509 509 $ hg -q id
510 a71343332ea9
510 577e60613a88
511 511 $ head -1 a
512 expand $Id: a,v a71343332ea9 1970/01/01 00:00:01 test $
512 expand $Id: a,v 577e60613a88 1970/01/01 00:00:15 test $
513 513
514 514 $ hg -q strip -n tip
515 515
516 516 Test patch queue repo
517 517
518 518 $ hg init --mq
519 519 $ hg qimport -r tip -n mqtest.diff
520 520 $ hg commit --mq -m mqtest
521 521
522 522 Keywords should not be expanded in patch
523 523
524 524 $ cat .hg/patches/mqtest.diff
525 525 # HG changeset patch
526 526 # User User Name <user@example.com>
527 527 # Date 1 0
528 528 # Node ID 40a904bbbe4cd4ab0a1f28411e35db26341a40ad
529 529 # Parent ef63ca68695bc9495032c6fda1350c71e6d256e9
530 530 cndiff
531 531
532 532 diff -r ef63ca68695b -r 40a904bbbe4c c
533 533 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
534 534 +++ b/c Thu Jan 01 00:00:01 1970 +0000
535 535 @@ -0,0 +1,2 @@
536 536 +$Id$
537 537 +tests for different changenodes
538 538
539 539 $ hg qpop
540 540 popping mqtest.diff
541 541 patch queue now empty
542 542
543 543 qgoto, implying qpush, should expand
544 544
545 545 $ hg qgoto mqtest.diff
546 546 applying mqtest.diff
547 547 now at: mqtest.diff
548 548 $ cat c
549 549 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
550 550 tests for different changenodes
551 551 $ hg cat c
552 552 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
553 553 tests for different changenodes
554 554
555 555 Keywords should not be expanded in filelog
556 556
557 557 $ hg --config 'extensions.keyword=!' cat c
558 558 $Id$
559 559 tests for different changenodes
560 560
561 561 qpop and move on
562 562
563 563 $ hg qpop
564 564 popping mqtest.diff
565 565 patch queue now empty
566 566
567 567 Copy and show added kwfiles
568 568
569 569 $ hg cp a c
570 570 $ hg kwfiles
571 571 a
572 572 c
573 573
574 574 Commit and show expansion in original and copy
575 575
576 576 $ hg --debug commit -ma2c -d '1 0' -u 'User Name <user@example.com>'
577 577 c
578 578 c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
579 579 removing unknown node 40a904bbbe4c from 1-phase boundary
580 580 overwriting c expanding keywords
581 581 committed changeset 2:25736cf2f5cbe41f6be4e6784ef6ecf9f3bbcc7d
582 582 $ cat a c
583 583 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
584 584 do not process $Id:
585 585 xxx $
586 586 expand $Id: c,v 25736cf2f5cb 1970/01/01 00:00:01 user $
587 587 do not process $Id:
588 588 xxx $
589 589
590 590 Touch copied c and check its status
591 591
592 592 $ touch c
593 593 $ hg status
594 594
595 595 Copy kwfile to keyword ignored file unexpanding keywords
596 596
597 597 $ hg --verbose copy a i
598 598 copying a to i
599 599 overwriting i shrinking keywords
600 600 $ head -n 1 i
601 601 expand $Id$
602 602 $ hg forget i
603 603 $ rm i
604 604
605 605 Copy ignored file to ignored file: no overwriting
606 606
607 607 $ hg --verbose copy b i
608 608 copying b to i
609 609 $ hg forget i
610 610 $ rm i
611 611
612 612 cp symlink file; hg cp -A symlink file (part1)
613 613 - copied symlink points to kwfile: overwrite
614 614
615 615 $ cp sym i
616 616 $ ls -l i
617 617 -rw-r--r--* (glob)
618 618 $ head -1 i
619 619 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
620 620 $ hg copy --after --verbose sym i
621 621 copying sym to i
622 622 overwriting i shrinking keywords
623 623 $ head -1 i
624 624 expand $Id$
625 625 $ hg forget i
626 626 $ rm i
627 627
628 628 Test different options of hg kwfiles
629 629
630 630 $ hg kwfiles
631 631 a
632 632 c
633 633 $ hg -v kwfiles --ignore
634 634 I b
635 635 I sym
636 636 $ hg kwfiles --all
637 637 K a
638 638 K c
639 639 I b
640 640 I sym
641 641
642 642 Diff specific revision
643 643
644 644 $ hg diff --rev 1
645 645 diff -r ef63ca68695b c
646 646 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
647 647 +++ b/c * (glob)
648 648 @@ -0,0 +1,3 @@
649 649 +expand $Id$
650 650 +do not process $Id:
651 651 +xxx $
652 652
653 653 Status after rollback:
654 654
655 655 $ hg rollback
656 656 repository tip rolled back to revision 1 (undo commit)
657 657 working directory now based on revision 1
658 658 $ hg status
659 659 A c
660 660 $ hg update --clean
661 661 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
662 662
663 663 #if symlink
664 664
665 665 cp symlink file; hg cp -A symlink file (part2)
666 666 - copied symlink points to kw ignored file: do not overwrite
667 667
668 668 $ cat a > i
669 669 $ ln -s i symignored
670 670 $ hg commit -Am 'fake expansion in ignored and symlink' i symignored
671 671 $ cp symignored x
672 672 $ hg copy --after --verbose symignored x
673 673 copying symignored to x
674 674 $ head -n 1 x
675 675 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
676 676 $ hg forget x
677 677 $ rm x
678 678
679 679 $ hg rollback
680 680 repository tip rolled back to revision 1 (undo commit)
681 681 working directory now based on revision 1
682 682 $ hg update --clean
683 683 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
684 684 $ rm i symignored
685 685
686 686 #endif
687 687
688 688 Custom keywordmaps as argument to kwdemo
689 689
690 690 $ hg --quiet kwdemo "Xinfo = {author}: {desc}"
691 691 [extensions]
692 692 keyword =
693 693 [keyword]
694 694 ** =
695 695 b = ignore
696 696 demo.txt =
697 697 i = ignore
698 698 [keywordset]
699 699 svn = False
700 700 [keywordmaps]
701 701 Xinfo = {author}: {desc}
702 702 $Xinfo: test: hg keyword configuration and expansion example $
703 703
704 704 Configure custom keywordmaps
705 705
706 706 $ cat <<EOF >>$HGRCPATH
707 707 > [keywordmaps]
708 708 > Id = {file} {node|short} {date|rfc822date} {author|user}
709 709 > Xinfo = {author}: {desc}
710 710 > EOF
711 711
712 712 Cat and hg cat files before custom expansion
713 713
714 714 $ cat a b
715 715 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
716 716 do not process $Id:
717 717 xxx $
718 718 ignore $Id$
719 719 $ hg cat sym a b && echo
720 720 expand $Id: a ef63ca68695b Thu, 01 Jan 1970 00:00:00 +0000 user $
721 721 do not process $Id:
722 722 xxx $
723 723 ignore $Id$
724 724 a
725 725
726 726 Write custom keyword and prepare multiline commit message
727 727
728 728 $ echo '$Xinfo$' >> a
729 729 $ cat <<EOF >> log
730 730 > firstline
731 731 > secondline
732 732 > EOF
733 733
734 734 Interrupted commit should not change state
735 735
736 736 $ hg commit
737 737 abort: empty commit message
738 738 [255]
739 739 $ hg status
740 740 M a
741 741 ? c
742 742 ? log
743 743
744 744 Commit with multiline message and custom expansion
745 745
746 746 $ hg --debug commit -l log -d '2 0' -u 'User Name <user@example.com>'
747 747 a
748 748 removing unknown node 40a904bbbe4c from 1-phase boundary
749 749 overwriting a expanding keywords
750 750 committed changeset 2:bb948857c743469b22bbf51f7ec8112279ca5d83
751 751 $ rm log
752 752
753 753 Stat, verify and show custom expansion (firstline)
754 754
755 755 $ hg status
756 756 ? c
757 757 $ hg verify
758 758 checking changesets
759 759 checking manifests
760 760 crosschecking files in changesets and manifests
761 761 checking files
762 762 3 files, 3 changesets, 4 total revisions
763 763 $ cat a b
764 764 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
765 765 do not process $Id:
766 766 xxx $
767 767 $Xinfo: User Name <user@example.com>: firstline $
768 768 ignore $Id$
769 769 $ hg cat sym a b && echo
770 770 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
771 771 do not process $Id:
772 772 xxx $
773 773 $Xinfo: User Name <user@example.com>: firstline $
774 774 ignore $Id$
775 775 a
776 776
777 777 annotate
778 778
779 779 $ hg annotate a
780 780 1: expand $Id$
781 781 1: do not process $Id:
782 782 1: xxx $
783 783 2: $Xinfo$
784 784
785 785 remove with status checks
786 786
787 787 $ hg debugrebuildstate
788 788 $ hg remove a
789 789 $ hg --debug commit -m rma
790 790 committed changeset 3:d14c712653769de926994cf7fbb06c8fbd68f012
791 791 $ hg status
792 792 ? c
793 793
794 794 Rollback, revert, and check expansion
795 795
796 796 $ hg rollback
797 797 repository tip rolled back to revision 2 (undo commit)
798 798 working directory now based on revision 2
799 799 $ hg status
800 800 R a
801 801 ? c
802 802 $ hg revert --no-backup --rev tip a
803 803 $ cat a
804 804 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
805 805 do not process $Id:
806 806 xxx $
807 807 $Xinfo: User Name <user@example.com>: firstline $
808 808
809 809 Clone to test global and local configurations
810 810
811 811 $ cd ..
812 812
813 813 Expansion in destinaton with global configuration
814 814
815 815 $ hg --quiet clone Test globalconf
816 816 $ cat globalconf/a
817 817 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
818 818 do not process $Id:
819 819 xxx $
820 820 $Xinfo: User Name <user@example.com>: firstline $
821 821
822 822 No expansion in destination with local configuration in origin only
823 823
824 824 $ hg --quiet --config 'keyword.**=ignore' clone Test localconf
825 825 $ cat localconf/a
826 826 expand $Id$
827 827 do not process $Id:
828 828 xxx $
829 829 $Xinfo$
830 830
831 831 Clone to test incoming
832 832
833 833 $ hg clone -r1 Test Test-a
834 834 adding changesets
835 835 adding manifests
836 836 adding file changes
837 837 added 2 changesets with 3 changes to 3 files
838 838 updating to branch default
839 839 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
840 840 $ cd Test-a
841 841 $ cat <<EOF >> .hg/hgrc
842 842 > [paths]
843 843 > default = ../Test
844 844 > EOF
845 845 $ hg incoming
846 846 comparing with $TESTTMP/Test (glob)
847 847 searching for changes
848 848 changeset: 2:bb948857c743
849 849 tag: tip
850 850 user: User Name <user@example.com>
851 851 date: Thu Jan 01 00:00:02 1970 +0000
852 852 summary: firstline
853 853
854 854 Imported patch should not be rejected
855 855
856 856 >>> import re
857 857 >>> text = re.sub(r'(Id.*)', r'\1 rejecttest', open('a').read())
858 858 >>> open('a', 'wb').write(text)
859 859 $ hg --debug commit -m'rejects?' -d '3 0' -u 'User Name <user@example.com>'
860 860 a
861 861 overwriting a expanding keywords
862 862 committed changeset 2:85e279d709ffc28c9fdd1b868570985fc3d87082
863 863 $ hg export -o ../rejecttest.diff tip
864 864 $ cd ../Test
865 865 $ hg import ../rejecttest.diff
866 866 applying ../rejecttest.diff
867 867 $ cat a b
868 868 expand $Id: a 4e0994474d25 Thu, 01 Jan 1970 00:00:03 +0000 user $ rejecttest
869 869 do not process $Id: rejecttest
870 870 xxx $
871 871 $Xinfo: User Name <user@example.com>: rejects? $
872 872 ignore $Id$
873 873
874 874 $ hg rollback
875 875 repository tip rolled back to revision 2 (undo import)
876 876 working directory now based on revision 2
877 877 $ hg update --clean
878 878 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
879 879
880 880 kwexpand/kwshrink on selected files
881 881
882 882 $ mkdir x
883 883 $ hg copy a x/a
884 884 $ hg --verbose kwshrink a
885 885 overwriting a shrinking keywords
886 886 - sleep required for dirstate.normal() check
887 887 $ sleep 1
888 888 $ hg status a
889 889 $ hg --verbose kwexpand a
890 890 overwriting a expanding keywords
891 891 $ hg status a
892 892
893 893 kwexpand x/a should abort
894 894
895 895 $ hg --verbose kwexpand x/a
896 896 abort: outstanding uncommitted changes
897 897 [255]
898 898 $ cd x
899 899 $ hg --debug commit -m xa -d '3 0' -u 'User Name <user@example.com>'
900 900 x/a
901 901 x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
902 902 overwriting x/a expanding keywords
903 903 committed changeset 3:b4560182a3f9a358179fd2d835c15e9da379c1e4
904 904 $ cat a
905 905 expand $Id: x/a b4560182a3f9 Thu, 01 Jan 1970 00:00:03 +0000 user $
906 906 do not process $Id:
907 907 xxx $
908 908 $Xinfo: User Name <user@example.com>: xa $
909 909
910 910 kwshrink a inside directory x
911 911
912 912 $ hg --verbose kwshrink a
913 913 overwriting x/a shrinking keywords
914 914 $ cat a
915 915 expand $Id$
916 916 do not process $Id:
917 917 xxx $
918 918 $Xinfo$
919 919 $ cd ..
920 920
921 921 kwexpand nonexistent
922 922
923 923 $ hg kwexpand nonexistent
924 924 nonexistent:* (glob)
925 925
926 926
927 927 hg serve
928 928 - expand with hgweb file
929 929 - no expansion with hgweb annotate/changeset/filediff
930 930 - check errors
931 931
932 932 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
933 933 $ cat hg.pid >> $DAEMON_PIDS
934 934 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'file/tip/a/?style=raw'
935 935 200 Script output follows
936 936
937 937 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
938 938 do not process $Id:
939 939 xxx $
940 940 $Xinfo: User Name <user@example.com>: firstline $
941 941 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'annotate/tip/a/?style=raw'
942 942 200 Script output follows
943 943
944 944
945 945 user@1: expand $Id$
946 946 user@1: do not process $Id:
947 947 user@1: xxx $
948 948 user@2: $Xinfo$
949 949
950 950
951 951
952 952
953 953 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'rev/tip/?style=raw'
954 954 200 Script output follows
955 955
956 956
957 957 # HG changeset patch
958 958 # User User Name <user@example.com>
959 959 # Date 3 0
960 960 # Node ID b4560182a3f9a358179fd2d835c15e9da379c1e4
961 961 # Parent bb948857c743469b22bbf51f7ec8112279ca5d83
962 962 xa
963 963
964 964 diff -r bb948857c743 -r b4560182a3f9 x/a
965 965 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
966 966 +++ b/x/a Thu Jan 01 00:00:03 1970 +0000
967 967 @@ -0,0 +1,4 @@
968 968 +expand $Id$
969 969 +do not process $Id:
970 970 +xxx $
971 971 +$Xinfo$
972 972
973 973 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'diff/bb948857c743/a?style=raw'
974 974 200 Script output follows
975 975
976 976
977 977 diff -r ef63ca68695b -r bb948857c743 a
978 978 --- a/a Thu Jan 01 00:00:00 1970 +0000
979 979 +++ b/a Thu Jan 01 00:00:02 1970 +0000
980 980 @@ -1,3 +1,4 @@
981 981 expand $Id$
982 982 do not process $Id:
983 983 xxx $
984 984 +$Xinfo$
985 985
986 986
987 987
988 988
989 989 $ cat errors.log
990 990
991 991 Prepare merge and resolve tests
992 992
993 993 $ echo '$Id$' > m
994 994 $ hg add m
995 995 $ hg commit -m 4kw
996 996 $ echo foo >> m
997 997 $ hg commit -m 5foo
998 998
999 999 simplemerge
1000 1000
1001 1001 $ hg update 4
1002 1002 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1003 1003 $ echo foo >> m
1004 1004 $ hg commit -m 6foo
1005 1005 created new head
1006 1006 $ hg merge
1007 1007 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1008 1008 (branch merge, don't forget to commit)
1009 1009 $ hg commit -m simplemerge
1010 1010 $ cat m
1011 1011 $Id: m 27d48ee14f67 Thu, 01 Jan 1970 00:00:00 +0000 test $
1012 1012 foo
1013 1013
1014 1014 conflict: keyword should stay outside conflict zone
1015 1015
1016 1016 $ hg update 4
1017 1017 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1018 1018 $ echo bar >> m
1019 1019 $ hg commit -m 8bar
1020 1020 created new head
1021 1021 $ hg merge
1022 1022 merging m
1023 1023 warning: conflicts during merge.
1024 1024 merging m incomplete! (edit conflicts, then use 'hg resolve --mark')
1025 1025 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1026 1026 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
1027 1027 [1]
1028 1028 $ cat m
1029 1029 $Id$
1030 1030 <<<<<<< local
1031 1031 bar
1032 1032 =======
1033 1033 foo
1034 1034 >>>>>>> other
1035 1035
1036 1036 resolve to local
1037 1037
1038 1038 $ HGMERGE=internal:local hg resolve -a
1039 1039 $ hg commit -m localresolve
1040 1040 $ cat m
1041 1041 $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
1042 1042 bar
1043 1043
1044 1044 Test restricted mode with transplant -b
1045 1045
1046 1046 $ hg update 6
1047 1047 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1048 1048 $ hg branch foo
1049 1049 marked working directory as branch foo
1050 1050 (branches are permanent and global, did you want a bookmark?)
1051 1051 $ mv a a.bak
1052 1052 $ echo foobranch > a
1053 1053 $ cat a.bak >> a
1054 1054 $ rm a.bak
1055 1055 $ hg commit -m 9foobranch
1056 1056 $ hg update default
1057 1057 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1058 1058 $ hg -y transplant -b foo tip
1059 1059 applying 4aa30d025d50
1060 1060 4aa30d025d50 transplanted to e00abbf63521
1061 1061
1062 1062 Expansion in changeset but not in file
1063 1063
1064 1064 $ hg tip -p
1065 1065 changeset: 11:e00abbf63521
1066 1066 tag: tip
1067 1067 parent: 9:800511b3a22d
1068 1068 user: test
1069 1069 date: Thu Jan 01 00:00:00 1970 +0000
1070 1070 summary: 9foobranch
1071 1071
1072 1072 diff -r 800511b3a22d -r e00abbf63521 a
1073 1073 --- a/a Thu Jan 01 00:00:00 1970 +0000
1074 1074 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1075 1075 @@ -1,3 +1,4 @@
1076 1076 +foobranch
1077 1077 expand $Id$
1078 1078 do not process $Id:
1079 1079 xxx $
1080 1080
1081 1081 $ head -n 2 a
1082 1082 foobranch
1083 1083 expand $Id: a e00abbf63521 Thu, 01 Jan 1970 00:00:00 +0000 test $
1084 1084
1085 1085 Turn off expansion
1086 1086
1087 1087 $ hg -q rollback
1088 1088 $ hg -q update -C
1089 1089
1090 1090 kwshrink with unknown file u
1091 1091
1092 1092 $ cp a u
1093 1093 $ hg --verbose kwshrink
1094 1094 overwriting a shrinking keywords
1095 1095 overwriting m shrinking keywords
1096 1096 overwriting x/a shrinking keywords
1097 1097
1098 1098 Keywords shrunk in working directory, but not yet disabled
1099 1099 - cat shows unexpanded keywords
1100 1100 - hg cat shows expanded keywords
1101 1101
1102 1102 $ cat a b
1103 1103 expand $Id$
1104 1104 do not process $Id:
1105 1105 xxx $
1106 1106 $Xinfo$
1107 1107 ignore $Id$
1108 1108 $ hg cat sym a b && echo
1109 1109 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
1110 1110 do not process $Id:
1111 1111 xxx $
1112 1112 $Xinfo: User Name <user@example.com>: firstline $
1113 1113 ignore $Id$
1114 1114 a
1115 1115
1116 1116 Now disable keyword expansion
1117 1117
1118 1118 $ rm "$HGRCPATH"
1119 1119 $ cat a b
1120 1120 expand $Id$
1121 1121 do not process $Id:
1122 1122 xxx $
1123 1123 $Xinfo$
1124 1124 ignore $Id$
1125 1125 $ hg cat sym a b && echo
1126 1126 expand $Id$
1127 1127 do not process $Id:
1128 1128 xxx $
1129 1129 $Xinfo$
1130 1130 ignore $Id$
1131 1131 a
1132 1132
1133 1133 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now