annotate tests/test-contrib-check-commit.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 e529b5f1b9e3
children 2fb3ae89e4e1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27328
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
1 Test the 'check-commit' script
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
2 ==============================
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
3
27700
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
4 A fine patch:
27328
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
5
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
6 $ cat > patch-with-long-header.diff << EOF
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
7 > # HG changeset patch
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
8 > # User timeless <timeless@mozdev.org>
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
9 > # Date 1448911706 0
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
10 > # Mon Nov 30 19:28:26 2015 +0000
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
11 > # Node ID c41cb6d2b7dbd62b1033727f8606b8c09fc4aa88
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
12 > # Parent 42aa0e570eaa364a622bc4443b0bcb79b1100a58
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
13 > # ClownJoke This is a veryly long header that should not be warned about because its not the description
27700
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
14 > bundle2: use Oxford comma (issue123) (BC)
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
15 >
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
16 > diff --git a/hgext/transplant.py b/hgext/transplant.py
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
17 > --- a/hgext/transplant.py
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
18 > +++ b/hgext/transplant.py
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
19 > @@ -599,7 +599,7 @@
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
20 > return
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
21 > if not (opts.get('source') or revs or
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
22 > opts.get('merge') or opts.get('branch')):
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
23 > - raise error.Abort(_('no source URL, branch revision or revision '
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
24 > + raise error.Abort(_('no source URL, branch revision, or revision '
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
25 > 'list provided'))
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
26 > if opts.get('all'):
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
27 >
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
28 > + def blahblah(x):
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
29 > + pass
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
30 > EOF
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
31 $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
32
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
33 A patch with lots of errors:
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
34
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
35 $ cat > patch-with-long-header.diff << EOF
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
36 > # HG changeset patch
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
37 > # User timeless
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
38 > # Date 1448911706 0
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
39 > # Mon Nov 30 19:28:26 2015 +0000
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
40 > # Node ID c41cb6d2b7dbd62b1033727f8606b8c09fc4aa88
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
41 > # Parent 42aa0e570eaa364a622bc4443b0bcb79b1100a58
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
42 > # ClownJoke This is a veryly long header that should not be warned about because its not the description
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
43 > transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
27328
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
44 >
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
45 > diff --git a/hgext/transplant.py b/hgext/transplant.py
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
46 > --- a/hgext/transplant.py
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
47 > +++ b/hgext/transplant.py
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
48 > @@ -599,7 +599,7 @@
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
49 > return
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
50 > if not (opts.get('source') or revs or
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
51 > opts.get('merge') or opts.get('branch')):
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
52 > - raise error.Abort(_('no source URL, branch revision or revision '
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
53 > + raise error.Abort(_('no source URL, branch revision, or revision '
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
54 > 'list provided'))
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
55 > if opts.get('all'):
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
56 > EOF
96dc6664fa9c check-commit: add a test for the patch checking script in contrib
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
57 $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit
27783
1d095371de47 check-commit: sort errors by line number
timeless <timeless@mozdev.org>
parents: 27782
diff changeset
58 1: username is not an email address
1d095371de47 check-commit: sort errors by line number
timeless <timeless@mozdev.org>
parents: 27782
diff changeset
59 # User timeless
1d095371de47 check-commit: sort errors by line number
timeless <timeless@mozdev.org>
parents: 27782
diff changeset
60 7: summary keyword should be most user-relevant one-word command or topic
27700
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
61 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
27783
1d095371de47 check-commit: sort errors by line number
timeless <timeless@mozdev.org>
parents: 27782
diff changeset
62 7: (BC) needs to be uppercase
27700
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
63 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
64 7: use (issueDDDD) instead of bug
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
65 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
27783
1d095371de47 check-commit: sort errors by line number
timeless <timeless@mozdev.org>
parents: 27782
diff changeset
66 7: no space allowed between issue and number
27700
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
67 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
68 7: summary line too long (limit is 78)
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
69 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
70 [1]
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
71
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
72 A patch with other errors:
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
73
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
74 $ cat > patch-with-long-header.diff << EOF
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
75 > # HG changeset patch
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
76 > # User timeless
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
77 > # Date 1448911706 0
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
78 > # Mon Nov 30 19:28:26 2015 +0000
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
79 > # Node ID c41cb6d2b7dbd62b1033727f8606b8c09fc4aa88
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
80 > # Parent 42aa0e570eaa364a622bc4443b0bcb79b1100a58
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
81 > # ClownJoke This is a veryly long header that should not be warned about because its not the description
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
82 > This has no topic and ends with a period.
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
83 >
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
84 > diff --git a/hgext/transplant.py b/hgext/transplant.py
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
85 > --- a/hgext/transplant.py
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
86 > +++ b/hgext/transplant.py
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
87 > @@ -599,7 +599,7 @@
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
88 > if opts.get('all'):
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
89 >
28013
e529b5f1b9e3 check-commit: check for double-addition of blank lines
Matt Mackall <mpm@selenic.com>
parents: 27783
diff changeset
90 >
e529b5f1b9e3 check-commit: check for double-addition of blank lines
Matt Mackall <mpm@selenic.com>
parents: 27783
diff changeset
91 > +
e529b5f1b9e3 check-commit: check for double-addition of blank lines
Matt Mackall <mpm@selenic.com>
parents: 27783
diff changeset
92 > + some = otherjunk
e529b5f1b9e3 check-commit: check for double-addition of blank lines
Matt Mackall <mpm@selenic.com>
parents: 27783
diff changeset
93 > +
27700
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
94 > +
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
95 > + def blah_blah(x):
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
96 > + pass
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
97 > +
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
98 >
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
99 > EOF
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
100 $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
101 1: username is not an email address
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
102 # User timeless
27783
1d095371de47 check-commit: sort errors by line number
timeless <timeless@mozdev.org>
parents: 27782
diff changeset
103 7: don't capitalize summary lines
27700
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
104 This has no topic and ends with a period.
27783
1d095371de47 check-commit: sort errors by line number
timeless <timeless@mozdev.org>
parents: 27782
diff changeset
105 7: summary line doesn't start with 'topic: '
27700
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
106 This has no topic and ends with a period.
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
107 7: don't add trailing period on summary line
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
108 This has no topic and ends with a period.
27783
1d095371de47 check-commit: sort errors by line number
timeless <timeless@mozdev.org>
parents: 27782
diff changeset
109 19: adds double empty line
1d095371de47 check-commit: sort errors by line number
timeless <timeless@mozdev.org>
parents: 27782
diff changeset
110 +
28013
e529b5f1b9e3 check-commit: check for double-addition of blank lines
Matt Mackall <mpm@selenic.com>
parents: 27783
diff changeset
111 20: adds a function with foo_bar naming
e529b5f1b9e3 check-commit: check for double-addition of blank lines
Matt Mackall <mpm@selenic.com>
parents: 27783
diff changeset
112 + def blah_blah(x):
e529b5f1b9e3 check-commit: check for double-addition of blank lines
Matt Mackall <mpm@selenic.com>
parents: 27783
diff changeset
113 23: adds double empty line
e529b5f1b9e3 check-commit: check for double-addition of blank lines
Matt Mackall <mpm@selenic.com>
parents: 27783
diff changeset
114 +
27700
374fad80ce69 tests: extend check-commit self-tests
Matt Mackall <mpm@selenic.com>
parents: 27328
diff changeset
115 [1]