From nobody Thu Apr 18 15:14:02 2024 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=patchew-devel-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1648130317; cv=none; d=zohomail.com; s=zohoarc; b=AetNawDEAi6EX7Noq0j2NtJ2qXPvg6m4NMObzy4fiKgM2eVoP9Z+Ybrjd98gqzjPgytjX2Mh/v49eliGVPmLozjs3nj4FwHdG1MYyeqMiD9IIW5B0uT7OyraYzNHa74VdEgZMioHLm7m1y38TbqgrVRtsIKTBx+3v4sUe3yll9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648130317; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=NnigjJl9M0QAFtvdImYW0DskR5K/atPAASDyCFa7Ld8=; b=IYZKMY5uHEF84LTdXmxBGUAfNdn/oQvU9GmKq3ZfPjM6O/e4oOkczKyqyEXXKPGfY01oFbabqn6gZiSm+lY0F8HqjdJ5K5O0EYZzYc1pZBxQ93E1dYn/q2FN4lOP0HQJW6Con0kQRLgTXlvf875cSydWG3eCtkemCpJOcq6nTTM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 16481303174731016.2590285164299; Thu, 24 Mar 2022 06:58:37 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-546-w3LtQMJ4Phqo1zIN9MovfQ-1; Thu, 24 Mar 2022 09:58:33 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0188E899EC4; Thu, 24 Mar 2022 13:58:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE352C27E8E; Thu, 24 Mar 2022 13:58:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9772E194034E; Thu, 24 Mar 2022 13:58:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CA873194034B for ; Thu, 24 Mar 2022 13:58:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A59B4400E54D; Thu, 24 Mar 2022 13:58:30 +0000 (UTC) Received: from avogadro.lan (unknown [10.39.195.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EFAA40CF8F7 for ; Thu, 24 Mar 2022 13:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648130316; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=NnigjJl9M0QAFtvdImYW0DskR5K/atPAASDyCFa7Ld8=; b=Lqj2bXED98B+EGOQjOTt7A2RRvI6mNcusGahEAiU6SfKJSsGf9H1ThuSA7vtICQ5bpJruU yq0heRYBa+Q/jaFbb1WTT4c3/+SdGTZMiNwPf78OR7AFYKHUGU/yFVXHIcgLIW0Xex3BTf p8hJbPImJ2J2tCg3JswWVqHrd4tRVWI= X-MC-Unique: w3LtQMJ4Phqo1zIN9MovfQ-1 X-Original-To: patchew-devel@listman.corp.redhat.com From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 24 Mar 2022 14:58:28 +0100 Message-Id: <20220324135828.178872-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Subject: [Patchew-devel] [PATCH] patchew-cli: remove apply options -b, -B, -t X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchew-devel-bounces@redhat.com Sender: "Patchew-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=patchew-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1648130317764100001 Content-Type: text/plain; charset="utf-8" Simplify _apply by moving the handling of branches and tags to applier mode= only. Signed-off-by: Paolo Bonzini --- patchew-cli | 84 ++++++++++++----------------------------------------- 1 file changed, 19 insertions(+), 65 deletions(-) diff --git a/patchew-cli b/patchew-cli index f269413..6ec93ed 100755 --- a/patchew-cli +++ b/patchew-cli @@ -952,36 +952,12 @@ class ApplyCommand(SubCommand): action=3D"store_true", help=3D"""Sign off the applied patch""", ) - parser.add_argument( - "--branch", - "-b", - help=3D"""Create a branch at current HEAD before - applying, with '%%m' replaced with the series' - message id""", - ) - parser.add_argument( - "--force-branch", - "-B", - help=3D"""Create a branch, overwrite even if a branch - with the same name already exists, and point to - current HEAD before applying, with '%%m' repla= ced - with the series' message id""", - ) - parser.add_argument( - "--tag", - "-t", - help=3D"""Create a tag after applying, with '%%m' - replaced with the series' message id. If a tag= with - the same name already exists, it will be - updated""", - ) parser.add_argument( "--applier-mode", action=3D"store_true", help=3D"""Useful for an applier worker of patchew. Clone and checkout a temporary repo, and apply= the - patch there. Implies --any, conflicts with -C,= -b, - -B and -t.""", + patch there. Implies --any, conflicts with -C.= """, ) parser.add_argument( "--applier-target", @@ -1015,25 +991,12 @@ class ApplyCommand(SubCommand): except: return [] =20 - def _apply(self, repo, s, branch, force_branch, tag, logf=3DNone, sign= off=3DFalse): - msgid =3D s["message_id"] - bn =3D None - if force_branch: - bn =3D force_branch - bo =3D "-B" - elif branch: - bn =3D branch - bo =3D "-b" - if bn: - bn =3D bn.replace("%m", msgid) - subprocess.check_call( - ["git", "checkout", bo, bn], cwd=3Drepo, stdout=3Dlogf, st= derr=3Dlogf - ) + def _apply(self, repo, uri, logf=3DNone, signoff=3DFalse): args =3D ["git", "am", "-m", "-3"] if signoff: args +=3D ["-s"] maintainers =3D set() - req =3D urllib.request.Request(s["mbox_uri"]) + req =3D urllib.request.Request(uri) resp =3D urllib.request.urlopen(req) respdata =3D resp.read() patchf =3D tempfile.NamedTemporaryFile() @@ -1043,13 +1006,6 @@ class ApplyCommand(SubCommand): args + [patchf.name], cwd=3Drepo, stdout=3Dlogf, stderr=3Dlogf ): raise ApplyFailedException() - elif tag: - subprocess.check_call( - ["git", "tag", "-f", tag.replace("%m", msgid)], - cwd=3Drepo, - stdout=3Dlogf, - stderr=3Dlogf, - ) return patchf =20 def _push(self, repo, remote, tag, logf, push_options): @@ -1099,15 +1055,25 @@ class ApplyCommand(SubCommand): else: remote, head =3D project_git, "master" git_clone_repo(wd, remote, "origin/" + head) - branch =3D message_id - force_branch =3D None tag =3D "patchew/" + message_id + subprocess.check_call( + ["git", "checkout", "-b", message_id], + cwd=3Dwd, + stdout=3Dlogf, + stderr=3Dlogf, + ) data["base"] =3D ( subprocess.check_output(["git", "rev-parse", "HEAD"], cwd= =3Dwd) .decode("utf-8") .strip() ) - patchf =3D self._apply(wd, toapply, branch, force_branch, tag,= logf) + patchf =3D self._apply(wd, toapply["mbox_uri"], logf) + subprocess.check_call( + ["git", "tag", "-f", tag.replace("%m", message_id)], + cwd=3Dwd, + stdout=3Dlogf, + stderr=3Dlogf, + ) maintainers =3D self._get_maintainers(wd, patchf.name) if push_repo: self._push(wd, push_repo, tag, logf, push_options) @@ -1153,13 +1119,8 @@ class ApplyCommand(SubCommand): =20 def do(self, args, argv): if args.applier_mode: - if ( - args.repo not in [None, "."] - or args.branch - or args.force_branch - or args.tag - ): - print("--applier-mode conflicts with -C, -b, -B and -t") + if args.repo not in [None, "."]: + print("--applier-mode conflicts with -C") return 1 return self._applier_mode(args) if args.applier_target: @@ -1184,14 +1145,7 @@ class ApplyCommand(SubCommand): return a.replace("%m", r[0]["message-id"]) if a else a =20 try: - self._apply( - args.repo, - r[0], - mformat(args.branch), - mformat(args.force_branch), - mformat(args.tag), - signoff=3Dargs.signoff, - ) + self._apply(args.repo, r[0]["mbox_uri"], signoff=3Dargs.signof= f) return 0 except: traceback.print_exc() --=20 2.35.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://listman.redhat.com/mailman/listinfo/patchew-devel