quilt-dev
[Top][All Lists]
Advanced

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

Re: [Quilt-dev] Time for a new release?


From: Peter Williams
Subject: Re: [Quilt-dev] Time for a new release?
Date: Fri, 08 Jul 2005 20:27:38 +1000
User-agent: Mozilla Thunderbird 1.0.2-6 (X11/20050513)

Jean Delvare wrote:
Hi all,

What about a new release of quilt soon? There have been quite a few
improvements in CVS recently, it would be great if more people could
take benefit of these.

Andreas?

Before you make this release could you please apply the attached patch?

It adds a "description" which can be used to view and set the description component of a patch's header. This will enable me to add mechanisms for adding/viewing patch descriptions to gquilt.

Peter
--
Peter Williams                                   address@hidden

"Learning, n. The kind of ignorance distinguishing the studious."
 -- Ambrose Bierce
Add a new command "description" to the quilt repertoire.

This function enables the user to read and set the description component of a
patch file without having to know the details of quilt's implementation (namely
the location of the patch files.

This will enable wrapper tools such as gquilt to provide interfaces for reading
and writing patch descriptions.

Signed-off-by: Peter Williams <address@hidden>
 Makefile.in          |    7 -
 quilt/description.in |  224 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 228 insertions(+), 3 deletions(-)


Index: quilt-savanna-cvs/Makefile.in
===================================================================
--- quilt-savanna-cvs.orig/Makefile.in  2005-07-08 11:09:57.000000000 +1000
+++ quilt-savanna-cvs/Makefile.in       2005-07-08 11:49:48.000000000 +1000
@@ -56,9 +56,10 @@
 SRC +=         $(BIN_SRC:%=bin/%)
 DIRT +=                $(BIN_IN:%=bin/%)
 
-QUILT_IN :=    add annotate applied delete diff edit files fold fork graph \
-               grep import mail new next patches pop previous push refresh \
-               remove rename series setup snapshot top unapplied upgrade
+QUILT_IN :=    add annotate applied delete description diff edit files fold \
+               fork graph grep import mail new next patches pop previous \
+               push refresh remove rename series setup snapshot top \
+               unapplied upgrade
 
 QUILT_SRC :=   $(QUILT_IN:%=%.in)
 QUILT :=       $(QUILT_IN)
Index: quilt-savanna-cvs/quilt/description.in
===================================================================
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
+++ quilt-savanna-cvs/quilt/description.in      2005-07-08 20:17:43.000000000 
+1000
@@ -0,0 +1,224 @@
+#! @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()
+{
+       printf $"Usage: quilt description [-s] [--backup] 
[--strip-trailing-whitespace] [patch]\n"
+
+       if [ x$1 = x-h ]
+       then
+               printf $"
+Accesses the description component of the specified patch, or the topmost
+patch by default.
+
+-s     Replace the patch's description with standard input.
+
+--backup
+       Create a backup copy of the old version of a patch as patch~.
+
+--strip-trailing-whitespace
+       Strip trailing whitespace at the end of lines of the description.
+"
+               exit 0
+       else
+               exit 1
+       fi
+}
+
+die ()
+{
+       local status=$1
+       [ -n "$tmp_patch" ] && rm -f $tmp_patch
+       [ -n "$tmp_header" ] && rm -f $tmp_header
+       [ -n "$tmp_result" ] && rm -f $tmp_result
+       exit $status
+}
+
+options=`getopt -o sh --long backup,strip-trailing-whitespace -- "$@"`
+
+if [ $? -ne 0 ]
+then
+       usage
+fi
+
+eval set -- "$options"
+
+opt_format=
+while true
+do
+       case "$1" in
+       -s)
+               opt_replace=1
+               shift ;;
+       -h)
+               usage -h ;;
+       --backup)
+               QUILT_BACKUP=1
+               shift ;;
+       --strip-trailing-whitespace)
+               opt_strip_whitespace=1
+               shift ;;
+       --)
+               shift
+               break ;;
+       esac
+done
+
+if [ $# -eq 1 ]
+then
+       opt_patch=$1
+elif [ $# -gt 1 ]
+then
+       usage
+fi
+
+QUILT_DESCRIPTION_OPTS="$QUILT_DESCRIPTION_OPTS $opt_format"
+
+if [ -n "$opt_patch" ]
+then
+       if ! patch=$(find_patch $opt_patch)
+       then
+               printf $"Patch %s is not in series\n" \
+                      "$(print_patch $opt_patch)" >&2
+               exit 1
+       fi
+else
+       patch=$(top_patch)
+       if [ -z "$patch" ]
+       then
+               printf $"No patches applied\n" >&2
+               exit 1
+       fi
+fi
+
+trap "die 1" SIGTERM
+
+patch_description_tail()
+{
+       local patch_file=$1
+
+       if [ -e "$patch_file" -o -z "$patch_file" ]
+       then
+               @AWK@ '
+               description_finished == 1 \
+                       { print
+                         next }
+               $1 == "***" || $1 == "---" \
+                       { description_finished = 1
+                         print eat $0
+                         next }
+               /^#? .* files? changed(, .* insertions?\(\+\))?(, .* 
deletions?\(-\))?/ \
+                       { description_finished = 1
+                         print ds $0
+                         next }
+               /^#? .*\|.*/ \
+                       { ds = ds $0 "\n"
+                         eat = ""
+                         next }
+               /^Index:[ \t]|^diff[ \t]|^==*$|^RCS file: |^retrieving revision 
[0-9]+(\.[0-9]+)*$/ \
+                       { eat = eat $0 "\n"
+                         ds = ""
+                         next }
+                       { eat = ""
+                         ds = ""
+                       }
+               ' $patch_file
+       fi
+}
+
+patch_file=$(patch_file_name $patch)
+
+trap "" SIGINT
+
+if [ -z "$opt_replace" ]
+then
+       if [ ! -e "$patch_file" ]
+       then
+               die 0
+       fi
+
+       if ! tmp_header=$(gen_tempfile)
+       then
+               die 1
+       fi
+
+       if ! cat_file $patch_file | patch_description > $tmp_header
+       then
+               die 1
+       fi
+
+       if [ ! -z "$opt_strip_whitespace" ]
+       then
+               tmp_header2=$(gen_tempfile)
+               if @SCRIPTS@/remove-trailing-ws < $tmp_header > $tmp_header2
+               then
+                       rm -f $tmp_header
+                       tmp_header=$tmp_header2
+               fi
+       fi
+
+       # strip any diffstat data off the end
+       @AWK@ '
+       /^#? .* files? changed(, .* insertions?\(\+\))?(, .* deletions?\(-\))?/ 
\
+               { exit }
+       /^#? .*\|.*/ \
+               { eat = eat $0 "\n"
+                 next }
+               { print eat $0
+                 eat = "" }
+       ' $tmp_header
+else
+       tmp_result=$(gen_tempfile) || die 1
+
+       cat > $tmp_result
+
+       if [ ! -z "$opt_strip_whitespace" ]
+       then
+               tmp_result2=$(gen_tempfile)
+               if @SCRIPTS@/remove-trailing-ws < $tmp_result > $tmp_result2
+               then
+                       rm -f $tmp_result
+                       tmp_result=$tmp_result2
+               fi
+       fi
+
+       if [ -e "$patch_file" ]
+       then
+               if ! cat_file $patch_file | patch_description_tail >> 
$tmp_result
+               then
+                       die 1
+               fi
+       fi
+
+       if ( [ -z "$QUILT_BACKUP" -o ! -e $patch_file ] || \
+              mv $patch_file $patch_file~ ) && \
+              cat_to_new_file $patch_file < $tmp_result
+       then
+               printf $"Set description for patch %s\n" "$(print_patch $patch)"
+       else
+               die 1
+       fi
+
+       rm -f $QUILT_PC/$patch~refresh
+fi
+die 0
+### Local Variables:
+### mode: shell-script
+### End:
+# vim:filetype=sh

reply via email to

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