On 13-Oct-05, Joe Green wrote:
> Olaf Dabrunz wrote:
> 
> >This patch adds option "--orig" to "quilt refresh". It saves the
> >original version of a patch as patch.orig.
> >
> 
> There's already a "--backup" option used in several places that saves 
> "patch" as "patch~".  It would probably be better to continue using this 
> option and add a "QUILT_BACKUP_SUFFIX" setting to override the "~" 
> suffix with something else.

When "--orig" is used, the patch.orig file will be created the first
time the patch is refreshed. It will not be touched when it already
exists.

This means that patch.orig will always contain the state of the patch
before work on it was started again. No matter how often the patch is
refreshed, diffing patch.orig and patch will show the changes between
the last released version of the patch and the current version. (This
diff can be reviewed before releasing the patch then.)

IMO patch~ is better suited as a single-level undo backup to revert to
the version before the last test of the patch.

For a release, patch.orig can (and in general will) be removed. For the
next revision of the patch "--orig" will recreate it again and it will
contain the latest released version again.

The "--orig" option is simply the implementation in quilt of ":set
patchmode=.orig" from "vim". (In vim, this option supports a similar
work-cycle for editing files. With quilt, the primary output of the work
cycle is patches, so it should be simple to compare and review patches
between releases.)


Because of your comment I checked again and "quilt header" should have a
"--orig" option as well, since it changes the patch. I attached an
updated patch.

OTOH, I believe "quilt delete" does not need to create another
(identical) backup file, since the patch~ file cannot be changed by
quilt anymore. Still, at least for this point, I am open for other
opinions.

Regards,

-- 
Olaf Dabrunz (od/odabrunz), SUSE Linux Products GmbH, Nürnberg

 quilt/header.in  |   16 +++++++++++++---
 quilt/refresh.in |   16 +++++++++++++---
 2 files changed, 26 insertions(+), 6 deletions(-)

Index: quilt/header.in
===================================================================
--- quilt/header.in.orig        2005-10-13 19:05:14.000000000 +0200
+++ quilt/header.in     2005-10-14 17:43:24.000000000 +0200
@@ -21,7 +21,7 @@
 
 usage()
 {
-       printf $"Usage: quilt header [-a|-r|-e] [--backup] [--strip-diffstat] 
[--strip-trailing-whitespace] [patch]\n"
+       printf $"Usage: quilt header [-a|-r|-e] [--backup] [--orig] 
[--strip-diffstat] [--strip-trailing-whitespace] [patch]\n"
 
        if [ x$1 = x-h ]
        then
@@ -41,6 +41,9 @@
 
 --backup
        Create a backup copy of the old version of a patch as patch~.
+
+--orig
+       Create a backup copy of the original version of a patch as patch.orig.
 " "$EDITOR"
                exit 0
        else
@@ -77,7 +80,7 @@
        fi
 }
 
-options=`getopt -o areh --long backup,strip-trailing-whitespace,strip-diffstat 
-- "$@"`
+options=`getopt -o areh --long 
backup,orig,strip-trailing-whitespace,strip-diffstat -- "$@"`
 
 if [ $? -ne 0 ]
 then
@@ -101,6 +104,9 @@
        --backup)
                QUILT_BACKUP=1
                shift ;;
+       --orig)
+               QUILT_ORIG=1
+               shift ;;
        --strip-diffstat)
                opt_strip_diffstat=1
                shift ;;
@@ -182,7 +188,11 @@
        
        cat_file "$patch_file_or_null" | patch_body >> $tmp2 || exit 1
 
-       if ( [ -z "$QUILT_BACKUP" -o ! -e $patch_file ] || \
+       if ( [ -z "$QUILT_ORIG" -o -e $patch_file.orig ] || \
+               ( [ ! -e $patch_file ] && \
+                       { touch $patch_file.orig ; true ; } || \
+                       mv $patch_file $patch_file.orig ) ) && \
+          ( [ -z "$QUILT_BACKUP" -o ! -e $patch_file ] || \
               mv $patch_file $patch_file~ ) && \
               cat_to_new_file $patch_file < $tmp2
        then
Index: quilt/refresh.in
===================================================================
--- quilt/refresh.in.orig       2005-10-14 15:14:27.000000000 +0200
+++ quilt/refresh.in    2005-10-14 16:15:01.000000000 +0200
@@ -19,7 +19,7 @@
 
 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] [--orig] 
[--strip-trailing-whitespace] [patch]\n"
        
        if [ x$1 = x-h ]
        then
@@ -58,6 +58,9 @@
 --backup
        Create a backup copy of the old version of a patch as patch~.
 
+--orig
+       Create a backup copy of the original version of a patch as patch.orig.
+
 --sort Sort files by their name instead of preserving the original order.
 
 --strip-trailing-whitespace
@@ -79,7 +82,7 @@
 }
 
 options=`getopt -o p:uU:cC:fh --long no-timestamps,diffstat,backup,sort \
-                             --long no-index \
+                             --long no-index,orig \
                              --long strip-trailing-whitespace -- "$@"`
 
 if [ $? -ne 0 ]
@@ -119,6 +122,9 @@
        --backup)
                QUILT_BACKUP=1
                shift ;;
+       --orig)
+               QUILT_ORIG=1
+               shift ;;
        --sort)
                opt_sort=1
                shift ;;
@@ -293,7 +299,11 @@
    diff -q $patch_file $tmp_result > /dev/null
 then
        printf $"Patch %s is unchanged\n" "$(print_patch $patch)"
-elif ( [ -z "$QUILT_BACKUP" -o ! -e $patch_file ] || \
+elif ( [ -z "$QUILT_ORIG" -o -e $patch_file.orig ] || \
+       ( [ ! -e $patch_file ] && \
+               { touch $patch_file.orig ; true ; } || \
+               mv $patch_file $patch_file.orig ) ) && \
+     ( [ -z "$QUILT_BACKUP" -o ! -e $patch_file ] || \
        mv $patch_file $patch_file~ ) && \
      cat_to_new_file $patch_file < $tmp_result
 then
_______________________________________________
Quilt-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/quilt-dev

Reply via email to