tests/test-diffstat.t
author Alexander Plavin <me@aplavin.ru>
Thu, 04 Jul 2013 14:18:44 +0400
changeset 19387 f2e4fdb3dd27
parent 17346 2944a6d35158
child 24432 e22248f6d257
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:
12147
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
     1
  $ hg init repo
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
     2
  $ cd repo
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
     3
  $ i=0; while [ "$i" -lt 213 ]; do echo a >> a; i=`expr $i + 1`; done
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
     4
  $ hg add a
14437
cbe13e6bdc34 patch: restore the previous output of 'diff --stat'
Steven Brown <StevenGBrown@gmail.com>
parents: 13395
diff changeset
     5
  $ cp a b
cbe13e6bdc34 patch: restore the previous output of 'diff --stat'
Steven Brown <StevenGBrown@gmail.com>
parents: 13395
diff changeset
     6
  $ hg add b
9640
9e76232fbfbe diff: add --stat for diffstat output
Brodie Rao <me+hg@dackz.net>
parents:
diff changeset
     7
12147
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
     8
Wide diffstat:
9640
9e76232fbfbe diff: add --stat for diffstat output
Brodie Rao <me+hg@dackz.net>
parents:
diff changeset
     9
12147
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    10
  $ hg diff --stat
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    11
   a |  213 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
14437
cbe13e6bdc34 patch: restore the previous output of 'diff --stat'
Steven Brown <StevenGBrown@gmail.com>
parents: 13395
diff changeset
    12
   b |  213 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cbe13e6bdc34 patch: restore the previous output of 'diff --stat'
Steven Brown <StevenGBrown@gmail.com>
parents: 13395
diff changeset
    13
   2 files changed, 426 insertions(+), 0 deletions(-)
12147
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    14
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    15
diffstat width:
9640
9e76232fbfbe diff: add --stat for diffstat output
Brodie Rao <me+hg@dackz.net>
parents:
diff changeset
    16
12147
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    17
  $ COLUMNS=24 hg diff --config ui.interactive=true --stat
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    18
   a |  213 ++++++++++++++
14437
cbe13e6bdc34 patch: restore the previous output of 'diff --stat'
Steven Brown <StevenGBrown@gmail.com>
parents: 13395
diff changeset
    19
   b |  213 ++++++++++++++
cbe13e6bdc34 patch: restore the previous output of 'diff --stat'
Steven Brown <StevenGBrown@gmail.com>
parents: 13395
diff changeset
    20
   2 files changed, 426 insertions(+), 0 deletions(-)
9640
9e76232fbfbe diff: add --stat for diffstat output
Brodie Rao <me+hg@dackz.net>
parents:
diff changeset
    21
12147
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    22
  $ hg ci -m adda
9640
9e76232fbfbe diff: add --stat for diffstat output
Brodie Rao <me+hg@dackz.net>
parents:
diff changeset
    23
12147
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    24
  $ cat >> a <<EOF
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    25
  > a
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    26
  > a
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    27
  > a
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    28
  > EOF
9640
9e76232fbfbe diff: add --stat for diffstat output
Brodie Rao <me+hg@dackz.net>
parents:
diff changeset
    29
12147
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    30
Narrow diffstat:
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    31
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    32
  $ hg diff --stat
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    33
   a |  3 +++
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    34
   1 files changed, 3 insertions(+), 0 deletions(-)
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    35
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    36
  $ hg ci -m appenda
9640
9e76232fbfbe diff: add --stat for diffstat output
Brodie Rao <me+hg@dackz.net>
parents:
diff changeset
    37
16098
c6c9b83a1e8a tests: tighten checks for octal escapes in shell printf.
Jim Hague <jim.hague@acm.org>
parents: 15363
diff changeset
    38
  >>> open("c", "wb").write("\0")
15363
628a4a9e411d diffstat: be more picky when marking file as 'binary' (issue2816)
Patrick Mezard <pmezard@gmail.com>
parents: 14437
diff changeset
    39
  $ touch d
628a4a9e411d diffstat: be more picky when marking file as 'binary' (issue2816)
Patrick Mezard <pmezard@gmail.com>
parents: 14437
diff changeset
    40
  $ hg add c d
9640
9e76232fbfbe diff: add --stat for diffstat output
Brodie Rao <me+hg@dackz.net>
parents:
diff changeset
    41
12147
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    42
Binary diffstat:
9640
9e76232fbfbe diff: add --stat for diffstat output
Brodie Rao <me+hg@dackz.net>
parents:
diff changeset
    43
12147
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    44
  $ hg diff --stat
15363
628a4a9e411d diffstat: be more picky when marking file as 'binary' (issue2816)
Patrick Mezard <pmezard@gmail.com>
parents: 14437
diff changeset
    45
   c |  Bin 
12147
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    46
   1 files changed, 0 insertions(+), 0 deletions(-)
9642
7d17794f08a9 diffstat: with --git, mark binary files with Bin
Brodie Rao <me+hg@dackz.net>
parents: 9640
diff changeset
    47
12147
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    48
Binary git diffstat:
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    49
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    50
  $ hg diff --stat --git
14437
cbe13e6bdc34 patch: restore the previous output of 'diff --stat'
Steven Brown <StevenGBrown@gmail.com>
parents: 13395
diff changeset
    51
   c |  Bin 
15363
628a4a9e411d diffstat: be more picky when marking file as 'binary' (issue2816)
Patrick Mezard <pmezard@gmail.com>
parents: 14437
diff changeset
    52
   d |    0 
628a4a9e411d diffstat: be more picky when marking file as 'binary' (issue2816)
Patrick Mezard <pmezard@gmail.com>
parents: 14437
diff changeset
    53
   2 files changed, 0 insertions(+), 0 deletions(-)
12147
2b171fe378c0 tests: unify test-diffstat
Adrian Buehlmann <adrian@cadifra.com>
parents: 9799
diff changeset
    54
13395
104c9ed93fc5 diffstat: fix parsing of filenames with spaces
Gastón Kleiman <gaston.kleiman@gmail.com>
parents: 12147
diff changeset
    55
  $ hg ci -m createb
104c9ed93fc5 diffstat: fix parsing of filenames with spaces
Gastón Kleiman <gaston.kleiman@gmail.com>
parents: 12147
diff changeset
    56
16098
c6c9b83a1e8a tests: tighten checks for octal escapes in shell printf.
Jim Hague <jim.hague@acm.org>
parents: 15363
diff changeset
    57
  >>> open("file with spaces", "wb").write("\0")
13395
104c9ed93fc5 diffstat: fix parsing of filenames with spaces
Gastón Kleiman <gaston.kleiman@gmail.com>
parents: 12147
diff changeset
    58
  $ hg add "file with spaces"
104c9ed93fc5 diffstat: fix parsing of filenames with spaces
Gastón Kleiman <gaston.kleiman@gmail.com>
parents: 12147
diff changeset
    59
104c9ed93fc5 diffstat: fix parsing of filenames with spaces
Gastón Kleiman <gaston.kleiman@gmail.com>
parents: 12147
diff changeset
    60
Filename with spaces diffstat:
104c9ed93fc5 diffstat: fix parsing of filenames with spaces
Gastón Kleiman <gaston.kleiman@gmail.com>
parents: 12147
diff changeset
    61
104c9ed93fc5 diffstat: fix parsing of filenames with spaces
Gastón Kleiman <gaston.kleiman@gmail.com>
parents: 12147
diff changeset
    62
  $ hg diff --stat
15363
628a4a9e411d diffstat: be more picky when marking file as 'binary' (issue2816)
Patrick Mezard <pmezard@gmail.com>
parents: 14437
diff changeset
    63
   file with spaces |  Bin 
13395
104c9ed93fc5 diffstat: fix parsing of filenames with spaces
Gastón Kleiman <gaston.kleiman@gmail.com>
parents: 12147
diff changeset
    64
   1 files changed, 0 insertions(+), 0 deletions(-)
104c9ed93fc5 diffstat: fix parsing of filenames with spaces
Gastón Kleiman <gaston.kleiman@gmail.com>
parents: 12147
diff changeset
    65
104c9ed93fc5 diffstat: fix parsing of filenames with spaces
Gastón Kleiman <gaston.kleiman@gmail.com>
parents: 12147
diff changeset
    66
Filename with spaces git diffstat:
104c9ed93fc5 diffstat: fix parsing of filenames with spaces
Gastón Kleiman <gaston.kleiman@gmail.com>
parents: 12147
diff changeset
    67
104c9ed93fc5 diffstat: fix parsing of filenames with spaces
Gastón Kleiman <gaston.kleiman@gmail.com>
parents: 12147
diff changeset
    68
  $ hg diff --stat --git
104c9ed93fc5 diffstat: fix parsing of filenames with spaces
Gastón Kleiman <gaston.kleiman@gmail.com>
parents: 12147
diff changeset
    69
   file with spaces |  Bin 
104c9ed93fc5 diffstat: fix parsing of filenames with spaces
Gastón Kleiman <gaston.kleiman@gmail.com>
parents: 12147
diff changeset
    70
   1 files changed, 0 insertions(+), 0 deletions(-)
17346
2944a6d35158 check-code: fix check for trailing whitespace on empty lines
Mads Kiilerich <mads@kiilerich.com>
parents: 16913
diff changeset
    71
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16098
diff changeset
    72
  $ cd ..