Mercurial > hg
annotate tests/test-import-context.t @ 43494:5d40317d42b7
dirs: reject consecutive slashes in paths
We shouldn't ever see those, and the fuzzer go really excited that if
it gives us a 65k string with 55k slashes in it we use a lot of RAM.
This is a better fix than what I tried in D7105. It was suggested by
Yuya, and I verified it does in fact cause the fuzzer to not OOM.
This is a revision of D7234, but with the missing set of an error
added. I added a unit test of the dirs behavior because I needed to
reason more carefully about the failure modes around consecutive
slashes.
Differential Revision: https://phab.mercurial-scm.org/D7252
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 17 Oct 2019 19:29:22 -0400 |
parents | c70bdd222dcd |
children | 4c1b4805db57 |
rev | line source |
---|---|
12825 | 1 Test applying context diffs |
2 | |
3 $ cat > writepatterns.py <<EOF | |
4 > import sys | |
5 > | |
6 > path = sys.argv[1] | |
7 > lasteol = sys.argv[2] == '1' | |
8 > patterns = sys.argv[3:] | |
9 > | |
36394
4bc983568016
py3: replace file() with open()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32940
diff
changeset
|
10 > fp = open(path, 'wb') |
12825 | 11 > for i, pattern in enumerate(patterns): |
12 > count = int(pattern[0:-1]) | |
38365
bf953d218a91
py3: encode sys.argv to bytes using .encode()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36394
diff
changeset
|
13 > char = pattern[-1].encode('utf8') + b'\n' |
12825 | 14 > if not lasteol and i == len(patterns) - 1: |
41738
c70bdd222dcd
tests: bulk changes to avoid whitespace errors of check-code.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
40350
diff
changeset
|
15 > fp.write((char * count)[:-1]) |
12825 | 16 > else: |
41738
c70bdd222dcd
tests: bulk changes to avoid whitespace errors of check-code.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
40350
diff
changeset
|
17 > fp.write(char * count) |
12825 | 18 > fp.close() |
19 > EOF | |
20 $ cat > cat.py <<EOF | |
21 > import sys | |
40350
633da7139e4a
py3: fix test-import-context.t
Matt Harbison <matt_harbison@yahoo.com>
parents:
39707
diff
changeset
|
22 > from mercurial import pycompat |
633da7139e4a
py3: fix test-import-context.t
Matt Harbison <matt_harbison@yahoo.com>
parents:
39707
diff
changeset
|
23 > from mercurial.utils import stringutil |
633da7139e4a
py3: fix test-import-context.t
Matt Harbison <matt_harbison@yahoo.com>
parents:
39707
diff
changeset
|
24 > pycompat.stdout.write(b'%s\n' |
633da7139e4a
py3: fix test-import-context.t
Matt Harbison <matt_harbison@yahoo.com>
parents:
39707
diff
changeset
|
25 > % stringutil.pprint(open(sys.argv[1], 'rb').read())) |
12825 | 26 > EOF |
27 | |
28 Initialize the test repository | |
29 | |
30 $ hg init repo | |
31 $ cd repo | |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38365
diff
changeset
|
32 $ "$PYTHON" ../writepatterns.py a 0 5A 1B 5C 1D |
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38365
diff
changeset
|
33 $ "$PYTHON" ../writepatterns.py b 1 1A 1B |
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38365
diff
changeset
|
34 $ "$PYTHON" ../writepatterns.py c 1 5A |
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38365
diff
changeset
|
35 $ "$PYTHON" ../writepatterns.py d 1 5A 1B |
12825 | 36 $ hg add |
37 adding a | |
38 adding b | |
39 adding c | |
40 adding d | |
41 $ hg ci -m addfiles | |
42 | |
43 Add file, missing a last end of line | |
44 | |
45 $ hg import --no-commit - <<EOF | |
46 > *** /dev/null 2010-10-16 18:05:49.000000000 +0200 | |
47 > --- b/newnoeol 2010-10-16 18:23:26.000000000 +0200 | |
48 > *************** | |
49 > *** 0 **** | |
50 > --- 1,2 ---- | |
51 > + a | |
52 > + b | |
53 > \ No newline at end of file | |
54 > *** a/a Sat Oct 16 16:35:51 2010 | |
55 > --- b/a Sat Oct 16 16:35:51 2010 | |
56 > *************** | |
57 > *** 3,12 **** | |
58 > A | |
59 > A | |
60 > A | |
61 > ! B | |
62 > C | |
63 > C | |
64 > C | |
65 > C | |
66 > C | |
67 > ! D | |
68 > \ No newline at end of file | |
69 > --- 3,13 ---- | |
70 > A | |
71 > A | |
72 > A | |
73 > ! E | |
74 > C | |
75 > C | |
76 > C | |
77 > C | |
78 > C | |
79 > ! F | |
80 > ! F | |
81 > | |
82 > *** a/b 2010-10-16 18:40:38.000000000 +0200 | |
83 > --- /dev/null 2010-10-16 18:05:49.000000000 +0200 | |
84 > *************** | |
85 > *** 1,2 **** | |
86 > - A | |
87 > - B | |
88 > --- 0 ---- | |
89 > *** a/c Sat Oct 16 21:34:26 2010 | |
90 > --- b/c Sat Oct 16 21:34:27 2010 | |
91 > *************** | |
92 > *** 3,5 **** | |
93 > --- 3,7 ---- | |
94 > A | |
95 > A | |
96 > A | |
97 > + B | |
98 > + B | |
99 > *** a/d Sat Oct 16 21:47:20 2010 | |
100 > --- b/d Sat Oct 16 21:47:22 2010 | |
101 > *************** | |
102 > *** 2,6 **** | |
103 > A | |
104 > A | |
105 > A | |
106 > - A | |
107 > - B | |
108 > --- 2,4 ---- | |
109 > EOF | |
110 applying patch from stdin | |
111 $ hg st | |
112 M a | |
113 M c | |
114 M d | |
115 A newnoeol | |
116 R b | |
117 | |
118 What's in a | |
119 | |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38365
diff
changeset
|
120 $ "$PYTHON" ../cat.py a |
12825 | 121 'A\nA\nA\nA\nA\nE\nC\nC\nC\nC\nC\nF\nF\n' |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38365
diff
changeset
|
122 $ "$PYTHON" ../cat.py newnoeol |
12825 | 123 'a\nb' |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38365
diff
changeset
|
124 $ "$PYTHON" ../cat.py c |
12825 | 125 'A\nA\nA\nA\nA\nB\nB\n' |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38365
diff
changeset
|
126 $ "$PYTHON" ../cat.py d |
12825 | 127 'A\nA\nA\nA\n' |
128 | |
16913
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
12825
diff
changeset
|
129 $ cd .. |