From nobody Tue Apr 16 18:24:26 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VJsrV4khtz5HJGQ; Tue, 16 Apr 2024 18:24:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VJsrV49bBz4jVJ; Tue, 16 Apr 2024 18:24:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713291866; h=from:from: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; bh=KbmW96CS0ne+ulqCcNbf3qLUTM9zUlgof9Epwbbm5S4=; b=pWgLySHO7N4sI2GfdeN7osN3JSBqsgNaCQFe9HweJlEUPgVbJYgMXM3H+e11/WFSlwvwwz IKG3IkYMfjE4hnlGijwvIZ+L1+7AfF9sqWbcctkjO8bU3So5MUgUe4mDnssZ9rRBe4yKPU Tgv9n9+HK0CY/npxEot8OuVBrbmc/C3YD+xt/IsRn9914KLvTfH2s1avZTjEjkNXw6sAs2 4Pup7kApXxswNy3RgJu/eAvfVDSChMmqPQ1B8bC2zJJf/7xBd5OhZ20F5O/GKD9bBUoqL1 8F1wd7A/0N8r0DJpUUpVxPq8EQOfdSN+JZF59yWYmauiBJDe+Sn8xxbKkD7BKQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713291866; a=rsa-sha256; cv=none; b=JAZNt/PvAA+42RrqMpgu8CHEohQ6knWSGSqUpjdLSiHpa22g5Ub9+8NegAgFzJQtyU8xAT 0lsReQrO1FE5k7jORo9/WssTA636ucoCi9yId6gdKUo7JQ/ACL3RK/vyt37BMB7Q8WPKMx up2YUSy9oHJNk4dg0t1OUaMScX2KZonOCvm32514E1J0dxxAOqcvzeHJsHVTpWXIJv411+ y2E0yKw2Wwdn2hvkRw/c5pYDjumkbdvsz3ezp4uxn9KiqPsb7byuf3HuwW5NLm18y08jtn Pm/RyiJQGEiWv3KVIklt0G19qyHEURAVOvTOG5avHcR8Y5zOzXTtb2pQeJAsHg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713291866; h=from:from: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; bh=KbmW96CS0ne+ulqCcNbf3qLUTM9zUlgof9Epwbbm5S4=; b=BiGQOzTeJvuy0VgXkJECe8NBPg12+6sRSqeESyy9BPs0bCFKK04Mlk4XlmOHoaex2+qsoO olyuVMRWfYyItwUKZ6rSY+fE2KyD/zgmF2gYOEhaP1sTdKz7jDIYIWJUWzoCJjQv/5Z2ua QSj+FAwLdu9M6lyI5ne0jLX0h4qrezPmuiVwaqLKankNihWgv9YPO83lwNiP9bBVVINUDk AWETJ80pD9xAMaWbkgfq1lGqKhpB7SAWFRWKCB94XeXXfKPNVxIS9tuAI6Onib4r7G5BHA houUhB9SIWaCLhaybCzoXI8B/aQaBUreEfEFdOmYr5R9Is58QZEsKyI1GdVEDw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VJsrV3mfcztsk; Tue, 16 Apr 2024 18:24:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43GIOQqj049750; Tue, 16 Apr 2024 18:24:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43GIOQkr049747; Tue, 16 Apr 2024 18:24:26 GMT (envelope-from git) Date: Tue, 16 Apr 2024 18:24:26 GMT Message-Id: <202404161824.43GIOQkr049747@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: d51c59002367 - main - mfc-candidates: fix output order with incorrect commit dates List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d51c590023675ca20a7da74d75a3b5a5dcfdfddc Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=d51c590023675ca20a7da74d75a3b5a5dcfdfddc commit d51c590023675ca20a7da74d75a3b5a5dcfdfddc Author: Ed Maste AuthorDate: 2024-04-16 15:41:05 +0000 Commit: Ed Maste CommitDate: 2024-04-16 18:20:40 +0000 mfc-candidates: fix output order with incorrect commit dates Previously we obtained the list of MFC candidate hashes (i.e., those commits only in the mfc-from branch), removed the already-merged commits based on "cherry picked from" commit message entries, and then printed the list sorted by commit time. This is usually the correct order, but it is not when commits have non-monotonically-increasing commit times. This is unfortunately the case for a number of commits in our tree. This made it difficult to merge some groups of dependent commits in the correct order. Instead, leave the from-list in git rev-parse order, and move the matching logic to a new lua script. Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D44808 --- tools/tools/git/candidatematch.lua | 66 ++++++++++++++++++++++++++++++++++++++ tools/tools/git/mfc-candidates.sh | 19 ++++------- 2 files changed, 72 insertions(+), 13 deletions(-) diff --git a/tools/tools/git/candidatematch.lua b/tools/tools/git/candidatematch.lua new file mode 100755 index 000000000000..98c247fca339 --- /dev/null +++ b/tools/tools/git/candidatematch.lua @@ -0,0 +1,66 @@ +#!/usr/libexec/flua + +-- MFC candidate script utility - $0 from-file to-file +-- +-- from-file specifies hashes that exist only in the "MFC from" branch and +-- to-file specifies the original hashes of commits already merged to the +-- "MFC to" branch. + +-- SPDX-License-Identifier: BSD-2-Clause +-- Copyright 2024 The FreeBSD Foundation + +-- Read a file and return its content as a table +local function read_file(filename) + local file = assert(io.open(filename, "r")) + local content = {} + for line in file:lines() do + table.insert(content, line) + end + file:close() + return content +end + +-- Remove hashes from 'set1' list that are present in 'set2' list +local function set_difference(set1, set2) + local set2_values = {} + for _, value in ipairs(set2) do + set2_values[value] = true + end + + local result = {} + for _, value in ipairs(set1) do + if not set2_values[value] then + table.insert(result, value) + end + end + return result +end + +-- Main function +local function main() + local from_file = arg[1] + local to_file = arg[2] + local exclude_file = arg[3] + + if not from_file or not to_file then + print("Usage: flua $0 from-file to-file") + return + end + + local from_hashes = read_file(from_file) + local to_hashes = read_file(to_file) + + local result_hashes = set_difference(from_hashes, to_hashes) + + if exclude_file then + exclude_hashes = read_file(exclude_file) + result_hashes = set_difference(result_hashes, exclude_hashes) + end + + -- Print the result + for _, hash in ipairs(result_hashes) do + print(hash) + end +end + +main() diff --git a/tools/tools/git/mfc-candidates.sh b/tools/tools/git/mfc-candidates.sh index d7fd4b5ded13..0787e1278991 100644 --- a/tools/tools/git/mfc-candidates.sh +++ b/tools/tools/git/mfc-candidates.sh @@ -124,16 +124,14 @@ fi # Commits in from_branch after branch point commits_from() { - git rev-list --first-parent $authorarg $to_branch..$from_branch "$@" |\ - sort + git rev-list --first-parent --reverse $authorarg $to_branch..$from_branch "$@" } # "cherry picked from" hashes from commits in to_branch after branch point commits_to() { git log $from_branch..$to_branch --grep 'cherry picked from' "$@" |\ - sed -E -n 's/^[[:space:]]*\(cherry picked from commit ([0-9a-f]+)\)[[:space:]]*$/\1/p' |\ - sort + sed -E -n 's/^[[:space:]]*\(cherry picked from commit ([0-9a-f]+)\)[[:space:]]*$/\1/p' } # Turn a list of short hashes (and optional descriptions) into a list of full @@ -164,16 +162,11 @@ fi commits_from "$@" > $from_list commits_to "$@" > $to_list -comm -23 $from_list $to_list > $candidate_list +/usr/libexec/flua $(dirname $0)/candidatematch.lua \ + $from_list $to_list $exclude_list > $candidate_list -if [ -n "$exclude_file" ]; then - mv $candidate_list $candidate_list.bak - comm -23 $candidate_list.bak $exclude_list > $candidate_list -fi - -# Sort by (but do not print) commit time while read hash; do - git show --pretty='%ct %h %s' --no-patch $hash -done < $candidate_list | sort -n | cut -d ' ' -f 2- + git show --pretty='%h %s' --no-patch $hash +done < $candidate_list rm -rf "$workdir"