]> git.ipfire.org Git - thirdparty/patchwork.git/log
thirdparty/patchwork.git
8 years agoviews: Don't munge the 'From' field of patches
Doug Anderson [Sat, 19 Nov 2016 19:32:09 +0000 (19:32 +0000)] 
views: Don't munge the 'From' field of patches

At the moment patchwork always uses the official submitter name (as
patchwork understands it) as the "From" for patches that you receive.
This isn't quite what users expect and has some unfortunate
consequences.

The biggest problem is that patchwork saves the "official" name for an
email address the first time it sees an email from them.  If that name
is wrong (or was missing) patchwork will be confused even if future
emails from this person are fixed.  There are similar problems if a
user changes his/her name (get married?).

It seems better to just have each patch report the actual "From" that
was used to send that patch.  We'll still return the submitter in
'X-Patchwork-Submitter' just in case someone wants it.

Reported-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agotrivial: PEP8 fixes
Stephen Finucane [Sun, 18 Dec 2016 22:39:13 +0000 (22:39 +0000)] 
trivial: PEP8 fixes

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agopwclient: Fix encoding problems
Robin Jarry [Thu, 15 Dec 2016 16:56:18 +0000 (17:56 +0100)] 
pwclient: Fix encoding problems

All data returned by the xmlrpc object is unicode decoded with 'utf-8' (on
python 3, unicode == str). Add from __future__ import unicode_literals
to make sure that everything is unicode and avoid surprises.

On python 2, printing unicode to stdout causes it to be encoded to str
(byte string) with the 'ascii' codec:

  >>> print some_unicode_string
  ...
  UnicodeEncodeError: 'ascii' codec can't encode character u'\u0142'
  in position 468: ordinal not in range(128)

Work around ths by avoiding any explicit call to unicode() and by
replacing sys.stdout and sys.stderr by unicode-aware file objects (as
returned by io.open()).

Guess the encoding of stdout and stderr by looking at (in that order):
sys.stdout.encoding, locale.getpreferredencoding(), the PYTHONIOENCODING
environment variable. If no encoding is defined, assume 'utf-8' as
output encoding.

Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
Tested-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Document how to backport patches
Stephen Finucane [Tue, 13 Dec 2016 18:12:02 +0000 (18:12 +0000)] 
docs: Document how to backport patches

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agopwclient: Fix Python 3 encoding of received strings
Thomas Monjalon [Tue, 13 Dec 2016 10:37:47 +0000 (11:37 +0100)] 
pwclient: Fix Python 3 encoding of received strings

The conversion encode("utf-8") makes a byte stream which is
poorly printed with Python 3.
However this encoding is required for Popen.communicate() but must be
done after str.join() which applies to a real string.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agopwclient: Support proxy configuration
Thomas Monjalon [Tue, 13 Dec 2016 10:37:46 +0000 (11:37 +0100)] 
pwclient: Support proxy configuration

The environment variables http_proxy and https_proxy can be used
to configure the HTTP transport.

The TCP connection is made with the proxy host, whereas the original host
is maintained in the HTTP POST URI via "handler" in "send_request".

The send_request() method of xmlrpclib has a different signature
and behaviour in Python 2 and 3.

Fixes #47

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agopwclient: Rework HTTP authentication
Thomas Monjalon [Tue, 13 Dec 2016 10:37:45 +0000 (11:37 +0100)] 
pwclient: Rework HTTP authentication

Transform the HTTP authentication class into a generic transport class.
The credentials become optional so this transport class is always used.

A side effect is to fix the Python 3 support for the authentication.
Fixes #59

It will help to bring proxy support while combining http/https and
authentication cases.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agotools: Update to use 'hasher'
Stephen Finucane [Wed, 30 Nov 2016 18:29:37 +0000 (18:29 +0000)] 
tools: Update to use 'hasher'

The old 'parser' module used to extract diffs from their surrounding
mbox fluff before hashing this. Seeing as this was only used in the
context of an actual git repo, avoid all of that rigmarole by just using
'git diff', which produces a plain diff, rather than 'git show'.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Tested-by: Tom Rini <trini@konsulko.com>
Closes-bug: #63

8 years agotools: Trivial formatting fixes
Stephen Finucane [Fri, 18 Nov 2016 00:54:51 +0000 (00:54 +0000)] 
tools: Trivial formatting fixes

These tools are currently broken, but before beginning surgery let's
clean things up. Use standard 4 spaces and the longer, but easier to
read, if-else-fi syntax for comparison.

Missing license headers are added for completeness sake.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Tested-by: Tom Rini <trini@konsulko.com>
8 years agohasher: Create hasher module
Stephen Finucane [Wed, 30 Nov 2016 19:00:25 +0000 (19:00 +0000)] 
hasher: Create hasher module

This exposes the hashing functionality of Patchwork without requiring
Django or similar dependencies.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Tested-by: Tom Rini <trini@konsulko.com>
8 years agoparser: Trivial rename of functions
Stephen Finucane [Wed, 30 Nov 2016 15:30:06 +0000 (15:30 +0000)] 
parser: Trivial rename of functions

'auto_delegate' doesn't actually delegate the patches - it merely finds
a suitable delegate based on the filename. Rename the function
accordingly.

'find_delegate' is also renamed to prevent confusion.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Tested-by: Tom Rini <trini@konsulko.com>
8 years agoparser: Remove unused parameter
Stephen Finucane [Fri, 18 Nov 2016 00:54:48 +0000 (00:54 +0000)] 
parser: Remove unused parameter

The find_content function expected a 'project' parameter but never
actually used it. Remove it and clean up tests accordingly.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Tested-by: Tom Rini <trini@konsulko.com>
8 years agoviews: don't duplicate tags in patch message when generating mbox
Andrew Donnellan [Wed, 23 Nov 2016 07:01:31 +0000 (18:01 +1100)] 
views: don't duplicate tags in patch message when generating mbox

When generating an mbox for a patch with tags in the original commit
message, e.g.:

    Example patch

    This patch is awesome!

Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Acked-by: Russell Currey <ruscur@russell.cc>
the tags from the original email are duplicated:

    Example patch

    This patch is awesome!

Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Acked-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Acked-by: Russell Currey <ruscur@russell.cc>
It appears that during the refactoring in ef56359fb776 ("models: Merge
patch and first comment"), we added a call to patch.patch_responses() to
extract the tags from the initial patch email, which we then append to the
patch email body... which already has the tags in it.

Remove the unnecessary append of patch.patch_responses when generating an
mbox.

Fixes: ef56359fb776 ("models: Merge patch and first comment")
Reported-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agotrivial: Resolve pep8 issues
Stephen Finucane [Thu, 24 Nov 2016 09:24:13 +0000 (09:24 +0000)] 
trivial: Resolve pep8 issues

flake8 3.2.0 updates the pycodestyle dependency to 2.2.0, which in
turn resolves a bug with E305. Upgrading results in a small number of
additional pep8 issues. Resolve these now.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoviews: Don't use attr(X, 'patch')
Stephen Finucane [Sat, 19 Nov 2016 20:43:16 +0000 (20:43 +0000)] 
views: Don't use attr(X, 'patch')

This doesn't play nice with Django 1.6 under Python 3.4, for some odd
reason.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoAdd support for comment permalink
Stephen Finucane [Sun, 25 Sep 2016 20:59:37 +0000 (21:59 +0100)] 
Add support for comment permalink

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes-bug: #39

8 years agoforms: Tighten validation on BundleForm
Stephen Finucane [Sat, 19 Nov 2016 18:38:55 +0000 (18:38 +0000)] 
forms: Tighten validation on BundleForm

The 'name' field of 'Bundle' cannot be blank, so update the form to
reflect this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoadmin: Integrate UserProfile fields into admin
Stephen Finucane [Sat, 29 Oct 2016 13:18:28 +0000 (14:18 +0100)] 
admin: Integrate UserProfile fields into admin

The 'User' model is extended by means of a 'UserProfile' model. These
fields are not correctly displayed in the admin UI, but they should be.
Let's fix this per the recommendations of the Django docs [1].

[1] https://docs.djangoproject.com/en/1.10/topics/auth/customizing/#extending-the-existing-user-model

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoFix parsing of interesing series reply structures
Daniel Axtens [Thu, 17 Nov 2016 05:11:59 +0000 (16:11 +1100)] 
Fix parsing of interesing series reply structures

There are some things you probably shouldn't do on public
mailing lists, but which people do anyway.

The first, and most understandable, is this:

          - [PATCH 1/2] test: Add some lorem ipsum
            - [PATCH 2/2] test: Convert to Markdown
              - [PATCH v2 1/2] test: Add some lorem ipsum
                - [PATCH v2 2/2] test: Convert to Markdown

We should correctly parse these by:
 - creating a new series if the version number changes
 - when deciding whether to create a SeriesReference, search by
   message-id alone, not the message-id/series pair. (Otherwise,
   we try to create a series ref for v1 2/2 in the series for v2,
   which breaks a uniqueness constraint.

The second, and less excusable, is this:

          - [PATCH 1/2] test: Add some lorem ipsum
            - [PATCH 2/2] test: Convert to Markdown
              - [PATCH 1/2] test: Add some lorem ipsum
                - [PATCH 2/2] test: Convert to Markdown

With this patch:
 - if we get a x/n for a series that already has an x/n, create a
   new series for it.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agorequirements: Test older versions of DRF
Stephen Finucane [Mon, 31 Oct 2016 18:23:29 +0000 (18:23 +0000)] 
requirements: Test older versions of DRF

We still care about Django 1.6 and 1.7, at least until 2.0 is released.
Start testing REST functionality on these versions by using older
versions.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agorequirements: Bump django-rest-framework to 3.5
Stephen Finucane [Mon, 31 Oct 2016 18:23:28 +0000 (18:23 +0000)] 
requirements: Bump django-rest-framework to 3.5

This requires explicitly declaring the 'field' parameter.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agorequirements: Bump selenium to 3.0
Stephen Finucane [Mon, 31 Oct 2016 18:23:27 +0000 (18:23 +0000)] 
requirements: Bump selenium to 3.0

3.0 introduces no notable changes for our use cases. Use the latest and
greatest.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agorequirements: Bump django-debug-toolbar to 1.6
Stephen Finucane [Mon, 31 Oct 2016 18:23:26 +0000 (18:23 +0000)] 
requirements: Bump django-debug-toolbar to 1.6

1.6 introduces little to no changes [1]. We already use the explicit
setup, so simply switch to the latest and greatest version.

[1] https://django-debug-toolbar.readthedocs.io/en/1.6/changes.html

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agorequirements: Loosen requirements for RDBMS libs
Stephen Finucane [Mon, 31 Oct 2016 18:23:25 +0000 (18:23 +0000)] 
requirements: Loosen requirements for RDBMS libs

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoFix parsing of un-numbered messages in series
Daniel Axtens [Wed, 16 Nov 2016 05:58:44 +0000 (16:58 +1100)] 
Fix parsing of un-numbered messages in series

Say we are sent the following:

          - [PATCH 0/2] A sample series
            - [PATCH 1/2] test: Add some lorem ipsum
            - Random message with diff

We expect that:
 1) we parse normally without errors
 2) we get a series with a cover letter and a patch
 3) the random message is orphaned

What happens is that we get an integrity error, boiling down to:

(1048, "Column 'number' cannot be null")

This is caused because we believe that the random message belongs
to the series because of the headers, but because there are no
numbers in the Subject, we pass "None" into the number field of
SeriesPatch. That turns into a null, and rightly hits an integrity
error.

Fix this by requring that a message has a series _and_ a number
before we try to add it to the series.

Add a test to verify correctness.

Reported-by: Daniel Wagner <wagi@monom.org>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agotravis: Disable sudo
Stephen Finucane [Mon, 31 Oct 2016 17:01:38 +0000 (17:01 +0000)] 
travis: Disable sudo

We don't need it, and disabling it can make builds faster. Disable it.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotravis: Integrate with codecov
Stephen Finucane [Sun, 23 Oct 2016 20:38:08 +0000 (21:38 +0100)] 
travis: Integrate with codecov

This mostly involves enabling coverage as a default tox target. We add
pep8 too, while we're at it.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotravis: Use tox-travis
Stephen Finucane [Sun, 23 Oct 2016 20:35:38 +0000 (21:35 +0100)] 
travis: Use tox-travis

This simplifies our .travis.yml file

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoRemove 'htdocs/images'
Stephen Finucane [Mon, 31 Oct 2016 17:12:39 +0000 (17:12 +0000)] 
Remove 'htdocs/images'

Remove 'htdocs/images'

Signed-off-by: Bruno Mendes <brunosouza@alunos.utfpr.edu.br>
Reviewed-by: Stephen Finucane <stephen@that.guru>
Closes: #40
8 years agoRemove 'htdocs/images'
Bruno Mendes [Mon, 31 Oct 2016 13:16:34 +0000 (11:16 -0200)] 
Remove 'htdocs/images'

Signed-off-by: Bruno Mendes <brunosouza@alunos.utfpr.edu.br>
Reviewed-by: Stephen Finucane <stephen@that.guru>
Closes: #40
8 years agoCHANGELOG: Indicate series support
Stephen Finucane [Mon, 31 Oct 2016 16:43:19 +0000 (16:43 +0000)] 
CHANGELOG: Indicate series support

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agotemplates: Integrate series view into patches
Stephen Finucane [Sat, 29 Oct 2016 13:13:40 +0000 (14:13 +0100)] 
templates: Integrate series view into patches

Patches for related series are listed on the patch page - this
provides a way to quickly grok a given patches location in a
series hierarchy.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Tested-by: Russell Currey <ruscur@russell.cc>
8 years agotemplates: Integrate series support
Stephen Finucane [Sat, 29 Oct 2016 13:13:39 +0000 (14:13 +0100)] 
templates: Integrate series support

Integrate support for series in the web UI. This is rather
straightforward, the only significant change being the addition of a
filter for series filtering.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
Tested-by: Russell Currey <ruscur@russell.cc>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
8 years agofilters: Handle invalid ids
Stephen Finucane [Sat, 29 Oct 2016 13:13:38 +0000 (14:13 +0100)] 
filters: Handle invalid ids

Two filters - SubmitterFilter and DelegateFilter - don't attempt to
handle invalid id values and will bubble an exception up as a 5xx
error. Correct this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
8 years agotests: Add tests for series
Stephen Finucane [Sat, 29 Oct 2016 13:13:37 +0000 (14:13 +0100)] 
tests: Add tests for series

Add a number of integration tests for parsing real series mbox files.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
Tested-by: Russell Currey <ruscur@russell.cc>
8 years agotests: Add mbox files for series tests
Stephen Finucane [Sat, 8 Oct 2016 19:02:38 +0000 (20:02 +0100)] 
tests: Add mbox files for series tests

Add a number of mbox files which we can use to unit test basic series
parsing functionality.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
Tested-by: Russell Currey <ruscur@russell.cc>
8 years agoparser: Add series parsing
Stephen Finucane [Sat, 29 Oct 2016 13:13:35 +0000 (14:13 +0100)] 
parser: Add series parsing

It is now possible to parse and store series, so do just that.
The parsing at the moment is based on both RFC822 headers and
subject lines.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Tested-by: Russell Currey <ruscur@russell.cc>
8 years agomodels: Add 'Series' model
Stephen Finucane [Sat, 29 Oct 2016 13:13:34 +0000 (14:13 +0100)] 
models: Add 'Series' model

Add a series model. This model is expected to act like a collection for
patches, similar to bundles but thread-orientated.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Tested-by: Russell Currey <ruscur@russell.cc>
8 years agomodels: Convert functions to properties
Stephen Finucane [Sat, 29 Oct 2016 13:13:33 +0000 (14:13 +0100)] 
models: Convert functions to properties

A number of models contain functions that are, semantically speaking,
actually properties. Mark them as such.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
8 years agoRemove 'htdocs/images' 58/head
Bruno Mendes [Mon, 31 Oct 2016 13:16:34 +0000 (11:16 -0200)] 
Remove 'htdocs/images'

8 years agoviews: Update how patch counts are retrieved
Stephen Finucane [Sat, 22 Oct 2016 11:23:27 +0000 (12:23 +0100)] 
views: Update how patch counts are retrieved

It's no longer possible to access 'Project.patch_set' as
'Project.submission_set' has replaced it. This was missed when the
cover letter feature was merged, so resolve it now.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Closes-bug: #54

8 years agodocs: Add getmail documentation
Stephen Finucane [Thu, 20 Oct 2016 07:08:39 +0000 (08:08 +0100)] 
docs: Add getmail documentation

It seems a lot of people are having success using tools like fetchmail
in combination with IMAP/POP-capable email accounts like Gmail.  While
fetchmail itself is rather decrepit, the Python-based getmail seems
actively supported and pretty easy to configure. Document this process.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agomodels: Remove TODO from 'refresh_tag_counts'
Stephen Finucane [Thu, 20 Oct 2016 07:28:56 +0000 (08:28 +0100)] 
models: Remove TODO from 'refresh_tag_counts'

There's actually no harm keeping this around as it makes the code.
Remove the TODO, replacing it with a note on why the function exists.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agomodels: Remove UserProfile.sync_person
Stephen Finucane [Thu, 20 Oct 2016 07:28:55 +0000 (08:28 +0100)] 
models: Remove UserProfile.sync_person

This doesn't seem to do anything, and hasn't for a very long time
(pre-0.9.0, at least).

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agomodels: Remove Bundle.n_patches
Stephen Finucane [Thu, 20 Oct 2016 07:28:54 +0000 (08:28 +0100)] 
models: Remove Bundle.n_patches

It doesn't really do much for us. Less LOC = win.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agomodels: Make use of aggregates
Stephen Finucane [Thu, 20 Oct 2016 07:28:53 +0000 (08:28 +0100)] 
models: Make use of aggregates

We're well past Django 1.1 now, so resolve a TODO to use aggregate
support introduced in this version. As part of this change, replace
the use of 'count' to check for presence of matching objects with
'exists'.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotrivial: Fix pep8 issue
Stephen Finucane [Thu, 20 Oct 2016 07:45:38 +0000 (08:45 +0100)] 
trivial: Fix pep8 issue

There should be two lines - not one.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Add delegation guide
Stephen Finucane [Tue, 11 Oct 2016 17:58:38 +0000 (18:58 +0100)] 
docs: Add delegation guide

We do autodelegation - let's tell people all about it.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Add X-Patchwork-* header documentation
Stephen Finucane [Tue, 11 Oct 2016 17:15:32 +0000 (18:15 +0100)] 
docs: Add X-Patchwork-* header documentation

Avoids sending people to the code to find out about this stuff. Include
examples using 'git-send-email', which should cover most folks.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Add basic REST API documentation
Stephen Finucane [Tue, 11 Oct 2016 17:14:43 +0000 (18:14 +0100)] 
docs: Add basic REST API documentation

This is only user-facing for now. Developer focused docs can be added
later.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Rework XML-RPC docs
Stephen Finucane [Tue, 11 Oct 2016 17:14:36 +0000 (18:14 +0100)] 
docs: Rework XML-RPC docs

Add a barebones usage guide for pwclient and simplify the existing doc
for this API. This entails move the existing doc from the deployment
section to development section, which makes more sense given its focus.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Structure docs folder like online
Stephen Finucane [Tue, 11 Oct 2016 17:13:11 +0000 (18:13 +0100)] 
docs: Structure docs folder like online

The XML-RPC doc is renamed accordingly.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREADME: Add missing '**'
Stephen Finucane [Mon, 10 Oct 2016 23:04:01 +0000 (00:04 +0100)] 
README: Add missing '**'

Must test docs before publising.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agomodels: Remove 'UserProfile.primary_project'
Stephen Finucane [Sun, 9 Oct 2016 22:35:48 +0000 (23:35 +0100)] 
models: Remove 'UserProfile.primary_project'

This field was unused and has been for a long time (pre-0.9.0).

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
8 years agotravis: Enable *-django110 targets
Stephen Finucane [Sun, 9 Oct 2016 19:07:25 +0000 (20:07 +0100)] 
travis: Enable *-django110 targets

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agorequirements: Add support for Django 1.10
Stephen Finucane [Sun, 9 Oct 2016 19:07:23 +0000 (20:07 +0100)] 
requirements: Add support for Django 1.10

All issues around 1.10 support have been resolved. Add tox targets
and extend the range of supported versions to include this release.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoviews: Resolve select_related issues
Stephen Finucane [Sun, 9 Oct 2016 19:07:21 +0000 (20:07 +0100)] 
views: Resolve select_related issues

Django 1.10 prohibits non-relational fields for nested relations [1].
Replace said call with a functional alternative.

[1] https://docs.djangoproject.com/en/dev/releases/1.10/#select-related-prohibits-non-relational-fields-for-nested-relations

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotemplates: Resolve cycle issues with Django 1.10
Stephen Finucane [Sun, 9 Oct 2016 19:07:18 +0000 (20:07 +0100)] 
templates: Resolve cycle issues with Django 1.10

The 'future.cycle' template tag is removed in Django 1.10. Since
Django 1.7 is still supported by Patchwork, it is necessary to
provide a custom 'cycle' wrapper to prevent the deprecation
warnings resolved by '9cab078' being reintroduced.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agorequirements: Bump django-rest-framework to 1.4.x
Stephen Finucane [Sun, 9 Oct 2016 19:07:16 +0000 (20:07 +0100)] 
requirements: Bump django-rest-framework to 1.4.x

This version is compatible with all versions of Django that Patchwork
is recommended for.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoRevert "Allow assigning of any user as delegate"
Stephen Finucane [Sun, 25 Sep 2016 21:37:11 +0000 (22:37 +0100)] 
Revert "Allow assigning of any user as delegate"

This reverts commit e0fd7cd91a5fbe0a0077c46bea870ccd09c8920d.

This change does not scale with a larger number of lists, and clearly
needs more work. Revert until such a time as this is carried out.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoparsearchive: Don't catch standard exceptions
Stephen Finucane [Sat, 8 Oct 2016 17:11:24 +0000 (18:11 +0100)] 
parsearchive: Don't catch standard exceptions

It's too broad. The exception that was intended to be caught should be
converted to a more specific exception instead.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREADME: Add 'stone-tools' presentation
Stephen Finucane [Sat, 8 Oct 2016 13:12:44 +0000 (14:12 +0100)] 
README: Add 'stone-tools' presentation

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoparsearchive: Handle broken patches
Stephen Finucane [Fri, 7 Oct 2016 18:50:46 +0000 (19:50 +0100)] 
parsearchive: Handle broken patches

Some emails are malformed and missing required fields, e.g. subject.
Keep a counter of all broken mails we receive.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoparsearchive: Convert to a management command
Stephen Finucane [Wed, 7 Sep 2016 21:16:43 +0000 (22:16 +0100)] 
parsearchive: Convert to a management command

As with parsemail, parsearchive makes more sense as a management
command. Make it so.

As with the conversion of the 'parsemail' tool, this removes
customisable logging as it's not necessary.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes-bug: #17

8 years agoparsemail: Convert to a management command
Daniel Axtens [Thu, 22 Sep 2016 02:15:09 +0000 (12:15 +1000)] 
parsemail: Convert to a management command

Management comands allow applications to register their own actions
with 'manage.py'. This provides some advantages, like automatically
configuring Django (removing the need for 'django.setup' calls) and
removing the need to set the PYTHON_PATH. The 'parsemail' script is a
natural fit for this type of application. Migrate 'parsemail' to a
management command.

This includes some extensive work on logging configuration, as logging
is moved from code into settings. In addition, it removes a lot of the
customizable logging previously introduced in the parsemail command, in
favour of modifications to the settings files.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Stephen Finucane <stephen@that.guru>
Partial-bug: #17
Closes-bug: #15

8 years agotests: Reduce duplication in MailParsingTest
Stephen Finucane [Fri, 7 Oct 2016 18:21:19 +0000 (19:21 +0100)] 
tests: Reduce duplication in MailParsingTest

...and rename to 'EncodingParseTest' to signify function of tests.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoparser tests: test parsing of interesting mail
Daniel Axtens [Tue, 20 Sep 2016 08:29:06 +0000 (18:29 +1000)] 
parser tests: test parsing of interesting mail

We have 4 new tests:
 - One with a header with a character that is neither 7-bit ASCII
   nor UTF-8.
 - One with UTF-8 in the body.
 - One with un-encoded UTF-8 in the headers.
 - One with a header that claims to be UTF-8 but isn't.

This also requires us to change how we open files on Python 3. Use
the binary file and message_from_binary_file setup under Python 3.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agoparser: subject_check needs to call clean_header
Daniel Axtens [Wed, 28 Sep 2016 04:06:07 +0000 (14:06 +1000)] 
parser: subject_check needs to call clean_header

When testing with headers with unencoded characters on Py3,
subject_check would fail. It was getting an Header class, rather
than a str/bytes, and so the regex was failing.

Run clean_header to decode everything fully first.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agoparser: parse headers containing invalid characters or codings
Daniel Axtens [Mon, 19 Sep 2016 14:23:58 +0000 (00:23 +1000)] 
parser: parse headers containing invalid characters or codings

If there is a non-ascii character in a header, parsing fails,
even on Py27.

This has huge Py2/Py3 complexities. The Py3 email package has tools
to handle this - we just need to use them. Py2, on the other hand,
needs a lot of hand-holding, as explained in the comments.

Additionally, support headers that claim an encoding, but fail to
decode with that encoding.

This is handy for mails with malformed headers containing weird
bytes.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reported-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agoparsemail-batch: Replace tabs with spaces
Stephen Finucane [Fri, 7 Oct 2016 17:58:03 +0000 (18:58 +0100)] 
parsemail-batch: Replace tabs with spaces

Let's keep our Bash scripts consistent with our Python.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoparsemail-batch.sh: pass command-line options to parsemail
Daniel Axtens [Fri, 2 Sep 2016 01:40:04 +0000 (11:40 +1000)] 
parsemail-batch.sh: pass command-line options to parsemail

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agoparsemail.sh: make testing easier
Daniel Axtens [Tue, 20 Sep 2016 06:43:24 +0000 (16:43 +1000)] 
parsemail.sh: make testing easier

 - Take PW_PYTHON, allowing the python version to be set
 - Only override DJANGO_SETTINGS_MODULE if it's not in the env
 - Pass parameters to parsemail.py

Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoui: Shrink vertical space
Thomas Monjalon [Thu, 8 Sep 2016 21:20:32 +0000 (23:20 +0200)] 
ui: Shrink vertical space

Reduce some vertical padding/margin and remove some useless titles
in list.html and patch.html.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agoui: Align patch form with above metadata
Thomas Monjalon [Thu, 8 Sep 2016 21:20:31 +0000 (23:20 +0200)] 
ui: Align patch form with above metadata

The box "Patch Properties" is now well aligned with lines
"Message ID", "State" and "Headers".

Give also more space with side box "Bundling".

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agoui: Align patch row with checkbox vertically
Thomas Monjalon [Thu, 8 Sep 2016 21:20:30 +0000 (23:20 +0200)] 
ui: Align patch row with checkbox vertically

When logged in, the checkbox in front of each row makes the line bigger.
And the text was not exactly in the middle of the line.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agoUpdate mailmap with new email
Stephen Finucane [Sun, 25 Sep 2016 21:00:47 +0000 (22:00 +0100)] 
Update mailmap with new email

Hotmail is unfortunately not standards compliant and has a bad habit of
rewriting message-ids. This breaks threading for both Mailman and
Patchwork. Clearly it's time to switch to another email address.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agobin/pwclient: fix spurious except catch
Yann E. MORIN [Sun, 25 Sep 2016 10:48:32 +0000 (12:48 +0200)] 
bin/pwclient: fix spurious except catch

The 'with' statement does not start an exception block like 'try' would,
so we get an error executing pwclient:

      File "/home/ymorin/bin/pwclient", line 300
        except IOError:
             ^
    SyntaxError: invalid syntax

Instead, don't try to catch any exception: any failure will be
propagated back up the stack and eventually cause an abort, which is
anyway what the except clause was trying to do.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
8 years agoparser: fix wrong parsing of diff comments
WEN Pingbo [Mon, 5 Sep 2016 14:31:46 +0000 (22:31 +0800)] 
parser: fix wrong parsing of diff comments

If the subject of a submission is prefixed by 'Re:', then it can't be a
patch or cover letter.

Signed-off-by: WEN Pingbo <wengpingbo@gmail.com>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
8 years agoAdd sqlparse to production requirements
Daniel Axtens [Tue, 20 Sep 2016 06:04:20 +0000 (16:04 +1000)] 
Add sqlparse to production requirements

It's required for migration #10 (w/ RunSQL), per upstream docs:

    https://docs.djangoproject.com/en/1.8/ref/migration-operations/#runsql

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
8 years agobin: Remove update-patchwork-status
Stephen Finucane [Fri, 9 Sep 2016 17:27:46 +0000 (18:27 +0100)] 
bin: Remove update-patchwork-status

If this ever did anything then it no longer does. Remove it.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
8 years agoCHANGELOG: Document latest changes
Stephen Finucane [Wed, 14 Sep 2016 17:18:52 +0000 (18:18 +0100)] 
CHANGELOG: Document latest changes

...in prep for v2.0.0.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
8 years agoCHANGELOG: Add v1.1.1 release
Stephen Finucane [Wed, 14 Sep 2016 16:51:22 +0000 (17:51 +0100)] 
CHANGELOG: Add v1.1.1 release

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
8 years agoCHANGELOG: Integrate UPGRADING content
Stephen Finucane [Wed, 14 Sep 2016 16:43:02 +0000 (17:43 +0100)] 
CHANGELOG: Integrate UPGRADING content

Rewrite the CHANGELOG as necessary, making better use of the
'UPGRADING' section

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
8 years agotrivial: Fix incorrectly subclassed 'save's
Stephen Finucane [Fri, 9 Sep 2016 16:23:53 +0000 (17:23 +0100)] 
trivial: Fix incorrectly subclassed 'save's

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotrivial: Remove unreachable code
Stephen Finucane [Fri, 9 Sep 2016 16:20:58 +0000 (17:20 +0100)] 
trivial: Remove unreachable code

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotrivial: noqa unused imports
Stephen Finucane [Fri, 9 Sep 2016 16:19:51 +0000 (17:19 +0100)] 
trivial: noqa unused imports

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotrivial: Combine if statements
Stephen Finucane [Fri, 9 Sep 2016 16:19:30 +0000 (17:19 +0100)] 
trivial: Combine if statements

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotrivial: Use 'in' operator
Stephen Finucane [Fri, 9 Sep 2016 16:02:58 +0000 (17:02 +0100)] 
trivial: Use 'in' operator

Don't do 'x == a or x == b'. Prefer 'x in [a, b]' instead.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotrivial: Don't use non-Pythonic names
Stephen Finucane [Fri, 9 Sep 2016 16:00:51 +0000 (17:00 +0100)] 
trivial: Don't use non-Pythonic names

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotrivial: Use implicit true/false for comparison
Stephen Finucane [Mon, 19 Sep 2016 22:15:38 +0000 (23:15 +0100)] 
trivial: Use implicit true/false for comparison

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotrivial: noqa any 'assert' functions
Stephen Finucane [Mon, 19 Sep 2016 22:15:26 +0000 (23:15 +0100)] 
trivial: noqa any 'assert' functions

There are advantages to sticking with unittest's use of camel case in
function names, but some code tools don't like this. noqa these lines
to hide the warnings.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotrivial: Remove broad exceptions where possible
Stephen Finucane [Thu, 8 Sep 2016 16:43:10 +0000 (17:43 +0100)] 
trivial: Remove broad exceptions where possible

The are two somewhat significant changes:

* The behavior of 'Bundle.add_patch' is changed. Previously this would
  raise an exception if the provided patch already existed in the
  bundle. Since this code was only used in one location, change this to
  return the BundlePatch if valid else None and change the calling code
  to check return value instead of catching the exception.
* Use a context manager to open the config file in pwclient. This loses
  a little granularity in error messaging, but this is a worthy
  compromise.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotrivial: Don't shadow built-ins
Stephen Finucane [Mon, 19 Sep 2016 22:15:14 +0000 (23:15 +0100)] 
trivial: Don't shadow built-ins

* Don't use 'str', 'id', 'max', etc. as variable names
* Remove unnecessary use of six.range
* Remove unnecessary use of six.map

There is one paramter in xmlrpc that cannot be renamed as it could
break some client code. noqa this instead.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoviews: Remove cyclic import
Stephen Finucane [Mon, 19 Sep 2016 22:15:01 +0000 (23:15 +0100)] 
views: Remove cyclic import

There's no need to do imports this way, so move notification handling
into a suitable module.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoxmlrpc: Bump version
Stephen Finucane [Thu, 8 Sep 2016 16:28:17 +0000 (17:28 +0100)] 
xmlrpc: Bump version

This should have been bumped with 'c547dc7'.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoxmlrpc: Factor out common code
Stephen Finucane [Thu, 8 Sep 2016 16:26:30 +0000 (17:26 +0100)] 
xmlrpc: Factor out common code

Now that every endpoint accepts negative max_counts, the code that does
this can be factored out.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agogitignore: Ignore vagrant and vim files
Stephen Finucane [Mon, 19 Sep 2016 22:11:54 +0000 (23:11 +0100)] 
gitignore: Ignore vagrant and vim files

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
8 years agoOptimise querying of checks in patch list view
Daniel Axtens [Thu, 15 Sep 2016 08:10:29 +0000 (18:10 +1000)] 
Optimise querying of checks in patch list view

tl;dr: with about 300 mails from the patchwork list, according to
django-debug-toolbar, to render '/project/patchwork/list/'

Without this patch:
 - ~1.35 seconds of CPU time
 - 110 SQL queries, taking ~70ms

With this patch:
 - < 0.3 seconds of CPU time
 - 10 SQL queries, taking <20ms

How? Replace an .exclude() on a QuerySet with a list comprehension.
Yes, that's normally a pessimisation.  Surprisingly, it's an
optimisation here.  Why? Where we're looking at patches in anything
that uses a generic_list() in the view, we do a prefetch_related. But,
if we then do a .filter or a .exclude, that throws out the existing,
cached information, and does another query. (See the Django docs on
prefetch_related)

So, do it 'by hand' in Python instead.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
8 years agofields: Stub out unused arguments
Stephen Finucane [Wed, 7 Sep 2016 21:03:49 +0000 (22:03 +0100)] 
fields: Stub out unused arguments

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
8 years agosettings: noqa the secret key
Stephen Finucane [Wed, 7 Sep 2016 21:03:48 +0000 (22:03 +0100)] 
settings: noqa the secret key

This is a development setting file. Dismiss the 'dodgy' warning on
landscape.io.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>