quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] Submit patch: allow "quilt delete" to delete patch files


From: Joe Green
Subject: [Quilt-dev] Submit patch: allow "quilt delete" to delete patch files
Date: Thu, 11 Aug 2005 15:49:30 -0700
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050317)

There was some discussion a couple of weeks ago about having an option to "quilt delete" to remove the patch files from the patches directory.  I've implemented this in the attached patch.

I've implemented this as two options:
-r      Remove the deleted patch file from the patches directory as well.

--backup
        Create a backup copy of a deleted patch file as patch~.
        Only supported when used with "-r".
What do you think?

-- 
Joe Green <address@hidden>
MontaVista Software, Inc.
Source: MontaVista Software, Inc. <address@hidden>
Type: Enhancement
Disposition: submit to http://savannah.nongnu.org/projects/quilt

Add options to the delete command that will remove the deleted patch from
the QUILT_PATCHES directory and optionally create a backup file.

Index: quilt-0.42/quilt/delete.in
===================================================================
--- quilt-0.42.orig/quilt/delete.in
+++ quilt-0.42/quilt/delete.in
@@ -19,7 +19,7 @@ fi
 
 usage()
 {
-       printf $"Usage: quilt delete [patch | -n]\n"
+       printf $"Usage: quilt delete [-r] [--backup] [patch | -n]\n"
        if [ x$1 = x-h ]
        then
                printf $"
@@ -29,6 +29,12 @@ topmost patch can be removed right now.)
 
 -n     Delete the next patch after topmost, rather than the specified
        or topmost patch.
+
+-r     Remove the deleted patch file from the patches directory as well.
+
+--backup
+       Create a backup copy of a deleted patch file as patch~.
+       Only supported when used with \"-r\".
 "
 
                exit 0
@@ -37,7 +43,7 @@ topmost patch can be removed right now.)
        fi
 }
 
-options=`getopt -o nh -- "$@"`
+options=`getopt -o nrh --long backup -- "$@"`
 
 if [ $? -ne 0 ]
 then
@@ -52,8 +58,14 @@ do
        -n)
                opt_next=1
                shift ;;
+       -r)
+               opt_remove=1
+               shift ;;
        -h)
                usage -h ;;
+       --backup)
+               QUILT_BACKUP=1
+               shift ;;
        --)
                shift
                break ;;
@@ -113,6 +125,28 @@ then
        printf $"Removed patch %s\n" "$(print_patch "$patch")"
 else
        printf $"Failed to remove patch %s\n" "$(print_patch "$patch")" >&2
+       exit 1
+fi
+
+patch_file=$(patch_file_name "$patch")
+if [ "$opt_remove" -a -e "$patch_file" ]
+then
+       if [ "$QUILT_BACKUP" ]
+       then
+               if ! mv -f "$patch_file" "$patch_file~"
+               then
+                       printf $"Failed to backup patch file \"%s\"\n" \
+                               "$patch_file" >&2
+                       exit 1
+               fi
+       else
+               if ! rm -f "$patch_file"
+               then
+                       printf $"Failed to remove patch file \"%s\"\n" \
+                               "$patch_file" >&2
+                       exit 1
+               fi
+       fi
 fi
 ### Local Variables:
 ### mode: shell-script
Index: quilt-0.42/bash_completion
===================================================================
--- quilt-0.42.orig/bash_completion
+++ quilt-0.42/bash_completion
@@ -139,7 +139,7 @@ _quilt_completion()
           COMPREPLY=( $( compgen -W "-h $(quilt applied)" -- $cur ) )
           ;;
        delete) 
-          COMPREPLY=( $( compgen -W "-n -h $(quilt series)" -- $cur ) )
+          COMPREPLY=( $( compgen -W "-n -r -h --backup $(quilt series)" -- 
$cur ) )
           ;;
        diff) 
           case $prev in

reply via email to

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