From patchwork Tue Nov 24 04:07:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 547814 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 01A1214029E for ; Tue, 24 Nov 2015 15:07:51 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id D988C1A02A1 for ; Tue, 24 Nov 2015 15:07:50 +1100 (AEDT) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lists.ozlabs.org (Postfix) with ESMTP id A86461A009B for ; Tue, 24 Nov 2015 15:07:46 +1100 (AEDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 23 Nov 2015 20:07:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,338,1444719600"; d="scan'208";a="606093832" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 23 Nov 2015 20:07:31 -0800 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id tAO47UT2005224; Tue, 24 Nov 2015 04:07:30 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id tAO47Usk001402; Tue, 24 Nov 2015 04:07:30 GMT Received: (from sfinucan@localhost) by sivswdev01.ir.intel.com with id tAO47UJx001398; Tue, 24 Nov 2015 04:07:30 GMT From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH] management: Create 'rehash' command Date: Tue, 24 Nov 2015 04:07:27 +0000 Message-Id: <1448338047-1352-1-git-send-email-stephen.finucane@intel.com> X-Mailer: git-send-email 2.0.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" The rehash script, though undocumented and possibly unused at the moment, likely has some value to some users. Howver, it makes more sense to provide this command as a management command like 'retag'. Do this. Signed-off-by: Stephen Finucane --- patchwork/bin/rehash.py | 34 ---------------------- patchwork/management/commands/rehash.py | 50 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 34 deletions(-) delete mode 100755 patchwork/bin/rehash.py create mode 100644 patchwork/management/commands/rehash.py diff --git a/patchwork/bin/rehash.py b/patchwork/bin/rehash.py deleted file mode 100755 index c44e49b..0000000 --- a/patchwork/bin/rehash.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python -# -# Patchwork - automated patch tracking system -# Copyright (C) 2008 Jeremy Kerr -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with Patchwork; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -from patchwork.models import Patch -import sys - -if __name__ == '__main__': - if len(sys.argv) > 1: - patches = Patch.objects.filter(id__in = sys.argv[1:]) - else: - patches = Patch.objects.all() - - for patch in patches: - print patch.id, patch.name - patch.hash = None - patch.save() diff --git a/patchwork/management/commands/rehash.py b/patchwork/management/commands/rehash.py new file mode 100644 index 0000000..a694d96 --- /dev/null +++ b/patchwork/management/commands/rehash.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# +# Patchwork - automated patch tracking system +# Copyright (C) 2008 Jeremy Kerr +# Copyright (C) 2015 Intel Corporation +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with Patchwork; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +import sys + +from django.core.management.base import BaseCommand + +from patchwork.models import Patch + + +class Command(BaseCommand): + help = 'Update the hashes on existing patches' + args = '[...]' + + def handle(self, *args, **options): + query = Patch.objects + + if args: + query = query.filter(id_in=args) + else: + query = query.all() + + count = query.count() + + for i, patch in enumerate(query.iterator()): + patch.hash = None + patch.save() + if (i % 10) == 0: + self.stdout.write('%06d/%06d\r' % (i, count), ending='') + self.stdout.flush() + self.stdout.write('\ndone')