##// END OF EJS Templates
py3: make sure we open the file in bytes mode...
Pulkit Goyal -
r35967:80e5210d default
parent child Browse files
Show More
@@ -1,29 +1,29
1 #require test-repo
1 #require test-repo
2
2
3 $ . "$TESTDIR/helpers-testrepo.sh"
3 $ . "$TESTDIR/helpers-testrepo.sh"
4
4
5 $ cat <<'EOF' > scanhelptopics.py
5 $ cat <<'EOF' > scanhelptopics.py
6 > from __future__ import absolute_import, print_function
6 > from __future__ import absolute_import, print_function
7 > import re
7 > import re
8 > import sys
8 > import sys
9 > if sys.platform == "win32":
9 > if sys.platform == "win32":
10 > import os, msvcrt
10 > import os, msvcrt
11 > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
11 > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
12 > topics = set()
12 > topics = set()
13 > topicre = re.compile(br':hg:`help ([a-z0-9\-.]+)`')
13 > topicre = re.compile(br':hg:`help ([a-z0-9\-.]+)`')
14 > for fname in sys.argv:
14 > for fname in sys.argv:
15 > with open(fname) as f:
15 > with open(fname, 'rb') as f:
16 > topics.update(m.group(1) for m in topicre.finditer(f.read()))
16 > topics.update(m.group(1) for m in topicre.finditer(f.read()))
17 > for s in sorted(topics):
17 > for s in sorted(topics):
18 > print(s)
18 > print(s)
19 > EOF
19 > EOF
20
20
21 $ cd "$TESTDIR"/..
21 $ cd "$TESTDIR"/..
22
22
23 Check if ":hg:`help TOPIC`" is valid:
23 Check if ":hg:`help TOPIC`" is valid:
24 (use "xargs -n1 -t" to see which help commands are executed)
24 (use "xargs -n1 -t" to see which help commands are executed)
25
25
26 $ testrepohg files 'glob:{hgdemandimport,hgext,mercurial}/**/*.py' \
26 $ testrepohg files 'glob:{hgdemandimport,hgext,mercurial}/**/*.py' \
27 > | sed 's|\\|/|g' \
27 > | sed 's|\\|/|g' \
28 > | xargs $PYTHON "$TESTTMP/scanhelptopics.py" \
28 > | xargs $PYTHON "$TESTTMP/scanhelptopics.py" \
29 > | xargs -n1 hg help > /dev/null
29 > | xargs -n1 hg help > /dev/null
@@ -1,298 +1,298
1 $ hg init
1 $ hg init
2 $ cat << EOF > a
2 $ cat << EOF > a
3 > Small Mathematical Series.
3 > Small Mathematical Series.
4 > One
4 > One
5 > Two
5 > Two
6 > Three
6 > Three
7 > Four
7 > Four
8 > Five
8 > Five
9 > Hop we are done.
9 > Hop we are done.
10 > EOF
10 > EOF
11 $ hg add a
11 $ hg add a
12 $ hg commit -m ancestor
12 $ hg commit -m ancestor
13 $ cat << EOF > a
13 $ cat << EOF > a
14 > Small Mathematical Series.
14 > Small Mathematical Series.
15 > 1
15 > 1
16 > 2
16 > 2
17 > 3
17 > 3
18 > 4
18 > 4
19 > 5
19 > 5
20 > Hop we are done.
20 > Hop we are done.
21 > EOF
21 > EOF
22 $ hg commit -m branch1
22 $ hg commit -m branch1
23 $ hg co 0
23 $ hg co 0
24 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
24 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
25 $ cat << EOF > a
25 $ cat << EOF > a
26 > Small Mathematical Series.
26 > Small Mathematical Series.
27 > 1
27 > 1
28 > 2
28 > 2
29 > 3
29 > 3
30 > 6
30 > 6
31 > 8
31 > 8
32 > Hop we are done.
32 > Hop we are done.
33 > EOF
33 > EOF
34 $ hg commit -m branch2
34 $ hg commit -m branch2
35 created new head
35 created new head
36
36
37 $ hg merge 1
37 $ hg merge 1
38 merging a
38 merging a
39 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
39 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
40 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
40 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
41 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
41 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
42 [1]
42 [1]
43
43
44 $ hg id
44 $ hg id
45 618808747361+c0c68e4fe667+ tip
45 618808747361+c0c68e4fe667+ tip
46
46
47 $ echo "[commands]" >> $HGRCPATH
47 $ echo "[commands]" >> $HGRCPATH
48 $ echo "status.verbose=true" >> $HGRCPATH
48 $ echo "status.verbose=true" >> $HGRCPATH
49 $ hg status
49 $ hg status
50 M a
50 M a
51 ? a.orig
51 ? a.orig
52 # The repository is in an unfinished *merge* state.
52 # The repository is in an unfinished *merge* state.
53
53
54 # Unresolved merge conflicts:
54 # Unresolved merge conflicts:
55 #
55 #
56 # a
56 # a
57 #
57 #
58 # To mark files as resolved: hg resolve --mark FILE
58 # To mark files as resolved: hg resolve --mark FILE
59
59
60 # To continue: hg commit
60 # To continue: hg commit
61 # To abort: hg update --clean . (warning: this will discard uncommitted changes)
61 # To abort: hg update --clean . (warning: this will discard uncommitted changes)
62
62
63
63
64 $ cat a
64 $ cat a
65 Small Mathematical Series.
65 Small Mathematical Series.
66 1
66 1
67 2
67 2
68 3
68 3
69 <<<<<<< working copy: 618808747361 - test: branch2
69 <<<<<<< working copy: 618808747361 - test: branch2
70 6
70 6
71 8
71 8
72 =======
72 =======
73 4
73 4
74 5
74 5
75 >>>>>>> merge rev: c0c68e4fe667 - test: branch1
75 >>>>>>> merge rev: c0c68e4fe667 - test: branch1
76 Hop we are done.
76 Hop we are done.
77
77
78 $ hg status --config commands.status.verbose=0
78 $ hg status --config commands.status.verbose=0
79 M a
79 M a
80 ? a.orig
80 ? a.orig
81
81
82 Verify custom conflict markers
82 Verify custom conflict markers
83
83
84 $ hg up -q --clean .
84 $ hg up -q --clean .
85 $ cat <<EOF >> .hg/hgrc
85 $ cat <<EOF >> .hg/hgrc
86 > [ui]
86 > [ui]
87 > mergemarkertemplate = '{author} {rev}'
87 > mergemarkertemplate = '{author} {rev}'
88 > EOF
88 > EOF
89
89
90 $ hg merge 1
90 $ hg merge 1
91 merging a
91 merging a
92 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
92 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
93 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
93 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
94 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
94 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
95 [1]
95 [1]
96
96
97 $ cat a
97 $ cat a
98 Small Mathematical Series.
98 Small Mathematical Series.
99 1
99 1
100 2
100 2
101 3
101 3
102 <<<<<<< working copy: test 2
102 <<<<<<< working copy: test 2
103 6
103 6
104 8
104 8
105 =======
105 =======
106 4
106 4
107 5
107 5
108 >>>>>>> merge rev: test 1
108 >>>>>>> merge rev: test 1
109 Hop we are done.
109 Hop we are done.
110
110
111 Verify line splitting of custom conflict marker which causes multiple lines
111 Verify line splitting of custom conflict marker which causes multiple lines
112
112
113 $ hg up -q --clean .
113 $ hg up -q --clean .
114 $ cat >> .hg/hgrc <<EOF
114 $ cat >> .hg/hgrc <<EOF
115 > [ui]
115 > [ui]
116 > mergemarkertemplate={author} {rev}\nfoo\nbar\nbaz
116 > mergemarkertemplate={author} {rev}\nfoo\nbar\nbaz
117 > EOF
117 > EOF
118
118
119 $ hg -q merge 1
119 $ hg -q merge 1
120 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
120 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
121 [1]
121 [1]
122
122
123 $ cat a
123 $ cat a
124 Small Mathematical Series.
124 Small Mathematical Series.
125 1
125 1
126 2
126 2
127 3
127 3
128 <<<<<<< working copy: test 2
128 <<<<<<< working copy: test 2
129 6
129 6
130 8
130 8
131 =======
131 =======
132 4
132 4
133 5
133 5
134 >>>>>>> merge rev: test 1
134 >>>>>>> merge rev: test 1
135 Hop we are done.
135 Hop we are done.
136
136
137 Verify line trimming of custom conflict marker using multi-byte characters
137 Verify line trimming of custom conflict marker using multi-byte characters
138
138
139 $ hg up -q --clean .
139 $ hg up -q --clean .
140 $ $PYTHON <<EOF
140 $ $PYTHON <<EOF
141 > fp = open('logfile', 'w')
141 > fp = open('logfile', 'wb')
142 > fp.write(b'12345678901234567890123456789012345678901234567890' +
142 > fp.write(b'12345678901234567890123456789012345678901234567890' +
143 > b'1234567890') # there are 5 more columns for 80 columns
143 > b'1234567890') # there are 5 more columns for 80 columns
144 >
144 >
145 > # 2 x 4 = 8 columns, but 3 x 4 = 12 bytes
145 > # 2 x 4 = 8 columns, but 3 x 4 = 12 bytes
146 > fp.write(u'\u3042\u3044\u3046\u3048'.encode('utf-8'))
146 > fp.write(u'\u3042\u3044\u3046\u3048'.encode('utf-8'))
147 >
147 >
148 > fp.close()
148 > fp.close()
149 > EOF
149 > EOF
150 $ hg add logfile
150 $ hg add logfile
151 $ hg --encoding utf-8 commit --logfile logfile
151 $ hg --encoding utf-8 commit --logfile logfile
152
152
153 $ cat >> .hg/hgrc <<EOF
153 $ cat >> .hg/hgrc <<EOF
154 > [ui]
154 > [ui]
155 > mergemarkertemplate={desc|firstline}
155 > mergemarkertemplate={desc|firstline}
156 > EOF
156 > EOF
157
157
158 $ hg -q --encoding utf-8 merge 1
158 $ hg -q --encoding utf-8 merge 1
159 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
159 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
160 [1]
160 [1]
161
161
162 $ cat a
162 $ cat a
163 Small Mathematical Series.
163 Small Mathematical Series.
164 1
164 1
165 2
165 2
166 3
166 3
167 <<<<<<< working copy: 1234567890123456789012345678901234567890123456789012345...
167 <<<<<<< working copy: 1234567890123456789012345678901234567890123456789012345...
168 6
168 6
169 8
169 8
170 =======
170 =======
171 4
171 4
172 5
172 5
173 >>>>>>> merge rev: branch1
173 >>>>>>> merge rev: branch1
174 Hop we are done.
174 Hop we are done.
175
175
176 Verify basic conflict markers
176 Verify basic conflict markers
177
177
178 $ hg up -q --clean 2
178 $ hg up -q --clean 2
179 $ printf "\n[ui]\nmergemarkers=basic\n" >> .hg/hgrc
179 $ printf "\n[ui]\nmergemarkers=basic\n" >> .hg/hgrc
180
180
181 $ hg merge 1
181 $ hg merge 1
182 merging a
182 merging a
183 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
183 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
184 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
184 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
185 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
185 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
186 [1]
186 [1]
187
187
188 $ cat a
188 $ cat a
189 Small Mathematical Series.
189 Small Mathematical Series.
190 1
190 1
191 2
191 2
192 3
192 3
193 <<<<<<< working copy
193 <<<<<<< working copy
194 6
194 6
195 8
195 8
196 =======
196 =======
197 4
197 4
198 5
198 5
199 >>>>>>> merge rev
199 >>>>>>> merge rev
200 Hop we are done.
200 Hop we are done.
201
201
202 internal:merge3
202 internal:merge3
203
203
204 $ hg up -q --clean .
204 $ hg up -q --clean .
205
205
206 $ hg merge 1 --tool internal:merge3
206 $ hg merge 1 --tool internal:merge3
207 merging a
207 merging a
208 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
208 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
209 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
209 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
210 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
210 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
211 [1]
211 [1]
212 $ cat a
212 $ cat a
213 Small Mathematical Series.
213 Small Mathematical Series.
214 <<<<<<< working copy
214 <<<<<<< working copy
215 1
215 1
216 2
216 2
217 3
217 3
218 6
218 6
219 8
219 8
220 ||||||| base
220 ||||||| base
221 One
221 One
222 Two
222 Two
223 Three
223 Three
224 Four
224 Four
225 Five
225 Five
226 =======
226 =======
227 1
227 1
228 2
228 2
229 3
229 3
230 4
230 4
231 5
231 5
232 >>>>>>> merge rev
232 >>>>>>> merge rev
233 Hop we are done.
233 Hop we are done.
234
234
235 Add some unconflicting changes on each head, to make sure we really
235 Add some unconflicting changes on each head, to make sure we really
236 are merging, unlike :local and :other
236 are merging, unlike :local and :other
237
237
238 $ hg up -C
238 $ hg up -C
239 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
239 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
240 updated to "e0693e20f496: 123456789012345678901234567890123456789012345678901234567890????"
240 updated to "e0693e20f496: 123456789012345678901234567890123456789012345678901234567890????"
241 1 other heads for branch "default"
241 1 other heads for branch "default"
242 $ printf "\n\nEnd of file\n" >> a
242 $ printf "\n\nEnd of file\n" >> a
243 $ hg ci -m "Add some stuff at the end"
243 $ hg ci -m "Add some stuff at the end"
244 $ hg up -r 1
244 $ hg up -r 1
245 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
245 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
246 $ printf "Start of file\n\n\n" > tmp
246 $ printf "Start of file\n\n\n" > tmp
247 $ cat a >> tmp
247 $ cat a >> tmp
248 $ mv tmp a
248 $ mv tmp a
249 $ hg ci -m "Add some stuff at the beginning"
249 $ hg ci -m "Add some stuff at the beginning"
250
250
251 Now test :merge-other and :merge-local
251 Now test :merge-other and :merge-local
252
252
253 $ hg merge
253 $ hg merge
254 merging a
254 merging a
255 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
255 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
256 1 files updated, 0 files merged, 0 files removed, 1 files unresolved
256 1 files updated, 0 files merged, 0 files removed, 1 files unresolved
257 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
257 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
258 [1]
258 [1]
259 $ hg resolve --tool :merge-other a
259 $ hg resolve --tool :merge-other a
260 merging a
260 merging a
261 (no more unresolved files)
261 (no more unresolved files)
262 $ cat a
262 $ cat a
263 Start of file
263 Start of file
264
264
265
265
266 Small Mathematical Series.
266 Small Mathematical Series.
267 1
267 1
268 2
268 2
269 3
269 3
270 6
270 6
271 8
271 8
272 Hop we are done.
272 Hop we are done.
273
273
274
274
275 End of file
275 End of file
276
276
277 $ hg up -C
277 $ hg up -C
278 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
278 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
279 updated to "18b51d585961: Add some stuff at the beginning"
279 updated to "18b51d585961: Add some stuff at the beginning"
280 1 other heads for branch "default"
280 1 other heads for branch "default"
281 $ hg merge --tool :merge-local
281 $ hg merge --tool :merge-local
282 merging a
282 merging a
283 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
283 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
284 (branch merge, don't forget to commit)
284 (branch merge, don't forget to commit)
285 $ cat a
285 $ cat a
286 Start of file
286 Start of file
287
287
288
288
289 Small Mathematical Series.
289 Small Mathematical Series.
290 1
290 1
291 2
291 2
292 3
292 3
293 4
293 4
294 5
294 5
295 Hop we are done.
295 Hop we are done.
296
296
297
297
298 End of file
298 End of file
General Comments 0
You need to be logged in to leave comments. Login now