mirror of
https://github.com/facebook/sapling.git
synced 2024-10-12 01:39:21 +03:00
a5201c7f89
When matching a file against the rules in .hgeol, the eol extension's hook should stop after the first matching rule is encountered. Otherwise, if this rule is contradicted by other more general rule (for example a catch-all at the end of .hgeol), some files are simply impossible to push. Trivial example: **.bat = CRLF ** = LF If all matching rules were applied, a .bat file would be rejected either because it has LFs (first rule) or because it has CRLFs (second rule).
91 lines
2.1 KiB
Perl
91 lines
2.1 KiB
Perl
Test the EOL hook
|
|
|
|
$ cat > $HGRCPATH <<EOF
|
|
> [diff]
|
|
> git = True
|
|
> EOF
|
|
$ hg init main
|
|
$ cat > main/.hg/hgrc <<EOF
|
|
> [extensions]
|
|
> eol =
|
|
>
|
|
> [hooks]
|
|
> pretxnchangegroup = python:hgext.eol.hook
|
|
> EOF
|
|
$ hg clone main fork
|
|
updating to branch default
|
|
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
$ cd fork
|
|
|
|
Create repo
|
|
$ cat > .hgeol <<EOF
|
|
> [patterns]
|
|
> mixed.txt = BIN
|
|
> crlf.txt = CRLF
|
|
> **.txt = native
|
|
> EOF
|
|
$ hg add .hgeol
|
|
$ hg commit -m 'Commit .hgeol'
|
|
|
|
$ printf "first\nsecond\nthird\n" > a.txt
|
|
$ hg add a.txt
|
|
$ hg commit -m 'LF a.txt'
|
|
$ hg push ../main
|
|
pushing to ../main
|
|
searching for changes
|
|
adding changesets
|
|
adding manifests
|
|
adding file changes
|
|
added 2 changesets with 2 changes to 2 files
|
|
|
|
$ printf "first\r\nsecond\r\nthird\n" > a.txt
|
|
$ hg commit -m 'CRLF a.txt'
|
|
$ hg push ../main
|
|
pushing to ../main
|
|
searching for changes
|
|
adding changesets
|
|
adding manifests
|
|
adding file changes
|
|
added 1 changesets with 1 changes to 1 files
|
|
error: pretxnchangegroup hook failed: a.txt should not have CRLF line endings
|
|
transaction abort!
|
|
rollback completed
|
|
abort: a.txt should not have CRLF line endings
|
|
[255]
|
|
|
|
$ printf "first\nsecond\nthird\n" > a.txt
|
|
$ hg commit -m 'LF a.txt (fixed)'
|
|
$ hg push ../main
|
|
pushing to ../main
|
|
searching for changes
|
|
adding changesets
|
|
adding manifests
|
|
adding file changes
|
|
added 2 changesets with 2 changes to 1 files
|
|
|
|
$ printf "first\nsecond\nthird\n" > crlf.txt
|
|
$ hg add crlf.txt
|
|
$ hg commit -m 'LF crlf.txt'
|
|
$ hg push ../main
|
|
pushing to ../main
|
|
searching for changes
|
|
adding changesets
|
|
adding manifests
|
|
adding file changes
|
|
added 1 changesets with 1 changes to 1 files
|
|
error: pretxnchangegroup hook failed: crlf.txt should not have LF line endings
|
|
transaction abort!
|
|
rollback completed
|
|
abort: crlf.txt should not have LF line endings
|
|
[255]
|
|
|
|
$ printf "first\r\nsecond\r\nthird\r\n" > crlf.txt
|
|
$ hg commit -m 'CRLF crlf.txt (fixed)'
|
|
$ hg push ../main
|
|
pushing to ../main
|
|
searching for changes
|
|
adding changesets
|
|
adding manifests
|
|
adding file changes
|
|
added 2 changesets with 2 changes to 1 files
|