test-import-eol.t
173 lines
| 3.6 KiB
| text/troff
|
Tads3Lexer
/ tests / test-import-eol.t
Nicolas Dumazet
|
r11808 | $ cat > makepatch.py <<EOF | ||
Yuya Nishihara
|
r37593 | > import sys | ||
> f = open(sys.argv[2], 'wb') | ||||
Nicolas Dumazet
|
r11808 | > w = f.write | ||
Pulkit Goyal
|
r36043 | > w(b'test message\n') | ||
> w(b'diff --git a/a b/a\n') | ||||
> w(b'--- a/a\n') | ||||
> w(b'+++ b/a\n') | ||||
> w(b'@@ -1,5 +1,5 @@\n') | ||||
> w(b' a\n') | ||||
> w(b'-bbb\r\n') | ||||
> w(b'+yyyy\r\n') | ||||
> w(b' cc\r\n') | ||||
Yuya Nishihara
|
r37593 | > w({'empty:lf': b' \n', | ||
> 'empty:crlf': b' \r\n', | ||||
> 'empty:stripped-lf': b'\n', | ||||
> 'empty:stripped-crlf': b'\r\n'}[sys.argv[1]]) | ||||
Pulkit Goyal
|
r36043 | > w(b' d\n') | ||
> w(b'-e\n') | ||||
Gregory Szorc
|
r41856 | > w(b'\\\\ No newline at end of file\n') | ||
Pulkit Goyal
|
r36043 | > w(b'+z\r\n') | ||
Gregory Szorc
|
r41856 | > w(b'\\\\ No newline at end of file\r\n') | ||
Nicolas Dumazet
|
r11808 | > EOF | ||
$ hg init repo | ||||
$ cd repo | ||||
$ echo '\.diff' > .hgignore | ||||
Test different --eol values | ||||
Matt Harbison
|
r39743 | $ "$PYTHON" -c 'open("a", "wb").write(b"a\nbbb\ncc\n\nd\ne")' | ||
Nicolas Dumazet
|
r11808 | $ hg ci -Am adda | ||
adding .hgignore | ||||
adding a | ||||
Matt Harbison
|
r39743 | $ "$PYTHON" ../makepatch.py empty:lf eol.diff | ||
$ "$PYTHON" ../makepatch.py empty:crlf eol-empty-crlf.diff | ||||
$ "$PYTHON" ../makepatch.py empty:stripped-lf eol-empty-stripped-lf.diff | ||||
$ "$PYTHON" ../makepatch.py empty:stripped-crlf eol-empty-stripped-crlf.diff | ||||
Nicolas Dumazet
|
r11808 | |||
invalid eol | ||||
$ hg --config patch.eol='LFCR' import eol.diff | ||||
applying eol.diff | ||||
Martin Geisler
|
r12070 | abort: unsupported line endings type: LFCR | ||
Matt Mackall
|
r12316 | [255] | ||
Nicolas Dumazet
|
r11808 | $ hg revert -a | ||
force LF | ||||
$ hg --traceback --config patch.eol='LF' import eol.diff | ||||
applying eol.diff | ||||
Yuya Nishihara
|
r37593 | $ hg id | ||
9e4ef7b3d4af tip | ||||
Mads Kiilerich
|
r12943 | $ cat a | ||
a | ||||
yyyy | ||||
cc | ||||
d | ||||
e (no-eol) | ||||
Nicolas Dumazet
|
r11808 | $ hg st | ||
Yuya Nishihara
|
r37593 | (test empty-line variants: all of them should generate the same revision) | ||
$ hg up -qC 0 | ||||
$ hg --config patch.eol='LF' import eol-empty-crlf.diff | ||||
applying eol-empty-crlf.diff | ||||
$ hg id | ||||
9e4ef7b3d4af tip | ||||
$ hg up -qC 0 | ||||
$ hg --config patch.eol='LF' import eol-empty-stripped-lf.diff | ||||
applying eol-empty-stripped-lf.diff | ||||
$ hg id | ||||
9e4ef7b3d4af tip | ||||
$ hg up -qC 0 | ||||
$ hg --config patch.eol='LF' import eol-empty-stripped-crlf.diff | ||||
applying eol-empty-stripped-crlf.diff | ||||
$ hg id | ||||
9e4ef7b3d4af tip | ||||
Nicolas Dumazet
|
r11808 | |||
force CRLF | ||||
$ hg up -C 0 | ||||
1 files updated, 0 files merged, 0 files removed, 0 files unresolved | ||||
$ hg --traceback --config patch.eol='CRLF' import eol.diff | ||||
applying eol.diff | ||||
Mads Kiilerich
|
r12943 | $ cat a | ||
a\r (esc) | ||||
yyyy\r (esc) | ||||
cc\r (esc) | ||||
\r (esc) | ||||
d\r (esc) | ||||
e (no-eol) | ||||
Nicolas Dumazet
|
r11808 | $ hg st | ||
auto EOL on LF file | ||||
$ hg up -C 0 | ||||
1 files updated, 0 files merged, 0 files removed, 0 files unresolved | ||||
$ hg --traceback --config patch.eol='auto' import eol.diff | ||||
applying eol.diff | ||||
Mads Kiilerich
|
r12943 | $ cat a | ||
a | ||||
yyyy | ||||
cc | ||||
d | ||||
e (no-eol) | ||||
Nicolas Dumazet
|
r11808 | $ hg st | ||
auto EOL on CRLF file | ||||
Matt Harbison
|
r39743 | $ "$PYTHON" -c 'open("a", "wb").write(b"a\r\nbbb\r\ncc\r\n\r\nd\r\ne")' | ||
Nicolas Dumazet
|
r11808 | $ hg commit -m 'switch EOLs in a' | ||
$ hg --traceback --config patch.eol='auto' import eol.diff | ||||
applying eol.diff | ||||
Mads Kiilerich
|
r12943 | $ cat a | ||
a\r (esc) | ||||
yyyy\r (esc) | ||||
cc\r (esc) | ||||
\r (esc) | ||||
d\r (esc) | ||||
e (no-eol) | ||||
Nicolas Dumazet
|
r11808 | $ hg st | ||
auto EOL on new file or source without any EOL | ||||
Matt Harbison
|
r39743 | $ "$PYTHON" -c 'open("noeol", "wb").write(b"noeol")' | ||
Nicolas Dumazet
|
r11808 | $ hg add noeol | ||
$ hg commit -m 'add noeol' | ||||
Matt Harbison
|
r39743 | $ "$PYTHON" -c 'open("noeol", "wb").write(b"noeol\r\nnoeol\n")' | ||
$ "$PYTHON" -c 'open("neweol", "wb").write(b"neweol\nneweol\r\n")' | ||||
Nicolas Dumazet
|
r11808 | $ hg add neweol | ||
$ hg diff --git > noeol.diff | ||||
$ hg revert --no-backup noeol neweol | ||||
$ rm neweol | ||||
$ hg --traceback --config patch.eol='auto' import -m noeol noeol.diff | ||||
applying noeol.diff | ||||
Mads Kiilerich
|
r12943 | $ cat noeol | ||
noeol\r (esc) | ||||
noeol | ||||
$ cat neweol | ||||
neweol | ||||
neweol\r (esc) | ||||
Nicolas Dumazet
|
r11808 | $ hg st | ||
Test --eol and binary patches | ||||
Matt Harbison
|
r39743 | $ "$PYTHON" -c 'open("b", "wb").write(b"a\x00\nb\r\nd")' | ||
Nicolas Dumazet
|
r11808 | $ hg ci -Am addb | ||
adding b | ||||
Matt Harbison
|
r39743 | $ "$PYTHON" -c 'open("b", "wb").write(b"a\x00\nc\r\nd")' | ||
Nicolas Dumazet
|
r11808 | $ hg diff --git > bin.diff | ||
$ hg revert --no-backup b | ||||
binary patch with --eol | ||||
$ hg import --config patch.eol='CRLF' -m changeb bin.diff | ||||
applying bin.diff | ||||
Mads Kiilerich
|
r12943 | $ cat b | ||
a\x00 (esc) | ||||
c\r (esc) | ||||
d (no-eol) | ||||
Nicolas Dumazet
|
r11808 | $ hg st | ||
$ cd .. | ||||