tests/test-convert-tla.t
author Alexander Plavin <me@aplavin.ru>
Thu, 04 Jul 2013 14:18:44 +0400
changeset 19387 f2e4fdb3dd27
parent 15441 e0348815e806
child 20117 aa9385f983fa
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>.


  $ "$TESTDIR/hghave" tla symlink || exit 80
  $ tla my-id "mercurial <mercurial@selenic.com>"
  $ echo "[extensions]" >> $HGRCPATH
  $ echo "convert=" >> $HGRCPATH
  $ echo 'graphlog =' >> $HGRCPATH

create tla archive

  $ tla make-archive tla@mercurial--convert `pwd`/hg-test-convert-tla

initialize tla repo

  $ mkdir tla-repo
  $ cd tla-repo/
  $ tla init-tree tla@mercurial--convert/tla--test--0
  $ tla import
  * creating version tla@mercurial--convert/tla--test--0
  * imported tla@mercurial--convert/tla--test--0

create initial files

  $ echo 'this is a file' > a
  $ tla add a
  $ mkdir src
  $ tla add src
  $ cd src
  $ dd count=1 if=/dev/zero of=b > /dev/null 2> /dev/null
  $ tla add b
  $ tla commit -s "added a file, src and src/b (binary)"
  A/ .arch-ids
  A/ src
  A/ src/.arch-ids
  A  .arch-ids/a.id
  A  a
  A  src/.arch-ids/=id
  A  src/.arch-ids/b.id
  A  src/b
  * update pristine tree (tla@mercurial--convert/tla--test--0--base-0 => tla--test--0--patch-1)
  * committed tla@mercurial--convert/tla--test--0--patch-1

create link file and modify a

  $ ln -s ../a a-link
  $ tla add a-link
  $ echo 'this a modification to a' >> ../a
  $ tla commit -s "added link to a and modify a"
  A  src/.arch-ids/a-link.id
  A  src/a-link
  M  a
  * update pristine tree (tla@mercurial--convert/tla--test--0--patch-1 => tla--test--0--patch-2)
  * committed tla@mercurial--convert/tla--test--0--patch-2

create second link and modify b

  $ ln -s ../a a-link-2
  $ tla add a-link-2
  $ dd count=1 seek=1 if=/dev/zero of=b > /dev/null 2> /dev/null
  $ tla commit -s "added second link and modify b"
  A  src/.arch-ids/a-link-2.id
  A  src/a-link-2
  Mb src/b
  * update pristine tree (tla@mercurial--convert/tla--test--0--patch-2 => tla--test--0--patch-3)
  * committed tla@mercurial--convert/tla--test--0--patch-3

b file to link and a-link-2 to regular file

  $ rm -f a-link-2
  $ echo 'this is now a regular file' > a-link-2
  $ ln -sf ../a b
  $ tla commit -s "file to link and link to file test"
  fl src/b
  lf src/a-link-2
  * update pristine tree (tla@mercurial--convert/tla--test--0--patch-3 => tla--test--0--patch-4)
  * committed tla@mercurial--convert/tla--test--0--patch-4

move a-link-2 file and src directory

  $ cd ..
  $ tla mv src/a-link-2 c
  $ tla mv src test
  $ tla commit -s "move and rename a-link-2 file and src directory"
  D/ src/.arch-ids
  A/ test/.arch-ids
  /> src	test
  => src/.arch-ids/a-link-2.id	.arch-ids/c.id
  => src/a-link-2	c
  => src/.arch-ids/=id	test/.arch-ids/=id
  => src/.arch-ids/a-link.id	test/.arch-ids/a-link.id
  => src/.arch-ids/b.id	test/.arch-ids/b.id
  * update pristine tree (tla@mercurial--convert/tla--test--0--patch-4 => tla--test--0--patch-5)
  * committed tla@mercurial--convert/tla--test--0--patch-5
  $ cd ..

converting tla repo to Mercurial

  $ hg convert tla-repo tla-repo-hg
  initializing destination tla-repo-hg repository
  analyzing tree version tla@mercurial--convert/tla--test--0...
  scanning source...
  sorting...
  converting...
  5 initial import
  4 added a file, src and src/b (binary)
  3 added link to a and modify a
  2 added second link and modify b
  1 file to link and link to file test
  0 move and rename a-link-2 file and src directory
  $ tla register-archive -d tla@mercurial--convert
  $ glog()
  > {
  >     hg glog --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
  > }

show graph log

  $ glog -R tla-repo-hg
  o  5 "move and rename a-link-2 file and src directory" files: c src/a-link src/a-link-2 src/b test/a-link test/b
  |
  o  4 "file to link and link to file test" files: src/a-link-2 src/b
  |
  o  3 "added second link and modify b" files: src/a-link-2 src/b
  |
  o  2 "added link to a and modify a" files: a src/a-link
  |
  o  1 "added a file, src and src/b (binary)" files: a src/b
  |
  o  0 "initial import" files:
  
  $ hg up -q -R tla-repo-hg
  $ hg -R tla-repo-hg manifest --debug
  c4072c4b72e1cabace081888efa148ee80ca3cbb 644   a
  0201ac32a3a8e86e303dff60366382a54b48a72e 644   c
  c0067ba5ff0b7c9a3eb17270839d04614c435623 644 @ test/a-link
  375f4263d86feacdea7e3c27100abd1560f2a973 644 @ test/b