summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2003-10-26 13:31:25 +0000
committerAndreas Gruenbacher <agruen@suse.de>2003-10-26 13:31:25 +0000
commitfa8a69af263c29ac5243e21878f24a3b175e11e6 (patch)
tree81d526c8921e68900f526fc27aa8eb3853fd8a4d
parentb0069c28a0600dd5dc01d5feaa9e10a805700577 (diff)
downloadquilt-fa8a69af263c29ac5243e21878f24a3b175e11e6.tar.gz
- Rename snapshot directory from ".snap0" to ".snap".
- `quilt diff: Speed up file list generation in `quilt diff'. Don't use modified_files anymore. Instead, add first_modified_by function. I want to get rid of the patches_per_file cache; it sometimes was not brought up to date. Some cleanups. - Add test/snapshot.test. - Fix two errors in the date format in quilt.changes.
-rw-r--r--quilt.changes15
-rw-r--r--quilt/diff.in104
-rw-r--r--quilt/snapshot.in2
-rw-r--r--scripts/patchfns.in21
-rw-r--r--test/snapshot.test61
5 files changed, 139 insertions, 64 deletions
diff --git a/quilt.changes b/quilt.changes
index 9cb0efa..ea27f30 100644
--- a/quilt.changes
+++ b/quilt.changes
@@ -1,4 +1,15 @@
-------------------------------------------------------------------
+Sun Oct 26 14:45:08 CET 2003 - agruen@suse.de
+
+- Rename snapshot directory from ".snap0" to ".snap".
+- `quilt diff: Speed up file list generation in `quilt diff'.
+ Don't use modified_files anymore. Instead, add first_modified_by
+ function. I want to get rid of the patches_per_file cache;
+ it sometimes was not brought up to date. Some cleanups.
+- Add test/snapshot.test.
+- Fix two errors in the date format in quilt.changes.
+
+-------------------------------------------------------------------
Fri Oct 24 00:50:08 CEST 2003 - agruen@suse.de
- `quilt add': Return exit code 2 when a file has already been
@@ -76,13 +87,13 @@ Sun Jul 20 00:31:53 CEST 2003 - agruen@suse.de
e.g., because the backups go to a ram disc, etc.
-------------------------------------------------------------------
-Wed 26 Jun 15:35:55 CEST 2003 - martin.quinson@tuxfamily.org
+Wed Jun 26 15:35:55 CEST 2003 - martin.quinson@tuxfamily.org
- Add what needed to have inteligent bash completion when using quilt
- Bump version to 0.24
-------------------------------------------------------------------
-Wed 25 Jun 15:35:55 CEST 2003 - martin.quinson@tuxfamily.org
+Wed Jun 25 15:35:55 CEST 2003 - martin.quinson@tuxfamily.org
- Make clean before dist to avoid to put cruft in tarballs
- remove po/*mo on make clean
diff --git a/quilt/diff.in b/quilt/diff.in
index 3e74b9d..2603f0b 100644
--- a/quilt/diff.in
+++ b/quilt/diff.in
@@ -83,6 +83,7 @@ do_diff()
die ()
{
local status=$1
+ [ -e "$tmp_files" ] && rm -f $tmp_files
[ -n "$workdir" ] && rm -rf $workdir
exit $status
}
@@ -106,7 +107,8 @@ do
last_patch=$(stripit $2)
shift 2 ;;
-c)
- opt_combine=$(stripit $2)
+ opt_combine=1
+ first_patch=$(stripit $2)
shift 2 ;;
-R)
opt_reverse=1
@@ -118,7 +120,7 @@ do
usage -h ;;
--snapshot)
opt_snapshot=1
- snap_dir=.pc/.snap0
+ snap_subdir=.snap
shift ;;
--diff)
opt_diff="$2"
@@ -131,9 +133,9 @@ done
opt_files=( "$@" )
-if [ -n "$opt_combine" -a -n "$opt_relative" ]
+if [ $[0$opt_combine + 0$opt_snapshot + 0$opt_relative] -gt 1 ]
then
- echo $"Options \`-c patch' and \`-z' cannot be combined."
+ echo $"Options \`-c patch', \`--snapshot', and \`-z' cannot be combined."
die 1
fi
@@ -163,84 +165,60 @@ then
die 1
fi
+trap "die 1" SIGTERM
+
+tmp_files=$(gen_tempfile)
+exec 4> $tmp_files # open $tmp_files
+
if [ -n "$opt_snapshot" -a ${#opt_files[@]} -eq 0 ]
then
# Add all files in the snapshot into the file list (they may all
# have changed).
while read file
do
- patches[${#patches[@]}]="-"
- file="${file#$snap_dir/}"
- files[${#files[@]}]="$file"
+ echo "${file#.pc/$snap_subdir/}" >&4
done \
- < <(find $snap_dir -type f)
+ < <(find .pc/$snap_subdir -type f)
# Also look at all patches that are currently applied.
- opt_combine="$(applied_patches | head -n 1)"
-
- # The patches-per-file cache is buggy -- it should best go away
- # completely.
- rm -f .pc/patches-per-file
+ opt_combine=1
+ first_patch="$(applied_patches | head -n 1)"
fi
if [ -n "$opt_combine" ]
then
- if ! refresh_patches_per_file
- then
- echo $"refresh_patches_per_file failed."
- die 1
- fi
-
set -- $(patches_before $last_patch) $last_patch
- if [ "x$opt_combine" != "x-" ]
+ if [ "$first_patch" != "-" ]
then
- while [ $# -ge 1 -a "$1" != "$opt_combine" ]
+ while [ $# -ge 1 -a "$1" != "$first_patch" ]
do
shift
done
if [ $# -eq 0 ]
then
- echo $"Patch $opt_combine not applied before $last_patch."
+ echo $"Patch $first_patch not applied before $last_patch."
die 1
fi
fi
-
- while read file first garbage
- do
- if [ ${#opt_files[@]} -gt 0 ] && \
- ! in_array "$file" "${opt_files[@]}"
- then
- continue
- fi
- in_array "$file" "${files[@]}" && continue
- patches[${#patches[@]}]="$first"
- files[${#files[@]}]="$file"
- done \
- < <(modified_files -- "$@")
+ patches=( $@ )
else
- for file in $(files_in_patch $last_patch)
+ patches=( $last_patch )
+fi
+
+for patch in ${patches[@]}
+do
+ for file in $(files_in_patch $patch)
do
if [ ${#opt_files[@]} -gt 0 ] && \
! in_array "$file" "${opt_files[@]}"
then
continue
fi
- in_array "$file" "${files[@]}" && continue
- files[${#files[@]}]="$file"
- done
-fi
-
-if [ ${#opt_files[@]} -gt 0 -a -z "$opt_snapshot" ]
-then
- for file in "${opt_files[@]}"
- do
- if ! in_array "$file" "${files[@]}"
- then
- echo $"File $file is not being modified."
- fi
- done
-fi
+ echo "$file" >&4
+ done < <(files_in_patch $patch)
+done
-trap "die 1" SIGTERM
+exec 4>&- # close $tmp_files
+files=( $(sort -u $tmp_files) )
if [ -n "$opt_relative" ]
then
@@ -291,19 +269,23 @@ then
fi
fi
-for ((i=0; i<${#files[@]}; i++))
+for file in "${files[@]}"
do
- file="${files[$i]}"
- first_patch=${patches[$i]:-$last_patch}
-
- if [ -n "$opt_snapshot" -a -e "$snap_dir/$file" ]
+ if [ -n "$opt_snapshot" -a -e ".pc/$snap_subdir/$file" ]
then
- old_file="$snap_dir/$file"
- elif [ -z "$opt_relative" ]
+ old_file=".pc/$snap_subdir/$file"
+ elif [ -n "$opt_relative" ]
then
- old_file="$(backup_file_name $first_patch $file)"
- else
old_file="$workdir/$file"
+ else
+ patch="$(first_modified_by $file ${patches[@]})"
+ if [ -z "$patch" ]
+ then
+ [ -z "$opt_snapshot" ] \
+ && echo $"File $file is not being modified."
+ continue
+ fi
+ old_file="$(backup_file_name $patch $file)"
fi
next_patch=$(next_patch_for_file $last_patch $file)
diff --git a/quilt/snapshot.in b/quilt/snapshot.in
index 079c81b..6883a59 100644
--- a/quilt/snapshot.in
+++ b/quilt/snapshot.in
@@ -63,7 +63,7 @@ then
usage
fi
-snap_dir=.pc/.snap0
+snap_dir=.pc/.snap
# Clean up from previous snapshot
rm -rf $snap_dir
diff --git a/scripts/patchfns.in b/scripts/patchfns.in
index ccd5c42..361087c 100644
--- a/scripts/patchfns.in
+++ b/scripts/patchfns.in
@@ -718,6 +718,27 @@ gen_tempfile()
fi
@MKTEMP@ $dir ${1:-${TMPDIR:-/tmp}/quilt}.XXXXXX
}
+
+first_modified_by()
+{
+ local file=$1 patch
+ local -a patches
+ if [ $# -eq 0 ]
+ then
+ patches=( $(applied_patches) )
+ else
+ shift
+ patches=( "$@" )
+ fi
+ for patch in ${patches[@]}
+ do
+ if [ -f ".pc/$patch/$file" ]
+ then
+ echo $patch
+ fi
+ done
+ return 1
+}
### Local Variables:
### mode: shell-script
### End:
diff --git a/test/snapshot.test b/test/snapshot.test
new file mode 100644
index 0000000..8ae8d29
--- /dev/null
+++ b/test/snapshot.test
@@ -0,0 +1,61 @@
+ $ mkdir d
+ $ cd d
+
+ $ quilt new snapshot
+ > Patch snapshot is now on top
+ $ quilt add f.txt
+ > File f.txt added to patch snapshot
+ $ cat > f.txt
+ < f.txt
+
+ $ quilt add g.txt
+ > File g.txt added to patch snapshot
+ $ cat > g.txt
+ < g.txt
+
+ $ quilt refresh
+ > Refreshed patch snapshot
+ $ quilt snapshot
+ $ quilt pop -q
+ > Removing snapshot
+ > No patches applied
+
+ $ quilt fork
+ > Fork of patches/snapshot created as patches/snapshot-2
+
+ $ quilt push -q
+ > Applying snapshot-2
+ > Now at patch snapshot-2
+
+ $ quilt remove g.txt
+ > File g.txt removed from patch snapshot-2
+
+ $ quilt add h.txt
+ > File h.txt added to patch snapshot-2
+
+ $ cat > h.txt
+ < h.txt
+
+ $ cat >> f.txt
+ < more changes
+
+ $ quilt refresh
+ > Refreshed patch snapshot-2
+
+ $ quilt diff --snapshot | grep -v "^\\(---\\|+++\\)"
+ > Index: d/f.txt
+ > ===================================================================
+ > @@ -1 +1,2 @@
+ > f.txt
+ > +more changes
+ > Index: d/g.txt
+ > ===================================================================
+ > @@ -1 +0,0 @@
+ > -g.txt
+ > Index: d/h.txt
+ > ===================================================================
+ > @@ -0,0 +1 @@
+ > +h.txt
+
+ $ cd ..
+ $ rm -rf d