189
191
if ($opts{'use_dev_null'}) {
190
192
$label_old = $old_file if $old_file eq '/dev/null';
192
my $success = $self->add_diff_file($old_file, "$new/$fn",
193
label_old => $label_old,
194
label_new => "$basedir/$fn",
197
if ($success and ($old_file eq "/dev/null")) {
199
warning(_g("newly created empty file '%s' will not " .
200
"be represented in diff"), $fn);
202
if ($mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
203
warning(_g("executable mode %04o of '%s' will " .
204
"not be represented in diff"), $mode, $fn)
205
unless $fn eq 'debian/rules';
207
if ($mode & (S_ISUID | S_ISGID | S_ISVTX)) {
208
warning(_g("special mode %04o of '%s' will not " .
209
"be represented in diff"), $mode, $fn);
194
push @diff_files, [$fn, $mode, $size, $old_file, "$new/$fn",
195
$label_old, "$basedir/$fn"];
214
197
unless (-p "$old/$fn") {
215
198
$self->_fail_not_same_type("$old/$fn", "$new/$fn");
235
218
lstat("$old/$fn") || syserr(_g("cannot stat file %s"), "$old/$fn");
237
220
if ($inc_removal) {
238
$self->add_diff_file("$old/$fn", "/dev/null",
239
label_old => "$basedir.orig/$fn",
240
label_new => "/dev/null",
221
push @diff_files, [$fn, 0, 0, "$old/$fn", "/dev/null",
222
"$basedir.orig/$fn", "/dev/null"];
243
224
warning(_g("ignoring deletion of file %s"), $fn);
254
235
find({ wanted => $scan_new, no_chdir => 1 }, $new);
255
236
find({ wanted => $scan_old, no_chdir => 1 }, $old);
238
if ($opts{"order_from"} and -e $opts{"order_from"}) {
239
my $order_from = Dpkg::Source::Patch->new(
240
filename => $opts{"order_from"});
241
my $analysis = $order_from->analyze($basedir, verbose => 0);
244
foreach my $fn (@{$analysis->{"patchorder"}}) {
246
$patchorder{$fn} = $i++;
248
# 'quilt refresh' sorts files as follows:
249
# - Any files in the existing patch come first, in the order in
250
# which they appear in the existing patch.
251
# - New files follow, sorted lexicographically.
252
# This seems a reasonable policy to follow, and avoids autopatches
253
# being shuffled when they are regenerated.
254
foreach my $diff_file (sort { $a->[0] cmp $b->[0] } @diff_files) {
255
my $fn = $diff_file->[0];
256
$patchorder{$fn} = $i++ unless exists $patchorder{$fn};
258
@diff_files = sort { $patchorder{$a->[0]} <=> $patchorder{$b->[0]} }
262
foreach my $diff_file (@diff_files) {
263
my ($fn, $mode, $size,
264
$old_file, $new_file, $label_old, $label_new) = @$diff_file;
265
my $success = $self->add_diff_file($old_file, $new_file,
266
label_old => $label_old,
267
label_new => $label_new, %opts);
269
$old_file eq "/dev/null" and $new_file ne "/dev/null") {
271
warning(_g("newly created empty file '%s' will not " .
272
"be represented in diff"), $fn);
274
if ($mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
275
warning(_g("executable mode %04o of '%s' will " .
276
"not be represented in diff"), $mode, $fn)
277
unless $fn eq 'debian/rules';
279
if ($mode & (S_ISUID | S_ISGID | S_ISVTX)) {
280
warning(_g("special mode %04o of '%s' will not " .
281
"be represented in diff"), $mode, $fn);
394
426
} elsif ($path{'new'} eq '/dev/null') {
395
427
error(_g("file removal without proper filename in diff `%s' (line %d)"),
396
428
$diff, $. - 1) unless defined $fn{'old'};
397
warning(_g("diff %s removes a non-existing file %s (line %d)"),
398
$diff, $fn{'old'}, $.) unless -e $fn{'old'};
429
if ($opts{"verbose"}) {
430
warning(_g("diff %s removes a non-existing file %s (line %d)"),
431
$diff, $fn{'old'}, $.) unless -e $fn{'old'};
400
434
my $fn = intuit_file_patched($fn{'old'}, $fn{'new'});
411
445
if ($filepatched{$fn}) {
412
error(_g("diff `%s' patches file %s twice"), $diff, $fn);
446
warning(_g("diff `%s' patches file %s twice"), $diff, $fn)
449
$filepatched{$fn} = 1;
450
push @patchorder, $fn;
414
$filepatched{$fn} = 1;
418
455
while (defined($_ = getline($self))) {
419
456
# read hunk header (@@)
420
next if /^\\ No newline/;
421
458
last unless (/^@@ -\d+(,(\d+))? \+\d+(,(\d+))? @\@( .*)?$/);
422
459
my ($olines, $nlines) = ($1 ? $2 : 1, $3 ? $4 : 1);
424
461
while ($olines || $nlines) {
425
462
unless (defined($_ = getline($self))) {
426
463
if (($olines == $nlines) and ($olines < 3)) {
427
warning(_g("unexpected end of diff `%s'"), $diff);
464
warning(_g("unexpected end of diff `%s'"), $diff)
430
468
error(_g("unexpected end of diff `%s'"), $diff);
433
next if /^\\ No newline/;
435
473
if (/^ / || /^$/) { --$olines; --$nlines; }
436
474
elsif (/^-/) { --$olines; }
450
488
unless ($diff_count) {
451
warning(_g("diff `%s' doesn't contain any patch"), $diff);
489
warning(_g("diff `%s' doesn't contain any patch"), $diff)
453
492
*$self->{'analysis'}{$destdir}{"dirtocreate"} = \%dirtocreate;
454
493
*$self->{'analysis'}{$destdir}{"filepatched"} = \%filepatched;
494
*$self->{'analysis'}{$destdir}{"patchorder"} = \@patchorder;
455
495
return *$self->{'analysis'}{$destdir};
502
542
# Reset the timestamp of all the patched files
503
543
# and remove .dpkg-orig files
504
my $now = $opts{"timestamp"} || time;
505
foreach my $fn (keys %{$analysis->{'filepatched'}}) {
544
my @files = keys %{$analysis->{'filepatched'}};
545
my $now = $opts{"timestamp"};
546
$now ||= fs_time($files[0]) if $opts{"force_timestamp"} and scalar @files;
547
foreach my $fn (@files) {
506
548
if ($opts{"force_timestamp"}) {
507
549
utime($now, $now, $fn) || $! == ENOENT ||
508
550
syserr(_g("cannot change timestamp for %s"), $fn);