quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] [PATCH] Don't 'quilt delete' an unrefreshed patch


From: Don Mullis
Subject: [Quilt-dev] [PATCH] Don't 'quilt delete' an unrefreshed patch
Date: Sun, 27 Dec 2009 20:22:30 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Modify the functionality of `quilt delete' to exit with an error
if it detects unrefreshed changes.

To access the old functionality, a `quilt delete -f' option is
introduced.  Note that this brings the paradigm of
`quilt delete'/`quilt delete -f' into accord with that of
`quilt pop'/`quilt pop -f'.  For either command, nothing will be
done if there are unrefreshed patches, unless '-f' is specified.
The consistency eliminates a detail that the user formerly had to
remember.

There is a potential to break scripts that might have unwittingly relied
on the old behavior.  A backward-compatible alternative is possible,
but would complicate the UI.

To help motivate this UI change, consider the following misadventure
that arose in a real-life interactive quilt session of an actual user
(who wishes to remain anonymous).

Suppose you're working on a patch p1, then realize that some changes
you're about to add really belong in a separate patch.  So you do

        <save buffers and kill editor with p1 changes>
        quilt new p2
        <add files to p2 and edit them>
        quilt refresh
        quilt pop

Looking again at p1, you realize that it too belongs somewhere else in
the stack, so as the first step in moving it you do ...

         quilt delete

... and all your unrefreshed changes to p1 are lost, irretrievably,
because there was no `quilt refresh' of p1 along the way.

Signed-off-by: Don Mullis <address@hidden>
---
 quilt/delete.in  |   18 +++++++++++++++---
 test/delete.test |   47 ++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 57 insertions(+), 8 deletions(-)

Index: quilt/quilt/delete.in
===================================================================
--- quilt.orig/quilt/delete.in  2009-12-26 21:57:05.000000000 -0800
+++ quilt/quilt/delete.in       2009-12-26 22:34:56.000000000 -0800
@@ -19,7 +19,7 @@ fi
 
 usage()
 {
-       printf $"Usage: quilt delete [-r] [--backup] [patch|-n]\n"
+       printf $"Usage: quilt delete [-fr] [--backup] [patch|-n]\n"
        if [ x$1 = x-h ]
        then
                printf $"
@@ -27,6 +27,9 @@ Remove the specified or topmost patch fr
 patch is applied, quilt will attempt to remove it first. (Only the
 topmost patch can be removed right now.)
 
+-f     Force remove. If patch was applied, the previous state will
+       be restored from backup files, and any unrefreshed changes lost.
+
 -n     Delete the next patch after topmost, rather than the specified
        or topmost patch.
 
@@ -43,7 +46,7 @@ topmost patch can be removed right now.)
        fi
 }
 
-options=`getopt -o nrh --long backup -- "$@"`
+options=`getopt -o fnrh --long backup -- "$@"`
 
 if [ $? -ne 0 ]
 then
@@ -55,6 +58,9 @@ eval set -- "$options"
 while true
 do
        case "$1" in
+       -f)
+               opt_force=1
+               shift ;;
        -n)
                opt_next=1
                shift ;;
@@ -103,7 +109,13 @@ if is_applied "$patch"; then
                       "$(print_patch "$patch")" >&2
                exit 1
        fi
-       if ! quilt_command pop -fq
+       if [ -n "$opt_force" ]
+       then
+               if ! quilt_command pop -qf
+               then
+                       exit 1
+               fi
+       elif ! quilt_command pop -q
        then
                exit 1
        fi
Index: quilt/test/delete.test
===================================================================
--- quilt.orig/test/delete.test 2009-12-26 21:57:05.000000000 -0800
+++ quilt/test/delete.test      2009-12-26 22:19:30.000000000 -0800
@@ -77,9 +77,11 @@ Test the delete command.
        $ touch .pc/test3/dir/file
        $ chmod a-rx .pc/test3/dir
 
-       $ quilt delete "test3"
-       > Removing patch %{P}test3
-       > .pc/test3/dir: Permission denied
+       # `quilt delete' does not specify -f to `quilt pop' now, and the
+       # the latter writes an absolute path into its message on stderr.
+       # Deal with this by throwing stderr away.
+       $ quilt delete "test3" 2>/dev/null || echo "delete failed as expected"
+       > delete failed as expected
 
        $ chmod a+rx .pc/test3/dir
 
@@ -89,16 +91,51 @@ Test the delete command.
        > .pc/test3/dir/file
 
        $ quilt applied
-       > No patches applied
+       > patches/test3
 
        $ quilt series
        > %{P}test3
 
        $ quilt delete
+       > Removing patch patches/test3
        > No patches applied
+       > Removed patch patches/test3
 
        $ quilt delete test3
-       > Removed patch %{P}test3
+       > No patches in series
+
+       $ quilt series
+
+       # Do not allow deletion of an unrefreshed patch
+       $ quilt new test4
+       > Patch %{P}test4 is now on top
+       $ quilt add file
+       > File file added to patch patches/test4
+       $ echo "x" >file
+       $ quilt delete
+       > Patch %{P}test4 does not remove cleanly (refresh it or enforce with 
-f)
+       $ quilt refresh
+       > Refreshed patch %{P}test4
+
+       $ quilt delete
+       > Removing patch patches/test4
+       > No patches applied
+       > Removed patch %{P}test4
+
+       $ quilt series
+
+       # Do not allow deletion of an unrefreshed patch, unless "-f" is 
specified
+       $ quilt new test4
+       > Patch %{P}test4 is now on top
+       $ quilt add file
+       > File file added to patch patches/test4
+       $ echo "x" >file
+       $ quilt delete -f
+       > Removing patch %{P}test4
+       > No patches applied
+       > Removed patch %{P}test4
 
        $ cd ..
        $ rm -rf d
+
+





reply via email to

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