Mercurial > hg-stable
comparison tests/test-import.t @ 36062:2a81ed6c3bb9
py3: replace file() with open() in test-import.t
file() is not present in Python 3.
This patch also adds a b'' prefix to make sure we write bytes in Python 3.
Differential Revision: https://phab.mercurial-scm.org/D2123
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sun, 11 Feb 2018 17:08:40 +0530 |
parents | 4441705b7111 |
children | d83191e9749b |
comparison
equal
deleted
inserted
replaced
36061:adec6374a0b2 | 36062:2a81ed6c3bb9 |
---|---|
54 regardless of the commit message in the patch) | 54 regardless of the commit message in the patch) |
55 | 55 |
56 $ cat > dummypatch.py <<EOF | 56 $ cat > dummypatch.py <<EOF |
57 > from __future__ import print_function | 57 > from __future__ import print_function |
58 > print('patching file a') | 58 > print('patching file a') |
59 > file('a', 'wb').write('line2\n') | 59 > open('a', 'wb').write(b'line2\n') |
60 > EOF | 60 > EOF |
61 $ hg clone -r0 a b | 61 $ hg clone -r0 a b |
62 adding changesets | 62 adding changesets |
63 adding manifests | 63 adding manifests |
64 adding file changes | 64 adding file changes |
289 > msg = email.Message.Message() | 289 > msg = email.Message.Message() |
290 > patch = open(sys.argv[1], 'rb').read() | 290 > patch = open(sys.argv[1], 'rb').read() |
291 > msg.set_payload('email commit message\n' + patch) | 291 > msg.set_payload('email commit message\n' + patch) |
292 > msg['Subject'] = 'email patch' | 292 > msg['Subject'] = 'email patch' |
293 > msg['From'] = 'email patcher' | 293 > msg['From'] = 'email patcher' |
294 > file(sys.argv[2], 'wb').write(msg.as_string()) | 294 > open(sys.argv[2], 'wb').write(msg.as_string()) |
295 > EOF | 295 > EOF |
296 | 296 |
297 | 297 |
298 plain diff in email, subject, message body | 298 plain diff in email, subject, message body |
299 | 299 |
387 > msg = email.Message.Message() | 387 > msg = email.Message.Message() |
388 > patch = open(sys.argv[1], 'rb').read() | 388 > patch = open(sys.argv[1], 'rb').read() |
389 > msg.set_payload('email patch\n\nnext line\n---\n' + patch) | 389 > msg.set_payload('email patch\n\nnext line\n---\n' + patch) |
390 > msg['Subject'] = '[PATCH] email patch' | 390 > msg['Subject'] = '[PATCH] email patch' |
391 > msg['From'] = 'email patcher' | 391 > msg['From'] = 'email patcher' |
392 > file(sys.argv[2], 'wb').write(msg.as_string()) | 392 > open(sys.argv[2], 'wb').write(msg.as_string()) |
393 > EOF | 393 > EOF |
394 | 394 |
395 | 395 |
396 plain diff in email, [PATCH] subject, message body with subject | 396 plain diff in email, [PATCH] subject, message body with subject |
397 | 397 |
827 Test importing a patch ending with a binary file removal | 827 Test importing a patch ending with a binary file removal |
828 | 828 |
829 $ hg init binaryremoval | 829 $ hg init binaryremoval |
830 $ cd binaryremoval | 830 $ cd binaryremoval |
831 $ echo a > a | 831 $ echo a > a |
832 $ $PYTHON -c "file('b', 'wb').write('a\x00b')" | 832 $ $PYTHON -c "open('b', 'wb').write(b'a\x00b')" |
833 $ hg ci -Am addall | 833 $ hg ci -Am addall |
834 adding a | 834 adding a |
835 adding b | 835 adding b |
836 $ hg rm a | 836 $ hg rm a |
837 $ hg rm b | 837 $ hg rm b |