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: Sat, 09 Jul 2005 13:58:55 +1000
User-agent: Mozilla Thunderbird 1.0.2-6 (X11/20050513)

Andreas Gruenbacher wrote:
Hello,

On Friday 08 July 2005 12:27, Peter Williams wrote:

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.


I have a few comments:

- I would rather make this the header command. We are usually calling what's above the actual patch the header, no? - I don't see why it's useful or necessary to remove the diffstat part. Any reasons? Presumably... - Instead of patch_description_tail, please reuse the patch_description function from patchfns (which is probably misnamed, and should be called patch_header instead.) - Is removing whitespace in the header really needed? I don't think anybody cares much about whitespace in the header at all; it's annyoing in the actual patch though. - We can easily get rid of the temporary files and use pipes instead. I can easily do that when checking in the final version if you wish.
 - The command must not touch $patch~refresh.
 - I see a dangling opt_format variable.

Attached is a new patch that addresses most of the above issues with the exception of possibly still making too much use of temporary files. It takes into account my comments in my earlier reply.

It adds a -a option to allow standard input to be appended to the current description and changes the -s flag to -r (for replace). These two options are mutually exclusive.

 - Could you please provide a test case?

I can't find any documentation on how the test mechanism works. Some pointers, please?

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 modify 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 |  203 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 207 insertions(+), 3 deletions(-)

 Makefile.in          |    7 +
 quilt/description.in |  203 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 207 insertions(+), 3 deletions(-)

 Makefile.in          |    7 +
 quilt/description.in |  203 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 207 insertions(+), 3 deletions(-)

 Makefile.in          |    7 +
 quilt/description.in |  203 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 207 insertions(+), 3 deletions(-)

 Makefile.in          |    7 +
 quilt/description.in |  203 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 207 insertions(+), 3 deletions(-)

 Makefile.in          |    7 +
 quilt/description.in |  203 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 207 insertions(+), 3 deletions(-)

 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-09 13:56:40.000000000 
+1000
@@ -0,0 +1,246 @@
+#! @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 [-a | -r] [--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.
+
+-a     Append standard input to the patch's description.
+
+-r     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 "$temp_descr" ] && rm -f $temp_descr
+       [ -n "$tmp_result" ] && rm -f $tmp_result
+       exit $status
+}
+
+options=`getopt -o arh --long backup,strip-trailing-whitespace -- "$@"`
+
+if [ $? -ne 0 ]
+then
+       usage
+fi
+
+eval set -- "$options"
+
+while true
+do
+       case "$1" in
+       -a)
+               [ -z "$opt_replace" ] || usage
+               opt_append=1
+               shift ;;
+       -r)
+               [ -z "$opt_append" ] || usage
+               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
+
+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() minus diffstat data (if present)
+patch_description_only()
+{
+       local patch_file=$1
+
+       if [ -e "$patch_file" -o -z "$patch_file" ]
+       then
+               patch_description $patch_file | @AWK@ '
+               /^#? .* files? changed(, .* insertions?\(\+\))?(, .* 
deletions?\(-\))?/ \
+                       { exit }
+               /^#? .*\|.*/ \
+                       { eat = eat $0 "\n"
+                         next }
+                       { print eat $0
+                         eat = "" }
+               '
+       fi
+}
+
+# the complement of patch_description_only()
+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"  -a -z "$opt_append" ]
+then
+       if [ ! -e "$patch_file" ]
+       then
+               die 0
+       fi
+
+       if ! temp_descr=$(gen_tempfile)
+       then
+               die 1
+       fi
+
+       if ! cat_file $patch_file | patch_description_only > $temp_descr
+       then
+               die 1
+       fi
+
+       if [ ! -z "$opt_strip_whitespace" ]
+       then
+               @SCRIPTS@/remove-trailing-ws < $temp_descr
+       else
+               cat $temp_descr
+       fi
+else
+       tmp_result=$(gen_tempfile) || die 1
+
+       if [ ! -z "$opt_append" -a -e "$patch_file" ]
+       then
+               if ! cat_file $patch_file | patch_description_only > $tmp_result
+               then
+                       die 1
+               fi
+               cat >> $tmp_result
+       else
+               cat > $tmp_result
+       fi
+
+       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
+               if [ -z "$opt_append" ]
+               then
+                       printf $"Replaced description for patch %s\n" 
"$(print_patch $patch)"
+               else
+                       printf $"Appended to description for patch %s\n" 
"$(print_patch $patch)"
+               fi
+       else
+               die 1
+       fi
+fi
+die 0
+### Local Variables:
+### mode: shell-script
+### End:
+# vim:filetype=sh

reply via email to

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