From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EAB0ECE58D for ; Fri, 11 Oct 2019 17:13:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6189A206A1 for ; Fri, 11 Oct 2019 17:13:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6189A206A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIyTZ-0003dL-5M for qemu-devel@archiver.kernel.org; Fri, 11 Oct 2019 13:13:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37612) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIxRm-0007mz-FM for qemu-devel@nongnu.org; Fri, 11 Oct 2019 12:07:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iIxRk-0005F1-2V for qemu-devel@nongnu.org; Fri, 11 Oct 2019 12:07:18 -0400 Received: from relay.sw.ru ([185.231.240.75]:48100) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iIxRj-0004GL-Mi; Fri, 11 Oct 2019 12:07:16 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.2) (envelope-from ) id 1iIxQb-0003XG-Ro; Fri, 11 Oct 2019 19:06:05 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Subject: [RFC v5 026/126] python: add commit-per-subsystem.py Date: Fri, 11 Oct 2019 19:04:12 +0300 Message-Id: <20191011160552.22907-27-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191011160552.22907-1-vsementsov@virtuozzo.com> References: <20191011160552.22907-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ronnie Sahlberg , Jeff Cody , Jan Kiszka , Alberto Garcia , Hailiang Zhang , qemu-block@nongnu.org, Aleksandar Rikalo , Halil Pasic , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Anthony Perard , Samuel Thibault , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Anthony Green , Laurent Vivier , Eduardo Habkost , Xie Changlong , Peter Lieven , "Dr. David Alan Gilbert" , Beniamino Galvani , Eric Auger , Alex Williamson , Stefan Hajnoczi , John Snow , Richard Henderson , Kevin Wolf , vsementsov@virtuozzo.com, Andrew Jeffery , Chris Wulff , Subbaraya Sundeep , Michael Walle , qemu-ppc@nongnu.org, Bastian Koppelmann , Igor Mammedov , Fam Zheng , Peter Maydell , sheepdog@lists.wpkg.org, Matthew Rosato , David Hildenbrand , Palmer Dabbelt , Thomas Huth , Max Filippov , "Denis V. Lunev" , Hannes Reinecke , Stefano Stabellini , "Gonglei \(Arei\)" , Liu Yuan , Artyom Tarasenko , Eric Farman , Amit Shah , Stefan Weil , Greg Kurz , Yuval Shaia , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Peter Chubb , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stafford Horne , qemu-riscv@nongnu.org, Cornelia Huck , Aleksandar Markovic , Aurelien Jarno , Paul Burton , Sagar Karandikar , Paul Durrant , Jason Wang , Gerd Hoffmann , "Edgar E. Iglesias" , Guan Xuetao , Ari Sundholm , Juan Quintela , Michael Roth , Christian Borntraeger , Joel Stanley , Jason Dillaman , Antony Pavlov , xen-devel@lists.xenproject.org, integration@gluster.org, Laszlo Ersek , "Richard W.M. Jones" , Andrew Baumann , Max Reitz , "Michael S. Tsirkin" , Mark Cave-Ayland , Vincenzo Maffione , Marek Vasut , armbru@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Alistair Francis , Pavel Dovgalyuk , Giuseppe Lettieri , Luigi Rizzo , David Gibson , Tony Krowiak , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Xiao Guangrong , Pierre Morel , Wen Congyang , Jean-Christophe Dubois , Paolo Bonzini , Stefan Berger Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add script to automatically commit tree-wide changes per-subsystem. Signed-off-by: Vladimir Sementsov-Ogievskiy --- CC: Gerd Hoffmann CC: "Gonglei (Arei)" CC: Eduardo Habkost CC: Igor Mammedov CC: Laurent Vivier CC: Amit Shah CC: Kevin Wolf CC: Max Reitz CC: John Snow CC: Ari Sundholm CC: Pavel Dovgalyuk CC: Paolo Bonzini CC: Stefan Hajnoczi CC: Fam Zheng CC: Stefan Weil CC: Ronnie Sahlberg CC: Peter Lieven CC: Eric Blake CC: "Denis V. Lunev" CC: Markus Armbruster CC: Alberto Garcia CC: Jason Dillaman CC: Wen Congyang CC: Xie Changlong CC: Liu Yuan CC: "Richard W.M. Jones" CC: Jeff Cody CC: "Marc-André Lureau" CC: "Daniel P. Berrangé" CC: Richard Henderson CC: Greg Kurz CC: "Michael S. Tsirkin" CC: Marcel Apfelbaum CC: Beniamino Galvani CC: Peter Maydell CC: "Cédric Le Goater" CC: Andrew Jeffery CC: Joel Stanley CC: Andrew Baumann CC: "Philippe Mathieu-Daudé" CC: Antony Pavlov CC: Jean-Christophe Dubois CC: Peter Chubb CC: Subbaraya Sundeep CC: Eric Auger CC: Alistair Francis CC: "Edgar E. Iglesias" CC: Stefano Stabellini CC: Anthony Perard CC: Paul Durrant CC: Paul Burton CC: Aleksandar Rikalo CC: Chris Wulff CC: Marek Vasut CC: David Gibson CC: Cornelia Huck CC: Halil Pasic CC: Christian Borntraeger CC: "Hervé Poussineau" CC: Xiao Guangrong CC: Aurelien Jarno CC: Aleksandar Markovic CC: Mark Cave-Ayland CC: Jason Wang CC: Laszlo Ersek CC: Yuval Shaia CC: Palmer Dabbelt CC: Sagar Karandikar CC: Bastian Koppelmann CC: David Hildenbrand CC: Thomas Huth CC: Eric Farman CC: Matthew Rosato CC: Hannes Reinecke CC: Michael Walle CC: Artyom Tarasenko CC: Stefan Berger CC: Samuel Thibault CC: Alex Williamson CC: Tony Krowiak CC: Pierre Morel CC: Michael Roth CC: Hailiang Zhang CC: Juan Quintela CC: "Dr. David Alan Gilbert" CC: Luigi Rizzo CC: Giuseppe Lettieri CC: Vincenzo Maffione CC: Jan Kiszka CC: Anthony Green CC: Stafford Horne CC: Guan Xuetao CC: Max Filippov CC: qemu-block@nongnu.org CC: integration@gluster.org CC: sheepdog@lists.wpkg.org CC: qemu-arm@nongnu.org CC: xen-devel@lists.xenproject.org CC: qemu-ppc@nongnu.org CC: qemu-s390x@nongnu.org CC: qemu-riscv@nongnu.org python/commit-per-subsystem.py | 204 +++++++++++++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100755 python/commit-per-subsystem.py diff --git a/python/commit-per-subsystem.py b/python/commit-per-subsystem.py new file mode 100755 index 0000000000..2ccf84cb15 --- /dev/null +++ b/python/commit-per-subsystem.py @@ -0,0 +1,204 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2019 Virtuozzo International GmbH +# +# This program 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. +# +# This program 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 this program. If not, see . +# + +import subprocess +import sys +import os +import glob + + +def git_add(pattern): + subprocess.run(['git', 'add', pattern]) + + +def git_commit(msg): + subprocess.run(['git', 'commit', '-m', msg], capture_output=True) + + +def git_changed_files(): + ret = subprocess.check_output(['git', 'diff', '--name-only'], encoding='utf-8').split('\n') + if ret[-1] == '': + del ret[-1] + return ret + + +maintainers = sys.argv[1] +message = sys.argv[2].strip() + +subsystem = None + +remap = { + 'Block layer core': 'block', + 'Block Jobs': 'block', + 'Dirty Bitmaps': 'block', + 'Block QAPI, monitor, command line': 'block', + 'Block I/O path': 'block', + 'Throttling infrastructure': 'block', + 'Architecture support': 's390x', + 'Guest CPU Cores (KVM)': 'kvm', + 'Guest CPU Cores (Xen)': 'xen', + 'Guest CPU cores (TCG)': 'tcg', + 'Network Block Device (NBD)': 'nbd', + 'Parallel NOR Flash devices': 'pflash', + 'Firmware configuration (fw_cfg)': 'fw_cfg', + 'Block SCSI subsystem': 'scsi', + 'Network device backends': 'net', + 'Netmap network backend': 'net', + 'Host Memory Backends': 'hostmem', + 'Cryptodev Backends': 'cryptodev', + 'QEMU Guest Agent': 'qga', + 'COLO Framework': 'colo', + 'Command line option argument parsing': 'cmdline', + 'Character device backends': 'chardev' +} + + +class Maintainers: + def add(self, subsystem, path, mapper, mapper_name, glob_count=1): + if subsystem in remap: + subsystem = remap[subsystem] + if subsystem not in self.subsystems: + self.subsystems.append(subsystem) + + if path[-1] == '/': + path = path[:-1] + + if path in mapper: + if mapper[path][1] == glob_count: + print('Warning: "{}" both in "{}" and "{}" in {} mapper with ' + 'same glob-count={}. {} ignored for this path.'.format( + path, mapper[path][0], subsystem, mapper_name, glob_count, + subsystem)) + return + if mapper[path][1] < glob_count: + # silently ignore worse match + return + + mapper[path] = (subsystem, glob_count) + + def __init__(self, file_name): + self.map_file = {} + self.map_glob_file = {} + self.map_dir = {} + self.map_glob_dir = {} + self.map_unmaintained_dir = { + 'python': ('python', 1), + 'hw/misc': ('misc', 1) + } + self.subsystems = ['python', 'misc'] + subsystem = None + + with open(file_name) as f: + mode2 = False + prevline = '' + for line in f: + line = line.rstrip() + if not line: + continue + if len(line) >= 2 and line[1] == ':': + if line[0] == 'F': + fname = line[3:] + if fname in ['*', '*/']: + continue + if os.path.isfile(fname): + self.add(subsystem, fname, self.map_file, 'file') + elif os.path.isdir(fname): + self.add(subsystem, fname, self.map_dir, 'dir') + else: + paths = glob.glob(fname) + if not paths: + print('Warning: nothing corresponds to "{}"'.format(fname)) + continue + + n = len(paths) + for f in paths: + if os.path.isfile(f): + self.add(subsystem, f, self.map_glob_file, 'glob-file', n) + else: + assert os.path.isdir(f) + self.add(subsystem, f, self.map_glob_dir, 'glob-dir', n) + elif line[:3] == '---': + subsystem = prevline + if subsystem == 'Devices': + mode2 = True + elif mode2: + subsystem = line + prevline = line + + def find_in_map_dir(self, file_name, mapper): + while file_name != '' and file_name not in mapper: + file_name = os.path.dirname(file_name) + + return None if file_name == '' else mapper[file_name][0] + + def find_in_map_file(self, file_name, mapper): + if file_name in mapper: + return mapper[file_name][0] + + def find_subsystem(self, file_name): + s = self.find_in_map_file(file_name, self.map_file) + if s is not None: + return s + + s = self.find_in_map_file(file_name, self.map_glob_file) + if s is not None: + return s + + s = self.find_in_map_dir(file_name, self.map_dir) + if s is not None: + return s + + s = self.find_in_map_dir(file_name, self.map_glob_dir) + if s is not None: + return s + + s = self.find_in_map_dir(file_name, self.map_unmaintained_dir) + if s is not None: + return s + + self.subsystems.append(file_name) + return file_name + + +def commit(subsystem): + msg = subsystem + if msg in remap: + msg = remap[msg] + msg += ': ' + message + git_commit(msg) + +mnt = Maintainers(maintainers) +res = {} +for f in git_changed_files(): + s = mnt.find_subsystem(f) + if s in res: + res[s].append(f) + else: + res[s] = [f] + +for s in mnt.subsystems: + if s in res: + print(s) + for f in res[s]: + print(' ', f) + +for s in mnt.subsystems: + if s in res: + for f in res[s]: + git_add(f) + commit(s) -- 2.21.0