Mercurial > hg
annotate tests/test-addremove-similar.t @ 30435:b86a448a2965
zstd: vendor python-zstandard 0.5.0
As the commit message for the previous changeset says, we wish
for zstd to be a 1st class citizen in Mercurial. To make that
happen, we need to enable Python to talk to the zstd C API. And
that requires bindings.
This commit vendors a copy of existing Python bindings. Why do we
need to vendor? As the commit message of the previous commit says,
relying on systems in the wild to have the bindings or zstd present
is a losing proposition. By distributing the zstd and bindings with
Mercurial, we significantly increase our chances that zstd will
work. Since zstd will deliver a better end-user experience by
achieving better performance, this benefits our users. Another
reason is that the Python bindings still aren't stable and the
API is somewhat fluid. While Mercurial could be coded to target
multiple versions of the Python bindings, it is safer to bundle
an explicit, known working version.
The added Python bindings are mostly a fully-featured interface
to the zstd C API. They allow one-shot operations, streaming,
reading and writing from objects implements the file object
protocol, dictionary compression, control over low-level compression
parameters, and more. The Python bindings work on Python 2.6,
2.7, and 3.3+ and have been tested on Linux and Windows. There are
CFFI bindings, but they are lacking compared to the C extension.
Upstream work will be needed before we can support zstd with PyPy.
But it will be possible.
The files added in this commit come from Git commit
e637c1b214d5f869cf8116c550dcae23ec13b677 from
https://github.com/indygreg/python-zstandard and are added without
modifications. Some files from the upstream repository have been
omitted, namely files related to continuous integration.
In the spirit of full disclosure, I'm the maintainer of the
"python-zstandard" project and have authored 100% of the code
added in this commit. Unfortunately, the Python bindings have
not been formally code reviewed by anyone. While I've tested
much of the code thoroughly (I even have tests that fuzz APIs),
there's a good chance there are bugs, memory leaks, not well
thought out APIs, etc. If someone wants to review the code and
send feedback to the GitHub project, it would be greatly
appreciated.
Despite my involvement with both projects, my opinions of code
style differ from Mercurial's. The code in this commit introduces
numerous code style violations in Mercurial's linters. So, the code
is excluded from most lints. However, some violations I agree with.
These have been added to the known violations ignore list for now.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 10 Nov 2016 22:15:58 -0800 |
parents | 478e2b85fcce |
children | 3a383caa97f4 |
rev | line source |
---|---|
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
1 $ hg init rep; cd rep |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
2 |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
3 $ touch empty-file |
29174
478e2b85fcce
tests: test-addremove-similar.t use print() for py3
timeless <timeless@mozdev.org>
parents:
26587
diff
changeset
|
4 $ $PYTHON -c 'for x in range(10000): print(x)' > large-file |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff
changeset
|
5 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
6 $ hg addremove |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
7 adding empty-file |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
8 adding large-file |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff
changeset
|
9 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
10 $ hg commit -m A |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff
changeset
|
11 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
12 $ rm large-file empty-file |
29174
478e2b85fcce
tests: test-addremove-similar.t use print() for py3
timeless <timeless@mozdev.org>
parents:
26587
diff
changeset
|
13 $ $PYTHON -c 'for x in range(10,10000): print(x)' > another-file |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff
changeset
|
14 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
15 $ hg addremove -s50 |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
16 adding another-file |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
17 removing empty-file |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
18 removing large-file |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
19 recording removal of large-file as rename to another-file (99% similar) |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff
changeset
|
20 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
21 $ hg commit -m B |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
22 |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
23 comparing two empty files caused ZeroDivisionError in the past |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff
changeset
|
24 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
25 $ hg update -C 0 |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
26 2 files updated, 0 files merged, 1 files removed, 0 files unresolved |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
27 $ rm empty-file |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
28 $ touch another-empty-file |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
29 $ hg addremove -s50 |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
30 adding another-empty-file |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
31 removing empty-file |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff
changeset
|
32 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
33 $ cd .. |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
34 |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
35 $ hg init rep2; cd rep2 |
4472
736e49292809
addremove: comparing two empty files caused ZeroDivisionError
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4135
diff
changeset
|
36 |
29174
478e2b85fcce
tests: test-addremove-similar.t use print() for py3
timeless <timeless@mozdev.org>
parents:
26587
diff
changeset
|
37 $ $PYTHON -c 'for x in range(10000): print(x)' > large-file |
478e2b85fcce
tests: test-addremove-similar.t use print() for py3
timeless <timeless@mozdev.org>
parents:
26587
diff
changeset
|
38 $ $PYTHON -c 'for x in range(50): print(x)' > tiny-file |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff
changeset
|
39 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
40 $ hg addremove |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
41 adding large-file |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
42 adding tiny-file |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff
changeset
|
43 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
44 $ hg commit -m A |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
45 |
29174
478e2b85fcce
tests: test-addremove-similar.t use print() for py3
timeless <timeless@mozdev.org>
parents:
26587
diff
changeset
|
46 $ $PYTHON -c 'for x in range(70): print(x)' > small-file |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
47 $ rm tiny-file |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
48 $ rm large-file |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff
changeset
|
49 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
50 $ hg addremove -s50 |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
51 removing large-file |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
52 adding small-file |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
53 removing tiny-file |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
54 recording removal of tiny-file as rename to small-file (82% similar) |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff
changeset
|
55 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
56 $ hg commit -m B |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff
changeset
|
57 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
58 should all fail |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff
changeset
|
59 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
60 $ hg addremove -s foo |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
61 abort: similarity must be a number |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
11851
diff
changeset
|
62 [255] |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
63 $ hg addremove -s -1 |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
64 abort: similarity must be between 0 and 100 |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
11851
diff
changeset
|
65 [255] |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
66 $ hg addremove -s 1e6 |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
67 abort: similarity must be between 0 and 100 |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
11851
diff
changeset
|
68 [255] |
4135
6cb6cfe43c5d
Avoid some false positives for addremove -s
Erling Ellingsen <erlingalf@gmail.com>
parents:
diff
changeset
|
69 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
70 $ cd .. |
4966
8d982aef0be1
addremove: print meaningful error message if --similar not numeric
Bryan O'Sullivan <bos@serpentine.com>
parents:
4472
diff
changeset
|
71 |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23481
diff
changeset
|
72 Issue1527: repeated addremove causes Abort |
8489
1a96f1d9599b
addremove/findrenames: find renames according to the match object (issue1527)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4966
diff
changeset
|
73 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
74 $ hg init rep3; cd rep3 |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
75 $ mkdir d |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
76 $ echo a > d/a |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
77 $ hg add d/a |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
78 $ hg commit -m 1 |
8489
1a96f1d9599b
addremove/findrenames: find renames according to the match object (issue1527)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4966
diff
changeset
|
79 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
80 $ mv d/a d/b |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
81 $ hg addremove -s80 |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
82 removing d/a |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
83 adding d/b |
15447
9910f60a37ee
tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents:
12399
diff
changeset
|
84 recording removal of d/a as rename to d/b (100% similar) (glob) |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
85 $ hg debugstate |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
86 r 0 0 1970-01-01 00:00:00 d/a |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
87 a 0 -1 unset d/b |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
88 copy: d/a -> d/b |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
89 $ mv d/b c |
8489
1a96f1d9599b
addremove/findrenames: find renames according to the match object (issue1527)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4966
diff
changeset
|
90 |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
91 no copies found here (since the target isn't in d |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
92 |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
93 $ hg addremove -s80 d |
23481
94091ab9d112
addremove: restore the relative path printing when files are named
Matt Harbison <matt_harbison@yahoo.com>
parents:
23465
diff
changeset
|
94 removing d/b (glob) |
11851
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
95 |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
96 copies here |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
97 |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
98 $ hg addremove -s80 |
db955418a6af
tests: unify test-addremove-similar
Martin Geisler <mg@lazybytes.net>
parents:
8489
diff
changeset
|
99 adding c |
15447
9910f60a37ee
tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents:
12399
diff
changeset
|
100 recording removal of d/a as rename to c (100% similar) (glob) |
16913
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
15447
diff
changeset
|
101 |
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
15447
diff
changeset
|
102 $ cd .. |