Mercurial > hg
annotate tests/test-hgweb-non-interactive.t @ 42619:20d0e59be79b
tests: show the files fields of changelogs for many merges
I don't think there's coverage for many of the subtle cases, and I
found it hard to understand what the code is doing by reading it. The
test takes 40s to run on a laptop, or 9s with --chg.
I have yet to find a description of what the files field is supposed
to be for merges. I thought it could be one of:
1. the files added/modified/removed relative to p1 (wouldn't seem
useful, but `hg diff -c -r mergerev` has this behavior)
2. the files with filelog nodes not in either parent (i.e., what is
needed to create a bundle out of a commit)
3. the files added/removed/modified files by merge itself [1]
It's clearly not 1, because file contents merges are symmetric. It's
clearly not 2 because removed files and exec bit changes are
listed. It's also not 3 but I think it's intended to be 3 and the
differences are bugs.
Assuming 3, the test shows that, for merges, the list of files both
overapproximates and underapproximates. All the cases involve file
changes not in the filelog but in the manifest (existence of file
at revision, exec bit and file vs symlink).
I didn't look at all underapproximations, but they looked minor. The
two overapproximations are problematic though because they both cause
potentially long lists of files when merging cleanly.
[1] even what it means for the merge commit itself to change a file is
not completely trivial. A file in the merge being the same as in one
of the parent is too lax as it would consider that merges change
nothing when they revert all the changes done on one side. The
criteria used in the test and in the next commit for "merge didn't
touch a file" is:
- the parents and the merge all have the same file
- or, one parent didn't touch the file and the other parent contains
the same file as the merge
Differential Revision: https://phab.mercurial-scm.org/D6612
author | Valentin Gatien-Baron <valentin.gatienbaron@gmail.com> |
---|---|
date | Tue, 02 Jul 2019 12:55:51 -0400 |
parents | f80f7a67e176 |
children | 4c1b4805db57 |
rev | line source |
---|---|
12440
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
1 Tests if hgweb can run without touching sys.stdin, as is required |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
2 by the WSGI standard and strictly implemented by mod_wsgi. |
5337
8c5ef3b87cb1
Don't try to determine interactivity if ui() called with interactive=False.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
3 |
13956
ffb5c09ba822
tests: remove redundant mkdir
Martin Geisler <mg@lazybytes.net>
parents:
12743
diff
changeset
|
4 $ hg init repo |
12440
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
5 $ cd repo |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
6 $ echo foo > bar |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
7 $ hg add bar |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
8 $ hg commit -m "test" |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
9 $ cat > request.py <<EOF |
28859
af2e00c85d0a
py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents:
26247
diff
changeset
|
10 > from __future__ import absolute_import |
af2e00c85d0a
py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents:
26247
diff
changeset
|
11 > import os |
af2e00c85d0a
py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents:
26247
diff
changeset
|
12 > import sys |
af2e00c85d0a
py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents:
26247
diff
changeset
|
13 > from mercurial import ( |
af2e00c85d0a
py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents:
26247
diff
changeset
|
14 > dispatch, |
39913
8bd589aecf65
py3: avoid b'' output in test-hgweb-non-interactive.t
Matt Harbison <matt_harbison@yahoo.com>
parents:
39707
diff
changeset
|
15 > encoding, |
28859
af2e00c85d0a
py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents:
26247
diff
changeset
|
16 > hg, |
39913
8bd589aecf65
py3: avoid b'' output in test-hgweb-non-interactive.t
Matt Harbison <matt_harbison@yahoo.com>
parents:
39707
diff
changeset
|
17 > pycompat, |
28859
af2e00c85d0a
py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents:
26247
diff
changeset
|
18 > ui as uimod, |
28861
86db5cb55d46
pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents:
28859
diff
changeset
|
19 > util, |
28859
af2e00c85d0a
py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents:
26247
diff
changeset
|
20 > ) |
af2e00c85d0a
py3: use absolute_import in test-hgweb-non-interactive.t
timeless <timeless@mozdev.org>
parents:
26247
diff
changeset
|
21 > ui = uimod.ui |
40203
f80f7a67e176
tests: fix style issue of importing hgweb in embedded code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39913
diff
changeset
|
22 > from mercurial.hgweb import hgweb_mod |
28861
86db5cb55d46
pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents:
28859
diff
changeset
|
23 > stringio = util.stringio |
12440
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
24 > |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
25 > class FileLike(object): |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
26 > def __init__(self, real): |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
27 > self.real = real |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
28 > def fileno(self): |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
29 > print >> sys.__stdout__, 'FILENO' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
30 > return self.real.fileno() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
31 > def read(self): |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
32 > print >> sys.__stdout__, 'READ' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
33 > return self.real.read() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
34 > def readline(self): |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
35 > print >> sys.__stdout__, 'READLINE' |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
36 > return self.real.readline() |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
37 > |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
38 > sys.stdin = FileLike(sys.stdin) |
28861
86db5cb55d46
pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents:
28859
diff
changeset
|
39 > errors = stringio() |
86db5cb55d46
pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents:
28859
diff
changeset
|
40 > input = stringio() |
86db5cb55d46
pycompat: switch to util.stringio for py3 compat
timeless <timeless@mozdev.org>
parents:
28859
diff
changeset
|
41 > output = stringio() |
12440
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
42 > |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
43 > def startrsp(status, headers): |
33720
27fb986e54d0
tests: fix simple heredoc print statements to work on Py3
Augie Fackler <augie@google.com>
parents:
32940
diff
changeset
|
44 > print('---- STATUS') |
27fb986e54d0
tests: fix simple heredoc print statements to work on Py3
Augie Fackler <augie@google.com>
parents:
32940
diff
changeset
|
45 > print(status) |
27fb986e54d0
tests: fix simple heredoc print statements to work on Py3
Augie Fackler <augie@google.com>
parents:
32940
diff
changeset
|
46 > print('---- HEADERS') |
27fb986e54d0
tests: fix simple heredoc print statements to work on Py3
Augie Fackler <augie@google.com>
parents:
32940
diff
changeset
|
47 > print([i for i in headers if i[0] != 'ETag']) |
27fb986e54d0
tests: fix simple heredoc print statements to work on Py3
Augie Fackler <augie@google.com>
parents:
32940
diff
changeset
|
48 > print('---- DATA') |
12743
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
49 > return output.write |
12440
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
50 > |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
51 > env = { |
12743
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
52 > 'wsgi.version': (1, 0), |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
53 > 'wsgi.url_scheme': 'http', |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
54 > 'wsgi.errors': errors, |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
55 > 'wsgi.input': input, |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
56 > 'wsgi.multithread': False, |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
57 > 'wsgi.multiprocess': False, |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
58 > 'wsgi.run_once': False, |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
59 > 'REQUEST_METHOD': 'GET', |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
60 > 'SCRIPT_NAME': '', |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
61 > 'PATH_INFO': '', |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
62 > 'QUERY_STRING': '', |
31008 | 63 > 'SERVER_NAME': '$LOCALIP', |
12743
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
64 > 'SERVER_PORT': os.environ['HGPORT'], |
4c4aeaab2339
check-code: add 'no tab indent' check for unified tests
Adrian Buehlmann <adrian@cadifra.com>
parents:
12440
diff
changeset
|
65 > 'SERVER_PROTOCOL': 'HTTP/1.0' |
12440
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
66 > } |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
67 > |
40203
f80f7a67e176
tests: fix style issue of importing hgweb in embedded code fragments
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39913
diff
changeset
|
68 > i = hgweb_mod.hgweb(b'.') |
26247
7df5d4760873
hgweb: consume generator inside context manager (issue4756)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26220
diff
changeset
|
69 > for c in i(env, startrsp): |
7df5d4760873
hgweb: consume generator inside context manager (issue4756)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26220
diff
changeset
|
70 > pass |
39913
8bd589aecf65
py3: avoid b'' output in test-hgweb-non-interactive.t
Matt Harbison <matt_harbison@yahoo.com>
parents:
39707
diff
changeset
|
71 > sys.stdout.flush() |
8bd589aecf65
py3: avoid b'' output in test-hgweb-non-interactive.t
Matt Harbison <matt_harbison@yahoo.com>
parents:
39707
diff
changeset
|
72 > pycompat.stdout.write(b'---- ERRORS\n') |
8bd589aecf65
py3: avoid b'' output in test-hgweb-non-interactive.t
Matt Harbison <matt_harbison@yahoo.com>
parents:
39707
diff
changeset
|
73 > pycompat.stdout.write(b'%s\n' % errors.getvalue()) |
33720
27fb986e54d0
tests: fix simple heredoc print statements to work on Py3
Augie Fackler <augie@google.com>
parents:
32940
diff
changeset
|
74 > print('---- OS.ENVIRON wsgi variables') |
27fb986e54d0
tests: fix simple heredoc print statements to work on Py3
Augie Fackler <augie@google.com>
parents:
32940
diff
changeset
|
75 > print(sorted([x for x in os.environ if x.startswith('wsgi')])) |
27fb986e54d0
tests: fix simple heredoc print statements to work on Py3
Augie Fackler <augie@google.com>
parents:
32940
diff
changeset
|
76 > print('---- request.ENVIRON wsgi variables') |
26220
a43328baa2ac
hgweb: use separate repo instances per thread
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26219
diff
changeset
|
77 > with i._obtainrepo() as repo: |
39913
8bd589aecf65
py3: avoid b'' output in test-hgweb-non-interactive.t
Matt Harbison <matt_harbison@yahoo.com>
parents:
39707
diff
changeset
|
78 > print(sorted([encoding.strfromlocal(x) for x in repo.ui.environ |
8bd589aecf65
py3: avoid b'' output in test-hgweb-non-interactive.t
Matt Harbison <matt_harbison@yahoo.com>
parents:
39707
diff
changeset
|
79 > if x.startswith(b'wsgi')])) |
12440
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
80 > EOF |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
39658
diff
changeset
|
81 $ "$PYTHON" request.py |
12440
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
82 ---- STATUS |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
83 200 Script output follows |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
84 ---- HEADERS |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
85 [('Content-Type', 'text/html; charset=ascii')] |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
86 ---- DATA |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
87 ---- ERRORS |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
88 |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
89 ---- OS.ENVIRON wsgi variables |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
90 [] |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
91 ---- request.ENVIRON wsgi variables |
d9f7753a94d5
tests: unify test-hgweb-non-interactive
Matt Mackall <mpm@selenic.com>
parents:
12183
diff
changeset
|
92 ['wsgi.errors', 'wsgi.input', 'wsgi.multiprocess', 'wsgi.multithread', 'wsgi.run_once', 'wsgi.url_scheme', 'wsgi.version'] |
16913
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
13956
diff
changeset
|
93 |
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
13956
diff
changeset
|
94 $ cd .. |