diff mbox series

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

Message ID 20180221141716.10908-3-dja@axtens.net
State Changes Requested
Headers show
Series Tools and fixes for parallel parsing | expand

Checks

Context Check Description
dja/snowpatch-0_1_0 success master/apply_patch Successfully applied
dja/snowpatch-snowpatch_job_snowpatch-patchwork success Test snowpatch/job/snowpatch-patchwork on branch master

Commit Message

Daniel Axtens Feb. 21, 2018, 2:17 p.m. UTC
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

Signed-off-by: Daniel Axtens <dja@axtens.net>
---
 patchwork/management/commands/debug_dump.py | 46 +++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 patchwork/management/commands/debug_dump.py

Comments

Andrew Donnellan Feb. 22, 2018, 3:18 a.m. UTC | #1
On 22/02/18 01:17, Daniel Axtens wrote:
> 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
> 
> Signed-off-by: Daniel Axtens <dja@axtens.net>

Don't know if "debug_dump" is the best name but I guess it's descriptive 
enough and I can't think of anything better off the top of my head.

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
diff mbox series

Patch

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@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)