[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [patch 7/8] Unmerged patches regenerated against CVS HEAD
From: |
Gary V. Vaughan |
Subject: |
[Quilt-dev] [patch 7/8] Unmerged patches regenerated against CVS HEAD |
Date: |
Thu, 22 Sep 2005 13:27:07 +0100 |
User-agent: |
quilt/0.42-1 |
GNU projects maintain ChangeLogs, which always cause a problem when
generating and applying patches. For some years now I've been using
clcleanup and cl2patch from savannah.gnu.org/projects/cvs-utils:
clcleanup removes the conflicting date section from the ChangeLog hunks,
so that patch doesn't reject them; cl2patch tweaks the same hunks so
that they can be successfully added to the top of the ChangeLog bearing
today's date.
This patch adds a filter option to refresh and push which allows me
to hook these scripts into quilt: quilt pop -a && cvs up && quilt push -a
now works properly on ChangeLog bearing projects without having to
manually fix up the ChangeLog after each push.
>From my $HOME/.quiltrc:
# Options to pass to commands (QUILT_${COMMAND}_ARGS)
QUILT_PUSH_ARGS="--color=auto --filter=/Users/gary/bin/cl2patch"
QUILT_REFRESH_ARGS="--no-timestamps --filter=/Users/gary/bin/clcleanup"
quilt/push.in | 40 +++++++++++++++++++++++++++++++++++++---
quilt/refresh.in | 23 ++++++++++++++++++++---
2 files changed, 57 insertions(+), 6 deletions(-)
Index: quilt-HEAD/quilt/push.in
===================================================================
--- quilt-HEAD.orig/quilt/push.in
+++ quilt-HEAD/quilt/push.in
@@ -21,7 +21,7 @@ setup_colors
usage()
{
- printf $"Usage: quilt push [-afqv] [--leave-rejects] [--interactive]
[--color[=always|auto|never]] [num|patch]\n"
+ printf $"Usage: quilt push [-afqv] [--leave-rejects] [--interactive]
[--color[=always|auto|never]] [--filter program] [num|patch]\n"
if [ x$1 = x-h ]
then
printf $"
@@ -51,6 +51,11 @@ be used.
--color[=always|auto|never]
Use syntax coloring.
+
+--filter program
+ Pass the patch file through PROGRAM. If PROGRAM returns
+ successfully, pass its output to the patch program instead of
+ the unfiltered patch file.
"
exit 0
else
@@ -89,10 +94,32 @@ colorize()
apply_patch()
{
local patch=$1 patch_file=$2
- local output
+ local output tmp_patch
[ -s $patch_file ] || return 0
+ # If there is a filter, attempt to apply it to the patch
+ # file before calling the patch program:
+ if [ -x "$opt_filter" ]
+ then
+ tmp_patch=$(gen_tempfile)
+
+ case $patch_file in
+ *.gz) gzip -cd $patch_file \
+ | $opt_filter > $tmp_patch ;;
+ *.bz2) bzip2 -cd $patch_file \
+ | $opt_filter > $tmp_patch ;;
+ *) $opt_filter < $patch_file > $tmp_patch ;;
+ esac
+
+ if [ $? -eq 0 ]
+ then
+ patch_file=$tmp_patch
+ else
+ printf $"Filter failed, continuing with unfiltered
patch\n" >&2
+ fi
+ fi
+
if [ "${patch_file:(-3)}" = ".gz" ]
then
gzip -cd $patch_file \
@@ -113,6 +140,9 @@ apply_patch()
$no_reject_files \
-E $silent $force_apply -i $patch_file 2>&1
fi
+
+ # Cleanup temporary files
+ [ -f "$tmp_patch" ] && rm -f $tmp_patch
}
rollback_patch()
@@ -245,7 +275,8 @@ list_patches()
fi
}
-options=`getopt -o fqvah --long leave-rejects,interactive,color:: -- "$@"`
+options=`getopt -o fqvah --long leave-rejects,interactive,color:: \
+ --long filter: -- "$@"`
if [ $? -ne 0 ]
then
@@ -290,6 +321,9 @@ do
usage ;;
esac
shift 2 ;;
+ --filter)
+ opt_filter="$2"
+ shift 2 ;;
--)
shift
break ;;
Index: quilt-HEAD/quilt/refresh.in
===================================================================
--- quilt-HEAD.orig/quilt/refresh.in
+++ quilt-HEAD/quilt/refresh.in
@@ -19,7 +19,7 @@ fi
usage()
{
- printf $"Usage: quilt refresh [-p n] [-f] [--no-timestamps]
[--no-index] [--diffstat] [--sort] [--backup] [--strip-trailing-whitespace]
[patch]\n"
+ printf $"Usage: quilt refresh [-p n] [-f] [--no-timestamps]
[--no-index] [--diffstat] [--sort] [--backup] [--strip-trailing-whitespace]
[--filter program] [patch]\n"
if [ x$1 = x-h ]
then
@@ -62,6 +62,10 @@ patch.
--strip-trailing-whitespace
Strip trailing whitespace at the end of lines.
+
+--filter program
+ Pass the patch through PROGRAM. If PROGRAM returns successfully,
+ replace patch with the output of PROGRAM.
"
exit 0
else
@@ -79,8 +83,8 @@ die ()
}
options=`getopt -o p:uU:cC:fh --long no-timestamps,diffstat,backup,sort \
- --long no-index \
- --long strip-trailing-whitespace -- "$@"`
+ --long no-index,strip-trailing-whitespace \
+ --long filter: -- "$@"`
if [ $? -ne 0 ]
then
@@ -125,6 +129,9 @@ do
--strip-trailing-whitespace)
opt_strip_whitespace=1
shift ;;
+ --filter)
+ opt_filter="$2"
+ shift 2 ;;
--)
shift
break ;;
@@ -236,6 +243,16 @@ else
fi
# FIXME: no stripping of non-topmost patch !!!
+if [ -x "$opt_filter" ]
+then
+ tmp_patch2=$(gen_tempfile)
+ if "$opt_filter" < $tmp_patch > $tmp_patch2
+ then
+ rm -f $tmp_patch
+ tmp_patch=$tmp_patch2
+ fi
+fi
+
patch_file=$(patch_file_name $patch)
trap "" SIGINT
--
Gary V. Vaughan ())_. address@hidden,gnu.org}
Research Scientist ( '/ http://tkd.kicks-ass.net
GNU Hacker / )= http://www.gnu.org/software/libtool
Technical Author `(_~)_ http://sources.redhat.com/autobook
- [Quilt-dev] [patch 0/8] Unmerged patches regenerated against CVS HEAD, Gary V. Vaughan, 2005/09/22
- [Quilt-dev] [patch 3/8] Unmerged patches regenerated against CVS HEAD, Gary V. Vaughan, 2005/09/22
- [Quilt-dev] [patch 6/8] Unmerged patches regenerated against CVS HEAD, Gary V. Vaughan, 2005/09/22
- [Quilt-dev] [patch 8/8] Unmerged patches regenerated against CVS HEAD, Gary V. Vaughan, 2005/09/22
- [Quilt-dev] [patch 7/8] Unmerged patches regenerated against CVS HEAD,
Gary V. Vaughan <=
- [Quilt-dev] [patch 5/8] Unmerged patches regenerated against CVS HEAD, Gary V. Vaughan, 2005/09/22
- [Quilt-dev] [patch 4/8] Unmerged patches regenerated against CVS HEAD, Gary V. Vaughan, 2005/09/22
- [Quilt-dev] [patch 2/8] Unmerged patches regenerated against CVS HEAD, Gary V. Vaughan, 2005/09/22
- [Quilt-dev] [patch 1/8] Unmerged patches regenerated against CVS HEAD, Gary V. Vaughan, 2005/09/22
- Re: [Quilt-dev] [patch 0/8] Unmerged patches regenerated against CVS HEAD, John Vandenberg, 2005/09/22