| 1 |
|
| 2 |
$ hg init t |
| 3 |
$ cd t |
| 4 |
$ cat > unix2dos.py <<EOF |
| 5 |
> import sys |
| 6 |
> |
| 7 |
> for path in sys.argv[1:]: |
| 8 |
> data = open(path, 'rb').read() |
| 9 |
> data = data.replace(b'\n', b'\r\n') |
| 10 |
> open(path, 'wb').write(data) |
| 11 |
> EOF |
| 12 |
$ echo '[hooks]' >> .hg/hgrc |
| 13 |
$ echo 'pretxncommit.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc |
| 14 |
$ echo 'pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc |
| 15 |
$ cat .hg/hgrc |
| 16 |
[hooks] |
| 17 |
pretxncommit.crlf = python:hgext.win32text.forbidcrlf |
| 18 |
pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf |
| 19 |
|
| 20 |
$ echo hello > f |
| 21 |
$ hg add f |
| 22 |
|
| 23 |
commit should succeed |
| 24 |
|
| 25 |
$ hg ci -m 1 |
| 26 |
|
| 27 |
$ hg clone . ../zoz |
| 28 |
updating to branch default |
| 29 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 30 |
$ cp .hg/hgrc ../zoz/.hg |
| 31 |
$ "$PYTHON" unix2dos.py f |
| 32 |
|
| 33 |
commit should fail |
| 34 |
|
| 35 |
$ hg ci -m 2.1 |
| 36 |
attempt to commit or push text file(s) using CRLF line endings |
| 37 |
in f583ea08d42a: f |
| 38 |
transaction abort! |
| 39 |
rollback completed |
| 40 |
abort: pretxncommit.crlf hook failed |
| 41 |
[40] |
| 42 |
|
| 43 |
$ mv .hg/hgrc .hg/hgrc.bak |
| 44 |
|
| 45 |
commits should succeed |
| 46 |
|
| 47 |
$ hg ci -m 2 |
| 48 |
$ hg cp f g |
| 49 |
$ hg ci -m 2.2 |
| 50 |
|
| 51 |
push should fail |
| 52 |
|
| 53 |
$ hg push ../zoz |
| 54 |
pushing to ../zoz |
| 55 |
searching for changes |
| 56 |
adding changesets |
| 57 |
adding manifests |
| 58 |
adding file changes |
| 59 |
attempt to commit or push text file(s) using CRLF line endings |
| 60 |
in bc2d09796734: g |
| 61 |
in b1aa5cde7ff4: f |
| 62 |
|
| 63 |
To prevent this mistake in your local repository, |
| 64 |
add to Mercurial.ini or .hg/hgrc: |
| 65 |
|
| 66 |
[hooks] |
| 67 |
pretxncommit.crlf = python:hgext.win32text.forbidcrlf |
| 68 |
|
| 69 |
and also consider adding: |
| 70 |
|
| 71 |
[extensions] |
| 72 |
win32text = |
| 73 |
[encode] |
| 74 |
** = cleverencode: |
| 75 |
[decode] |
| 76 |
** = cleverdecode: |
| 77 |
transaction abort! |
| 78 |
rollback completed |
| 79 |
abort: pretxnchangegroup.crlf hook failed |
| 80 |
[40] |
| 81 |
|
| 82 |
$ mv .hg/hgrc.bak .hg/hgrc |
| 83 |
$ echo hello > f |
| 84 |
$ hg rm g |
| 85 |
|
| 86 |
commit should succeed |
| 87 |
|
| 88 |
$ hg ci -m 2.3 |
| 89 |
|
| 90 |
push should succeed |
| 91 |
|
| 92 |
$ hg push ../zoz |
| 93 |
pushing to ../zoz |
| 94 |
searching for changes |
| 95 |
adding changesets |
| 96 |
adding manifests |
| 97 |
adding file changes |
| 98 |
added 3 changesets with 3 changes to 2 files |
| 99 |
|
| 100 |
and now for something completely different |
| 101 |
|
| 102 |
$ mkdir d |
| 103 |
$ echo hello > d/f2 |
| 104 |
$ "$PYTHON" unix2dos.py d/f2 |
| 105 |
$ hg add d/f2 |
| 106 |
$ hg ci -m 3 |
| 107 |
attempt to commit or push text file(s) using CRLF line endings |
| 108 |
in 053ba1a3035a: d/f2 |
| 109 |
transaction abort! |
| 110 |
rollback completed |
| 111 |
abort: pretxncommit.crlf hook failed |
| 112 |
[40] |
| 113 |
$ hg revert -a |
| 114 |
forgetting d/f2 |
| 115 |
$ rm d/f2 |
| 116 |
|
| 117 |
$ hg rem f |
| 118 |
$ hg ci -m 4 |
| 119 |
|
| 120 |
$ "$PYTHON" -c 'open("bin", "wb").write(b"hello\x00\x0D\x0A")' |
| 121 |
$ hg add bin |
| 122 |
$ hg ci -m 5 |
| 123 |
$ hg log -v |
| 124 |
changeset: 5:f0b1c8d75fce |
| 125 |
tag: tip |
| 126 |
user: test |
| 127 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 128 |
files: bin |
| 129 |
description: |
| 130 |
5 |
| 131 |
|
| 132 |
|
| 133 |
changeset: 4:77796dbcd4ad |
| 134 |
user: test |
| 135 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 136 |
files: f |
| 137 |
description: |
| 138 |
4 |
| 139 |
|
| 140 |
|
| 141 |
changeset: 3:7c1b5430b350 |
| 142 |
user: test |
| 143 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 144 |
files: f g |
| 145 |
description: |
| 146 |
2.3 |
| 147 |
|
| 148 |
|
| 149 |
changeset: 2:bc2d09796734 |
| 150 |
user: test |
| 151 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 152 |
files: g |
| 153 |
description: |
| 154 |
2.2 |
| 155 |
|
| 156 |
|
| 157 |
changeset: 1:b1aa5cde7ff4 |
| 158 |
user: test |
| 159 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 160 |
files: f |
| 161 |
description: |
| 162 |
2 |
| 163 |
|
| 164 |
|
| 165 |
changeset: 0:fcf06d5c4e1d |
| 166 |
user: test |
| 167 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 168 |
files: f |
| 169 |
description: |
| 170 |
1 |
| 171 |
|
| 172 |
|
| 173 |
$ hg clone . dupe |
| 174 |
updating to branch default |
| 175 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 176 |
|
| 177 |
$ for x in a b c d; do echo content > dupe/$x; done |
| 178 |
$ hg -R dupe add |
| 179 |
adding dupe/a |
| 180 |
adding dupe/b |
| 181 |
adding dupe/c |
| 182 |
adding dupe/d |
| 183 |
$ "$PYTHON" unix2dos.py dupe/b dupe/c dupe/d |
| 184 |
$ hg -R dupe ci -m a dupe/a |
| 185 |
$ hg -R dupe ci -m b/c dupe/[bc] |
| 186 |
$ hg -R dupe ci -m d dupe/d |
| 187 |
$ hg -R dupe log -v |
| 188 |
changeset: 8:67ac5962ab43 |
| 189 |
tag: tip |
| 190 |
user: test |
| 191 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 192 |
files: d |
| 193 |
description: |
| 194 |
d |
| 195 |
|
| 196 |
|
| 197 |
changeset: 7:68c127d1834e |
| 198 |
user: test |
| 199 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 200 |
files: b c |
| 201 |
description: |
| 202 |
b/c |
| 203 |
|
| 204 |
|
| 205 |
changeset: 6:adbf8bf7f31d |
| 206 |
user: test |
| 207 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 208 |
files: a |
| 209 |
description: |
| 210 |
a |
| 211 |
|
| 212 |
|
| 213 |
changeset: 5:f0b1c8d75fce |
| 214 |
user: test |
| 215 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 216 |
files: bin |
| 217 |
description: |
| 218 |
5 |
| 219 |
|
| 220 |
|
| 221 |
changeset: 4:77796dbcd4ad |
| 222 |
user: test |
| 223 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 224 |
files: f |
| 225 |
description: |
| 226 |
4 |
| 227 |
|
| 228 |
|
| 229 |
changeset: 3:7c1b5430b350 |
| 230 |
user: test |
| 231 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 232 |
files: f g |
| 233 |
description: |
| 234 |
2.3 |
| 235 |
|
| 236 |
|
| 237 |
changeset: 2:bc2d09796734 |
| 238 |
user: test |
| 239 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 240 |
files: g |
| 241 |
description: |
| 242 |
2.2 |
| 243 |
|
| 244 |
|
| 245 |
changeset: 1:b1aa5cde7ff4 |
| 246 |
user: test |
| 247 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 248 |
files: f |
| 249 |
description: |
| 250 |
2 |
| 251 |
|
| 252 |
|
| 253 |
changeset: 0:fcf06d5c4e1d |
| 254 |
user: test |
| 255 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 256 |
files: f |
| 257 |
description: |
| 258 |
1 |
| 259 |
|
| 260 |
|
| 261 |
$ hg pull dupe |
| 262 |
pulling from dupe |
| 263 |
searching for changes |
| 264 |
adding changesets |
| 265 |
adding manifests |
| 266 |
adding file changes |
| 267 |
attempt to commit or push text file(s) using CRLF line endings |
| 268 |
in 67ac5962ab43: d |
| 269 |
in 68c127d1834e: b |
| 270 |
in 68c127d1834e: c |
| 271 |
|
| 272 |
To prevent this mistake in your local repository, |
| 273 |
add to Mercurial.ini or .hg/hgrc: |
| 274 |
|
| 275 |
[hooks] |
| 276 |
pretxncommit.crlf = python:hgext.win32text.forbidcrlf |
| 277 |
|
| 278 |
and also consider adding: |
| 279 |
|
| 280 |
[extensions] |
| 281 |
win32text = |
| 282 |
[encode] |
| 283 |
** = cleverencode: |
| 284 |
[decode] |
| 285 |
** = cleverdecode: |
| 286 |
transaction abort! |
| 287 |
rollback completed |
| 288 |
abort: pretxnchangegroup.crlf hook failed |
| 289 |
[40] |
| 290 |
|
| 291 |
$ hg log -v |
| 292 |
changeset: 5:f0b1c8d75fce |
| 293 |
tag: tip |
| 294 |
user: test |
| 295 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 296 |
files: bin |
| 297 |
description: |
| 298 |
5 |
| 299 |
|
| 300 |
|
| 301 |
changeset: 4:77796dbcd4ad |
| 302 |
user: test |
| 303 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 304 |
files: f |
| 305 |
description: |
| 306 |
4 |
| 307 |
|
| 308 |
|
| 309 |
changeset: 3:7c1b5430b350 |
| 310 |
user: test |
| 311 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 312 |
files: f g |
| 313 |
description: |
| 314 |
2.3 |
| 315 |
|
| 316 |
|
| 317 |
changeset: 2:bc2d09796734 |
| 318 |
user: test |
| 319 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 320 |
files: g |
| 321 |
description: |
| 322 |
2.2 |
| 323 |
|
| 324 |
|
| 325 |
changeset: 1:b1aa5cde7ff4 |
| 326 |
user: test |
| 327 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 328 |
files: f |
| 329 |
description: |
| 330 |
2 |
| 331 |
|
| 332 |
|
| 333 |
changeset: 0:fcf06d5c4e1d |
| 334 |
user: test |
| 335 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 336 |
files: f |
| 337 |
description: |
| 338 |
1 |
| 339 |
|
| 340 |
|
| 341 |
$ rm .hg/hgrc |
| 342 |
$ (echo some; echo text) > f3 |
| 343 |
$ "$PYTHON" -c 'open("f4.bat", "wb").write(b"rem empty\x0D\x0A")' |
| 344 |
$ hg add f3 f4.bat |
| 345 |
$ hg ci -m 6 |
| 346 |
$ cat bin |
| 347 |
hello\x00\r (esc) |
| 348 |
$ cat f3 |
| 349 |
some |
| 350 |
text |
| 351 |
$ cat f4.bat |
| 352 |
rem empty\r (esc) |
| 353 |
|
| 354 |
$ echo '[extensions]' >> .hg/hgrc |
| 355 |
$ echo 'win32text = ' >> .hg/hgrc |
| 356 |
$ echo '[decode]' >> .hg/hgrc |
| 357 |
$ echo '** = cleverdecode:' >> .hg/hgrc |
| 358 |
$ echo '[encode]' >> .hg/hgrc |
| 359 |
$ echo '** = cleverencode:' >> .hg/hgrc |
| 360 |
$ cat .hg/hgrc |
| 361 |
[extensions] |
| 362 |
win32text = |
| 363 |
[decode] |
| 364 |
** = cleverdecode: |
| 365 |
[encode] |
| 366 |
** = cleverencode: |
| 367 |
|
| 368 |
Trigger deprecation warning: |
| 369 |
|
| 370 |
$ hg id -t |
| 371 |
win32text is deprecated: https://mercurial-scm.org/wiki/Win32TextExtension |
| 372 |
tip |
| 373 |
|
| 374 |
Disable warning: |
| 375 |
|
| 376 |
$ echo '[win32text]' >> .hg/hgrc |
| 377 |
$ echo 'warn = no' >> .hg/hgrc |
| 378 |
$ hg id -t |
| 379 |
tip |
| 380 |
|
| 381 |
$ rm f3 f4.bat bin |
| 382 |
$ hg co -C |
| 383 |
WARNING: f4.bat already has CRLF line endings |
| 384 |
and does not need EOL conversion by the win32text plugin. |
| 385 |
Before your next commit, please reconsider your encode/decode settings in |
| 386 |
Mercurial.ini or $TESTTMP/t/.hg/hgrc. |
| 387 |
3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 388 |
$ cat bin |
| 389 |
hello\x00\r (esc) |
| 390 |
$ cat f3 |
| 391 |
some\r (esc) |
| 392 |
text\r (esc) |
| 393 |
$ cat f4.bat |
| 394 |
rem empty\r (esc) |
| 395 |
|
| 396 |
$ "$PYTHON" -c 'open("f5.sh", "wb").write(b"# empty\x0D\x0A")' |
| 397 |
$ hg add f5.sh |
| 398 |
$ hg ci -m 7 |
| 399 |
$ cat f5.sh |
| 400 |
# empty\r (esc) |
| 401 |
$ hg cat f5.sh |
| 402 |
# empty |
| 403 |
$ echo '% just linefeed' > linefeed |
| 404 |
$ hg ci -qAm 8 linefeed |
| 405 |
$ cat linefeed |
| 406 |
% just linefeed |
| 407 |
$ hg cat linefeed |
| 408 |
% just linefeed |
| 409 |
$ hg st -q |
| 410 |
$ hg revert -a linefeed |
| 411 |
no changes needed to linefeed |
| 412 |
$ cat linefeed |
| 413 |
% just linefeed |
| 414 |
$ hg st -q |
| 415 |
$ echo modified >> linefeed |
| 416 |
$ hg st -q |
| 417 |
M linefeed |
| 418 |
$ hg revert -a |
| 419 |
reverting linefeed |
| 420 |
$ hg st -q |
| 421 |
$ cat linefeed |
| 422 |
% just linefeed\r (esc) |
| 423 |
|
| 424 |
$ cd .. |