diff options
Diffstat (limited to 'scripts/Dpkg/Source/Package')
-rw-r--r-- | scripts/Dpkg/Source/Package/V2.pm | 29 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Package/V3/quilt.pm | 44 |
2 files changed, 39 insertions, 34 deletions
diff --git a/scripts/Dpkg/Source/Package/V2.pm b/scripts/Dpkg/Source/Package/V2.pm index de1274769..1021d9e80 100644 --- a/scripts/Dpkg/Source/Package/V2.pm +++ b/scripts/Dpkg/Source/Package/V2.pm @@ -602,22 +602,25 @@ sub register_patch { return $patch; } +sub _is_bad_patch_name { + my ($dir, $patch_name) = @_; + + return 1 if not defined($patch_name); + return 1 if not length($patch_name); + + my $patch = File::Spec->catfile($dir, "debian", "patches", $patch_name); + if (-e $patch) { + warning(_g("cannot register changes in %s, this patch already exists"), + $patch); + return 1; + } + return 0; +} + sub do_commit { my ($self, $dir) = @_; my ($patch_name, $tmpdiff) = @{$self->{'options'}{'ARGV'}}; - sub bad_patch_name { - my ($dir, $patch_name) = @_; - return 1 if not defined($patch_name); - return 1 if not length($patch_name); - my $patch = File::Spec->catfile($dir, "debian", "patches", $patch_name); - if (-e $patch) { - warning(_g("cannot register changes in %s, this patch already exists"), $patch); - return 1; - } - return 0; - } - $self->prepare_build($dir); # Try to fix up a broken relative filename for the patch @@ -645,7 +648,7 @@ sub do_commit { info(_g("there are no local changes to record")); return; } - while (bad_patch_name($dir, $patch_name)) { + while (_is_bad_patch_name($dir, $patch_name)) { # Ask the patch name interactively print STDOUT _g("Enter the desired patch name: "); chomp($patch_name = <STDIN>); diff --git a/scripts/Dpkg/Source/Package/V3/quilt.pm b/scripts/Dpkg/Source/Package/V3/quilt.pm index 3b7d0e319..f32a49909 100644 --- a/scripts/Dpkg/Source/Package/V3/quilt.pm +++ b/scripts/Dpkg/Source/Package/V3/quilt.pm @@ -214,25 +214,27 @@ sub check_patches_applied { $self->apply_patches($dir, usage => 'preparation', verbose => 1); } -sub register_patch { - my ($self, $dir, $tmpdiff, $patch_name) = @_; +sub _add_line { + my ($file, $line) = @_; - sub add_line { - my ($file, $line) = @_; - open(my $file_fh, ">>", $file) || syserr(_g("cannot write %s"), $file); - print $file_fh "$line\n"; - close($file_fh); - } + open(my $file_fh, ">>", $file) || syserr(_g("cannot write %s"), $file); + print $file_fh "$line\n"; + close($file_fh); +} - sub drop_line { - my ($file, $re) = @_; - open(my $file_fh, "<", $file) || syserr(_g("cannot read %s"), $file); - my @lines = <$file_fh>; - close($file_fh); - open($file_fh, ">", $file) || syserr(_g("cannot write %s"), $file); - print($file_fh $_) foreach grep { not /^\Q$re\E\s*$/ } @lines; - close($file_fh); - } +sub _drop_line { + my ($file, $re) = @_; + + open(my $file_fh, "<", $file) || syserr(_g("cannot read %s"), $file); + my @lines = <$file_fh>; + close($file_fh); + open($file_fh, ">", $file) || syserr(_g("cannot write %s"), $file); + print($file_fh $_) foreach grep { not /^\Q$re\E\s*$/ } @lines; + close($file_fh); +} + +sub register_patch { + my ($self, $dir, $tmpdiff, $patch_name) = @_; my $quilt = $self->build_quilt_object($dir); @@ -255,8 +257,8 @@ sub register_patch { $quilt->setup_db(); # Add patch to series file if (not $has_patch) { - add_line($series, $patch_name); - add_line($applied, $patch_name); + _add_line($series, $patch_name); + _add_line($applied, $patch_name); $quilt->load_series(); $quilt->load_db(); } @@ -268,8 +270,8 @@ sub register_patch { } else { # Remove auto_patch from series if ($has_patch) { - drop_line($series, $patch_name); - drop_line($applied, $patch_name); + _drop_line($series, $patch_name); + _drop_line($applied, $patch_name); erasedir($quilt->get_db_file($patch_name)); $quilt->load_db(); $quilt->load_series(); |