summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwangdi <wangdi>2003-11-28 08:38:56 +0000
committerwangdi <wangdi>2003-11-28 08:38:56 +0000
commit27a1e504e8438cf335a3eb9a30f1853fa041aa7d (patch)
treea3a6566f8f2b93ce1fbb22322e41ec36a0ff3c70
parentea8da5a7eb278c9d7cce4fee93e9e7e8bce3abd8 (diff)
downloadquilt-27a1e504e8438cf335a3eb9a30f1853fa041aa7d.tar.gz
restore reverse_patch for -R option
-rwxr-xr-xscripts/rpatch.in62
1 files changed, 46 insertions, 16 deletions
diff --git a/scripts/rpatch.in b/scripts/rpatch.in
index a8bdf18..982221a 100755
--- a/scripts/rpatch.in
+++ b/scripts/rpatch.in
@@ -6,7 +6,6 @@
#
# 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 ]
@@ -100,7 +99,7 @@ check_for_pending_changes()
if [ -s $remains ]
then
- echo $"Patch $patch does not remove cleanly (enforce with -f)."
+ echo $"Patch $patch does not remove cleanly (enforce with -f or -R)."
status=1
fi
rm -f $remains
@@ -109,6 +108,33 @@ check_for_pending_changes()
return $status
}
+reverse_patch()
+{
+ local patch=$1
+ local patch_file=$(patch_file_name $patch)
+
+ if ! [ -s $patch_file ]
+ then
+ echo $"Patch file $patch_file appears to be empty"
+ return 0
+ fi
+
+ if [ "x${patch_file:(-3)}" = "x.gz" ]
+ then
+ gzip -cd $patch_file \
+ | @PATCH@ $(patch_args $patch) --no-backup-if-mismatch \
+ -R -E $silent
+ elif [ "x${patch_file:(-4)}" = "x.bz2" ]
+ then
+ bzip2 -cd $patch_file \
+ | @PATCH@ $(patch_args $patch) --no-backup-if-mismatch \
+ -R -E $silent
+ else
+ @PATCH@ $(patch_args $patch) --no-backup-if-mismatch \
+ -R -E $silent -i $patch_file
+ fi
+}
+
rpatch()
{
local patch=$1 pc_file=$(gen_tempfile) status=0
@@ -141,21 +167,25 @@ rpatch()
fi
done
fi
-
- if [ -z "$opt_force" ] && \
- ( [ -n "$opt_remove" ] || files_may_have_changed $patch )
- then
- check_for_pending_changes $patch $pc_file || status=1
- fi
-
- if [ $status -eq 0 ]
+ if [ -n "$opt_remove" ]
then
- echo $"Removing $patch"
- rm -f ".pc/$patch/.timestamp"
- @LIB@/backup-files $silent -f $pc_file -B .pc/$patch/ -r
- status=$?
- remove_from_db $patch
- rm -f .pc/$patch~refresh
+ reverse_patch $patch
+ remove_from_db $patch
+ rm -f .pc/$patch~refresh
+ else
+ if [ -z "$opt_force" ] && ( files_may_have_changed $patch )
+ then
+ check_for_pending_changes $patch $pc_file || status=1
+ fi
+ if [ $status -eq 0 ]
+ then
+ echo $"Removing $patch"
+ rm -f ".pc/$patch/.timestamp"
+ @LIB@/backup-files $silent -f $pc_file -B .pc/$patch/ -r
+ status=$?
+ remove_from_db $patch
+ rm -f .pc/$patch~refresh
+ fi
fi
rm -f $pc_file
trap - SIGINT