tests/test-audit-path.t
author Alexander Plavin <me@aplavin.ru>
Thu, 04 Jul 2013 14:18:44 +0400
changeset 19387 f2e4fdb3dd27
parent 18506 ef60083b5536
child 27234 15c6eb0a51bd
permissions -rw-r--r--
hgweb: code selection without line numbers in file source view All the source lines are put in a <pre> tag, which gives correct display and copy&paste in both Chromium (WebKit) and FireFox: line numbers are not copied, all the tabs and spaces are kept. This doesn't change the visual appearance of the view compared to current hgweb version and doesn't use any JS code. Also, stripes in this view are now generated clientside with CSS. This implementation is chosen because other variants have important issues: Strategy FF Chrome current D,LT,E,T,L D,L pre S,NW S,NW pre/div/nbsp LT,E,T,TS,NW TS,NW pre/div/br LT,E,T,NW NW ol/li/nbsp LT,E,T,TS,AJ TS,AJ ol/li/br LT,E,T,AJ AJ pre/span LV LV Legend Strategies: - current: implemented in hgweb before this patch, i.e. divs for each line, and line numbers links in the div too - pre: the whole code in one pre tag with newlines, all line numbers in another one with 'float: left' - pre/div/{nbsp,br}: same as just 'pre', but separate divs for each line and &nbsp; or <br> instead of empty lines (otherwise they are not copied at all) - ol/li/{nbsp,br}: a single ol with li's and divs for each line, &nbsp; or <br> same as in previous strategy - pre/span: this patch Problems: D = (very minor) display problems, like wrong width of leading tabs LT = loses leading/trailing whitespace E = loses embedded whitespace B = loses blank lines T = loses tabs L = selects line numbers LV = (only) visually selects line numbers LVE = (only) visually selects line numbers at empty lines S = no stripes (and no ability to easily highlight lines-which-are-linked-at in the future) TS = space copied instead of empty line AJ = get anchor links only with JS (they work even without) NW = no linewrap easily possible (in future) As for browser versions compatibility, the CSS tricks used are supported in (according to caniuse.com): a) line numbers generation with 'content:' property and CSS counters: IE 8+, all other popular browsers (in pre-WebKit Opera numbers are being copied) b) stripes ('nth-child' selector): IE 8+, FF 3.5+, Safari 3.2+, Opera 9.5+, all other popular browsers c) line numbers are not visually selected ('user-select:' property): IE 10+, Opera 15.0+, all other popular browsers This patch is based on a demo implementation by Martin Geisler <martin@geisler.net>.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11855
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
     1
  $ hg init
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
     2
16908
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
     3
audit of .hg
11855
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
     4
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
     5
  $ hg add .hg/00changelog.i
15447
9910f60a37ee tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents: 15441
diff changeset
     6
  abort: path contains illegal component: .hg/00changelog.i (glob)
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 11855
diff changeset
     7
  [255]
5158
d316124ebbea Make audit_path more stringent.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
     8
16908
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
     9
#if symlink
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
    10
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
    11
Symlinks
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
    12
11855
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    13
  $ mkdir a
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    14
  $ echo a > a/a
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    15
  $ hg ci -Ama
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    16
  adding a/a
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    17
  $ ln -s a b
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    18
  $ echo b > a/b
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    19
  $ hg add b/b
15447
9910f60a37ee tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents: 15441
diff changeset
    20
  abort: path 'b/b' traverses symbolic link 'b' (glob)
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 11855
diff changeset
    21
  [255]
11855
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    22
  $ hg add b
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    23
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    24
should still fail - maybe
5158
d316124ebbea Make audit_path more stringent.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    25
11855
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    26
  $ hg add b/b
15447
9910f60a37ee tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents: 15441
diff changeset
    27
  abort: path 'b/b' traverses symbolic link 'b' (glob)
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 11855
diff changeset
    28
  [255]
5158
d316124ebbea Make audit_path more stringent.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    29
16908
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
    30
#endif
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
    31
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
    32
11855
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    33
unbundle tampered bundle
5158
d316124ebbea Make audit_path more stringent.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    34
11855
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    35
  $ hg init target
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    36
  $ cd target
16350
4f795f5fbb0b tests: make tests work if directory contains special characters
Thomas Arendsen Hein <thomas@intevation.de>
parents: 15521
diff changeset
    37
  $ hg unbundle "$TESTDIR/bundles/tampered.hg"
11855
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    38
  adding changesets
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    39
  adding manifests
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    40
  adding file changes
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    41
  added 5 changesets with 6 changes to 6 files (+4 heads)
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    42
  (run 'hg heads' to see heads, 'hg merge' to merge)
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    43
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    44
attack .hg/test
7554
11a4eb81fb4f test-audit-path: add more tests (issue 1450)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5158
diff changeset
    45
11855
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    46
  $ hg manifest -r0
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    47
  .hg/test
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    48
  $ hg update -Cr0
16908
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
    49
  abort: path contains illegal component: .hg/test (glob)
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 11855
diff changeset
    50
  [255]
7554
11a4eb81fb4f test-audit-path: add more tests (issue 1450)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5158
diff changeset
    51
11855
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    52
attack foo/.hg/test
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    53
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    54
  $ hg manifest -r1
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    55
  foo/.hg/test
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    56
  $ hg update -Cr1
16908
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
    57
  abort: path 'foo/.hg/test' is inside nested repo 'foo' (glob)
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 11855
diff changeset
    58
  [255]
7554
11a4eb81fb4f test-audit-path: add more tests (issue 1450)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5158
diff changeset
    59
11855
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    60
attack back/test where back symlinks to ..
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    61
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    62
  $ hg manifest -r2
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    63
  back
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    64
  back/test
16908
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
    65
#if symlink
11855
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    66
  $ hg update -Cr2
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    67
  abort: path 'back/test' traverses symbolic link 'back'
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 11855
diff changeset
    68
  [255]
16908
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
    69
#else
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
    70
('back' will be a file and cause some other system specific error)
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
    71
  $ hg update -Cr2
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
    72
  abort: * (glob)
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
    73
  [255]
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
    74
#endif
11855
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    75
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    76
attack ../test
7554
11a4eb81fb4f test-audit-path: add more tests (issue 1450)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5158
diff changeset
    77
11855
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    78
  $ hg manifest -r3
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    79
  ../test
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    80
  $ hg update -Cr3
16908
6a997aacba5d tests: convert some 'hghave symlink' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 16350
diff changeset
    81
  abort: path contains illegal component: ../test (glob)
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 11855
diff changeset
    82
  [255]
11855
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    83
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    84
attack /tmp/test
7554
11a4eb81fb4f test-audit-path: add more tests (issue 1450)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5158
diff changeset
    85
11855
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    86
  $ hg manifest -r4
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    87
  /tmp/test
054b0d9c3f0c tests: unify test-audit-path
Martin Geisler <mg@lazybytes.net>
parents: 7681
diff changeset
    88
  $ hg update -Cr4
18506
ef60083b5536 tests: fix for windows - slashes and no serve
Mads Kiilerich <madski@unity3d.com>
parents: 18336
diff changeset
    89
  abort: path contains illegal component: /tmp/test (glob)
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 11855
diff changeset
    90
  [255]
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16908
diff changeset
    91
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16908
diff changeset
    92
  $ cd ..