about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-01-19 05:44:12 +0000
committerEric Wong <e@80x24.org>2019-01-20 04:24:54 +0000
commit0412b5fd8b5e98e4967a0f210cfb2b922ed59d43 (patch)
treef4aa3934555fb644034f8e7f4f58d6579bdbb625 /lib
parent915cd090798069a44dbb4b4c243bff9af2ae1b76 (diff)
downloadpublic-inbox-0412b5fd8b5e98e4967a0f210cfb2b922ed59d43.tar.gz
We'll be breaking this up into several steps, too; since
searching inboxes for patch blobs can take 10s of milliseconds
for me.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/SolverGit.pm28
1 files changed, 10 insertions, 18 deletions
diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm
index 70d8a934..beafa42d 100644
--- a/lib/PublicInbox/SolverGit.pm
+++ b/lib/PublicInbox/SolverGit.pm
@@ -361,11 +361,13 @@ sub solve ($$$$) {
         my @todo = ($req);
         my $found = {}; # { abbrev => [ ::Git, oid_full, type, size, $di ] }
         my $patches = []; # [ array of $di hashes ]
-
-        my $max = $self->{max_steps} || 200;
-        my $steps = 0;
+        my $max = $self->{max_patches} || 200;
 
         while (defined(my $want = pop @todo)) {
+                if (scalar(@$patches) > $max) {
+                        print $out "Aborting, too many steps to $oid_b\n";
+                        return;
+                }
                 # 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)) {
@@ -373,9 +375,8 @@ sub solve ($$$$) {
                                 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?
+                        last; # ok, one blob resolved, more to go?
                 }
 
                 # scan through inboxes to look for emails which results in
@@ -390,21 +391,12 @@ sub solve ($$$$) {
                         # good, we can find a path to the oid we $want, now
                         # lets see if we need to apply more patches:
                         my $src = $di->{oid_a};
-                        if ($src !~ /\A0+\z/) {
-                                if (++$steps > $max) {
-                                        print $out
-"Aborting, too many steps to $oid_b\n";
 
-                                        return;
-                                }
+                        last if $src =~ /\A0+\z/;
 
-                                # we have to solve it using another oid, fine:
-                                my $job = {
-                                        oid_b => $src,
-                                        path_b => $di->{path_a},
-                                };
-                                push @todo, $job;
-                        }
+                        # we have to solve it using another oid, fine:
+                        my $job = { oid_b => $src, path_b => $di->{path_a} };
+                        push @todo, $job;
                         last; # onto the next @todo item
                 }
                 unless ($di) {