[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [PATCH v3] Check for series file consistency
From: |
Jean Delvare |
Subject: |
[Quilt-dev] [PATCH v3] Check for series file consistency |
Date: |
Tue, 14 Oct 2014 11:14:51 +0200 |
Quilt allows manual changes to the series file to some degree. For
example, adding comments or reordering patches in the unapplied
section of the series file is OK. However, changing the order of
applied patches breaks a number of assumptions and can cause quilt to
produce unexpected or confusing results.
For example, starting from this:
+ patches/01.patch
= patches/02.patch
patches/03.patch
patches/04.patch
and moving the last patch at the beginning of the series file,
"quilt series -v" will print:
+ patches/04.patch
+ patches/01.patch
= patches/02.patch
patches/03.patch
That is, it will claim that 04.patch is applied, while it it not.
Likewise, 04.patch would be listed by neither "quilt applied" nor
"quilt unapplied".
While addressing all such cases would certainly be possible, that
would require a significant amount of work, and would come with
performance penalties. It would also be difficult to be certain that
all issues have been found and addressed. So it seems more reasonable
to simply spot such manual changes to the series file and ask the user
to pop all patches to start from a clean state as needed.
---
Changed since v2:
* Skip further tests if $DB is empty.
* Made the warning message shorter.
quilt/scripts/patchfns.in | 35 ++++++++++++++++++++++++++++++++---
test/altered-series.test | 44 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 76 insertions(+), 3 deletions(-)
--- quilt.orig/quilt/scripts/patchfns.in 2014-10-14 09:29:34.525928263
+0200
+++ quilt/quilt/scripts/patchfns.in 2014-10-14 10:35:51.371949210 +0200
@@ -953,6 +953,24 @@ version_check()
return 1
}
+consistency_check()
+{
+ local top applied patches
+
+ top=$(top_patch)
+ applied=$(applied_before "$top")
+ patches=$(patches_before "$top")
+
+ if [ "$applied" != "$patches" ]
+ then
+ return 1
+ else
+ # Skip check until series file is modified again
+ touch "$DB"
+ return 0
+ fi
+}
+
print_patch()
{
echo "${QUILT_PATCHES_PREFIX:+$SUBDIR_DOWN$QUILT_PATCHES/}$1"
@@ -1114,10 +1132,21 @@ fi
DB="$QUILT_PC/applied-patches"
-if [ -z "$skip_version_check" ] && ! version_check
+if [ -z "$skip_version_check" ]
then
- printf $"The working tree was created by an older version of quilt.
Please run 'quilt upgrade'.\n" >&2
- exit 1
+ if ! version_check
+ then
+ printf $"The working tree was created by an older version of
quilt. Please run 'quilt upgrade'.\n" >&2
+ exit 1
+ fi
+
+ # Check if series file was modified manually, and if this is the case,
+ # make sure it is still consistent with the applied patches
+ if [ -s "$DB" -a ! "$DB" -nt "$SERIES" ] && [ "$QUILT_COMMAND" != pop ]
&& ! consistency_check
+ then
+ printf $"The series file no longer matches the applied patches.
Please run 'quilt pop -a'.\n" >&2
+ exit 1
+ fi
fi
### Local Variables:
### mode: shell-script
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ quilt/test/altered-series.test 2014-10-14 09:51:33.419153109 +0200
@@ -0,0 +1,44 @@
+# Check that manual changes to the series file are detected
+
+$ mkdir patches
+$ cat > patches/series
+< 01.patch
+< 02.patch
+< 03.patch
+
+$ quilt push -q
+> Applying patch patches/01.patch
+> Patch patches/01.patch does not exist; applied empty patch
+> Now at patch patches/01.patch
+
+$ quilt series -v
+> = patches/01.patch
+> patches/02.patch
+> patches/03.patch
+
+# Touch the series file but preserve the order -> OK
+$ touch patches/series
+
+$ quilt series -v
+> = patches/01.patch
+> patches/02.patch
+> patches/03.patch
+
+# Change the order of the patch series -> complain
+$ cat > patches/series
+< 03.patch
+< 01.patch
+< 02.patch
+
+$ quilt series -v
+> The series file no longer matches the applied patches. Please run 'quilt pop
-a'.
+
+$ quilt pop -a
+> Patch patches/01.patch appears to be empty, removing
+>
+> No patches applied
+
+$ quilt series -v
+> patches/03.patch
+> patches/01.patch
+> patches/02.patch
--
Jean Delvare
SUSE L3 Support
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Quilt-dev] [PATCH v3] Check for series file consistency,
Jean Delvare <=