Debian Codegraph @

tests/test-hgweb-annotate-whitespace.t

raw
1 #require serve
2
3 Create a repo with whitespace only changes
4
5 $ hg init repo-with-whitespace
6 $ cd repo-with-whitespace
7 $ cat > foo << EOF
8 > line 0
9 > line 1
10 > line 2
11 > line 3
12 > EOF
13 $ hg -q commit -A -m 'commit 0'
14 $ cat > foo << EOF
15 > line 0
16 > line 1 modified by 1
17 > line 2
18 > line 3
19 > EOF
20 $ hg commit -m 'commit 1'
21 $ cat > foo << EOF
22 > line 0
23 > line 1 modified by 1
24 > line 2
25 > line 3
26 > EOF
27 $ hg commit -m 'commit 2 (leading whitespace on line 2)'
28 $ cat > foo << EOF
29 > line 0
30 > line 1 modified by 1
31 > line 2
32 > EOF
33 Need to use printf to avoid check-code complaining about trailing whitespace.
34 $ printf 'line 3 \n' >> foo
35 $ hg commit -m 'commit 3 (trailing whitespace on line 3)'
36 $ cat > foo << EOF
37 > line 0
38 > line 1 modified by 1
39 > line 2
40 > EOF
41 $ printf 'line 3 \n' >> foo
42 $ hg commit -m 'commit 4 (intra whitespace on line 0)'
43 $ cat > foo << EOF
44 > line 0
45 >
46 > line 1 modified by 1
47 > line 2
48 > EOF
49 $ printf 'line 3 \n' >> foo
50 $ hg commit -m 'commit 5 (add blank line between line 0 and 1)'
51 $ cat > foo << EOF
52 > line 0
53 >
54 >
55 > line 1 modified by 1
56 > line 2
57 > EOF
58 $ printf 'line 3 \n' >> foo
59 $ hg commit -m 'commit 6 (add another blank line between line 0 and 1)'
60
61 $ hg log -G -T '{rev}:{node|short} {desc}'
62 @ 6:9d1b2c7db017 commit 6 (add another blank line between line 0 and 1)
63 |
64 o 5:400ef1d40470 commit 5 (add blank line between line 0 and 1)
65 |
66 o 4:08adbe269f24 commit 4 (intra whitespace on line 0)
67 |
68 o 3:dcb62cfbfc9b commit 3 (trailing whitespace on line 3)
69 |
70 o 2:6bdb694e7b8c commit 2 (leading whitespace on line 2)
71 |
72 o 1:23e1e37387dc commit 1
73 |
74 o 0:b9c578134d72 commit 0
75
76
77 $ hg serve -p $HGPORT -d --pid-file hg.pid
78 $ cat hg.pid >> $DAEMON_PIDS
79 $ hg serve --config annotate.ignorews=true -p $HGPORT1 -d --pid-file hg.pid
80 $ cat hg.pid >> $DAEMON_PIDS
81 $ cd ..
82
83 Annotate works
84
85 $ get-with-headers.py --json $LOCALIP:$HGPORT 'json-annotate/9d1b2c7db017/foo'
86 200 Script output follows
87
88 {
89 "abspath": "foo",
90 "annotate": [
91 {
92 "abspath": "foo",
93 "author": "test",
94 "desc": "commit 4 (intra whitespace on line 0)",
95 "line": "line 0\n",
96 "lineno": 1,
97 "node": "08adbe269f24cf22d975eadeec16790c5b22f558",
98 "revdate": [
99 0.0,
100 0
101 ],
102 "targetline": 1
103 },
104 {
105 "abspath": "foo",
106 "author": "test",
107 "desc": "commit 5 (add blank line between line 0 and 1)",
108 "line": "\n",
109 "lineno": 2,
110 "node": "400ef1d404706cfb48afd2b78ce6addf641ced25",
111 "revdate": [
112 0.0,
113 0
114 ],
115 "targetline": 2
116 },
117 {
118 "abspath": "foo",
119 "author": "test",
120 "desc": "commit 6 (add another blank line between line 0 and 1)",
121 "line": "\n",
122 "lineno": 3,
123 "node": "9d1b2c7db0175870a950f8c48c9c4ead1058f2c5",
124 "revdate": [
125 0.0,
126 0
127 ],
128 "targetline": 3
129 },
130 {
131 "abspath": "foo",
132 "author": "test",
133 "desc": "commit 1",
134 "line": "line 1 modified by 1\n",
135 "lineno": 4,
136 "node": "23e1e37387dcfca4c0ed0cc568d1e4b9bfed241a",
137 "revdate": [
138 0.0,
139 0
140 ],
141 "targetline": 2
142 },
143 {
144 "abspath": "foo",
145 "author": "test",
146 "desc": "commit 2 (leading whitespace on line 2)",
147 "line": " line 2\n",
148 "lineno": 5,
149 "node": "6bdb694e7b8cebb68d5b6b27b4bcc2a49d62c602",
150 "revdate": [
151 0.0,
152 0
153 ],
154 "targetline": 3
155 },
156 {
157 "abspath": "foo",
158 "author": "test",
159 "desc": "commit 3 (trailing whitespace on line 3)",
160 "line": "line 3 \n",
161 "lineno": 6,
162 "node": "dcb62cfbfc9b3ab995a5cbbaff6e1971c3e4f865",
163 "revdate": [
164 0.0,
165 0
166 ],
167 "targetline": 4
168 }
169 ],
170 "author": "test",
171 "children": [],
172 "date": [
173 0.0,
174 0
175 ],
176 "desc": "commit 6 (add another blank line between line 0 and 1)",
177 "node": "9d1b2c7db0175870a950f8c48c9c4ead1058f2c5",
178 "parents": [
179 "400ef1d404706cfb48afd2b78ce6addf641ced25"
180 ],
181 "permissions": ""
182 }
183
184 annotate.ignorews=1 config option is honored
185
186 $ get-with-headers.py --json $LOCALIP:$HGPORT1 'json-annotate/9d1b2c7db017/foo'
187 200 Script output follows
188
189 {
190 "abspath": "foo",
191 "annotate": [
192 {
193 "abspath": "foo",
194 "author": "test",
195 "desc": "commit 0",
196 "line": "line 0\n",
197 "lineno": 1,
198 "node": "b9c578134d72b3a9d26afde8ddd76c0a93c5adbc",
199 "revdate": [
200 0.0,
201 0
202 ],
203 "targetline": 1
204 },
205 {
206 "abspath": "foo",
207 "author": "test",
208 "desc": "commit 5 (add blank line between line 0 and 1)",
209 "line": "\n",
210 "lineno": 2,
211 "node": "400ef1d404706cfb48afd2b78ce6addf641ced25",
212 "revdate": [
213 0.0,
214 0
215 ],
216 "targetline": 2
217 },
218 {
219 "abspath": "foo",
220 "author": "test",
221 "desc": "commit 6 (add another blank line between line 0 and 1)",
222 "line": "\n",
223 "lineno": 3,
224 "node": "9d1b2c7db0175870a950f8c48c9c4ead1058f2c5",
225 "revdate": [
226 0.0,
227 0
228 ],
229 "targetline": 3
230 },
231 {
232 "abspath": "foo",
233 "author": "test",
234 "desc": "commit 1",
235 "line": "line 1 modified by 1\n",
236 "lineno": 4,
237 "node": "23e1e37387dcfca4c0ed0cc568d1e4b9bfed241a",
238 "revdate": [
239 0.0,
240 0
241 ],
242 "targetline": 2
243 },
244 {
245 "abspath": "foo",
246 "author": "test",
247 "desc": "commit 0",
248 "line": " line 2\n",
249 "lineno": 5,
250 "node": "b9c578134d72b3a9d26afde8ddd76c0a93c5adbc",
251 "revdate": [
252 0.0,
253 0
254 ],
255 "targetline": 3
256 },
257 {
258 "abspath": "foo",
259 "author": "test",
260 "desc": "commit 0",
261 "line": "line 3 \n",
262 "lineno": 6,
263 "node": "b9c578134d72b3a9d26afde8ddd76c0a93c5adbc",
264 "revdate": [
265 0.0,
266 0
267 ],
268 "targetline": 4
269 }
270 ],
271 "author": "test",
272 "children": [],
273 "date": [
274 0.0,
275 0
276 ],
277 "desc": "commit 6 (add another blank line between line 0 and 1)",
278 "node": "9d1b2c7db0175870a950f8c48c9c4ead1058f2c5",
279 "parents": [
280 "400ef1d404706cfb48afd2b78ce6addf641ced25"
281 ],
282 "permissions": ""
283 }
284
285 ignorews=1 query string argument enables whitespace skipping
286
287 $ get-with-headers.py --json $LOCALIP:$HGPORT 'json-annotate/9d1b2c7db017/foo?ignorews=1'
288 200 Script output follows
289
290 {
291 "abspath": "foo",
292 "annotate": [
293 {
294 "abspath": "foo",
295 "author": "test",
296 "desc": "commit 0",
297 "line": "line 0\n",
298 "lineno": 1,
299 "node": "b9c578134d72b3a9d26afde8ddd76c0a93c5adbc",
300 "revdate": [
301 0.0,
302 0
303 ],
304 "targetline": 1
305 },
306 {
307 "abspath": "foo",
308 "author": "test",
309 "desc": "commit 5 (add blank line between line 0 and 1)",
310 "line": "\n",
311 "lineno": 2,
312 "node": "400ef1d404706cfb48afd2b78ce6addf641ced25",
313 "revdate": [
314 0.0,
315 0
316 ],
317 "targetline": 2
318 },
319 {
320 "abspath": "foo",
321 "author": "test",
322 "desc": "commit 6 (add another blank line between line 0 and 1)",
323 "line": "\n",
324 "lineno": 3,
325 "node": "9d1b2c7db0175870a950f8c48c9c4ead1058f2c5",
326 "revdate": [
327 0.0,
328 0
329 ],
330 "targetline": 3
331 },
332 {
333 "abspath": "foo",
334 "author": "test",
335 "desc": "commit 1",
336 "line": "line 1 modified by 1\n",
337 "lineno": 4,
338 "node": "23e1e37387dcfca4c0ed0cc568d1e4b9bfed241a",
339 "revdate": [
340 0.0,
341 0
342 ],
343 "targetline": 2
344 },
345 {
346 "abspath": "foo",
347 "author": "test",
348 "desc": "commit 0",
349 "line": " line 2\n",
350 "lineno": 5,
351 "node": "b9c578134d72b3a9d26afde8ddd76c0a93c5adbc",
352 "revdate": [
353 0.0,
354 0
355 ],
356 "targetline": 3
357 },
358 {
359 "abspath": "foo",
360 "author": "test",
361 "desc": "commit 0",
362 "line": "line 3 \n",
363 "lineno": 6,
364 "node": "b9c578134d72b3a9d26afde8ddd76c0a93c5adbc",
365 "revdate": [
366 0.0,
367 0
368 ],
369 "targetline": 4
370 }
371 ],
372 "author": "test",
373 "children": [],
374 "date": [
375 0.0,
376 0
377 ],
378 "desc": "commit 6 (add another blank line between line 0 and 1)",
379 "node": "9d1b2c7db0175870a950f8c48c9c4ead1058f2c5",
380 "parents": [
381 "400ef1d404706cfb48afd2b78ce6addf641ced25"
382 ],
383 "permissions": ""
384 }
385
386 ignorews=0 query string argument disables when config defaults to enabled
387
388 $ get-with-headers.py --json $LOCALIP:$HGPORT1 'json-annotate/9d1b2c7db017/foo?ignorews=0'
389 200 Script output follows
390
391 {
392 "abspath": "foo",
393 "annotate": [
394 {
395 "abspath": "foo",
396 "author": "test",
397 "desc": "commit 4 (intra whitespace on line 0)",
398 "line": "line 0\n",
399 "lineno": 1,
400 "node": "08adbe269f24cf22d975eadeec16790c5b22f558",
401 "revdate": [
402 0.0,
403 0
404 ],
405 "targetline": 1
406 },
407 {
408 "abspath": "foo",
409 "author": "test",
410 "desc": "commit 5 (add blank line between line 0 and 1)",
411 "line": "\n",
412 "lineno": 2,
413 "node": "400ef1d404706cfb48afd2b78ce6addf641ced25",
414 "revdate": [
415 0.0,
416 0
417 ],
418 "targetline": 2
419 },
420 {
421 "abspath": "foo",
422 "author": "test",
423 "desc": "commit 6 (add another blank line between line 0 and 1)",
424 "line": "\n",
425 "lineno": 3,
426 "node": "9d1b2c7db0175870a950f8c48c9c4ead1058f2c5",
427 "revdate": [
428 0.0,
429 0
430 ],
431 "targetline": 3
432 },
433 {
434 "abspath": "foo",
435 "author": "test",
436 "desc": "commit 1",
437 "line": "line 1 modified by 1\n",
438 "lineno": 4,
439 "node": "23e1e37387dcfca4c0ed0cc568d1e4b9bfed241a",
440 "revdate": [
441 0.0,
442 0
443 ],
444 "targetline": 2
445 },
446 {
447 "abspath": "foo",
448 "author": "test",
449 "desc": "commit 2 (leading whitespace on line 2)",
450 "line": " line 2\n",
451 "lineno": 5,
452 "node": "6bdb694e7b8cebb68d5b6b27b4bcc2a49d62c602",
453 "revdate": [
454 0.0,
455 0
456 ],
457 "targetline": 3
458 },
459 {
460 "abspath": "foo",
461 "author": "test",
462 "desc": "commit 3 (trailing whitespace on line 3)",
463 "line": "line 3 \n",
464 "lineno": 6,
465 "node": "dcb62cfbfc9b3ab995a5cbbaff6e1971c3e4f865",
466 "revdate": [
467 0.0,
468 0
469 ],
470 "targetline": 4
471 }
472 ],
473 "author": "test",
474 "children": [],
475 "date": [
476 0.0,
477 0
478 ],
479 "desc": "commit 6 (add another blank line between line 0 and 1)",
480 "node": "9d1b2c7db0175870a950f8c48c9c4ead1058f2c5",
481 "parents": [
482 "400ef1d404706cfb48afd2b78ce6addf641ced25"
483 ],
484 "permissions": ""
485 }
486
487 ignorewsamount=1 query string enables whitespace amount skipping
488
489 $ get-with-headers.py --json $LOCALIP:$HGPORT 'json-annotate/9d1b2c7db017/foo?ignorewsamount=1'
490 200 Script output follows
491
492 {
493 "abspath": "foo",
494 "annotate": [
495 {
496 "abspath": "foo",
497 "author": "test",
498 "desc": "commit 0",
499 "line": "line 0\n",
500 "lineno": 1,
501 "node": "b9c578134d72b3a9d26afde8ddd76c0a93c5adbc",
502 "revdate": [
503 0.0,
504 0
505 ],
506 "targetline": 1
507 },
508 {
509 "abspath": "foo",
510 "author": "test",
511 "desc": "commit 5 (add blank line between line 0 and 1)",
512 "line": "\n",
513 "lineno": 2,
514 "node": "400ef1d404706cfb48afd2b78ce6addf641ced25",
515 "revdate": [
516 0.0,
517 0
518 ],
519 "targetline": 2
520 },
521 {
522 "abspath": "foo",
523 "author": "test",
524 "desc": "commit 6 (add another blank line between line 0 and 1)",
525 "line": "\n",
526 "lineno": 3,
527 "node": "9d1b2c7db0175870a950f8c48c9c4ead1058f2c5",
528 "revdate": [
529 0.0,
530 0
531 ],
532 "targetline": 3
533 },
534 {
535 "abspath": "foo",
536 "author": "test",
537 "desc": "commit 1",
538 "line": "line 1 modified by 1\n",
539 "lineno": 4,
540 "node": "23e1e37387dcfca4c0ed0cc568d1e4b9bfed241a",
541 "revdate": [
542 0.0,
543 0
544 ],
545 "targetline": 2
546 },
547 {
548 "abspath": "foo",
549 "author": "test",
550 "desc": "commit 2 (leading whitespace on line 2)",
551 "line": " line 2\n",
552 "lineno": 5,
553 "node": "6bdb694e7b8cebb68d5b6b27b4bcc2a49d62c602",
554 "revdate": [
555 0.0,
556 0
557 ],
558 "targetline": 3
559 },
560 {
561 "abspath": "foo",
562 "author": "test",
563 "desc": "commit 0",
564 "line": "line 3 \n",
565 "lineno": 6,
566 "node": "b9c578134d72b3a9d26afde8ddd76c0a93c5adbc",
567 "revdate": [
568 0.0,
569 0
570 ],
571 "targetline": 4
572 }
573 ],
574 "author": "test",
575 "children": [],
576 "date": [
577 0.0,
578 0
579 ],
580 "desc": "commit 6 (add another blank line between line 0 and 1)",
581 "node": "9d1b2c7db0175870a950f8c48c9c4ead1058f2c5",
582 "parents": [
583 "400ef1d404706cfb48afd2b78ce6addf641ced25"
584 ],
585 "permissions": ""
586 }
587
588 ignorewseol=1 query string enables whitespace end of line skipping
589
590 $ get-with-headers.py --json $LOCALIP:$HGPORT 'json-annotate/9d1b2c7db017/foo?ignorewseol=1'
591 200 Script output follows
592
593 {
594 "abspath": "foo",
595 "annotate": [
596 {
597 "abspath": "foo",
598 "author": "test",
599 "desc": "commit 4 (intra whitespace on line 0)",
600 "line": "line 0\n",
601 "lineno": 1,
602 "node": "08adbe269f24cf22d975eadeec16790c5b22f558",
603 "revdate": [
604 0.0,
605 0
606 ],
607 "targetline": 1
608 },
609 {
610 "abspath": "foo",
611 "author": "test",
612 "desc": "commit 5 (add blank line between line 0 and 1)",
613 "line": "\n",
614 "lineno": 2,
615 "node": "400ef1d404706cfb48afd2b78ce6addf641ced25",
616 "revdate": [
617 0.0,
618 0
619 ],
620 "targetline": 2
621 },
622 {
623 "abspath": "foo",
624 "author": "test",
625 "desc": "commit 6 (add another blank line between line 0 and 1)",
626 "line": "\n",
627 "lineno": 3,
628 "node": "9d1b2c7db0175870a950f8c48c9c4ead1058f2c5",
629 "revdate": [
630 0.0,
631 0
632 ],
633 "targetline": 3
634 },
635 {
636 "abspath": "foo",
637 "author": "test",
638 "desc": "commit 1",
639 "line": "line 1 modified by 1\n",
640 "lineno": 4,
641 "node": "23e1e37387dcfca4c0ed0cc568d1e4b9bfed241a",
642 "revdate": [
643 0.0,
644 0
645 ],
646 "targetline": 2
647 },
648 {
649 "abspath": "foo",
650 "author": "test",
651 "desc": "commit 2 (leading whitespace on line 2)",
652 "line": " line 2\n",
653 "lineno": 5,
654 "node": "6bdb694e7b8cebb68d5b6b27b4bcc2a49d62c602",
655 "revdate": [
656 0.0,
657 0
658 ],
659 "targetline": 3
660 },
661 {
662 "abspath": "foo",
663 "author": "test",
664 "desc": "commit 0",
665 "line": "line 3 \n",
666 "lineno": 6,
667 "node": "b9c578134d72b3a9d26afde8ddd76c0a93c5adbc",
668 "revdate": [
669 0.0,
670 0
671 ],
672 "targetline": 4
673 }
674 ],
675 "author": "test",
676 "children": [],
677 "date": [
678 0.0,
679 0
680 ],
681 "desc": "commit 6 (add another blank line between line 0 and 1)",
682 "node": "9d1b2c7db0175870a950f8c48c9c4ead1058f2c5",
683 "parents": [
684 "400ef1d404706cfb48afd2b78ce6addf641ced25"
685 ],
686 "permissions": ""
687 }
688
689 ignoreblanklines=1 query string enables whitespace blank line skipping
690
691 $ get-with-headers.py --json $LOCALIP:$HGPORT 'json-annotate/9d1b2c7db017/foo?ignoreblanklines=1'
692 200 Script output follows
693
694 {
695 "abspath": "foo",
696 "annotate": [
697 {
698 "abspath": "foo",
699 "author": "test",
700 "desc": "commit 4 (intra whitespace on line 0)",
701 "line": "line 0\n",
702 "lineno": 1,
703 "node": "08adbe269f24cf22d975eadeec16790c5b22f558",
704 "revdate": [
705 0.0,
706 0
707 ],
708 "targetline": 1
709 },
710 {
711 "abspath": "foo",
712 "author": "test",
713 "desc": "commit 5 (add blank line between line 0 and 1)",
714 "line": "\n",
715 "lineno": 2,
716 "node": "400ef1d404706cfb48afd2b78ce6addf641ced25",
717 "revdate": [
718 0.0,
719 0
720 ],
721 "targetline": 2
722 },
723 {
724 "abspath": "foo",
725 "author": "test",
726 "desc": "commit 6 (add another blank line between line 0 and 1)",
727 "line": "\n",
728 "lineno": 3,
729 "node": "9d1b2c7db0175870a950f8c48c9c4ead1058f2c5",
730 "revdate": [
731 0.0,
732 0
733 ],
734 "targetline": 3
735 },
736 {
737 "abspath": "foo",
738 "author": "test",
739 "desc": "commit 1",
740 "line": "line 1 modified by 1\n",
741 "lineno": 4,
742 "node": "23e1e37387dcfca4c0ed0cc568d1e4b9bfed241a",
743 "revdate": [
744 0.0,
745 0
746 ],
747 "targetline": 2
748 },
749 {
750 "abspath": "foo",
751 "author": "test",
752 "desc": "commit 2 (leading whitespace on line 2)",
753 "line": " line 2\n",
754 "lineno": 5,
755 "node": "6bdb694e7b8cebb68d5b6b27b4bcc2a49d62c602",
756 "revdate": [
757 0.0,
758 0
759 ],
760 "targetline": 3
761 },
762 {
763 "abspath": "foo",
764 "author": "test",
765 "desc": "commit 3 (trailing whitespace on line 3)",
766 "line": "line 3 \n",
767 "lineno": 6,
768 "node": "dcb62cfbfc9b3ab995a5cbbaff6e1971c3e4f865",
769 "revdate": [
770 0.0,
771 0
772 ],
773 "targetline": 4
774 }
775 ],
776 "author": "test",
777 "children": [],
778 "date": [
779 0.0,
780 0
781 ],
782 "desc": "commit 6 (add another blank line between line 0 and 1)",
783 "node": "9d1b2c7db0175870a950f8c48c9c4ead1058f2c5",
784 "parents": [
785 "400ef1d404706cfb48afd2b78ce6addf641ced25"
786 ],
787 "permissions": ""
788 }