| 1 |
|
| 2 |
Test interactions between mq and patch.eol |
| 3 |
|
| 4 |
|
| 5 |
$ cat <<EOF >> $HGRCPATH |
| 6 |
> [extensions] |
| 7 |
> mq = |
| 8 |
> [diff] |
| 9 |
> nodates = 1 |
| 10 |
> EOF |
| 11 |
|
| 12 |
$ cat > makepatch.py <<EOF |
| 13 |
> f = open('eol.diff', 'wb') |
| 14 |
> w = f.write |
| 15 |
> w(b'test message\n') |
| 16 |
> w(b'diff --git a/a b/a\n') |
| 17 |
> w(b'--- a/a\n') |
| 18 |
> w(b'+++ b/a\n') |
| 19 |
> w(b'@@ -1,5 +1,5 @@\n') |
| 20 |
> w(b' a\n') |
| 21 |
> w(b'-b\r\n') |
| 22 |
> w(b'+y\r\n') |
| 23 |
> w(b' c\r\n') |
| 24 |
> w(b' d\n') |
| 25 |
> w(b'-e\n') |
| 26 |
> w(b'\\\\ No newline at end of file\n') |
| 27 |
> w(b'+z\r\n') |
| 28 |
> w(b'\\\\ No newline at end of file\r\n') |
| 29 |
> EOF |
| 30 |
|
| 31 |
$ cat > cateol.py <<EOF |
| 32 |
> import sys |
| 33 |
> try: |
| 34 |
> stdout = sys.stdout.buffer |
| 35 |
> except AttributeError: |
| 36 |
> stdout = sys.stdout |
| 37 |
> for line in open(sys.argv[1], 'rb'): |
| 38 |
> line = line.replace(b'\r', b'<CR>') |
| 39 |
> line = line.replace(b'\n', b'<LF>') |
| 40 |
> stdout.write(line + b'\n') |
| 41 |
> EOF |
| 42 |
|
| 43 |
$ hg init repo |
| 44 |
$ cd repo |
| 45 |
$ echo '\.diff' > .hgignore |
| 46 |
$ echo '\.rej' >> .hgignore |
| 47 |
|
| 48 |
|
| 49 |
Test different --eol values |
| 50 |
|
| 51 |
$ "$PYTHON" -c 'open("a", "wb").write(b"a\nb\nc\nd\ne")' |
| 52 |
$ hg ci -Am adda |
| 53 |
adding .hgignore |
| 54 |
adding a |
| 55 |
$ "$PYTHON" ../makepatch.py |
| 56 |
$ hg qimport eol.diff |
| 57 |
adding eol.diff to series file |
| 58 |
|
| 59 |
should fail in strict mode |
| 60 |
|
| 61 |
$ hg qpush |
| 62 |
applying eol.diff |
| 63 |
patching file a |
| 64 |
Hunk #1 FAILED at 0 |
| 65 |
1 out of 1 hunks FAILED -- saving rejects to file a.rej |
| 66 |
patch failed, unable to continue (try -v) |
| 67 |
patch failed, rejects left in working directory |
| 68 |
errors during apply, please fix and qrefresh eol.diff |
| 69 |
[2] |
| 70 |
$ hg qpop |
| 71 |
popping eol.diff |
| 72 |
patch queue now empty |
| 73 |
|
| 74 |
invalid eol |
| 75 |
|
| 76 |
$ hg --config patch.eol='LFCR' qpush |
| 77 |
applying eol.diff |
| 78 |
patch failed, unable to continue (try -v) |
| 79 |
patch failed, rejects left in working directory |
| 80 |
errors during apply, please fix and qrefresh eol.diff |
| 81 |
[2] |
| 82 |
$ hg qpop |
| 83 |
popping eol.diff |
| 84 |
patch queue now empty |
| 85 |
|
| 86 |
force LF |
| 87 |
|
| 88 |
$ hg --config patch.eol='CRLF' qpush |
| 89 |
applying eol.diff |
| 90 |
now at: eol.diff |
| 91 |
$ hg qrefresh |
| 92 |
$ "$PYTHON" ../cateol.py .hg/patches/eol.diff |
| 93 |
# HG changeset patch<LF> |
| 94 |
# Parent 0d0bf99a8b7a3842c6f8ef09e34f69156c4bd9d0<LF> |
| 95 |
test message<LF> |
| 96 |
<LF> |
| 97 |
diff -r 0d0bf99a8b7a a<LF> |
| 98 |
--- a/a<LF> |
| 99 |
+++ b/a<LF> |
| 100 |
@@ -1,5 +1,5 @@<LF> |
| 101 |
-a<LF> |
| 102 |
-b<LF> |
| 103 |
-c<LF> |
| 104 |
-d<LF> |
| 105 |
-e<LF> |
| 106 |
\ No newline at end of file<LF> |
| 107 |
+a<CR><LF> |
| 108 |
+y<CR><LF> |
| 109 |
+c<CR><LF> |
| 110 |
+d<CR><LF> |
| 111 |
+z<LF> |
| 112 |
\ No newline at end of file<LF> |
| 113 |
$ "$PYTHON" ../cateol.py a |
| 114 |
a<CR><LF> |
| 115 |
y<CR><LF> |
| 116 |
c<CR><LF> |
| 117 |
d<CR><LF> |
| 118 |
z |
| 119 |
$ hg qpop |
| 120 |
popping eol.diff |
| 121 |
patch queue now empty |
| 122 |
|
| 123 |
push again forcing LF and compare revisions |
| 124 |
|
| 125 |
$ hg --config patch.eol='CRLF' qpush |
| 126 |
applying eol.diff |
| 127 |
now at: eol.diff |
| 128 |
$ "$PYTHON" ../cateol.py a |
| 129 |
a<CR><LF> |
| 130 |
y<CR><LF> |
| 131 |
c<CR><LF> |
| 132 |
d<CR><LF> |
| 133 |
z |
| 134 |
$ hg qpop |
| 135 |
popping eol.diff |
| 136 |
patch queue now empty |
| 137 |
|
| 138 |
push again without LF and compare revisions |
| 139 |
|
| 140 |
$ hg qpush |
| 141 |
applying eol.diff |
| 142 |
now at: eol.diff |
| 143 |
$ "$PYTHON" ../cateol.py a |
| 144 |
a<CR><LF> |
| 145 |
y<CR><LF> |
| 146 |
c<CR><LF> |
| 147 |
d<CR><LF> |
| 148 |
z |
| 149 |
$ hg qpop |
| 150 |
popping eol.diff |
| 151 |
patch queue now empty |
| 152 |
$ cd .. |
| 153 |
|
| 154 |
|
| 155 |
Test .rej file EOL are left unchanged |
| 156 |
|
| 157 |
$ hg init testeol |
| 158 |
$ cd testeol |
| 159 |
$ "$PYTHON" -c "open('a', 'wb').write(b'1\r\n2\r\n3\r\n4')" |
| 160 |
$ hg ci -Am adda |
| 161 |
adding a |
| 162 |
$ "$PYTHON" -c "open('a', 'wb').write(b'1\r\n2\r\n33\r\n4')" |
| 163 |
$ hg qnew patch1 |
| 164 |
$ hg qpop |
| 165 |
popping patch1 |
| 166 |
patch queue now empty |
| 167 |
$ "$PYTHON" -c "open('a', 'wb').write(b'1\r\n22\r\n33\r\n4')" |
| 168 |
$ hg ci -m changea |
| 169 |
|
| 170 |
$ hg --config 'patch.eol=LF' qpush |
| 171 |
applying patch1 |
| 172 |
patching file a |
| 173 |
Hunk #1 FAILED at 0 |
| 174 |
1 out of 1 hunks FAILED -- saving rejects to file a.rej |
| 175 |
patch failed, unable to continue (try -v) |
| 176 |
patch failed, rejects left in working directory |
| 177 |
errors during apply, please fix and qrefresh patch1 |
| 178 |
[2] |
| 179 |
$ hg qpop |
| 180 |
popping patch1 |
| 181 |
patch queue now empty |
| 182 |
$ cat a.rej |
| 183 |
--- a |
| 184 |
+++ a |
| 185 |
@@ -1,4 +1,4 @@ |
| 186 |
1\r (esc) |
| 187 |
2\r (esc) |
| 188 |
-3\r (esc) |
| 189 |
+33\r (esc) |
| 190 |
4 |
| 191 |
\ No newline at end of file |
| 192 |
|
| 193 |
$ hg --config 'patch.eol=auto' qpush |
| 194 |
applying patch1 |
| 195 |
patching file a |
| 196 |
Hunk #1 FAILED at 0 |
| 197 |
1 out of 1 hunks FAILED -- saving rejects to file a.rej |
| 198 |
patch failed, unable to continue (try -v) |
| 199 |
patch failed, rejects left in working directory |
| 200 |
errors during apply, please fix and qrefresh patch1 |
| 201 |
[2] |
| 202 |
$ hg qpop |
| 203 |
popping patch1 |
| 204 |
patch queue now empty |
| 205 |
$ cat a.rej |
| 206 |
--- a |
| 207 |
+++ a |
| 208 |
@@ -1,4 +1,4 @@ |
| 209 |
1\r (esc) |
| 210 |
2\r (esc) |
| 211 |
-3\r (esc) |
| 212 |
+33\r (esc) |
| 213 |
4 |
| 214 |
\ No newline at end of file |
| 215 |
$ cd .. |