From patchwork Mon Jul 6 03:41:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1323282 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B0Wd14B07z9sDX for ; Mon, 6 Jul 2020 13:43:33 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=VaHvKePx; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4B0Wd10nvdzDqft for ; Mon, 6 Jul 2020 13:43:33 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=chromium.org (client-ip=2607:f8b0:4864:20::d42; helo=mail-io1-xd42.google.com; envelope-from=sjg@chromium.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=VaHvKePx; dkim-atps=neutral Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4B0WbY1pKVzDqN1 for ; Mon, 6 Jul 2020 13:42:17 +1000 (AEST) Received: by mail-io1-xd42.google.com with SMTP id f6so22314820ioj.5 for ; Sun, 05 Jul 2020 20:42:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EnSRjNej/pkGnx4xnLUljCYERQfN61SbYvy0eEE10kY=; b=VaHvKePxmimgyFB5V1W2QxyNiTNFVI+qz1OtTsKoEieifwPBiv3+6dCmNHip02JsjP C14/JTZ76CH06oDSbRNEcM9/EThadygBKiNSZoOlv2CX7hWHZWXzwr45NysDSf7BS2Zu nH7XEQV6+CCdnTFv9t6rKcTxue79NbL+1q24g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EnSRjNej/pkGnx4xnLUljCYERQfN61SbYvy0eEE10kY=; b=UfmBYtogwjM7DDwtg9tEiF9G7B1VvbJj3bh1H3GmVcXXOAJ8V0VClX6vF4iOCIoEXk Fj7s3pKd3PgvYqrj9NmwSaWpZk/nCkCHWO2PshThWK0cFA7hZtzp/w1qYnx/BCqqlKPZ cLcxez2Zg+ViXTn1BfyI9bmbHDcfW1qJJt2En/eA5ZYUdub/qWDzsFftsvvnmlDGtJRS ZCOvpiu8nJ96r6Q1gdGQcq6s6G22ZHHxC+2gnBjCxd0e4kCEPJZskDGBUF+lL9xpIrZs 7lu+nqweDfpYQdT8MqMQ/TkQ5kJ5Qcynm6uXIQ1UVcXM4lPtAL+embxPL/KEIZUwMGd4 KpQw== X-Gm-Message-State: AOAM531JsRa+IgzKPGNjUmgMihOA5wzZsIzbTFsWYBfLpLFHPq4C+W2Y 4+Mdl+ytjUBOKa+ch3ImoB8kxQ== X-Google-Smtp-Source: ABdhPJyfdEcOT3LgTYjJT+/jW1NYCUQUNjxtjnfyY/CA5L95cXpPGNWV0YXn2pLXFR9wnqoW8v0qrQ== X-Received: by 2002:a05:6602:164c:: with SMTP id y12mr23719403iow.143.1594006935088; Sun, 05 Jul 2020 20:42:15 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id r15sm1664958ilh.86.2020.07.05.20.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 20:42:14 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Subject: [RFC PATCH 05/16] patman: Allow skipping patches at the end Date: Sun, 5 Jul 2020 21:41:52 -0600 Message-Id: <20200706034203.2171077-6-sjg@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200706034203.2171077-1-sjg@chromium.org> References: <20200706034203.2171077-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Rini , Simon Glass , patchwork@lists.ozlabs.org Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" The -s option allows skipping patches at the top of the branch. Sometimes there are commits at the bottom that need to be skipped. At present it is necessary to count the number of commits and then use -c to tell patman how many to process. Add a -e option to easily skip a number of commits at the bottom of the branch. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/patman/control.py | 8 +++++--- tools/patman/func_test.py | 13 +++++++++++-- tools/patman/main.py | 2 ++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tools/patman/control.py b/tools/patman/control.py index b48eac41fd..b481ff6b27 100644 --- a/tools/patman/control.py +++ b/tools/patman/control.py @@ -20,7 +20,7 @@ def setup(): """Do required setup before doing anything""" gitutil.Setup() -def prepare_patches(col, branch, count, start, ignore_binary): +def prepare_patches(col, branch, count, start, end, ignore_binary): """Figure out what patches to generate, then generate them The patch files are written to the current directory, e.g. 0001_xxx.patch @@ -32,6 +32,8 @@ def prepare_patches(col, branch, count, start, ignore_binary): count (int): Number of patches to produce, or -1 to produce patches for the current branch back to the upstream commit start (int): Start partch to use (0=first / top of branch) + end (int): End patch to use (0=last one in series, 1=one before that, + etc.) ignore_binary (bool): Don't generate patches for binary files Returns: @@ -50,7 +52,7 @@ def prepare_patches(col, branch, count, start, ignore_binary): 'No commits found to process - please use -c flag')) # Read the metadata from the commits - to_do = count + to_do = count - end series = patchstream.GetMetaData(branch, start, to_do) cover_fname, patch_files = gitutil.CreatePatches( branch, start, to_do, ignore_binary, series) @@ -159,7 +161,7 @@ def send(options): setup() col = terminal.Color() series, cover_fname, patch_files = prepare_patches( - col, options.branch, options.count, options.start, + col, options.branch, options.count, options.start, options.end, options.ignore_binary) ok = check_patches(series, patch_files, options.check_patch, options.verbose) diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py index 588be73ef4..810af9c604 100644 --- a/tools/patman/func_test.py +++ b/tools/patman/func_test.py @@ -430,7 +430,8 @@ complicated as possible''') col = terminal.Color() with capture_sys_output() as _: _, cover_fname, patch_files = control.prepare_patches( - col, branch=None, count=-1, start=0, ignore_binary=False) + col, branch=None, count=-1, start=0, end=0, + ignore_binary=False) self.assertIsNone(cover_fname) self.assertEqual(2, len(patch_files)) @@ -438,9 +439,17 @@ complicated as possible''') self.assertEqual(3, gitutil.CountCommitsToBranch('second')) with capture_sys_output() as _: _, cover_fname, patch_files = control.prepare_patches( - col, branch='second', count=-1, start=0, + col, branch='second', count=-1, start=0, end=0, ignore_binary=False) self.assertIsNotNone(cover_fname) self.assertEqual(3, len(patch_files)) + + # Check that it can skip patches at the end + with capture_sys_output() as _: + _, cover_fname, patch_files = control.prepare_patches( + col, branch='second', count=-1, start=0, end=1, + ignore_binary=False) + self.assertIsNotNone(cover_fname) + self.assertEqual(2, len(patch_files)) finally: os.chdir(orig_dir) diff --git a/tools/patman/main.py b/tools/patman/main.py index 066754196e..4d7a3044ea 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -35,6 +35,8 @@ parser.add_option('-b', '--branch', type='str', help="Branch to process (by default, the current branch)") parser.add_option('-c', '--count', dest='count', type='int', default=-1, help='Automatically create patches from top n commits') +parser.add_option('-e', '--end', type='int', default=0, + help='Commits to skip at end of patch list') parser.add_option('-i', '--ignore-errors', action='store_true', dest='ignore_errors', default=False, help='Send patches email even if patch errors are found')