[PATCH v2 2/9] debugging: add command to dump patches and series

Daniel Axtens dja at axtens.net
Sun Feb 25 01:50:13 AEDT 2018


I don't want a full dump, just enough to know if the same patches
and series have been created with roughly the same properties. This
seemed like the easiest way to do it.

Usage:
  python3 manage.py debug_dump > file
  ... make changes, reset db, reload files ...
  python3 manage.py debug_dump > file2
  diff -u file file2

Reviewed-by: Andrew Donnellan <andrew.donnellan at au1.ibm.com>
Signed-off-by: Daniel Axtens <dja at axtens.net>
---
 patchwork/management/commands/debug_dump.py | 46 +++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 patchwork/management/commands/debug_dump.py

diff --git a/patchwork/management/commands/debug_dump.py b/patchwork/management/commands/debug_dump.py
new file mode 100644
index 000000000000..f668dd14f1d2
--- /dev/null
+++ b/patchwork/management/commands/debug_dump.py
@@ -0,0 +1,46 @@
+# Patchwork - automated patch tracking system
+# Copyright (C) 2018 Daniel Axtens <dja at axtens.net>
+#
+# This file is part of the Patchwork package.
+#
+# Patchwork is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Patchwork is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+from django.core.management import base
+
+from patchwork.models import Patch
+from patchwork.models import Series
+
+
+class Command(base.BaseCommand):
+    help = 'DEBUG COMMAND: Return a minimal robust representation of the db.'
+
+    def handle(self, *args, **options):
+        """This is to check the invariance of parsing as messages are
+        reordered or received in parallel."""
+
+        series = []
+        for s in Series.objects.all():
+            series += ['%s :: v%d :: %d patches :: %s'
+                       % (s.name, s.version, s.total, s.submitter.email)]
+
+        series.sort()
+        print('=== %d series ===' % len(series))
+        for s in series:
+            print(s)
+
+        patches = []
+        for p in Patch.objects.all():
+            patches += ['%s :: ID %s' % (p.name, p.msgid)]
+
+        patches.sort()
+        print('=== %d patches ===' % len(patches))
+        for p in patches:
+            print(p)
-- 
2.14.1



More information about the Patchwork mailing list