chiark / gitweb /
Overwrite: Support --overwrite without a version
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 26 Sep 2016 00:07:05 +0000 (01:07 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 26 Sep 2016 00:36:40 +0000 (01:36 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
dgit

diff --git a/dgit b/dgit
index 54337f7..5a37363 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -63,7 +63,7 @@ our $existing_package = 'dpkg';
 our $cleanmode;
 our $changes_since_version;
 our $rmchanges;
-our $overwrite_version;
+our $overwrite_version; # undef: not specified; '': check changelog
 our $quilt_mode;
 our $quilt_modes_re = 'linear|smash|auto|nofix|nocheck|gbp|dpm|unapplied';
 our $we_are_responder;
@@ -2404,8 +2404,26 @@ sub pseudomerge_version_check ($$) {
     my $i_arch_v = [ (getfield $arch_clogp, 'Version'),
                     'version currently in archive' ];
     if (defined $overwrite_version) {
-       infopair_cond_equal([ $overwrite_version, '--overwrite= version' ],
-                           $i_arch_v);
+       if (length $overwrite_version) {
+           infopair_cond_equal([ $overwrite_version,
+                                 '--overwrite= version' ],
+                               $i_arch_v);
+       } else {
+           my $v = $i_arch_v->[0];
+           progress "Checking package changelog for archive version $v ...";
+           eval {
+               my @xa = ("-f$v", "-t$v");
+               my $vclogp = parsechangelog @xa;
+               my $cv = [ (getfield $vclogp, 'Version'),
+                          "Version field from dpkg-parsechangelog @xa" ];
+               infopair_cond_equal($i_arch_v, $cv);
+           };
+           if ($@) {
+               $@ =~ s/^dgit: //gm;
+               fail "$@".
+                   "Perhaps debian/changelog does not mention $v ?";
+           }
+       }
     }
     
     printdebug "pseudomerge_version_check i_arch_v @$i_arch_v\n";
@@ -2423,6 +2441,7 @@ sub pseudomerge_make_commit ($$$$ $$) {
     chomp $msg_msg;
     $msg_cmd .=
        !defined $overwrite_version ? ""
+       : !length  $overwrite_version ? " --overwrite"
        : " --overwrite=".$overwrite_version;
 
     mkpath '.git/dgit';
@@ -4564,7 +4583,10 @@ sub parseopts () {
            } elsif (m/^--no-rm-on-error$/s) {
                push @ropts, $_;
                $rmonerror = 0;
-           } elsif (m/^--overwrite=(.*)$/s) {
+           } elsif (m/^--overwrite$/s) {
+               push @ropts, $_;
+               $overwrite_version = '';
+           } elsif (m/^--overwrite=(.+)$/s) {
                push @ropts, $_;
                $overwrite_version = $1;
            } elsif (m/^--(no-)?rm-old-changes$/s) {