summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.in2
-rw-r--r--quilt.changes10
-rw-r--r--quilt/files.in38
-rw-r--r--quilt/fold.in122
-rwxr-xr-xscripts/apatch.in58
-rw-r--r--test/fold.test57
-rw-r--r--test/one.test4
7 files changed, 237 insertions, 54 deletions
diff --git a/Makefile.in b/Makefile.in
index 5c254db..b6fa588 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -57,7 +57,7 @@ DIRT += $(BIN_IN:%=bin/%)
QUILT_IN := add applied delete diff files import new next patches \
pop previous push refresh remove series setup top unapplied \
- fork snapshot edit
+ fold fork snapshot edit
QUILT_SRC := $(QUILT_IN:%=%.in)
QUILT := $(QUILT_IN)
diff --git a/quilt.changes b/quilt.changes
index 1f7f938..9f70878 100644
--- a/quilt.changes
+++ b/quilt.changes
@@ -1,4 +1,14 @@
-------------------------------------------------------------------
+Mon Nov 17 20:31:36 CET 2003 - agruen@suse.de
+
+- Add new command `quilt fold' to fold one patch into another.
+- Fix bug in `quilt files': Files that are neither present in the
+ working directory and have an empty backup copy sometimes were
+ still listed.
+- Some minor cleanups in apatch.
+- Add test/fold.test, and fix a now-useless check in one.test.
+
+-------------------------------------------------------------------
Sat Nov 15 08:44:19 CET 2003 - agruen@suse.de
- Merge some changes from wangdi:
diff --git a/quilt/files.in b/quilt/files.in
index 796b9e2..3db405e 100644
--- a/quilt/files.in
+++ b/quilt/files.in
@@ -87,28 +87,30 @@ then
fi
fi
-if [ -z "$opt_verbose" ]
-then
- files_in_patch $patch
-else
- for file in $(files_in_patch $patch)
- do
- status=" "
- if [ -s $(backup_file_name $patch $file) ]
+for file in $(files_in_patch $patch)
+do
+ status=" "
+ if [ -s $(backup_file_name $patch $file) ]
+ then
+ if ! [ -s $file ]
+ then
+ status="-"
+ fi
+ else
+ if [ -s $file ]
then
- if ! [ -s $file ]
- then
- status="-"
- fi
+ status="+"
else
- if [ -s $file ]
- then
- status="+"
- fi
+ continue
fi
+ fi
+ if [ -z "$opt_verbose" ]
+ then
+ echo "$file"
+ else
echo "$status $file"
- done
-fi
+ fi
+done
### Local Variables:
### mode: shell-script
### End:
diff --git a/quilt/fold.in b/quilt/fold.in
new file mode 100644
index 0000000..65769fe
--- /dev/null
+++ b/quilt/fold.in
@@ -0,0 +1,122 @@
+#! @BASH@
+
+# This script is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# 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 ]
+ then
+ echo "Cannot read library @SCRIPTS@/patchfns" >&2
+ exit 1
+ fi
+ . @SCRIPTS@/patchfns
+fi
+
+usage()
+{
+ echo $"Usage: quilt fold [-p strip-level]"
+ if [ x$1 = x-h ]
+ then
+ echo $"
+
+Fold the patch read from standard input into the topmost patch: After
+making sure that all files modified by the patchfile are part of the
+topmost patch, the patch is applied with the specified strip level
+(which defaults to 1).
+
+-p strip-level
+ The number of pathname components to strip from file names
+ when applying patchfile."
+
+ exit 0
+ else
+ exit 1
+ fi
+}
+
+options=`getopt -o p:qh -- "$@"`
+
+if [ $? -ne 0 ]
+then
+ usage
+fi
+
+eval set -- "$options"
+
+while true
+do
+ case "$1" in
+ -p)
+ opt_strip_level=$2
+ shift 2 ;;
+ -q)
+ opt_silent=1
+ shift ;;
+ -h)
+ usage -h ;;
+ --)
+ shift
+ break ;;
+ esac
+done
+
+if [ $# -ne 0 ]
+then
+ usage
+fi
+
+: ${opt_strip_level:=1}
+[ -n "$opt_silent" ] && silent=-s
+
+top=$(top_patch)
+if [ -z "$top" ]
+then
+ echo $"No patch applied"
+fi
+
+trap "failed=1" SIGINT
+
+workdir=$(gen_tempfile -d $PWD)
+@PATCH@ -p$opt_strip_level $silent --backup --prefix="$workdir/" -E \
+|| failed=1
+
+if [ -z "$failed" ]
+then
+ for file in $(find $workdir -type f -a ! -path "$workdir/.timestamp")
+ do
+ backup_file="$(backup_file_name $top "${file:${#workdir}+1}")"
+ if ! [ -e "$backup_file" ]
+ then
+ if ! ln "$file" "$backup_file"
+ then
+ failed=1
+ break
+ fi
+ fi
+ done
+fi
+if [ -n "$failed" ]
+then
+ for file in $(find $workdir -type f -a ! -path "$workdir/.timestamp")
+ do
+ backup_file="$(backup_file_name $top "${file:${#workdir}+1}")"
+ if ! mv -f "$backup_file" "$file"
+ then
+ echo $"File ${file:${#workdir}+1} may be corrupted"
+ fi
+ done
+ rm -rf $workdir
+ exit 1
+fi
+
+rm -rf $workdir
+exit 0
+### Local Variables:
+### mode: shell-script
+### End:
+# vim:filetype=sh
diff --git a/scripts/apatch.in b/scripts/apatch.in
index 3ec72e4..ad64104 100755
--- a/scripts/apatch.in
+++ b/scripts/apatch.in
@@ -23,20 +23,6 @@ usage()
exit 1
}
-rollback_patch()
-{
- local patch=$1 pc_file=$(gen_tempfile)
-
- # FIXME backup_files should scan the directory hierarchy itself.
- files_in_patch $patch > $pc_file
- @LIB@/backup-files $silent_unless_verbose -f $pc_file -B .pc/$patch/ -r
- if [ -z "$opt_leave_rejects" ]
- then
- @SED@ -e 's/$/\.rej/' $pc_file | xargs rm -f
- fi
- rm -f $pc_file
-}
-
interrupt()
{
rollback_patch $1
@@ -57,32 +43,32 @@ apply_patch()
if [ "x${patch_file:(-3)}" = "x.gz" ]
then
- output="$(
gzip -cd $patch_file \
| @PATCH@ $(patch_args $patch) --backup --prefix=".pc/$patch/" \
- -E $silent $force_apply 2>&1 )"
+ -E $silent $force_apply 2>&1
elif [ "x${patch_file:(-4)}" = "x.bz2" ]
then
- output="$(
bzip2 -cd $patch_file \
| @PATCH@ $(patch_args $patch) --backup --prefix=".pc/$patch/" \
- -E $silent $force_apply 2>&1 )"
+ -E $silent $force_apply 2>&1
else
- output="$(
@PATCH@ $(patch_args $patch) --backup --prefix=".pc/$patch/" \
- -E $silent -i $patch_file $force_apply 2>&1 )"
+ -E $silent $force_apply -i $patch_file 2>&1
fi
- status=${PIPESTATUS[0]}
- if [ $status -ne 0 -a -z "$opt_leave_rejects" ]
- then
- # The reject files are removed in rollback_patch.
- echo "$output" \
- | sed -e 's/-- saving rejects to file \(.\+\)\.rej/-- rejects in file \1/'
- elif [ -n "$output" ]
+}
+
+rollback_patch()
+{
+ local patch=$1 pc_file=$(gen_tempfile)
+
+ # FIXME backup_files should scan the directory hierarchy itself.
+ files_in_patch $patch > $pc_file
+ @LIB@/backup-files $silent_unless_verbose -f $pc_file -B .pc/$patch/ -r
+ if [ -z "$opt_leave_rejects" ]
then
- echo "$output"
+ @SED@ -e 's/$/\.rej/' $pc_file | xargs rm -f
fi
- return $status
+ rm -f $pc_file
}
apatch()
@@ -93,11 +79,21 @@ apatch()
echo $"Applying $patch"
trap "interrupt $patch" SIGINT
- apply_patch $patch
- status=$?
+ output="$(apply_patch $patch)"
+ status=${PIPESTATUS[0]}
trap "" SIGINT
+ if [ $status -ne 0 -a -z "$opt_leave_rejects" ]
+ then
+ # The reject files are removed in rollback_patch.
+ echo "$output" \
+ | sed -e 's/-- saving rejects to file \(.\+\)\.rej/-- rejects in file \1/'
+ elif [ -n "$output" ]
+ then
+ echo "$output"
+ fi
+
if [ $status -eq 0 -o -n "$opt_force" ]
then
add_to_db $patch
diff --git a/test/fold.test b/test/fold.test
new file mode 100644
index 0000000..b0aeb90
--- /dev/null
+++ b/test/fold.test
@@ -0,0 +1,57 @@
+ $ mkdir d
+ $ cd d
+
+ $ mkdir patches
+ $ cat > patches/series
+ < patch1.diff
+ < patch2.diff
+
+ $ cat > patches/patch1.diff
+ < --- q.orig/file1.txt
+ < +++ q/file1.txt
+ < @@ -0,0 +1 @@
+ < +This is file1.txt.
+ < --- q.orig/file2.txt
+ < +++ q/file2.txt
+ < @@ -0,0 +1 @@
+ < +This is file2.txt.
+
+ $ cat > patches/patch2.diff
+ < --- q.orig/file2.txt
+ < +++ q/file2.txt
+ < @@ -1 +0,0 @@
+ < -This is file2.txt.
+ < --- q.orig/file3.txt
+ < +++ q/file3.txt
+ < @@ -0,0 +1 @@
+ < +This is file3.txt.
+
+ $ quilt push -q
+ > Applying patch1
+ > Now at patch patch1
+
+ $ quilt files
+ > file1.txt
+ > file2.txt
+
+ $ quilt fold -q < patches/patch2.diff
+ $ quilt files
+ > file1.txt
+ > file3.txt
+
+ $ quilt diff | sed -e "s/\\t.*//"
+ > Index: d/file1.txt
+ > ===================================================================
+ > --- d.orig/file1.txt
+ > +++ d/file1.txt
+ > @@ -0,0 +1 @@
+ > +This is file1.txt.
+ > Index: d/file3.txt
+ > ===================================================================
+ > --- d.orig/file3.txt
+ > +++ d/file3.txt
+ > @@ -0,0 +1 @@
+ > +This is file3.txt.
+
+ $ cd ..
+ $ rm -rf d
diff --git a/test/one.test b/test/one.test
index d1298c5..d72858f 100644
--- a/test/one.test
+++ b/test/one.test
@@ -23,10 +23,6 @@ of the installed quilt with `make check'.
$ quilt refresh
> Nothing in patch patch1
- $ quilt files
- > dir/file1
- > file2
-
$ echo "This is file two." > file2
$ quilt diff | sed -e "s/\\t.*//"
> Index: d/file2