forked from pool/quilt
Backport functional and performance regression fixes from upstream:
* Fix bash completion of patch names * Fix refresh error message * Fix quilt diff -z on file names including spaces * Fix quilt files output when there are no files * Fix patches heuristic for unapplied patches with timestamps * Re-enable testing of patch-wrapper * Fix performance regression in quilt patches * Performance boost for series, applies and unapplied commands OBS-URL: https://build.opensuse.org/package/show/devel:tools:scm/quilt?expand=0&rev=78
This commit is contained in:
parent
3b6642fd7b
commit
3a7d64b475
162
quilt-bash_completion-fix-completion-of-patch-names.patch
Normal file
162
quilt-bash_completion-fix-completion-of-patch-names.patch
Normal file
@ -0,0 +1,162 @@
|
||||
From: Jean Delvare <jdelvare@suse.de>
|
||||
Date: Tue, 7 Jan 2014 16:56:16 +0100
|
||||
Subject: bash_completion: Fix completion of patch names
|
||||
Patch-mainline: yes
|
||||
Git-commit: f535e6f731668035a3fa2472628ba82146ea7262
|
||||
References: bnc#872719
|
||||
|
||||
When the user's quilt configuration file (~/.quiltrc or
|
||||
/etc/quilt.quiltrc) contains QUILT_PATCHES_PREFIX=yes (and the
|
||||
default /etc/quilt.quiltrc does), bash completion chokes on patch
|
||||
names. This is because quilt series, applied and unapplied return
|
||||
relative patch names instead of the expected absolute patch names.
|
||||
|
||||
This can be solved by skipping configuration files when quilt is
|
||||
called from the bash completion script.
|
||||
|
||||
This fixes bug #27111:
|
||||
https://savannah.nongnu.org/bugs/index.php?27111
|
||||
|
||||
diff --git a/bash_completion b/bash_completion
|
||||
index 19736cb..0918598 100644
|
||||
--- a/bash_completion
|
||||
+++ b/bash_completion
|
||||
@@ -6,6 +6,11 @@
|
||||
# This file is part of the distribution of quilt, and is distributed under
|
||||
# the same licence than quilt itself
|
||||
|
||||
+# WARNING: This script doesn't read user or system quiltrc files, and assumes
|
||||
+# that QUILT_PC is left unchanged. If you have changed QUILT_PC and want
|
||||
+# completion to work then you must set QUILT_PC in your global environment
|
||||
+# (for example in ~/.profile) and not just in your quiltrc file.
|
||||
+
|
||||
if type quilt &> /dev/null ; then
|
||||
|
||||
if ! type _expand &> /dev/null ; then
|
||||
@@ -123,7 +128,7 @@ _quilt_completion()
|
||||
add)
|
||||
case $prev in
|
||||
-P)
|
||||
- COMPREPLY=( $( compgen -W "$(quilt applied 2>/dev/null)" -- $cur ) )
|
||||
+ COMPREPLY=( $( compgen -W "$(quilt --quiltrc - applied 2>/dev/null)" -- $cur ) )
|
||||
;;
|
||||
*)
|
||||
_quilt_comfile
|
||||
@@ -134,7 +139,7 @@ _quilt_completion()
|
||||
annotate)
|
||||
case $prev in
|
||||
-P)
|
||||
- COMPREPLY=( $( compgen -W "$(quilt applied 2>/dev/null)" -- $cur ) )
|
||||
+ COMPREPLY=( $( compgen -W "$(quilt --quiltrc - applied 2>/dev/null)" -- $cur ) )
|
||||
;;
|
||||
*)
|
||||
_quilt_comfile
|
||||
@@ -143,10 +148,10 @@ _quilt_completion()
|
||||
esac
|
||||
;;
|
||||
applied)
|
||||
- COMPREPLY=( $( compgen -W "-h $(quilt applied 2>/dev/null)" -- $cur ) )
|
||||
+ COMPREPLY=( $( compgen -W "-h $(quilt --quiltrc - applied 2>/dev/null)" -- $cur ) )
|
||||
;;
|
||||
delete)
|
||||
- COMPREPLY=( $( compgen -W "-n -r -h --backup $(quilt series)" -- $cur ) )
|
||||
+ COMPREPLY=( $( compgen -W "-n -r -h --backup $(quilt --quiltrc - series)" -- $cur ) )
|
||||
;;
|
||||
diff)
|
||||
case $prev in
|
||||
@@ -154,7 +159,7 @@ _quilt_completion()
|
||||
COMPREPLY=( $( compgen -W "0 1" -- $cur ) )
|
||||
;;
|
||||
-P|--combine)
|
||||
- COMPREPLY=( $( compgen -W "$(quilt applied 2>/dev/null)" -- $cur ) )
|
||||
+ COMPREPLY=( $( compgen -W "$(quilt --quiltrc - applied 2>/dev/null)" -- $cur ) )
|
||||
;;
|
||||
--diff|-U|-C)
|
||||
;;
|
||||
@@ -171,10 +176,10 @@ _quilt_completion()
|
||||
files)
|
||||
case $prev in
|
||||
--combine)
|
||||
- COMPREPLY=( $( compgen -W "$(quilt applied 2>/dev/null)" -- $cur ) )
|
||||
+ COMPREPLY=( $( compgen -W "$(quilt --quiltrc - applied 2>/dev/null)" -- $cur ) )
|
||||
;;
|
||||
*)
|
||||
- COMPREPLY=( $( compgen -W "-a -l -v -h --combine $(quilt applied 2>/dev/null)" -- $cur ) )
|
||||
+ COMPREPLY=( $( compgen -W "-a -l -v -h --combine $(quilt --quiltrc - applied 2>/dev/null)" -- $cur ) )
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
@@ -198,7 +203,7 @@ _quilt_completion()
|
||||
COMPREPLY=( $( compgen -W "files" -- $cur ) )
|
||||
;;
|
||||
*)
|
||||
- COMPREPLY=( $( compgen -W "-T -h --all --reduce --lines --edge-labels $(quilt applied 2>/dev/null)" -- $cur ) )
|
||||
+ COMPREPLY=( $( compgen -W "-T -h --all --reduce --lines --edge-labels $(quilt --quiltrc - applied 2>/dev/null)" -- $cur ) )
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
@@ -207,7 +212,7 @@ _quilt_completion()
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "-h" -- $cur ) )
|
||||
;;
|
||||
header)
|
||||
- COMPREPLY=( $( compgen -W "-a -e -h -r --backup --strip-diffstat --strip-trailing-whitespace $(quilt series)" -- $cur ) )
|
||||
+ COMPREPLY=( $( compgen -W "-a -e -h -r --backup --strip-diffstat --strip-trailing-whitespace $(quilt --quiltrc - series)" -- $cur ) )
|
||||
;;
|
||||
import)
|
||||
case $prev in
|
||||
@@ -229,17 +234,17 @@ _quilt_completion()
|
||||
COMPREPLY=( $( compgen -W "-m --prefix --mbox --send --sender --from --subject --to --cc --bcc" -- $cur ) )
|
||||
;;
|
||||
next|previous)
|
||||
- COMPREPLY=( $( compgen -W "$(quilt series)" -- $cur ) )
|
||||
+ COMPREPLY=( $( compgen -W "$(quilt --quiltrc - series)" -- $cur ) )
|
||||
;;
|
||||
patches)
|
||||
_quilt_comfile
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "-v -h" -- $cur ) )
|
||||
;;
|
||||
pop)
|
||||
- COMPREPLY=( $( compgen -W "-a -f -R -q -v -h $(quilt applied 2>/dev/null)" -- $cur ) )
|
||||
+ COMPREPLY=( $( compgen -W "-a -f -R -q -v -h $(quilt --quiltrc - applied 2>/dev/null)" -- $cur ) )
|
||||
;;
|
||||
push)
|
||||
- COMPREPLY=( $( compgen -W "-a -f -q -v -h --leave-rejects --interactive --color $(quilt unapplied 2>/dev/null)" -- $cur ) )
|
||||
+ COMPREPLY=( $( compgen -W "-a -f -q -v -h --leave-rejects --interactive --color $(quilt --quiltrc - unapplied 2>/dev/null)" -- $cur ) )
|
||||
;;
|
||||
refresh)
|
||||
case $prev in
|
||||
@@ -249,14 +254,14 @@ _quilt_completion()
|
||||
-U|-C)
|
||||
;;
|
||||
*)
|
||||
- COMPREPLY=( $( compgen -W "-p -u -U -c -C -f -h $(quilt applied 2>/dev/null) --no-timestamps --no-index --diffstat --sort --backup --strip-trailing-whitespace" -- $cur ) )
|
||||
+ COMPREPLY=( $( compgen -W "-p -u -U -c -C -f -h $(quilt --quiltrc - applied 2>/dev/null) --no-timestamps --no-index --diffstat --sort --backup --strip-trailing-whitespace" -- $cur ) )
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
remove|revert)
|
||||
case $prev in
|
||||
-P)
|
||||
- COMPREPLY=( $( compgen -W "$(quilt applied 2>/dev/null)" -- $cur ) )
|
||||
+ COMPREPLY=( $( compgen -W "$(quilt --quiltrc - applied 2>/dev/null)" -- $cur ) )
|
||||
;;
|
||||
*)
|
||||
_quilt_comfile
|
||||
@@ -267,7 +272,7 @@ _quilt_completion()
|
||||
rename)
|
||||
case $prev in
|
||||
-P)
|
||||
- COMPREPLY=( $( compgen -W "$(quilt series)" -- $cur ) )
|
||||
+ COMPREPLY=( $( compgen -W "$(quilt --quiltrc - series)" -- $cur ) )
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $( compgen -W "-P -h" -- $cur ) )
|
||||
@@ -292,7 +297,7 @@ _quilt_completion()
|
||||
COMPREPLY=( $( compgen -W "-d -h" -- $cur ) )
|
||||
;;
|
||||
unapplied)
|
||||
- COMPREPLY=( $( compgen -W "-h $(quilt series)" -- $cur ) )
|
||||
+ COMPREPLY=( $( compgen -W "-h $(quilt --quiltrc - series)" -- $cur ) )
|
||||
;;
|
||||
fork|new|top|upgrade)
|
||||
;;
|
97
quilt-boost-the-speed-of-series-applied-and-unapplied.patch
Normal file
97
quilt-boost-the-speed-of-series-applied-and-unapplied.patch
Normal file
@ -0,0 +1,97 @@
|
||||
From: Jean Delvare <jdelvare@suse.de>
|
||||
Date: Sun, 2 Mar 2014 16:29:24 +0100
|
||||
Subject: Boost the speed of the series, applied and unapplied commands
|
||||
Patch-mainline: yes
|
||||
Git-commit: e052a2d22569f56a30285716da11b4e0a1eed052
|
||||
References: bnc#872719
|
||||
|
||||
The current implementation of the series, applied and unapplied
|
||||
commands performs rather poorly, especially on large patch sets. To
|
||||
make things worse, bash completion makes use of these commands, so
|
||||
it becomes next to unusable on large patch sets.
|
||||
|
||||
Instead of looping over each patch, use the power of printf to print
|
||||
everything in one go. Performance gains on a 15k patch series are
|
||||
breathtaking:
|
||||
|
||||
series: 189.4 s -> 0.6 s
|
||||
series -v: 92.9 s -> 0.6 s
|
||||
applied: 3.5 s -> 0.1 s
|
||||
unapplied: 3.9 s -> 0.1 s
|
||||
|
||||
---
|
||||
quilt/applied.in | 5 +----
|
||||
quilt/scripts/patchfns.in | 8 ++++++++
|
||||
quilt/series.in | 9 ++++-----
|
||||
quilt/unapplied.in | 10 ++--------
|
||||
4 files changed, 15 insertions(+), 17 deletions(-)
|
||||
|
||||
--- a/quilt/applied.in
|
||||
+++ b/quilt/applied.in
|
||||
@@ -61,10 +61,7 @@ patch=$(find_applied_patch "$1") || exit
|
||||
|
||||
setup_pager
|
||||
|
||||
-for patch in $(applied_before "$patch") $patch
|
||||
-do
|
||||
- echo "$(print_patch $patch)"
|
||||
-done
|
||||
+printf "$(patch_format)\n" $(applied_before "$patch") "$patch"
|
||||
|
||||
### Local Variables:
|
||||
### mode: shell-script
|
||||
--- a/quilt/scripts/patchfns.in
|
||||
+++ b/quilt/scripts/patchfns.in
|
||||
@@ -976,6 +976,14 @@ print_patch() {
|
||||
echo -n "${QUILT_PATCHES_PREFIX:+$SUBDIR_DOWN$QUILT_PATCHES/}$1"
|
||||
}
|
||||
|
||||
+# Generate a format suitable to print patch names with printf
|
||||
+patch_format()
|
||||
+{
|
||||
+ local prefix=${QUILT_PATCHES_PREFIX:+$SUBDIR_DOWN$QUILT_PATCHES/}
|
||||
+
|
||||
+ echo -n "${prefix/\%/%%}%s"
|
||||
+}
|
||||
+
|
||||
setup_colors()
|
||||
{
|
||||
local C=diff_hdr=32:diff_add=36:diff_mod=35:diff_rem=35:diff_hunk=33:diff_ctx=35:diff_cctx=33:patch_offs=33:patch_fuzz=35:patch_fail=31:series_app=32:series_top=33:series_una=00:clear=00
|
||||
--- a/quilt/series.in
|
||||
+++ b/quilt/series.in
|
||||
@@ -40,12 +40,11 @@ cat_patches()
|
||||
{
|
||||
local color=$1 prefix=$2
|
||||
shift 2
|
||||
- local patch
|
||||
|
||||
- for patch in "$@"
|
||||
- do
|
||||
- echo "$color$prefix$(print_patch "$patch")$color_clear"
|
||||
- done
|
||||
+ if [ $# -ge 1 ]
|
||||
+ then
|
||||
+ printf "$color$prefix$(patch_format)$color_clear\n" "$@"
|
||||
+ fi
|
||||
}
|
||||
|
||||
options=`getopt -o vh --long color:: -- "$@"`
|
||||
--- a/quilt/unapplied.in
|
||||
+++ b/quilt/unapplied.in
|
||||
@@ -67,14 +67,8 @@ fi
|
||||
|
||||
setup_pager
|
||||
|
||||
-(
|
||||
- echo "$patch"
|
||||
- patches_after "$patch"
|
||||
-) \
|
||||
-| while read patch
|
||||
-do
|
||||
- echo "$(print_patch $patch)"
|
||||
-done
|
||||
+printf "$(patch_format)\n" "$patch" $(patches_after "$patch")
|
||||
+
|
||||
### Local Variables:
|
||||
### mode: shell-script
|
||||
### End:
|
28
quilt-enable-patch-wrapper-test.patch
Normal file
28
quilt-enable-patch-wrapper-test.patch
Normal file
@ -0,0 +1,28 @@
|
||||
From: Jean Delvare <jdelvare@suse.de>
|
||||
Date: Wed, 16 Apr 2014 11:44:55 +0200
|
||||
Subject: Re-enable patch-wrapper test
|
||||
Patch-mainline: yes
|
||||
Git-commit: 293c4ddbf61f69a5cfb3a71f89cb3e48d3ccda7e
|
||||
References: bnc#872719
|
||||
|
||||
The patch-wrapper test was unconditionally disabled by commit
|
||||
97200435 ("Only run test/patch-wrapper.test if the
|
||||
--with-patch-wrapper config option is used.") Re-enable this test
|
||||
when the --with-patch-wrapper config option is actually used.
|
||||
|
||||
---
|
||||
Makefile.in | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
--- a/Makefile.in
|
||||
+++ b/Makefile.in
|
||||
@@ -120,6 +120,9 @@ NON_EXEC_IN := doc/quilt.1 doc/README qu
|
||||
GIT_DESC := $(shell ./git-desc | sed -e 's:^v::')
|
||||
|
||||
TESTS := $(filter-out test/patch-wrapper.test,$(wildcard test/*.test))
|
||||
+ifneq ($(PATCH_WRAPPER),)
|
||||
+TESTS += test/patch-wrapper.test
|
||||
+endif
|
||||
DIRT += test/.depend $(wildcard test/.*.ok)
|
||||
|
||||
# Settings for running the uninstalled version of quilt in the source tree:
|
37
quilt-files-return-nothing-if-there-are-no-files.patch
Normal file
37
quilt-files-return-nothing-if-there-are-no-files.patch
Normal file
@ -0,0 +1,37 @@
|
||||
From: Jean Delvare <jdelvare@suse.de>
|
||||
Date: Fri, 14 Feb 2014 15:52:57 +0100
|
||||
Subject: files: Return nothing if there are no files
|
||||
Patch-mainline: yes
|
||||
Git-commit: 4d8358ae52ce574920c7f3aba7453f305fabf1ba
|
||||
References: bnc#872719
|
||||
|
||||
"quilt files" returns a blank line if no files are included in the
|
||||
patch. This could easily break constructs such as "quilt files | wc
|
||||
-l". Let "quilt files" return nothing at all if there are no files in
|
||||
the patch.
|
||||
|
||||
diff --git a/quilt/files.in b/quilt/files.in
|
||||
index 6e107ee..355fa21 100644
|
||||
--- a/quilt/files.in
|
||||
+++ b/quilt/files.in
|
||||
@@ -128,7 +128,7 @@ list_files_in_patch()
|
||||
fi
|
||||
# Note: If opt_labels is set, then use_status is not set.
|
||||
IFS=
|
||||
- echo $(files_in_patch "$patch") |
|
||||
+ files_in_patch "$patch" |
|
||||
sort |
|
||||
while read file
|
||||
do
|
||||
diff --git a/test/example1.test b/test/example1.test
|
||||
index ec73b81..7eaa228 100644
|
||||
--- a/test/example1.test
|
||||
+++ b/test/example1.test
|
||||
@@ -12,6 +12,7 @@ http://the-tech.mit.edu/Shakespeare/midsummer/full.html
|
||||
$ quilt new flower.diff
|
||||
> Patch %{P}flower.diff is now on top
|
||||
|
||||
+ $ quilt files
|
||||
$ quilt add Oberon.txt
|
||||
> File Oberon.txt added to patch %{P}flower.diff
|
||||
|
26
quilt-fix-quilt-diff-z-on-files-with-spaces-in-name.patch
Normal file
26
quilt-fix-quilt-diff-z-on-files-with-spaces-in-name.patch
Normal file
@ -0,0 +1,26 @@
|
||||
From: Jean Delvare <jdelvare@suse.de>
|
||||
Date: Mon, 10 Feb 2014 13:11:34 +0100
|
||||
Subject: patchfns: Fix "quilt diff -z" on files with spaces in their names
|
||||
Patch-mainline: yes
|
||||
Git-commit: 6051b9347f59f761ef744cb7cc813d5eadd86b55
|
||||
References: bnc#872719
|
||||
|
||||
Before this fix, "quilt diff -z" would fail on files with spaces in
|
||||
their names, with the following error message:
|
||||
Failed to copy files to temporary directory
|
||||
|
||||
---
|
||||
quilt/scripts/patchfns.in | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/quilt/scripts/patchfns.in
|
||||
+++ b/quilt/scripts/patchfns.in
|
||||
@@ -887,7 +887,7 @@ apply_patch_temporarily()
|
||||
local prefix=$QUILT_PC/$patch/
|
||||
[ ${prefix:0:1} == / ] || prefix=$PWD/$prefix
|
||||
if ! ( cd $workdir && \
|
||||
- $QUILT_DIR/scripts/backup-files -B $prefix -r -k -s ${@:--} )
|
||||
+ $QUILT_DIR/scripts/backup-files -B $prefix -r -k -s "${@:--}" )
|
||||
then
|
||||
printf $"Failed to copy files to temporary directory\n" >&2
|
||||
return 1
|
@ -0,0 +1,80 @@
|
||||
From: Jean Delvare <jdelvare@suse.de>
|
||||
Date: Wed, 9 Apr 2014 10:17:09 +0200
|
||||
Subject: patches: Fix heuristic for unapplied patches with timestamps
|
||||
Patch-mainline: yes
|
||||
Git-commit: 6c8254913549bea07fe62124324a68af773188f8
|
||||
References: bnc#872719
|
||||
|
||||
The heuristic to find file names in unapplied patches fails miserably
|
||||
on all patches with timestamps. We have to consider everything past
|
||||
the last tab as the timestamp and strip it. The timestamp itself will
|
||||
contain spaces so we can't split on that.
|
||||
|
||||
This fixes a regression introduced by commit 4df47975. It's hard to
|
||||
believe this has been broken for over 4 years and nobody ever noticed.
|
||||
|
||||
---
|
||||
quilt/patches.in | 2 +-
|
||||
test/timestamps.test | 46 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 47 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/quilt/patches.in
|
||||
+++ b/quilt/patches.in
|
||||
@@ -74,7 +74,7 @@ touched_by_patch()
|
||||
| awk '
|
||||
/^(\+\+\+|---)[ \t]/ {
|
||||
sub(/^(\+\+\+|---)[ \t]/, "")
|
||||
- sub(/[ \t][^ \t]*$/, "")
|
||||
+ sub(/\t[^\t]*$/, "")
|
||||
sub(/^\/dev\/null/, "")
|
||||
for (i=0; i<'$strip'; i++)
|
||||
sub(/^[^\/]*\//, "")
|
||||
--- /dev/null
|
||||
+++ b/test/timestamps.test
|
||||
@@ -0,0 +1,46 @@
|
||||
+# Test how quilt behaves when patches include timestamps
|
||||
+
|
||||
+$ mkdir patches
|
||||
+
|
||||
+$ cat > patches/series
|
||||
+< unified-create.patch
|
||||
+< unified-update.patch
|
||||
+< unified-delete.patch
|
||||
+
|
||||
+$ cat > patches/unified-create.patch
|
||||
+< diff -ruN a/file b/file
|
||||
+< --- a/file 1970-01-01 01:00:00.000000000 +0100
|
||||
+< +++ b/file 2014-01-15 11:19:43.000000000 +0100
|
||||
+< @@ -0,0 +1 @@
|
||||
+< +new line
|
||||
+
|
||||
+$ cat > patches/unified-update.patch
|
||||
+< diff -ruN a/file b/file
|
||||
+< --- a/file 2014-01-15 11:19:43.000000000 +0100
|
||||
+< +++ b/file 2014-01-15 11:20:17.000000000 +0100
|
||||
+< @@ -1 +1 @@
|
||||
+< -new line
|
||||
+< +updated line
|
||||
+
|
||||
+$ cat > patches/unified-delete.patch
|
||||
+< diff -ruN a/file b/file
|
||||
+< --- a/file 2014-01-15 11:20:17.000000000 +0100
|
||||
+< +++ b/file 1970-01-01 01:00:00.000000000 +0100
|
||||
+< @@ -1 +0,0 @@
|
||||
+< -updated line
|
||||
+
|
||||
+$ quilt patches file
|
||||
+> patches/unified-create.patch
|
||||
+> patches/unified-update.patch
|
||||
+> patches/unified-delete.patch
|
||||
+
|
||||
+$ quilt push -qa
|
||||
+> Applying patch patches/unified-create.patch
|
||||
+> Applying patch patches/unified-update.patch
|
||||
+> Applying patch patches/unified-delete.patch
|
||||
+> Now at patch patches/unified-delete.patch
|
||||
+
|
||||
+$ quilt patches file
|
||||
+> patches/unified-create.patch
|
||||
+> patches/unified-update.patch
|
||||
+> patches/unified-delete.patch
|
59
quilt-patches-optimize-processing-of-unapplied-patches.patch
Normal file
59
quilt-patches-optimize-processing-of-unapplied-patches.patch
Normal file
@ -0,0 +1,59 @@
|
||||
From: Jean Delvare <jdelvare@suse.de>
|
||||
Date: Sat, 15 Feb 2014 18:43:41 +0100
|
||||
Subject: patches: Optimize processing of unapplied patches
|
||||
Patch-mainline: yes
|
||||
Git-commit: 1b95644e3a00f07a6711c881d2dcdac14206a57e
|
||||
References: bnc#872719
|
||||
|
||||
* Don't check for $strip = ab twice, once is enough.
|
||||
* Quote the file names to be suitable in regular expressions only
|
||||
once, instead of doing it again for every patch. This fixes a
|
||||
performance regression introduced in 8ebb056d ("patches: Add
|
||||
support for multiple files"), sorry about that.
|
||||
|
||||
These two simple changes bring a huge performance boost on unapplied
|
||||
patches, of about 50% in the single file case and growing as you add
|
||||
files.
|
||||
|
||||
diff --git a/quilt/patches.in b/quilt/patches.in
|
||||
index 3f3caed..6ec5e01 100644
|
||||
--- a/quilt/patches.in
|
||||
+++ b/quilt/patches.in
|
||||
@@ -70,7 +70,6 @@ scan_applied()
|
||||
touched_by_patch()
|
||||
{
|
||||
local strip=$1 patch=$2
|
||||
- [ $strip = ab ] && strip=1
|
||||
cat_file $(patch_file_name $patch) \
|
||||
| awk '
|
||||
/^(\+\+\+|---)[ \t]/ {
|
||||
@@ -89,7 +88,14 @@ scan_unapplied()
|
||||
{
|
||||
local color=$1 prefix=$2 strip
|
||||
shift 2
|
||||
- local patch file file_bre match
|
||||
+ local patch file match
|
||||
+ local -a files_bre
|
||||
+
|
||||
+ # Quote each file name only once
|
||||
+ for file in "${opt_files[@]}"
|
||||
+ do
|
||||
+ files_bre[${#files_bre[@]}]=$(quote_bre "$file")
|
||||
+ done
|
||||
|
||||
for patch in "$@"
|
||||
do
|
||||
@@ -97,11 +103,10 @@ scan_unapplied()
|
||||
[ "$strip" = ab ] && strip=1
|
||||
|
||||
match=
|
||||
- for file in "${opt_files[@]}"
|
||||
+ for file in "${files_bre[@]}"
|
||||
do
|
||||
- file_bre="$(quote_bre "$file")"
|
||||
if touched_by_patch $strip $patch \
|
||||
- | grep -q "^$file_bre\$"
|
||||
+ | grep -q "^$file\$"
|
||||
then
|
||||
match=1
|
||||
break
|
85
quilt-patches-optimize-the-multiple-files-case.patch
Normal file
85
quilt-patches-optimize-the-multiple-files-case.patch
Normal file
@ -0,0 +1,85 @@
|
||||
From: Jean Delvare <jdelvare@suse.de>
|
||||
Date: Sat, 15 Feb 2014 18:43:48 +0100
|
||||
Subject: patches: Optimize the multiple files case
|
||||
Patch-mainline: yes
|
||||
Git-commit: aadae7a30499c318ae18cb6b216f1d7fe60e49b7
|
||||
References: bnc#872719
|
||||
|
||||
I didn't put too many thoughts when adding support for multiple files
|
||||
to the "patches" command. The nested loop approach turns out to be
|
||||
very inefficient for unapplied patches.
|
||||
|
||||
Get rid of the innermost loop by building a single pattern matching
|
||||
all filenames at once. That way, performance no longer depends on the
|
||||
number of files (as far as unapplied patches are concerned.)
|
||||
|
||||
diff --git a/quilt/patches.in b/quilt/patches.in
|
||||
index 6ec5e01..89c5b86 100644
|
||||
--- a/quilt/patches.in
|
||||
+++ b/quilt/patches.in
|
||||
@@ -88,7 +88,7 @@ scan_unapplied()
|
||||
{
|
||||
local color=$1 prefix=$2 strip
|
||||
shift 2
|
||||
- local patch file match
|
||||
+ local patch file
|
||||
local -a files_bre
|
||||
|
||||
# Quote each file name only once
|
||||
@@ -97,23 +97,19 @@ scan_unapplied()
|
||||
files_bre[${#files_bre[@]}]=$(quote_bre "$file")
|
||||
done
|
||||
|
||||
+ # "Or" all files in a single pattern
|
||||
+ file=\\\($(array_join \\\| "${files_bre[@]}")\\\)
|
||||
+
|
||||
for patch in "$@"
|
||||
do
|
||||
strip=$(patch_strip_level $patch)
|
||||
[ "$strip" = ab ] && strip=1
|
||||
|
||||
- match=
|
||||
- for file in "${files_bre[@]}"
|
||||
- do
|
||||
- if touched_by_patch $strip $patch \
|
||||
- | grep -q "^$file\$"
|
||||
- then
|
||||
- match=1
|
||||
- break
|
||||
- fi
|
||||
- done
|
||||
-
|
||||
- [ -z "$match" ] || echo "$color$prefix$(print_patch $patch)$color_clear"
|
||||
+ if touched_by_patch $strip "$patch" \
|
||||
+ | grep -q "^$file\$"
|
||||
+ then
|
||||
+ echo "$color$prefix$(print_patch $patch)$color_clear"
|
||||
+ fi
|
||||
done
|
||||
}
|
||||
|
||||
diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in
|
||||
index 42e8de8..e00c819 100644
|
||||
--- a/quilt/scripts/patchfns.in
|
||||
+++ b/quilt/scripts/patchfns.in
|
||||
@@ -76,6 +76,20 @@ trap run_exit_handlers EXIT
|
||||
|
||||
# ========================================================
|
||||
|
||||
+# Join multiple stings using the given separator.
|
||||
+array_join()
|
||||
+{
|
||||
+ local sep=$1 str=$2
|
||||
+ shift 2
|
||||
+
|
||||
+ printf %s "$str"
|
||||
+
|
||||
+ for str in "$@"
|
||||
+ do
|
||||
+ printf %s%s "$sep" "$str"
|
||||
+ done
|
||||
+}
|
||||
+
|
||||
# Quote a string for use in a basic regular expression.
|
||||
quote_bre()
|
||||
{
|
23
quilt-refresh-fix-error-message.patch
Normal file
23
quilt-refresh-fix-error-message.patch
Normal file
@ -0,0 +1,23 @@
|
||||
From: Jean Delvare <jdelvare@suse.de>
|
||||
Date: Thu, 6 Feb 2014 08:50:34 +0100
|
||||
Subject: refresh: Fix error message
|
||||
Patch-mainline: yes
|
||||
Git-commit: 5df0d39bcd087190fe414bef9a7e4055c941bc76
|
||||
References: bnc#872719
|
||||
|
||||
The message was not updated when support for -pab was added.
|
||||
|
||||
diff --git a/quilt/refresh.in b/quilt/refresh.in
|
||||
index 97b81a6..41d43a7 100644
|
||||
--- a/quilt/refresh.in
|
||||
+++ b/quilt/refresh.in
|
||||
@@ -199,7 +199,8 @@ ab)
|
||||
num_strip_level=1
|
||||
;;
|
||||
*)
|
||||
- printf $"Cannot refresh patches with -p%s, please specify -p0 or -p1 instead\n" "$opt_strip_level" >&2
|
||||
+ printf $"Cannot refresh patches with -p%s, please specify -p0, -p1, or -pab instead\n" \
|
||||
+ "$opt_strip_level" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
18
quilt.spec
18
quilt.spec
@ -44,6 +44,15 @@ Patch2: quilt-support-vimdiff.patch
|
||||
Patch3: patch-wrapper-rpm.diff
|
||||
Patch4: setup-check-for-rpmbuild.patch
|
||||
Patch5: suse-workaround-pseudo-release.patch
|
||||
Patch6: quilt-bash_completion-fix-completion-of-patch-names.patch
|
||||
Patch7: quilt-refresh-fix-error-message.patch
|
||||
Patch8: quilt-fix-quilt-diff-z-on-files-with-spaces-in-name.patch
|
||||
Patch9: quilt-files-return-nothing-if-there-are-no-files.patch
|
||||
Patch10: quilt-patches-optimize-processing-of-unapplied-patches.patch
|
||||
Patch11: quilt-patches-optimize-the-multiple-files-case.patch
|
||||
Patch12: quilt-boost-the-speed-of-series-applied-and-unapplied.patch
|
||||
Patch13: quilt-patches-fix-heuristic-for-unapplied-patches-with-timestamps.patch
|
||||
Patch14: quilt-enable-patch-wrapper-test.patch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildArch: noarch
|
||||
Recommends: procmail
|
||||
@ -68,6 +77,15 @@ http://www.zip.com.au/~akpm/linux/patches/.
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
%patch5 -p1
|
||||
%patch6 -p1
|
||||
%patch7 -p1
|
||||
%patch8 -p1
|
||||
%patch9 -p1
|
||||
%patch10 -p1
|
||||
%patch11 -p1
|
||||
%patch12 -p1
|
||||
%patch13 -p1
|
||||
%patch14 -p1
|
||||
|
||||
%build
|
||||
# --with-rpmbuild=/usr/lib/rpm/rpmb:
|
||||
|
Loading…
Reference in New Issue
Block a user