emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New "make benchmark" target


From: Pip Cet
Subject: Re: New "make benchmark" target
Date: Sat, 18 Jan 2025 05:29:01 +0000

Pip Cet <pipcet@protonmail.com> writes:

> "Andrea Corallo" <acorallo@gnu.org> writes:

>> I've git.sv.gnu.org/srv/git/emacs.git called 'savannah' instead of
>> 'origin' as I've other remotes.  I think we should have a way to specify
>> the remote name.
>
> Hmm.  Wouldn't that be confusing in the case where people use a fresh
> checkout rather than a new worktree?

I decided just to remove that option.  The new version of the script is
run from the emacs repository, avoiding the need to create an extra
emacs worktree completely.  The elpa repository can be provided in the
emacs directory (in a subdirectory called "elpa"), or it can be checked
out from savannah.

Further changes:

1. Use bash -e to abort after an error.
2. Clone the ELPA repository from emacs/elpa if available; if not, we
clone it from savannah
3. Work in a temporary directory (use mktemp)
4. Safety prompt
5. Consistently name remotes and branches with nonce value
6. Use A==>B syntax for paths, allowing us to create several directories
7. Finally, tell the user what to do afterwards (git commit -n)

As a side effect of (2), this script runs much faster than the previous
version.  I mention this because that confused me at first.

I haven't tested this without an existing elpa repository copy.
Checking out elpa from savannah takes quite a while.

Here's the new script:

#!/bin/bash -e
# Merge ELPA package into the Emacs repository

# Copyright (C) 2024-2025 Free Software Foundation, Inc.

# This file is part of GNU Emacs.

# GNU Emacs 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 3 of the License, or
# (at your option) any later version.

# GNU Emacs 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 GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.

# This code merges an ELPA package that lives in a branch of
# https://git.savannah.gnu.org/git/emacs/elpa.git into the Emacs repo.
#
# It attempts to do the following things:
#
# - Move mentioned files to new directories
#
# - Preserve complete history from original repo for the files

# Dependencies required
#
# - https://github.com/newren/git-filter-repo
#    nix shell nixpkgs#git-filter-repo
#    arch: pacman -S git-filter-repo
# - git

# The code is originally from
# https://gist.github.com/2ed97f2ec85958986983d5cb78202770.git

# Authors:
#  Payas Relekar <relekarpayas@gmail.com>
#  João Távora <joaotavora@gmail.com>
#  Pip Cet <pipcet@protonmail.com>

# The ELPA repo will be cloned, unless a copy is provided in the "elpa"
# subdirectory of the emacs repository.  You should not use a worktree!
#
# Run like this:
#
#   bash -ex ./admin/elpa2emacs.sh externals/elisp-benchmarks 
"benchmarks==>benchmarks/benchmarks" "resources==>benchmarks/resources" 
"elisp-benchmarks.el==>benchmarks/elisp-benchmarks.el"
#

# arguments
OLDDIR="$PWD"
TMPDIR=`mktemp -d`
BRANCH="$1" # a branch name in the ELPA repo
shift
PATHS="$@" # paths of files or directories to be matched.

if ! test -f "$PWD"/etc/JOKES; then
    echo "Run this in the root directory of an Emacs repository"
    exit 1
fi

read -r -p "This script is potentially dangerous.  Enter YES to run it: "
if ! test x"$REPLY" = xYES; then
    echo "Not confirmed."
    exit 1
fi

NONCE=nonce"$(date +'%s')"

pushd "$TMPDIR"
# clone repos
if [ -r "$OLDDIR"/elpa/.git ]; then
    git clone -b "$BRANCH" "$OLDDIR"/elpa "$TMPDIR"/elpa
else
    git clone -b "$BRANCH" https://git.savannah.gnu.org/git/emacs/elpa.git 
"$TMPDIR"/elpa
fi

# filter elpa to keep only the appropriate files.  This destroys the
# newly-created copy of the elpa repo.

pushd elpa
git checkout "$BRANCH"
git checkout -b "$NONCE"

> tmp-list
for P in $PATHS; do
    echo "$P" >> tmp-list
done
for P in $PATHS; do
    echo "$P" | sed -e 's/==>.*//g' >> tmp-list
done
git filter-repo -f --paths-from-file tmp-list
popd
popd

# Merge into the emacs repo.  This will not destroy the entire Emacs
# repository, but will add a branch which is visible in all worktrees.

# add filtered elpa as upstream
git remote add elpa2emacs-filtered-elpa-$NONCE $TMPDIR/elpa/
git fetch elpa2emacs-filtered-elpa-$NONCE
git merge remotes/elpa2emacs-filtered-elpa-$NONCE/$NONCE 
--allow-unrelated-histories --no-commit
git remote remove elpa2emacs-filtered-elpa-$NONCE

rm -rf "$TMPDIR"
echo "You can now commit the merge by running: git commit -n"




reply via email to

[Prev in Thread] Current Thread [Next in Thread]