From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id D338521427 for ; Mon, 21 Jan 2019 20:52:56 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 14/37] solver: more verbose blob resolution Date: Mon, 21 Jan 2019 20:52:30 +0000 Message-Id: <20190121205253.10455-15-e@80x24.org> In-Reply-To: <20190121205253.10455-1-e@80x24.org> References: <20190121205253.10455-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Help users find out where each step of the resolution came from. Also, we must clean abort the process if we have missing blobs. And refine the output to avoid unnecessary braces, too. --- lib/PublicInbox/SolverGit.pm | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm index 8dfc52e..29cfd21 100644 --- a/lib/PublicInbox/SolverGit.pm +++ b/lib/PublicInbox/SolverGit.pm @@ -57,7 +57,7 @@ sub solve_existing ($$$) { scalar(@ambiguous) ? \@ambiguous : undef; } -# returns a hashref with information about a diff: +# returns a hashref with information about a diff ($di): # { # oid_a => abbreviated pre-image oid, # oid_b => abbreviated post-image oid, @@ -279,7 +279,7 @@ sub di_url ($) { # can have different HTTP_HOST on the same instance. my $url = $di->{ibx}->base_url; my $mid = $di->{smsg}->{mid}; - defined($url) ? "<$url$mid/>" : "<$mid>"; + defined($url) ? "$url$mid/" : "<$mid>"; } sub apply_patches ($$$$$) { @@ -338,7 +338,7 @@ sub dump_patches ($$) { } # recreate $oid_b -# Returns a 2-element array ref: [ PublicInbox::Git object, oid_full ] +# Returns an array ref: [ ::Git object, oid_full, type, size, di ] # or undef if nothing was found. sub solve ($$$$) { my ($self, $out, $oid_b, $hints) = @_; @@ -357,14 +357,12 @@ sub solve ($$$$) { while (defined(my $want = pop @todo)) { # see if we can find the blob in an existing git repo: + my $want_oid = $want->{oid_b}; if (my $existing = solve_existing($self, $out, $want)) { - my $want_oid = $want->{oid_b}; - if ($want_oid eq $oid_b) { # DONE! - my @pub_urls = $existing->[0]->pub_urls; - print $out "found $want_oid in ", - join("\n", @pub_urls),"\n"; - return $existing; - } + print $out "found $want_oid in ", + join("\n", $existing->[0]->pub_urls), "\n"; + + return $existing if $want_oid eq $oid_b; # DONE! $found->{$want_oid} = $existing; next; # ok, one blob resolved, more to go? @@ -372,10 +370,12 @@ sub solve ($$$$) { # scan through inboxes to look for emails which results in # the oid we want: + my $di; foreach my $ibx (@{$self->{inboxes}}) { - my $di = find_extract_diff($self, $ibx, $want) or next; + $di = find_extract_diff($self, $ibx, $want) or next; unshift @$patches, $di; + print $out "found $want_oid in ",di_url($di),"\n"; # good, we can find a path to the oid we $want, now # lets see if we need to apply more patches: @@ -397,6 +397,10 @@ sub solve ($$$$) { } last; # onto the next @todo item } + unless ($di) { + print $out "$want_oid could not be found\n"; + return; + } } unless (scalar(@$patches)) { -- EW