From nobody Thu Aug 01 16:07:17 2024 X-Original-To: dev-commits-src-all@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 4WZYks4QWpz5T0CB; Thu, 01 Aug 2024 16:07:17 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WZYks2WcJz4bRb; Thu, 1 Aug 2024 16:07:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722528437; 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=rmcqxz8A1X2jlPgajF3Ks7HlMXoJvUEhr75ZNvRL7Pg=; b=d1KFLH88+sl0z2S/ycNlFR+yK10qTMxdXVsRggkO7gDGxrlMSb8A8I+1jwWPwPJQYcbOXm 1ohIpmO4dkqfNHgGj15O0rA92Wn2XHZpTxh2bLO/wglzDqSxUQOCcKXE9Z0bj9Qk7hmuhx kF4Myd694QgWa8d8BE4/mTKVnrFh4+Hxamw97oV/ylDoTZE7gtAMo3nCDisYq1vmEZ1Ni7 xb9HItz/n2+rVw/UeO25gkLvJ0u2GV73cVxQfBX/QJYV/QmMxvhI4vu7bnrRd+gdGeC8DT 9e7b136+sEIkBGhz0Pf8VNbSJjJVKxbZiKrw+6pXWsOqFSRj4lgl4Tf96wsSqQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722528437; a=rsa-sha256; cv=none; b=bHUm9bcMxN+8rNXHH9UKHCV2JIQlQM1HVetVnd3lC/IdqglUH+UZ4e4HoPgI4rC/YObpSZ l/JgQ/sb/uTDmgKO3UFfrPjtfIxhU96v00Lizb1UBuabpdpGoFqz8YxtdWm0BmbwjYmcOy gYmSUwz4OjFdFWpXA6cXY5qhGwyu93eZYPBoyc5o6cCAXEx00JJcwPKwjHGuo2o9cZdTuV DbpGfEqRwmD1ezh/XkeTuF2ZVN1CThkVGZlSPOlYArwaE/E8Tm+M6t5LeXMPYfb53YDDtc FDFLr+xvxTW5rFoPVk8c3QR5FnGqYN1e3Tyb2VmDm94M15YzsMl+rVhnhbVLow== 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=1722528437; 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=rmcqxz8A1X2jlPgajF3Ks7HlMXoJvUEhr75ZNvRL7Pg=; b=lCBtW6fq4lwKlT0DsYsgDFsXUxcJtC3OoliMKIizuFAQxjZECuwA1c/QeV+me4dopUVS6d FVYGTkSrtzV0anxTww39XM78FXyyKQpDvrHbqo5Y8t0Dsvdiia9FZh9sDPqi/iSSipUovH Lo0nDNwCZYkUeyaCaqwqvhdz7kxImW/ceM+fbTUwbfqaaN6oO07dMQnuQY40BW4XPNQ+gR 7jWvxEQeL4zR5zJXJaevPqby1RX7lQ55Ej1QIjMknGDyT7gfnz3AoG96QlHpjtW/8i3wot fFcQwR2CigU2DMjC1dy+aPZk4ErL1inNg9PsK6qJ7hr/Y6SeG9AnFIYX/kcHPw== 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 4WZYks27mNzrm4; Thu, 1 Aug 2024 16:07:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 471G7HI8078884; Thu, 1 Aug 2024 16:07:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 471G7HZV078881; Thu, 1 Aug 2024 16:07:17 GMT (envelope-from git) Date: Thu, 1 Aug 2024 16:07:17 GMT Message-Id: <202408011607.471G7HZV078881@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 63cd0ebe4be8 - stable/14 - mfc-candidates: fix output order with incorrect commit dates List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 63cd0ebe4be8dde0e0cec23920ed40f7618042d3 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=63cd0ebe4be8dde0e0cec23920ed40f7618042d3 commit 63cd0ebe4be8dde0e0cec23920ed40f7618042d3 Author: Ed Maste AuthorDate: 2024-04-16 15:41:05 +0000 Commit: Ed Maste CommitDate: 2024-08-01 15:11:45 +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 (cherry picked from commit d51c590023675ca20a7da74d75a3b5a5dcfdfddc) --- 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 6610f539fef0..dd88710a4a4a 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 @@ -161,16 +159,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"