summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2018-12-09 23:06:29 +0100
committerGuillem Jover <guillem@debian.org>2019-01-15 03:42:39 +0100
commite326eda15c84d0456aa2e1c22c996e89ef6c40f2 (patch)
tree9d62a7f97c92ff2a760ecbc3e958b33ae9c8c0c5
parent1fa3e4360b4ebadef4f0f486fb4a029e6bbdc705 (diff)
downloaddpkg-e326eda15c84d0456aa2e1c22c996e89ef6c40f2.tar.gz
Dpkg::Changelog::Debian: Preserve modelines at EOF
We should keep these and consider them as pseudo-EOF markers, and stop processing once seen. [lamby@debian.org: - Initial test cases for dpkg-mergechangelogs functional tests. ] Closes: #916056
-rw-r--r--debian/changelog3
-rw-r--r--man/deb-changelog.man10
-rw-r--r--man/dpkg-mergechangelogs.man4
-rw-r--r--scripts/Dpkg/Changelog/Debian.pm8
-rw-r--r--scripts/Makefile.am1
-rw-r--r--scripts/t/Dpkg_Changelog.t8
-rw-r--r--scripts/t/Dpkg_Changelog/stop-modeline13
-rw-r--r--scripts/t/merge_changelogs/ch-a2
-rw-r--r--scripts/t/merge_changelogs/ch-b2
-rw-r--r--scripts/t/merge_changelogs/ch-merged2
-rw-r--r--scripts/t/merge_changelogs/ch-merged-basic2
-rw-r--r--scripts/t/merge_changelogs/ch-merged-pr2
-rw-r--r--scripts/t/merge_changelogs/ch-merged-pr-basic2
-rw-r--r--scripts/t/merge_changelogs/ch-old2
14 files changed, 50 insertions, 11 deletions
diff --git a/debian/changelog b/debian/changelog
index 14970a692..9a6e7a47d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,9 @@
dpkg (1.19.3) UNRELEASED; urgency=medium
[ Guillem Jover ]
+ * Perl modules:
+ - Dpkg::Changelog::Debian: Preserve modelines at EOF. Closes: #916056
+ Thanks to Chris Lamb <lamby@debian.org> for initial test cases.
* Documentation:
- dpkg(1): Clarify --remove action. Closes: #914478
- dpkg-query(1): Clarify --list option behavior when no arguments are
diff --git a/man/deb-changelog.man b/man/deb-changelog.man
index 6aaa5d2cf..c4485e045 100644
--- a/man/deb-changelog.man
+++ b/man/deb-changelog.man
@@ -142,12 +142,12 @@ The maintainer details and the date must be separated by exactly two
spaces.
.PP
Any line that consists entirely (i.e., no leading whitespace) of \fB#\fP
-or \fB/* */\fP style comments, RCS keywords, Vim modelines or Emacs local
-variables should be ignored.
+or \fB/* */\fP style comments or RCS keywords.
.PP
-Ancient changelog entries with other formats at the end of the file should
-be accepted and preserved on output, but their contents might be otherwise
-ignored and parsing stopped at that point.
+Vim modelines or Emacs local variables, and ancient changelog entries with
+other formats at the end of the file should be accepted and preserved on
+output, but their contents might be otherwise ignored and parsing stopped
+at that point.
.PP
The entire changelog must be encoded in UTF-8.
.SH FILES
diff --git a/man/dpkg-mergechangelogs.man b/man/dpkg-mergechangelogs.man
index 9cda23ef0..4d6159c02 100644
--- a/man/dpkg-mergechangelogs.man
+++ b/man/dpkg-mergechangelogs.man
@@ -75,8 +75,8 @@ The accepted values are: \fB0\fP and \fB1\fP (default).
.SH LIMITATIONS
.P
Anything that is not parsed by Dpkg::Changelog is lost during the merge.
-This might include stuff like Vim modelines, Emacs variables, comments
-which were not supposed to be there, etc.
+This might include stuff like comments which were not supposed to be
+there, etc.
.
.SH INTEGRATION WITH GIT
.P
diff --git a/scripts/Dpkg/Changelog/Debian.pm b/scripts/Dpkg/Changelog/Debian.pm
index a44ac666c..937acb5e0 100644
--- a/scripts/Dpkg/Changelog/Debian.pm
+++ b/scripts/Dpkg/Changelog/Debian.pm
@@ -162,9 +162,13 @@ sub parse {
$expect= START_CHANGES;
@blanklines = ();
} elsif (m/^(?:;;\s*)?Local variables:/io) {
- last; # skip Emacs variables at end of file
+ # Save any trailing Emacs variables at end of file.
+ $self->set_unparsed_tail("$_\n" . (file_slurp($fh) // ''));
+ last;
} elsif (m/^vim:/io) {
- last; # skip Vim modelines at end of file
+ # Save any trailing Vim modelines at end of file.
+ $self->set_unparsed_tail("$_\n" . (file_slurp($fh) // ''));
+ last;
} elsif (m/^\$\w+:.*\$/o) {
next; # skip stuff that look like a RCS keyword
} elsif (m/^\# /o) {
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index d7bd8d2f7..d68560173 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -311,6 +311,7 @@ test_data = \
t/Dpkg_Changelog/misplaced-tz \
t/Dpkg_Changelog/regressions \
t/Dpkg_Changelog/shadow \
+ t/Dpkg_Changelog/stop-modeline \
t/Dpkg_Changelog/unreleased \
t/Dpkg_Checksums/empty \
t/Dpkg_Checksums/data-1 \
diff --git a/scripts/t/Dpkg_Changelog.t b/scripts/t/Dpkg_Changelog.t
index 8aa1bfc45..f487ff560 100644
--- a/scripts/t/Dpkg_Changelog.t
+++ b/scripts/t/Dpkg_Changelog.t
@@ -16,7 +16,7 @@
use strict;
use warnings;
-use Test::More tests => 96;
+use Test::More tests => 102;
use Test::Dpkg qw(:paths);
use File::Basename;
@@ -36,7 +36,7 @@ my $vendor = get_current_vendor();
#########################
foreach my $file ("$datadir/countme", "$datadir/shadow", "$datadir/fields",
- "$datadir/regressions", "$datadir/date-format") {
+ "$datadir/regressions", "$datadir/date-format", "$datadir/stop-modeline") {
my $changes = Dpkg::Changelog::Debian->new(verbose => 0);
$changes->load($file);
@@ -346,6 +346,10 @@ Xb-Userfield2: foobar
is($data[2]->get_timestamp(), 'Mon, 01 Jan 2000 00:00:00 +0000',
'get date w/ DoW, and zero timezone offset');
}
+ if ($file eq "$datadir/stop-modeline") {
+ is($changes->get_unparsed_tail(), "vim: et\n",
+ 'get unparsed modeline at EOF');
+ }
if ($file eq "$datadir/regressions") {
my $f = ($changes->format_range('dpkg'))[0];
is("$f->{Version}", '0', 'version 0 correctly parsed');
diff --git a/scripts/t/Dpkg_Changelog/stop-modeline b/scripts/t/Dpkg_Changelog/stop-modeline
new file mode 100644
index 000000000..5b8a7b438
--- /dev/null
+++ b/scripts/t/Dpkg_Changelog/stop-modeline
@@ -0,0 +1,13 @@
+modeline (2.0-1) unstable; urgency=low
+
+ * Upload.
+
+ -- Dpkg Developers <debian-dpkg@lists.debian.org> Tue, 4 Oct 2005 01:49:05 +0200
+
+modeline (1.0-1) unstable; urgency=low
+
+ * Upload.
+
+ -- Dpkg Developers <debian-dpkg@lists.debian.org> Tue, 4 Oct 2005 01:48:05 +0200
+
+vim: et
diff --git a/scripts/t/merge_changelogs/ch-a b/scripts/t/merge_changelogs/ch-a
index 02dad9397..ff5419d8d 100644
--- a/scripts/t/merge_changelogs/ch-a
+++ b/scripts/t/merge_changelogs/ch-a
@@ -90,3 +90,5 @@ test (1.0-1) unstable; urgency=low
* Initial release. (Closes: #XXXXXX)
-- Raphaël Hertzog <hertzog@debian.org> Sun, 18 Apr 2010 17:37:46 +0200
+
+vim: et
diff --git a/scripts/t/merge_changelogs/ch-b b/scripts/t/merge_changelogs/ch-b
index 9eb78699b..a74145f82 100644
--- a/scripts/t/merge_changelogs/ch-b
+++ b/scripts/t/merge_changelogs/ch-b
@@ -85,3 +85,5 @@ test (1.0-1) unstable; urgency=low
* Initial release. (Closes: #XXXXXX)
-- Raphaël Hertzog <hertzog@debian.org> Sun, 18 Apr 2010 17:37:46 +0200
+
+vim: et
diff --git a/scripts/t/merge_changelogs/ch-merged b/scripts/t/merge_changelogs/ch-merged
index c995f1cf9..29a985d16 100644
--- a/scripts/t/merge_changelogs/ch-merged
+++ b/scripts/t/merge_changelogs/ch-merged
@@ -111,3 +111,5 @@ test (1.0-1) unstable; urgency=low
* Initial release. (Closes: #XXXXXX)
-- Raphaël Hertzog <hertzog@debian.org> Sun, 18 Apr 2010 17:37:46 +0200
+
+vim: et
diff --git a/scripts/t/merge_changelogs/ch-merged-basic b/scripts/t/merge_changelogs/ch-merged-basic
index 6b054c353..f89fe1123 100644
--- a/scripts/t/merge_changelogs/ch-merged-basic
+++ b/scripts/t/merge_changelogs/ch-merged-basic
@@ -134,3 +134,5 @@ test (1.0-1) unstable; urgency=low
* Initial release. (Closes: #XXXXXX)
-- Raphaël Hertzog <hertzog@debian.org> Sun, 18 Apr 2010 17:37:46 +0200
+
+vim: et
diff --git a/scripts/t/merge_changelogs/ch-merged-pr b/scripts/t/merge_changelogs/ch-merged-pr
index 467211c80..a58f09779 100644
--- a/scripts/t/merge_changelogs/ch-merged-pr
+++ b/scripts/t/merge_changelogs/ch-merged-pr
@@ -104,3 +104,5 @@ test (1.0-1) unstable; urgency=low
* Initial release. (Closes: #XXXXXX)
-- Raphaël Hertzog <hertzog@debian.org> Sun, 18 Apr 2010 17:37:46 +0200
+
+vim: et
diff --git a/scripts/t/merge_changelogs/ch-merged-pr-basic b/scripts/t/merge_changelogs/ch-merged-pr-basic
index 61f46cd69..773361253 100644
--- a/scripts/t/merge_changelogs/ch-merged-pr-basic
+++ b/scripts/t/merge_changelogs/ch-merged-pr-basic
@@ -136,3 +136,5 @@ test (1.0-1) unstable; urgency=low
* Initial release. (Closes: #XXXXXX)
-- Raphaël Hertzog <hertzog@debian.org> Sun, 18 Apr 2010 17:37:46 +0200
+
+vim: et
diff --git a/scripts/t/merge_changelogs/ch-old b/scripts/t/merge_changelogs/ch-old
index 12ee224c1..5ff7dd366 100644
--- a/scripts/t/merge_changelogs/ch-old
+++ b/scripts/t/merge_changelogs/ch-old
@@ -83,3 +83,5 @@ test (1.0-1) unstable; urgency=low
* Initial release. (Closes: #XXXXXX)
-- Raphaël Hertzog <hertzog@debian.org> Sun, 18 Apr 2010 17:37:46 +0200
+
+vim: et