2020-04-15 01:47:33 +03:00
|
|
|
#require py2
|
2019-12-10 02:24:31 +03:00
|
|
|
#chg-compatible
|
|
|
|
|
2010-08-12 17:57:06 +04:00
|
|
|
$ cat > makepatch.py <<EOF
|
2020-01-29 03:40:32 +03:00
|
|
|
> f = open('eol.diff', 'wb')
|
2010-08-12 17:57:06 +04:00
|
|
|
> w = f.write
|
2020-01-31 23:58:35 +03:00
|
|
|
> _ = 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')
|
|
|
|
> _ = w(b' \n')
|
|
|
|
> _ = w(b' d\n')
|
|
|
|
> _ = w(b'-e\n')
|
|
|
|
> _ = w(b'\ No newline at end of file\n')
|
|
|
|
> _ = w(b'+z\r\n')
|
|
|
|
> _ = w(b'\ No newline at end of file\r\n')
|
2010-08-12 17:57:06 +04:00
|
|
|
> EOF
|
|
|
|
|
|
|
|
$ hg init repo
|
|
|
|
$ cd repo
|
2019-03-21 08:26:03 +03:00
|
|
|
$ echo '*\.diff' > .gitignore
|
2010-08-12 17:57:06 +04:00
|
|
|
|
|
|
|
|
|
|
|
Test different --eol values
|
|
|
|
|
2020-08-19 10:31:05 +03:00
|
|
|
$ printf "a\nbbb\ncc\n\nd\ne" > a
|
2010-08-12 17:57:06 +04:00
|
|
|
$ hg ci -Am adda
|
2019-03-21 08:26:03 +03:00
|
|
|
adding .gitignore
|
2010-08-12 17:57:06 +04:00
|
|
|
adding a
|
2017-06-20 16:45:02 +03:00
|
|
|
$ $PYTHON ../makepatch.py
|
2010-08-12 17:57:06 +04:00
|
|
|
|
|
|
|
|
|
|
|
invalid eol
|
|
|
|
|
|
|
|
$ hg --config patch.eol='LFCR' import eol.diff
|
|
|
|
applying eol.diff
|
2010-08-30 00:55:37 +04:00
|
|
|
abort: unsupported line endings type: LFCR
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-08-12 17:57:06 +04:00
|
|
|
$ hg revert -a
|
|
|
|
|
|
|
|
|
|
|
|
force LF
|
|
|
|
|
|
|
|
$ hg --traceback --config patch.eol='LF' import eol.diff
|
|
|
|
applying eol.diff
|
2010-11-08 03:41:42 +03:00
|
|
|
$ cat a
|
|
|
|
a
|
|
|
|
yyyy
|
|
|
|
cc
|
|
|
|
|
|
|
|
d
|
|
|
|
e (no-eol)
|
2010-08-12 17:57:06 +04:00
|
|
|
$ hg st
|
|
|
|
|
|
|
|
|
|
|
|
force CRLF
|
|
|
|
|
2020-10-08 21:06:31 +03:00
|
|
|
$ hg up -C 'desc(adda)'
|
2010-08-12 17:57:06 +04:00
|
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ hg --traceback --config patch.eol='CRLF' import eol.diff
|
|
|
|
applying eol.diff
|
2010-11-08 03:41:42 +03:00
|
|
|
$ cat a
|
|
|
|
a\r (esc)
|
|
|
|
yyyy\r (esc)
|
|
|
|
cc\r (esc)
|
|
|
|
\r (esc)
|
|
|
|
d\r (esc)
|
|
|
|
e (no-eol)
|
2010-08-12 17:57:06 +04:00
|
|
|
$ hg st
|
|
|
|
|
|
|
|
|
|
|
|
auto EOL on LF file
|
|
|
|
|
2020-10-08 21:06:31 +03:00
|
|
|
$ hg up -C 'desc(adda)'
|
2010-08-12 17:57:06 +04:00
|
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ hg --traceback --config patch.eol='auto' import eol.diff
|
|
|
|
applying eol.diff
|
2010-11-08 03:41:42 +03:00
|
|
|
$ cat a
|
|
|
|
a
|
|
|
|
yyyy
|
|
|
|
cc
|
|
|
|
|
|
|
|
d
|
|
|
|
e (no-eol)
|
2010-08-12 17:57:06 +04:00
|
|
|
$ hg st
|
|
|
|
|
|
|
|
|
|
|
|
auto EOL on CRLF file
|
|
|
|
|
2020-08-19 10:31:05 +03:00
|
|
|
$ printf "a\r\nbbb\r\ncc\r\n\r\nd\r\ne" > a
|
2010-08-12 17:57:06 +04:00
|
|
|
$ hg commit -m 'switch EOLs in a'
|
|
|
|
$ hg --traceback --config patch.eol='auto' import eol.diff
|
|
|
|
applying eol.diff
|
2010-11-08 03:41:42 +03:00
|
|
|
$ cat a
|
|
|
|
a\r (esc)
|
|
|
|
yyyy\r (esc)
|
|
|
|
cc\r (esc)
|
|
|
|
\r (esc)
|
|
|
|
d\r (esc)
|
|
|
|
e (no-eol)
|
2010-08-12 17:57:06 +04:00
|
|
|
$ hg st
|
|
|
|
|
|
|
|
|
|
|
|
auto EOL on new file or source without any EOL
|
|
|
|
|
2020-08-19 10:31:05 +03:00
|
|
|
$ printf "noeol" > noeol
|
2010-08-12 17:57:06 +04:00
|
|
|
$ hg add noeol
|
|
|
|
$ hg commit -m 'add noeol'
|
2020-08-19 10:31:05 +03:00
|
|
|
$ printf "noeol\r\nnoeol\n" > noeol
|
|
|
|
$ printf "neweol\nneweol\r\n" > neweol
|
2010-08-12 17:57:06 +04:00
|
|
|
$ 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
|
2010-11-08 03:41:42 +03:00
|
|
|
$ cat noeol
|
|
|
|
noeol\r (esc)
|
|
|
|
noeol
|
|
|
|
$ cat neweol
|
|
|
|
neweol
|
|
|
|
neweol\r (esc)
|
2010-08-12 17:57:06 +04:00
|
|
|
$ hg st
|
|
|
|
|
|
|
|
|
|
|
|
Test --eol and binary patches
|
|
|
|
|
2020-08-19 10:31:05 +03:00
|
|
|
$ printf "a\x00\nb\r\nd" > b
|
2010-08-12 17:57:06 +04:00
|
|
|
$ hg ci -Am addb
|
|
|
|
adding b
|
2020-08-19 10:31:05 +03:00
|
|
|
$ printf "a\x00\nc\r\nd" > b
|
2010-08-12 17:57:06 +04:00
|
|
|
$ 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
|
2010-11-08 03:41:42 +03:00
|
|
|
$ cat b
|
|
|
|
a\x00 (esc)
|
|
|
|
c\r (esc)
|
|
|
|
d (no-eol)
|
2010-08-12 17:57:06 +04:00
|
|
|
$ hg st
|
|
|
|
$ cd ..
|