On 1/21/06, Jean Delvare <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> A recent change to CVS broke "quilt delete -n" when no patch is
> currently applied. This is caused by the find_patch_in_series function
> failing when called without a patch name parameter and no patch is
> currently applied.

Thanks for pointing this out.

> I'm not sure how we want to fix that. I tried changing
> find_patch_in_series' behavior to match delete's expectations but then
> the test suite fails elsewhere. Hints anyone?

The following patch addresses the problem.  I've included a new error
message for when pop fails as the current error is deceptively normal.

--
John
Index: quilt/test/delete.test
===================================================================
--- quilt.orig/test/delete.test 2006-01-21 19:21:48.000000000 +1100
+++ quilt/test/delete.test      2006-01-21 19:52:25.000000000 +1100
@@ -4,6 +4,9 @@
        $ mkdir -p d/patches
        $ cd d
 
+       $ quilt delete
+       > No patches in series
+
        $ cat > test.txt
        < Calling pci_match_id() would be more feasible.
 
@@ -31,6 +34,9 @@
        $ quilt refresh
        > Refreshed patch %{P}test2
 
+       $ quilt delete test1
+       > Patch %{P}test1 is currently applied
+
        $ quilt pop
        > Removing patch %{P}test2
        > Restoring test.txt
@@ -58,5 +64,40 @@
 
        $ quilt series
 
+       $ echo "test1" > %{P}series
+       $ quilt delete -n
+       > No patches applied
+
+       $ quilt series
+       > %{P}test1
+
+       # Force the pop operaton to fail
+       $ echo "test3" > %{P}/series
+       $ echo "test3" > .pc/applied-patches
+       $ mkdir -p .pc/test3/dir
+       $ touch .pc/test3/dir/file
+       $ chmod a-rx .pc/test3/dir
+
+       $ quilt delete "test3"
+       > Removing patch %{P}test3
+       > .pc/test3/dir: Permission denied
+       > Patch %{P}test3 is currently applied
+
+       $ chmod a+rx .pc/test3/dir
+
+       $ find .pc/test3
+       > .pc/test3
+       > .pc/test3/dir
+       > .pc/test3/dir/file
+
+       $ quilt applied
+       > No patches applied
+
+       $ quilt series
+       > %{P}test3
+
+       $ quilt delete test3
+       > Removed patch %{P}test3
+
        $ cd ..
        $ rm -rf d




When no patches are applied, delete -n previously removed
the first patch.

Adds tests for quilt delete with and without -n when no
patches are applied, top most and other applied patches.

When pop fails during a delete, it will still remove the
entry from applied-patches, and the state of the backup 
directory in .pc/ is unknown.  AFAICS a strong warning
is necessary.

Index: quilt/quilt/delete.in
===================================================================
--- quilt.orig/quilt/delete.in  2006-01-21 19:51:42.000000000 +1100
+++ quilt/quilt/delete.in       2006-01-21 19:52:38.000000000 +1100
@@ -77,22 +77,26 @@
        usage
 fi
 
-patch=$(find_patch_in_series "$1") || exit 1
-
 if [ -n "$opt_next" ]
 then
-       if ! patch="$(patch_after "$patch")"
+       if has_applied
+       then
+               patch=$(patch_after $(top_patch))
+       elif ! patch=$(find_first_patch)
        then
                printf $"No next patch\n" >&2
                exit 1
        fi
-elif is_applied "$patch"
-then
-       if [ "$patch" != "$(top_patch)" ] || \
-          ! quilt_command pop -fq
-       then
-               printf $"Patch %s is currently applied\n" \
-                      "$(print_patch $patch)" >&2
+elif [ -n "$1" -a "$1" != "$(top_patch)" ]
+then
+       patch=$(find_unapplied_patch "$1") || exit 1
+else
+       patch=$(find_top_patch) || exit 1
+
+       if ! quilt_command pop -fq
+       then
+               printf $"Removing patch %s failed\n" \
+                       "$(print_patch "$patch")" >&2
                exit 1
        fi
 fi
Index: quilt/quilt/scripts/patchfns.in
===================================================================
--- quilt.orig/quilt/scripts/patchfns.in        2006-01-21 19:51:42.000000000 
+1100
+++ quilt/quilt/scripts/patchfns.in     2006-01-21 19:52:38.000000000 +1100
@@ -330,6 +330,12 @@
        grep -q "^$(quote_bre $patch)\$" $DB
 }
 
+has_applied()
+{
+       [ -e $DB ] || return 1
+       first=$(head -1 $DB) || return 1
+}
+
 applied_patches()
 {
        [ -e $DB ] || return 1
@@ -536,7 +542,7 @@
                patch=$(find_patch "$name") || return 1
                if is_applied "$patch"
                then
-                       printf $"Patch %s is already applied\n" \
+                       printf $"Patch %s is currently applied\n" \
                                "$(print_patch $patch)" >&2
                                return 1
                fi
Index: quilt/test/three.test
===================================================================
--- quilt.orig/test/three.test  2006-01-21 19:51:43.000000000 +1100
+++ quilt/test/three.test       2006-01-21 19:52:38.000000000 +1100
@@ -135,7 +135,7 @@
        > Now at patch patches/patch2.diff
 
        $ quilt push patch2
-       > Patch patches/patch2.diff is already applied
+       > Patch patches/patch2.diff is currently applied
 
        $ quilt push
        > File series fully applied, ends at patch patches/patch2.diff
Index: quilt/test/delete.test
===================================================================
--- quilt.orig/test/delete.test 2006-01-21 19:52:25.000000000 +1100
+++ quilt/test/delete.test      2006-01-21 19:54:30.000000000 +1100
@@ -66,10 +66,9 @@
 
        $ echo "test1" > %{P}series
        $ quilt delete -n
-       > No patches applied
+       > Removed patch %{P}test1
 
        $ quilt series
-       > %{P}test1
 
        # Force the pop operaton to fail
        $ echo "test3" > %{P}/series
@@ -81,7 +80,7 @@
        $ quilt delete "test3"
        > Removing patch %{P}test3
        > .pc/test3/dir: Permission denied
-       > Patch %{P}test3 is currently applied
+       > Removing patch %{P}test3 failed
 
        $ chmod a+rx .pc/test3/dir
 




_______________________________________________
Quilt-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/quilt-dev

Reply via email to