tests/test-eol-hook.t
author Patrick Mezard <pmezard@gmail.com>
Sun, 13 Mar 2011 15:07:44 +0100
changeset 13616 e6f93ca9ce86
parent 13615 686dec753b52
child 13617 9cb1a42cd4b3
permissions -rw-r--r--
eol: make the hook check all new heads, not only tip (issue2666) Report and test by Antoine Pitrou <solipsis@pitrou.net>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12423
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
     1
Test the EOL hook
11249
0bb67503ad4b eol: extension for managing file EOLs
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     2
12423
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
     3
  $ hg init main
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
     4
  $ cat > main/.hg/hgrc <<EOF
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
     5
  > [hooks]
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
     6
  > pretxnchangegroup = python:hgext.eol.hook
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
     7
  > EOF
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
     8
  $ hg clone main fork
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
     9
  updating to branch default
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    10
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    11
  $ cd fork
11249
0bb67503ad4b eol: extension for managing file EOLs
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    12
12423
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    13
Create repo
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    14
  $ cat > .hgeol <<EOF
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    15
  > [patterns]
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    16
  > mixed.txt = BIN
13501
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    17
  > crlf.txt = CRLF
12423
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    18
  > **.txt = native
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    19
  > EOF
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    20
  $ hg add .hgeol
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    21
  $ hg commit -m 'Commit .hgeol'
11249
0bb67503ad4b eol: extension for managing file EOLs
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    22
12423
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    23
  $ printf "first\nsecond\nthird\n" > a.txt
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    24
  $ hg add a.txt
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    25
  $ hg commit -m 'LF a.txt'
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    26
  $ hg push ../main
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    27
  pushing to ../main
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    28
  searching for changes
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    29
  adding changesets
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    30
  adding manifests
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    31
  adding file changes
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    32
  added 2 changesets with 2 changes to 2 files
11249
0bb67503ad4b eol: extension for managing file EOLs
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    33
12423
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    34
  $ printf "first\r\nsecond\r\nthird\n" > a.txt
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    35
  $ hg commit -m 'CRLF a.txt'
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    36
  $ hg push ../main
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    37
  pushing to ../main
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    38
  searching for changes
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    39
  adding changesets
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    40
  adding manifests
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    41
  adding file changes
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    42
  added 1 changesets with 1 changes to 1 files
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    43
  error: pretxnchangegroup hook failed: a.txt should not have CRLF line endings
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    44
  transaction abort!
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    45
  rollback completed
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    46
  abort: a.txt should not have CRLF line endings
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    47
  [255]
11249
0bb67503ad4b eol: extension for managing file EOLs
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    48
12423
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    49
  $ printf "first\nsecond\nthird\n" > a.txt
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    50
  $ hg commit -m 'LF a.txt (fixed)'
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    51
  $ hg push ../main
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    52
  pushing to ../main
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    53
  searching for changes
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    54
  adding changesets
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    55
  adding manifests
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    56
  adding file changes
10c3385fa89e tests: unify test-eol-hook
Matt Mackall <mpm@selenic.com>
parents: 11249
diff changeset
    57
  added 2 changesets with 2 changes to 1 files
13501
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    58
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    59
  $ printf "first\nsecond\nthird\n" > crlf.txt
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    60
  $ hg add crlf.txt
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    61
  $ hg commit -m 'LF crlf.txt'
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    62
  $ hg push ../main
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    63
  pushing to ../main
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    64
  searching for changes
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    65
  adding changesets
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    66
  adding manifests
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    67
  adding file changes
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    68
  added 1 changesets with 1 changes to 1 files
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    69
  error: pretxnchangegroup hook failed: crlf.txt should not have LF line endings
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    70
  transaction abort!
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    71
  rollback completed
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    72
  abort: crlf.txt should not have LF line endings
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    73
  [255]
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    74
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    75
  $ printf "first\r\nsecond\r\nthird\r\n" > crlf.txt
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    76
  $ hg commit -m 'CRLF crlf.txt (fixed)'
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    77
  $ hg push ../main
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    78
  pushing to ../main
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    79
  searching for changes
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    80
  adding changesets
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    81
  adding manifests
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    82
  adding file changes
50b825c1adb1 eol: stop after first matched rule in hook (issue2660)
Antoine Pitrou <solipsis@pitrou.net>
parents: 12423
diff changeset
    83
  added 2 changesets with 2 changes to 1 files
13616
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
    84
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
    85
  $ printf "first\r\nsecond" > b.txt
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
    86
  $ hg add b.txt
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
    87
  $ hg commit -m 'CRLF b.txt'
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
    88
  $ hg push ../main
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
    89
  pushing to ../main
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
    90
  searching for changes
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
    91
  adding changesets
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
    92
  adding manifests
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
    93
  adding file changes
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
    94
  added 1 changesets with 1 changes to 1 files
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
    95
  error: pretxnchangegroup hook failed: b.txt should not have CRLF line endings
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
    96
  transaction abort!
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
    97
  rollback completed
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
    98
  abort: b.txt should not have CRLF line endings
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
    99
  [255]
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   100
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   101
  $ hg up -r -2
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   102
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   103
  $ printf "some\nother\nfile" > c.txt
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   104
  $ hg add c.txt
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   105
  $ hg commit -m "LF c.txt, b.txt doesn't exist here"
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   106
  created new head
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   107
  $ hg push -f ../main
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   108
  pushing to ../main
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   109
  searching for changes
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   110
  adding changesets
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   111
  adding manifests
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   112
  adding file changes
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   113
  added 2 changesets with 2 changes to 2 files (+1 heads)
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   114
  error: pretxnchangegroup hook failed: b.txt should not have CRLF line endings
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   115
  transaction abort!
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   116
  rollback completed
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   117
  abort: b.txt should not have CRLF line endings
e6f93ca9ce86 eol: make the hook check all new heads, not only tip (issue2666)
Patrick Mezard <pmezard@gmail.com>
parents: 13615
diff changeset
   118
  [255]