chiark / gitweb /
Dgit.pm: Move is_orig_file_of_p_v and its dependencies from dgit
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 3 Aug 2018 12:49:37 +0000 (13:49 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 3 Aug 2018 13:53:44 +0000 (14:53 +0100)
We want is_orig_file_of_p_v, so move it and all the things it depends
on.

NFC.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Debian/Dgit.pm
dgit

index 0e2464d6d1505bd52e3c4976eb12a8094bb8c063..05e4c0c85178f490ad3de9c33b4d0f60cdf3107a 100644 (file)
@@ -43,6 +43,7 @@ BEGIN {
                      dep14_version_mangle
                       debiantags debiantag_old debiantag_new
                      debiantag_maintview
                      dep14_version_mangle
                       debiantags debiantag_old debiantag_new
                      debiantag_maintview
+                     stripepoch source_file_leafname is_orig_file_of_p_v
                      server_branch server_ref
                       stat_exists link_ltarget
                      hashfile
                      server_branch server_ref
                       stat_exists link_ltarget
                      hashfile
@@ -57,6 +58,7 @@ BEGIN {
                      git_reflog_action_msg  git_update_ref_cmd
                       $package_re $component_re $deliberately_re
                      $distro_re $versiontag_re $series_filename_re
                      git_reflog_action_msg  git_update_ref_cmd
                       $package_re $component_re $deliberately_re
                      $distro_re $versiontag_re $series_filename_re
+                     $orig_f_comp_re $orig_f_sig_re $orig_f_tail_re
                      $extra_orig_namepart_re
                      $git_null_obj
                       $branchprefix
                      $extra_orig_namepart_re
                      $git_null_obj
                       $branchprefix
@@ -91,6 +93,9 @@ our $versiontag_re = qr{[-+.\%_0-9a-zA-Z/]+};
 our $branchprefix = 'dgit';
 our $series_filename_re = qr{(?:^|\.)series(?!\n)$}s;
 our $extra_orig_namepart_re = qr{[-0-9a-z]+};
 our $branchprefix = 'dgit';
 our $series_filename_re = qr{(?:^|\.)series(?!\n)$}s;
 our $extra_orig_namepart_re = qr{[-0-9a-z]+};
+our $orig_f_comp_re = qr{orig(?:-$extra_orig_namepart_re)?};
+our $orig_f_sig_re = '\\.(?:asc|gpg|pgp)';
+our $orig_f_tail_re = "$orig_f_comp_re\\.tar(?:\\.\\w+)?(?:$orig_f_sig_re)?";
 our $git_null_obj = '0' x 40;
 our $ffq_refprefix = 'ffq-prev';
 our $gdrlast_refprefix = 'debrebase-last';
 our $git_null_obj = '0' x 40;
 our $ffq_refprefix = 'ffq-prev';
 our $gdrlast_refprefix = 'debrebase-last';
@@ -220,6 +225,24 @@ sub debiantags ($$) {
     map { $_->($version, $distro) } (\&debiantag_new, \&debiantag_old);
 }
 
     map { $_->($version, $distro) } (\&debiantag_new, \&debiantag_old);
 }
 
+sub stripepoch ($) {
+    my ($vsn) = @_;
+    $vsn =~ s/^\d+\://;
+    return $vsn;
+}
+
+sub source_file_leafname ($$$) {
+    my ($package,$vsn,$sfx) = @_;
+    return "${package}_".(stripepoch $vsn).$sfx
+}
+
+sub is_orig_file_of_p_v ($$$) {
+    my ($package, $f, $upstreamvsn) = @_;
+    my $base = source_file_leafname $package, $upstreamvsn, '';
+    return 0 unless $f =~ m/^\Q$base\E\.$orig_f_tail_re$/;
+    return 1;
+}
+
 sub server_branch ($) { return "$branchprefix/$_[0]"; }
 sub server_ref ($) { return "refs/".server_branch($_[0]); }
 
 sub server_branch ($) { return "$branchprefix/$_[0]"; }
 sub server_ref ($) { return "refs/".server_branch($_[0]); }
 
diff --git a/dgit b/dgit
index 48feca950dbf3ab556bc0185970d58c135716b02..ddc2d6ca06a58afb63dbc154974ef18561275822 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -100,9 +100,6 @@ our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)");
 
 our $suite_re = '[-+.0-9a-z]+';
 our $cleanmode_re = 'dpkg-source(?:-d)?|git|git-ff|check|none';
 
 our $suite_re = '[-+.0-9a-z]+';
 our $cleanmode_re = 'dpkg-source(?:-d)?|git|git-ff|check|none';
-our $orig_f_comp_re = qr{orig(?:-$extra_orig_namepart_re)?};
-our $orig_f_sig_re = '\\.(?:asc|gpg|pgp)';
-our $orig_f_tail_re = "$orig_f_comp_re\\.tar(?:\\.\\w+)?(?:$orig_f_sig_re)?";
 
 our $git_authline_re = '^([^<>]+) \<(\S+)\> (\d+ [-+]\d+)$';
 our $splitbraincache = 'dgit-intern/quilt-cache';
 
 our $git_authline_re = '^([^<>]+) \<(\S+)\> (\d+ [-+]\d+)$';
 our $splitbraincache = 'dgit-intern/quilt-cache';
@@ -201,16 +198,8 @@ sub lref () { return "refs/heads/".lbranch(); }
 sub lrref () { return "refs/remotes/$remotename/".server_branch($csuite); }
 sub rrref () { return server_ref($csuite); }
 
 sub lrref () { return "refs/remotes/$remotename/".server_branch($csuite); }
 sub rrref () { return server_ref($csuite); }
 
-sub stripepoch ($) {
-    my ($vsn) = @_;
-    $vsn =~ s/^\d+\://;
-    return $vsn;
-}
-
-sub srcfn ($$) {
-    my ($vsn,$sfx) = @_;
-    return "${package}_".(stripepoch $vsn).$sfx
-}
+sub srcfn ($$) { return &source_file_leafname($package, @_); }
+sub is_orig_file_of_vsn ($$) { return &is_orig_file_of_p_v($package, @_); }
 
 sub dscfn ($) {
     my ($vsn) = @_;
 
 sub dscfn ($) {
     my ($vsn) = @_;
@@ -1867,13 +1856,6 @@ sub is_orig_file_in_dsc ($$) {
     return 1;
 }
 
     return 1;
 }
 
-sub is_orig_file_of_vsn ($$) {
-    my ($f, $upstreamvsn) = @_;
-    my $base = srcfn $upstreamvsn, '';
-    return 0 unless $f =~ m/^\Q$base\E\.$orig_f_tail_re$/;
-    return 1;
-}
-
 # This function determines whether a .changes file is source-only from
 # the point of view of dak.  Thus, it permits *_source.buildinfo
 # files.
 # This function determines whether a .changes file is source-only from
 # the point of view of dak.  Thus, it permits *_source.buildinfo
 # files.