Changelog: add 'export' command to copy a series of patches into numbered files. - To prevent sending unappliable/broken patches 'export' only exports applied patches. Maybe '-f' would be appropriate to force exporting anyway. - add initial bash completion %diffstat Makefile.in | 2 bash_completion | 2 quilt/export.in | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 174 insertions(+), 2 deletions(-) %patch Index: cvs/quilt/export.in =================================================================== --- cvs.orig/quilt/export.in 1970-01-01 01:00:00.000000000 +0100 +++ cvs/quilt/export.in 2004-01-11 16:09:21.000000000 +0100 @@ -0,0 +1,172 @@ +#! @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 @SCRIPTS@/patchfns ] + then + echo "Cannot read library @SCRIPTS@/patchfns" >&2 + exit 1 + fi + . @SCRIPTS@/patchfns +fi + +usage() +{ + local redirect + if [ x$1 != x-h ] + then + redirect='>&2' + fi + eval echo $"Usage: quilt export [-p n] [-c patch] [-P patch] [file ...]" $redirect + + if [ x$1 = x-h ] + then + echo $" + +Produces a diff of the specified file(s) in the topmost or specified +patch. If no files are specified, all files that are modified are +included. + +-p n Create a -p n style patch (-p0 or -p1 are supported). + +-P patch + Create a diff for the specified patch. (Defaults to the topmost + patch.) + +-c patch + Create a combined diff for all patches between this patch and + the patch specified with -P. A patch name of \"-\" is equivalent + to specifying the first applied patch. + +" + exit 0 + else + exit 1 + fi +} + +die () +{ + local status=$1 + [ -e "$tmp_files" ] && rm -f $tmp_files + [ -n "$workdir" ] && rm -rf $workdir + exit $status +} + +options=`getopt -o p:P:c:h -- "$@"` + +if [ $? -ne 0 ] +then + usage +fi + +eval set -- "$options" + +while true +do + case "$1" in + -p) + opt_strip_level=$2 + shift 2 ;; + -P) + last_patch=$(stripit $2) + shift 2 ;; + -c) + first_patch=$(stripit $2) + shift 2 ;; + -h) + usage -h ;; + --) + shift + break ;; + esac +done + +if [ $# -ne 1 ] +then + usage +fi +export_dir=( "$1" ) + +if [ -e "$export_dir" ] +then + echo "$export_dir already exists" >&2 + die 1 +fi + +if [ -z "$last_patch" ] +then + last_patch=$(top_patch) + if [ -z "$last_patch" ] + then + echo $"No patch seem to be applied" >&2 + die 1 + fi +fi + +if [ -z "$first_patch" ] +then + first_patch='-' +fi + +if ! is_applied "$last_patch" +then + echo $"Patch $last_patch is not applied" >&2 + die 1 +fi + +if [ -z "$opt_strip_level" ] +then + opt_strip_level=$(patch_strip_level $last_patch) +fi +if [ "$opt_strip_level" != 0 -a "$opt_strip_level" != 1 ] +then + echo $"Cannot diff patches with -p$opt_strip_level, please specify -p0 or -p1 instead" >&2 + die 1 +fi + +trap "die 1" SIGTERM + +set -- $(patches_before $last_patch) $last_patch +if [ "$first_patch" != "-" ] +then + while [ $# -ge 1 -a "$1" != "$first_patch" ] + do + shift + done + if [ $# -eq 0 ] + then + echo $"Patch $first_patch not applied before $last_patch." + die 1 + fi +fi + +mkdir "$export_dir" + +patches=( $@ ) + +index_width=$(echo -n address@hidden | wc -c) +if [ -f ${SERIES}.txt ] +then + _00=$(seq -f %0$index_width.0f 0 0) + cp -v ${SERIES}.txt "${export_dir}/${_00}_desc.txt" +fi +for patch in address@hidden +do + read index + filename=$(patch_file_name ${patch}) + cp -v $filename "${export_dir}/${index}_${patch}.diff" +done < <(seq -f %0$index_width.0f 1 address@hidden) + +die 0 +### Local Variables: +### mode: shell-script +### End: +# vim:filetype=sh Index: cvs/Makefile.in =================================================================== --- cvs.orig/Makefile.in 2004-01-10 14:00:19.000000000 +0100 +++ cvs/Makefile.in 2004-01-11 16:07:08.000000000 +0100 @@ -57,7 +57,7 @@ QUILT_IN := add applied delete diff files import new next patches \ pop previous push refresh remove series setup top unapplied \ - fold fork snapshot edit + fold fork snapshot edit export QUILT_SRC := $(QUILT_IN:%=%.in) QUILT := $(QUILT_IN) Index: cvs/bash_completion =================================================================== --- cvs.orig/bash_completion 2004-01-11 16:07:08.000000000 +0100 +++ cvs/bash_completion 2004-01-11 16:08:40.000000000 +0100 @@ -28,7 +28,7 @@ # commands (added to patches) cmds='add applied delete diff edit files fold fork import new next \ patches pop previous push refresh remove series setup \ - snapshot top unapplied' + snapshot top unapplied export' patches=`cat_series` pcount=`cat_series | wc -l`