[PATCH v4 1/1] management: introduce replacerelations command

Daniel Axtens dja at axtens.net
Thu Jul 23 10:52:52 AEST 2020


Hi Rohit,

Some more things:

1) `docker-compose run web --tox` fails, both pep8 and in some of the
substantive tests:

Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.............................................................................................................................................................................................................................................................................Invalid path: xyz123random
.F..........................................................................................................................................................................................................................................s................................................................................
======================================================================
FAIL: test_valid_relations (patchwork.tests.test_management.ReplacerelationsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/patchwork/patchwork/patchwork/tests/test_management.py", line 143, in test_valid_relations
    self.assertEqual(models.PatchRelation.objects.count(), 2)
AssertionError: 0 != 2

----------------------------------------------------------------------

(Please could you also silence the 'invalid path' print during tests?)

2) There's an line at the end of test_management.py.

3) I reformatted the docs to wrap at 80 columns and I made some minor
changes to the wording and punctuation in the process. Please wrap
future changes at 80 columns. I also found that the patch groups file
doesn't render as separate lines in a web browser, it renders as

"1 3 5 2 7 10 11 12"

I've fixed this.

You can render the docs to html locally with

docker-compose run web --tox -e docs

Here's my proposed docs:

diff --git a/docs/deployment/management.rst b/docs/deployment/management.rst
index 9c57f1962283..7bff699329fb 100644
--- a/docs/deployment/management.rst
+++ b/docs/deployment/management.rst
@@ -116,6 +116,42 @@ the :ref:`deployment installation guide <deployment-parsemail>`.
 
    input mbox filename. If not supplied, a patch will be read from ``stdin``.
 
+replacerelations
+~~~~~~~~~~~~~~~~
+
+.. program:: manage.py replacerelations
+
+Parse a patch groups file and store any relation found
+
+.. code-block:: shell
+
+    ./manage.py replacerelations <infile>
+
+This is a script used to ingest relations into Patchwork.
+
+A patch groups file contains on each line a list of space separated patch IDs
+of patches that form a relation.
+
+For example, consider the contents of a sample patch groups file::
+
+    1 3 5
+    2
+    7 10 11 12
+In this case the script will identify 2 relations, (1, 3, 5) and
+(7, 10, 11, 12). The single patch ID "2" on the second line is ignored as a
+relation always consists of more than 1 patch.
+
+Further, if a patch ID in the patch groups file does not exist in the database
+of the Patchwork instance, that patch ID will be silently ignored while forming
+the relations.
+
+Running this script will remove all existing relations and replace them with
+the relations found in the file.
+
+.. option:: infile
+
+    input patch groups file.
+
 rehash
 ~~~~~~
 
Kind regards,
Daniel


More information about the Patchwork mailing list