| 1 |
Test EOL patching |
| 2 |
|
| 3 |
$ cat >> $HGRCPATH <<EOF |
| 4 |
> [diff] |
| 5 |
> git = 1 |
| 6 |
> EOF |
| 7 |
|
| 8 |
Set up helpers |
| 9 |
|
| 10 |
$ seteol () { |
| 11 |
> if [ $1 = "LF" ]; then |
| 12 |
> EOL='\n' |
| 13 |
> else |
| 14 |
> EOL='\r\n' |
| 15 |
> fi |
| 16 |
> } |
| 17 |
|
| 18 |
$ makerepo () { |
| 19 |
> seteol $1 |
| 20 |
> echo |
| 21 |
> echo "# ==== setup $1 repository ====" |
| 22 |
> echo '% hg init' |
| 23 |
> hg init repo |
| 24 |
> cd repo |
| 25 |
> cat > .hgeol <<EOF |
| 26 |
> [repository] |
| 27 |
> native = $1 |
| 28 |
> [patterns] |
| 29 |
> unix.txt = LF |
| 30 |
> win.txt = CRLF |
| 31 |
> **.txt = native |
| 32 |
> EOF |
| 33 |
> printf "first\r\nsecond\r\nthird\r\n" > win.txt |
| 34 |
> printf "first\nsecond\nthird\n" > unix.txt |
| 35 |
> printf "first${EOL}second${EOL}third${EOL}" > native.txt |
| 36 |
> hg commit --addremove -m 'checkin' |
| 37 |
> cd .. |
| 38 |
> } |
| 39 |
|
| 40 |
$ dotest () { |
| 41 |
> seteol $1 |
| 42 |
> echo |
| 43 |
> echo "% hg clone repo repo-$1" |
| 44 |
> hg clone --noupdate repo repo-$1 |
| 45 |
> cd repo-$1 |
| 46 |
> cat > .hg/hgrc <<EOF |
| 47 |
> [extensions] |
| 48 |
> eol = |
| 49 |
> [eol] |
| 50 |
> native = $1 |
| 51 |
> EOF |
| 52 |
> hg update |
| 53 |
> echo '% native.txt' |
| 54 |
> cat native.txt |
| 55 |
> echo '% unix.txt' |
| 56 |
> cat unix.txt |
| 57 |
> echo '% win.txt' |
| 58 |
> cat win.txt |
| 59 |
> printf "first${EOL}third${EOL}" > native.txt |
| 60 |
> printf "first\r\nthird\r\n" > win.txt |
| 61 |
> printf "first\nthird\n" > unix.txt |
| 62 |
> echo '% hg diff' |
| 63 |
> hg diff > p |
| 64 |
> cat p |
| 65 |
> echo '% hg revert' |
| 66 |
> hg revert --all |
| 67 |
> echo '% hg import' |
| 68 |
> hg import -m 'patch' p |
| 69 |
> echo '% native.txt' |
| 70 |
> cat native.txt |
| 71 |
> echo '% unix.txt' |
| 72 |
> cat unix.txt |
| 73 |
> echo '% win.txt' |
| 74 |
> cat win.txt |
| 75 |
> echo '% hg diff -c tip' |
| 76 |
> hg diff -c tip |
| 77 |
> cd .. |
| 78 |
> rm -r repo-$1 |
| 79 |
> } |
| 80 |
|
| 81 |
Run tests |
| 82 |
|
| 83 |
$ makerepo LF |
| 84 |
|
| 85 |
# ==== setup LF repository ==== |
| 86 |
% hg init |
| 87 |
adding .hgeol |
| 88 |
adding native.txt |
| 89 |
adding unix.txt |
| 90 |
adding win.txt |
| 91 |
$ dotest LF |
| 92 |
|
| 93 |
% hg clone repo repo-LF |
| 94 |
4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 95 |
% native.txt |
| 96 |
first |
| 97 |
second |
| 98 |
third |
| 99 |
% unix.txt |
| 100 |
first |
| 101 |
second |
| 102 |
third |
| 103 |
% win.txt |
| 104 |
first\r (esc) |
| 105 |
second\r (esc) |
| 106 |
third\r (esc) |
| 107 |
% hg diff |
| 108 |
diff --git a/native.txt b/native.txt |
| 109 |
--- a/native.txt |
| 110 |
+++ b/native.txt |
| 111 |
@@ -1,3 +1,2 @@ |
| 112 |
first |
| 113 |
-second |
| 114 |
third |
| 115 |
diff --git a/unix.txt b/unix.txt |
| 116 |
--- a/unix.txt |
| 117 |
+++ b/unix.txt |
| 118 |
@@ -1,3 +1,2 @@ |
| 119 |
first |
| 120 |
-second |
| 121 |
third |
| 122 |
diff --git a/win.txt b/win.txt |
| 123 |
--- a/win.txt |
| 124 |
+++ b/win.txt |
| 125 |
@@ -1,3 +1,2 @@ |
| 126 |
first\r (esc) |
| 127 |
-second\r (esc) |
| 128 |
third\r (esc) |
| 129 |
% hg revert |
| 130 |
reverting native.txt |
| 131 |
reverting unix.txt |
| 132 |
reverting win.txt |
| 133 |
% hg import |
| 134 |
applying p |
| 135 |
% native.txt |
| 136 |
first |
| 137 |
third |
| 138 |
% unix.txt |
| 139 |
first |
| 140 |
third |
| 141 |
% win.txt |
| 142 |
first\r (esc) |
| 143 |
third\r (esc) |
| 144 |
% hg diff -c tip |
| 145 |
diff --git a/native.txt b/native.txt |
| 146 |
--- a/native.txt |
| 147 |
+++ b/native.txt |
| 148 |
@@ -1,3 +1,2 @@ |
| 149 |
first |
| 150 |
-second |
| 151 |
third |
| 152 |
diff --git a/unix.txt b/unix.txt |
| 153 |
--- a/unix.txt |
| 154 |
+++ b/unix.txt |
| 155 |
@@ -1,3 +1,2 @@ |
| 156 |
first |
| 157 |
-second |
| 158 |
third |
| 159 |
diff --git a/win.txt b/win.txt |
| 160 |
--- a/win.txt |
| 161 |
+++ b/win.txt |
| 162 |
@@ -1,3 +1,2 @@ |
| 163 |
first\r (esc) |
| 164 |
-second\r (esc) |
| 165 |
third\r (esc) |
| 166 |
$ dotest CRLF |
| 167 |
|
| 168 |
% hg clone repo repo-CRLF |
| 169 |
4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 170 |
% native.txt |
| 171 |
first\r (esc) |
| 172 |
second\r (esc) |
| 173 |
third\r (esc) |
| 174 |
% unix.txt |
| 175 |
first |
| 176 |
second |
| 177 |
third |
| 178 |
% win.txt |
| 179 |
first\r (esc) |
| 180 |
second\r (esc) |
| 181 |
third\r (esc) |
| 182 |
% hg diff |
| 183 |
diff --git a/native.txt b/native.txt |
| 184 |
--- a/native.txt |
| 185 |
+++ b/native.txt |
| 186 |
@@ -1,3 +1,2 @@ |
| 187 |
first |
| 188 |
-second |
| 189 |
third |
| 190 |
diff --git a/unix.txt b/unix.txt |
| 191 |
--- a/unix.txt |
| 192 |
+++ b/unix.txt |
| 193 |
@@ -1,3 +1,2 @@ |
| 194 |
first |
| 195 |
-second |
| 196 |
third |
| 197 |
diff --git a/win.txt b/win.txt |
| 198 |
--- a/win.txt |
| 199 |
+++ b/win.txt |
| 200 |
@@ -1,3 +1,2 @@ |
| 201 |
first\r (esc) |
| 202 |
-second\r (esc) |
| 203 |
third\r (esc) |
| 204 |
% hg revert |
| 205 |
reverting native.txt |
| 206 |
reverting unix.txt |
| 207 |
reverting win.txt |
| 208 |
% hg import |
| 209 |
applying p |
| 210 |
% native.txt |
| 211 |
first\r (esc) |
| 212 |
third\r (esc) |
| 213 |
% unix.txt |
| 214 |
first |
| 215 |
third |
| 216 |
% win.txt |
| 217 |
first\r (esc) |
| 218 |
third\r (esc) |
| 219 |
% hg diff -c tip |
| 220 |
diff --git a/native.txt b/native.txt |
| 221 |
--- a/native.txt |
| 222 |
+++ b/native.txt |
| 223 |
@@ -1,3 +1,2 @@ |
| 224 |
first |
| 225 |
-second |
| 226 |
third |
| 227 |
diff --git a/unix.txt b/unix.txt |
| 228 |
--- a/unix.txt |
| 229 |
+++ b/unix.txt |
| 230 |
@@ -1,3 +1,2 @@ |
| 231 |
first |
| 232 |
-second |
| 233 |
third |
| 234 |
diff --git a/win.txt b/win.txt |
| 235 |
--- a/win.txt |
| 236 |
+++ b/win.txt |
| 237 |
@@ -1,3 +1,2 @@ |
| 238 |
first\r (esc) |
| 239 |
-second\r (esc) |
| 240 |
third\r (esc) |
| 241 |
$ rm -r repo |
| 242 |
$ makerepo CRLF |
| 243 |
|
| 244 |
# ==== setup CRLF repository ==== |
| 245 |
% hg init |
| 246 |
adding .hgeol |
| 247 |
adding native.txt |
| 248 |
adding unix.txt |
| 249 |
adding win.txt |
| 250 |
$ dotest LF |
| 251 |
|
| 252 |
% hg clone repo repo-LF |
| 253 |
4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 254 |
% native.txt |
| 255 |
first |
| 256 |
second |
| 257 |
third |
| 258 |
% unix.txt |
| 259 |
first |
| 260 |
second |
| 261 |
third |
| 262 |
% win.txt |
| 263 |
first\r (esc) |
| 264 |
second\r (esc) |
| 265 |
third\r (esc) |
| 266 |
% hg diff |
| 267 |
diff --git a/native.txt b/native.txt |
| 268 |
--- a/native.txt |
| 269 |
+++ b/native.txt |
| 270 |
@@ -1,3 +1,2 @@ |
| 271 |
first\r (esc) |
| 272 |
-second\r (esc) |
| 273 |
third\r (esc) |
| 274 |
diff --git a/unix.txt b/unix.txt |
| 275 |
--- a/unix.txt |
| 276 |
+++ b/unix.txt |
| 277 |
@@ -1,3 +1,2 @@ |
| 278 |
first |
| 279 |
-second |
| 280 |
third |
| 281 |
diff --git a/win.txt b/win.txt |
| 282 |
--- a/win.txt |
| 283 |
+++ b/win.txt |
| 284 |
@@ -1,3 +1,2 @@ |
| 285 |
first\r (esc) |
| 286 |
-second\r (esc) |
| 287 |
third\r (esc) |
| 288 |
% hg revert |
| 289 |
reverting native.txt |
| 290 |
reverting unix.txt |
| 291 |
reverting win.txt |
| 292 |
% hg import |
| 293 |
applying p |
| 294 |
% native.txt |
| 295 |
first |
| 296 |
third |
| 297 |
% unix.txt |
| 298 |
first |
| 299 |
third |
| 300 |
% win.txt |
| 301 |
first\r (esc) |
| 302 |
third\r (esc) |
| 303 |
% hg diff -c tip |
| 304 |
diff --git a/native.txt b/native.txt |
| 305 |
--- a/native.txt |
| 306 |
+++ b/native.txt |
| 307 |
@@ -1,3 +1,2 @@ |
| 308 |
first\r (esc) |
| 309 |
-second\r (esc) |
| 310 |
third\r (esc) |
| 311 |
diff --git a/unix.txt b/unix.txt |
| 312 |
--- a/unix.txt |
| 313 |
+++ b/unix.txt |
| 314 |
@@ -1,3 +1,2 @@ |
| 315 |
first |
| 316 |
-second |
| 317 |
third |
| 318 |
diff --git a/win.txt b/win.txt |
| 319 |
--- a/win.txt |
| 320 |
+++ b/win.txt |
| 321 |
@@ -1,3 +1,2 @@ |
| 322 |
first\r (esc) |
| 323 |
-second\r (esc) |
| 324 |
third\r (esc) |
| 325 |
$ dotest CRLF |
| 326 |
|
| 327 |
% hg clone repo repo-CRLF |
| 328 |
4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 329 |
% native.txt |
| 330 |
first\r (esc) |
| 331 |
second\r (esc) |
| 332 |
third\r (esc) |
| 333 |
% unix.txt |
| 334 |
first |
| 335 |
second |
| 336 |
third |
| 337 |
% win.txt |
| 338 |
first\r (esc) |
| 339 |
second\r (esc) |
| 340 |
third\r (esc) |
| 341 |
% hg diff |
| 342 |
diff --git a/native.txt b/native.txt |
| 343 |
--- a/native.txt |
| 344 |
+++ b/native.txt |
| 345 |
@@ -1,3 +1,2 @@ |
| 346 |
first\r (esc) |
| 347 |
-second\r (esc) |
| 348 |
third\r (esc) |
| 349 |
diff --git a/unix.txt b/unix.txt |
| 350 |
--- a/unix.txt |
| 351 |
+++ b/unix.txt |
| 352 |
@@ -1,3 +1,2 @@ |
| 353 |
first |
| 354 |
-second |
| 355 |
third |
| 356 |
diff --git a/win.txt b/win.txt |
| 357 |
--- a/win.txt |
| 358 |
+++ b/win.txt |
| 359 |
@@ -1,3 +1,2 @@ |
| 360 |
first\r (esc) |
| 361 |
-second\r (esc) |
| 362 |
third\r (esc) |
| 363 |
% hg revert |
| 364 |
reverting native.txt |
| 365 |
reverting unix.txt |
| 366 |
reverting win.txt |
| 367 |
% hg import |
| 368 |
applying p |
| 369 |
% native.txt |
| 370 |
first\r (esc) |
| 371 |
third\r (esc) |
| 372 |
% unix.txt |
| 373 |
first |
| 374 |
third |
| 375 |
% win.txt |
| 376 |
first\r (esc) |
| 377 |
third\r (esc) |
| 378 |
% hg diff -c tip |
| 379 |
diff --git a/native.txt b/native.txt |
| 380 |
--- a/native.txt |
| 381 |
+++ b/native.txt |
| 382 |
@@ -1,3 +1,2 @@ |
| 383 |
first\r (esc) |
| 384 |
-second\r (esc) |
| 385 |
third\r (esc) |
| 386 |
diff --git a/unix.txt b/unix.txt |
| 387 |
--- a/unix.txt |
| 388 |
+++ b/unix.txt |
| 389 |
@@ -1,3 +1,2 @@ |
| 390 |
first |
| 391 |
-second |
| 392 |
third |
| 393 |
diff --git a/win.txt b/win.txt |
| 394 |
--- a/win.txt |
| 395 |
+++ b/win.txt |
| 396 |
@@ -1,3 +1,2 @@ |
| 397 |
first\r (esc) |
| 398 |
-second\r (esc) |
| 399 |
third\r (esc) |
| 400 |
$ rm -r repo |