Mercurial > hg
comparison tests/test-mq-eol.t @ 35945:1dbd8a62b581
py3: use open() instead of file()
file() is not present in Python 3.
Differential Revision: https://phab.mercurial-scm.org/D2073
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Wed, 07 Feb 2018 13:19:19 +0530 |
parents | 24849d53697d |
children | a67b144ef74f |
comparison
equal
deleted
inserted
replaced
35944:01b4d88ccb24 | 35945:1dbd8a62b581 |
---|---|
8 > [diff] | 8 > [diff] |
9 > nodates = 1 | 9 > nodates = 1 |
10 > EOF | 10 > EOF |
11 | 11 |
12 $ cat > makepatch.py <<EOF | 12 $ cat > makepatch.py <<EOF |
13 > f = file('eol.diff', 'wb') | 13 > f = open('eol.diff', 'wb') |
14 > w = f.write | 14 > w = f.write |
15 > w('test message\n') | 15 > w('test message\n') |
16 > w('diff --git a/a b/a\n') | 16 > w('diff --git a/a b/a\n') |
17 > w('--- a/a\n') | 17 > w('--- a/a\n') |
18 > w('+++ b/a\n') | 18 > w('+++ b/a\n') |
28 > w('\ No newline at end of file\r\n') | 28 > w('\ No newline at end of file\r\n') |
29 > EOF | 29 > EOF |
30 | 30 |
31 $ cat > cateol.py <<EOF | 31 $ cat > cateol.py <<EOF |
32 > import sys | 32 > import sys |
33 > for line in file(sys.argv[1], 'rb'): | 33 > for line in open(sys.argv[1], 'rb'): |
34 > line = line.replace('\r', '<CR>') | 34 > line = line.replace('\r', '<CR>') |
35 > line = line.replace('\n', '<LF>') | 35 > line = line.replace('\n', '<LF>') |
36 > print(line) | 36 > print(line) |
37 > EOF | 37 > EOF |
38 | 38 |
42 $ echo '\.rej' >> .hgignore | 42 $ echo '\.rej' >> .hgignore |
43 | 43 |
44 | 44 |
45 Test different --eol values | 45 Test different --eol values |
46 | 46 |
47 $ $PYTHON -c 'file("a", "wb").write("a\nb\nc\nd\ne")' | 47 $ $PYTHON -c 'open("a", "wb").write("a\nb\nc\nd\ne")' |
48 $ hg ci -Am adda | 48 $ hg ci -Am adda |
49 adding .hgignore | 49 adding .hgignore |
50 adding a | 50 adding a |
51 $ $PYTHON ../makepatch.py | 51 $ $PYTHON ../makepatch.py |
52 $ hg qimport eol.diff | 52 $ hg qimport eol.diff |
150 | 150 |
151 Test .rej file EOL are left unchanged | 151 Test .rej file EOL are left unchanged |
152 | 152 |
153 $ hg init testeol | 153 $ hg init testeol |
154 $ cd testeol | 154 $ cd testeol |
155 $ $PYTHON -c "file('a', 'wb').write('1\r\n2\r\n3\r\n4')" | 155 $ $PYTHON -c "open('a', 'wb').write('1\r\n2\r\n3\r\n4')" |
156 $ hg ci -Am adda | 156 $ hg ci -Am adda |
157 adding a | 157 adding a |
158 $ $PYTHON -c "file('a', 'wb').write('1\r\n2\r\n33\r\n4')" | 158 $ $PYTHON -c "open('a', 'wb').write('1\r\n2\r\n33\r\n4')" |
159 $ hg qnew patch1 | 159 $ hg qnew patch1 |
160 $ hg qpop | 160 $ hg qpop |
161 popping patch1 | 161 popping patch1 |
162 patch queue now empty | 162 patch queue now empty |
163 $ $PYTHON -c "file('a', 'wb').write('1\r\n22\r\n33\r\n4')" | 163 $ $PYTHON -c "open('a', 'wb').write('1\r\n22\r\n33\r\n4')" |
164 $ hg ci -m changea | 164 $ hg ci -m changea |
165 | 165 |
166 $ hg --config 'patch.eol=LF' qpush | 166 $ hg --config 'patch.eol=LF' qpush |
167 applying patch1 | 167 applying patch1 |
168 patching file a | 168 patching file a |