[Jean Delvare]
> I would like to rename a patch which is in a quilt series. "quilt
> rename" doesn't seem to exist. I searched the web and could only
> find one reference, which is an older thread on this list:
> http://lists.gnu.org/archive/html/quilt-dev/2003-07/msg00002.html
[Baruch Even]
> To rename a patch simply rename the patch and do the same in the
> series file.
Additionally, as the patch was applied, I would have had to rename the
corresponding directory in .pc, and update .pc/applied-patches. In other
words...
> Alternatively, add the quilt rename command to quilt and submit the
> patch :-) it should do just what the above line says, should be
> pretty simple.
...a script would make the job easier, indeed.
I took my chance on it. Unsurprisingly, it ends up as a simplified
version of the fork patch. Differences:
1* Rename can operate on any patch, not only the topmost one. This
includes unapplied patches.
2* The new name must be provided, it is never guessed.
3* Of course, the patch file is renamed instead of being duplicated.
Point #2 could be modified if needed. Not sure it, but since the fork
command has it, maybe it is after all.
I think I now understand the point of the fork command, but still
believe that it should be better documented.
My rename script is attached. Works just fine for me. If it receives
positive feedback, I will provide a clean patch against quilt CVS.
Kudos to the developers of quilt, this quick hack was really easy, even
without a strong background of shell scripting. The code structure is
very clean.
There are two things I left in because the fork script had them, but
don't fully understand. Hints would be appreciated.
new_patch=${1#$QUILT_PATCHES/}
Why is the prefix stripping needed here?
( [ -e "$(patch_file_name $patch)" ] && \
! mv "$(patch_file_name $patch)" \
"$(patch_file_name $new_patch)" )
I don't quite see how $patch could not exist, since we previously
checked that it was in the series. Or is it really only an integrity
check?
Thanks,
--
Jean Delvare
#! /usr/bin/bash
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# See the COPYING and AUTHORS files for more details.
# Read in library functions
if [ "$(type -t patch_file_name)" != function ]
then
if ! [ -r /usr/local/share/quilt/scripts/patchfns ]
then
echo "Cannot read library
/usr/local/share/quilt/scripts/patchfns" >&2
exit 1
fi
. /usr/local/share/quilt/scripts/patchfns
fi
usage()
{
printf $"Usage: quilt rename [-p patch] new_name\n"
if [ x$1 = x-h ]
then
printf $"
Rename the topmost or named patch.
-p patch
Patch to rename.
"
exit 0
else
exit 1
fi
}
options=`getopt -o p:h -- "$@"`
if [ $? -ne 0 ]
then
usage
fi
eval set -- "$options"
while true
do
case "$1" in
-p)
if ! patch=$(find_patch $2)
then
printf $"Patch %s is not in series\n" "$2" >&2
exit 1
fi
shift 2 ;;
-h)
usage -h ;;
--)
shift
break ;;
esac
done
if [ $# -ne 1 ]
then
usage
fi
if [ ! -n "$patch" ]
then
patch=$(top_patch)
if [ -z "$patch" ]
then
printf $"No patches applied\n" >&2
exit 1
fi
fi
new_patch=${1#QUILT_PATCHES/}
if patch_in_series $new_patch || \
[ -d "$QUILT_PC/$new_patch" ] || \
[ -e "$(patch_file_name $new_patch)" ]
then
printf $"Patch %s exists already, please choose a different name\n" \
"$(print_patch $new_patch)" >&2
exit 1
fi
if ( is_applied $patch && \
( ! rename_in_db "$patch" "$new_patch" || \
! mv "$QUILT_PC/$patch" "$QUILT_PC/$new_patch" ) ) || \
! rename_in_series "$patch" "$new_patch" || \
( [ -e "$(patch_file_name $patch)" ] && \
! mv "$(patch_file_name $patch)" \
"$(patch_file_name $new_patch)" )
then
printf $"Renaming of patch %s to %s failed\n" \
"$(print_patch $patch)" \
"$(print_patch $new_patch)" >&2
exit 1
fi
printf $"Patch %s renamed to %s\n" \
"$(print_patch $patch)" \
"$(print_patch $new_patch)"
### Local Variables:
### mode: shell-script
### End:
# vim:filetype=sh
_______________________________________________
Quilt-dev mailing list
[EMAIL PROTECTED]
http://lists.nongnu.org/mailman/listinfo/quilt-dev