summaryrefslogtreecommitdiff
path: root/git-debrebase
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2017-05-14 21:49:45 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2018-06-16 12:25:49 +0100
commit5e9409d925fe81f6c9c4eed767febf6b59738742 (patch)
tree73c86399aaf5866d9471b0a7e6dd2838e6d7cda9 /git-debrebase
parent1e621dc9be091f1d54b450b85322445c363a602c (diff)
git-debrebase: wip import handling etc.
Diffstat (limited to 'git-debrebase')
-rwxr-xr-xgit-debrebase67
1 files changed, 51 insertions, 16 deletions
diff --git a/git-debrebase b/git-debrebase
index d6bd8a5..3048793 100755
--- a/git-debrebase
+++ b/git-debrebase
@@ -332,6 +332,14 @@ sub walk {
my $rewrite_from_here = sub {
push @processed, { SpecialMethod => 'StartRewrite' };
};
+ my $bomb = sub { # usage: return $bomb->();
+ print $report " Unprocessable" if $report;
+ $prprdelim->();
+ if ($nogenerate) {
+ return (undef,undef);
+ }
+ die "commit $cur: Cannot cope with this commit";
+ };
my $cur = $input;
my $basis;
@@ -340,6 +348,14 @@ sub walk {
my $prprdelim = sub { print $report $prdelim if $report; $prdelim=""; };
for (;;) {
+ if (!defined $cur) {
+ if ($report) {
+ print $report $predelim, "Origin";
+ $prdelim = "\n";
+ }
+ $basis = undef;
+ last;
+ }
$cl = classify $cur;
my $ty = $cl->{Type};
my $st = $cl->{SubType};
@@ -349,7 +365,7 @@ sub walk {
}
$found{$ty. ( defined($st) ? "-$st" : '' )}++;
push @processed, $cl;
- my $p0 = $cl->{Parents}[0]{CommitId};
+ my $p0 = @[ $cl->{Parents} }==1 ? $cl->{Parents}[0]{CommitId} : undef;
if ($ty eq 'AddPatches') {
$cur = $p0;
$rewrite_from_here->();
@@ -381,8 +397,7 @@ sub walk {
} elsif ($ty eq 'BreakwaterUpstreamMerge') {
$basis = $cur;
last;
- } elsif ($ty eq 'DgitImportUnpatched' &&
- @pseudomerges == 1) {
+ } elsif ($ty eq 'DgitImportUnpatched') {
# This import has a tree which is just like a breakwater
# tree, but it has the wrong history. Its ought to have
# the previous breakwater (which dgit ought to have
@@ -397,6 +412,10 @@ sub walk {
printf $report " Differs=%#x", $differs if $report;
if ($differs & D_UPS) {
printf $report " D_UPS" if $report;
+ # This will also trigger if a non-dgit git-based NMU
+ # deleted .gitignore (which is a thing that some of
+ # the existing git tools do if the user doesn't
+ # somehow tell them not to). Ah well.
push @deb_cl, {
%$cl,
SpecialMethod => 'DgitImportUpstreamUpdate',
@@ -407,21 +426,37 @@ sub walk {
%$cl,
SpecialMethod => 'DgitImportDebianUpdate',
$xmsg->("convert dgit import: upstream changes")
- };
- $prprdelim->();
- $basis = walk
- $pseudomerges[0]{Overwritten},
- $nogenerate, $report,
- 1, $depth+1;
+ };
+ my $pm = $pseudomerges[-1];
+ if (defined $pm) {
+ # To an extent, this is heurstic. Imports don't have
+ # a useful history of the debian/ branch. We assume
+ # that the first pseudomerge after an import has a
+ # useful history or debian/, and ignore the histories
+ # from later pseudomerge. Often the first pseudomerge
+ # will be the dgit import of the upload to the actual
+ # suite intended by the non-dgit NMUer, and later
+ # pseudomerges may represent in-archive copies.
+ my $ovwr = $pm->{Overwritten};
+ printf $report " PM=%s \@Ovewritten:%d", $pm, (scalar @$ovwr)
+ if $report;
+ if (@$ovwr != 1) {
+ return $bomb->();
+ }
+ $basis = walk
+ $ovwr->[0]{CommitId},
+ $nogenerate, $report,
+ 1, $depth+1;
+ } else {
+ # Everything is from this import.
+ printf $report " NoPM" if $report;
+
+ xxx set basis to undef or something to mean make origin
+ }
$rewrite_from_here->();
last;
- } else {
- print $report " Unprocessable" if $report;
- $prprdelim->();
- if ($nogenerate) {
- return (undef,undef);
- }
- die "commit $cur: Cannot cope with this commit";
+ } else {
+ return $bomb->();
}
}
$prprdelim->();