@matheusbsbs / matheus-bagliano / commits / 8e3f9b17a5
Fork 0

git-svn: abstract out a block into new method other_gs()

We will be adding a more places that need to find git revisions corresponding to new parents, so abstract out this section into a new method. Signed-off-by: Yuval Kogman <nothingmuch@woobling.org> Signed-off-by: Sam Vilain <sam@vilain.net> Acked-by: Eric Wong <normalperson@yhbt.net> [ew: minor formatting changes]

Sam Vilain committed Jun 26, 2007 at 19:23 UTC 8e3f9b17a5186c8122eebf5cefdf6062a21f07d9
1 file changed +24 -16
git-svn.perl
+24 -16
@@ -2389,22 +2389,8 @@ sub find_parent_branch {
2389 print STDERR "Found possible branch point: ",
2390 "$new_url => ", $self->full_url, ", $r\n";
2391 $branch_from =~ s#^/##;
2392 - my $gs = Git::SVN->find_by_url($new_url, $repos_root, $branch_from);
2393 - unless ($gs) {
2394 - my $ref_id = $self->{ref_id};
2395 - $ref_id =~ s/\@\d+$//;
2396 - $ref_id .= "\@$r";
2397 - # just grow a tail if we're not unique enough :x
2398 - $ref_id .= '-' while find_ref($ref_id);
2399 - print STDERR "Initializing parent: $ref_id\n";
2400 - my ($u, $p, $repo_id) = ($new_url, '', $ref_id);
2401 - if ($u =~ s#^\Q$url\E(/|$)##) {
2402 - $p = $u;
2403 - $u = $url;
2404 - $repo_id = $self->{repo_id};
2405 - }
2406 - $gs = Git::SVN->init($u, $p, $repo_id, $ref_id, 1);
2407 - }
2392 + my $gs = $self->other_gs($new_url, $url, $repos_root,
2393 + $branch_from, $r, $self->{ref_id});
2394 my ($r0, $parent) = $gs->find_rev_before($r, 1);
2395 {
2396 my ($base, $head);
@@ -2586,6 +2572,28 @@ sub parse_svn_date {
2572 return $parsed_date;
2573 }
2574
2575 +sub other_gs {
2576 + my ($self, $new_url, $url, $repos_root,
2577 + $branch_from, $r, $old_ref_id) = @_;
2578 + my $gs = Git::SVN->find_by_url($new_url, $repos_root, $branch_from);
2579 + unless ($gs) {
2580 + my $ref_id = $old_ref_id;
2581 + $ref_id =~ s/\@\d+$//;
2582 + $ref_id .= "\@$r";
2583 + # just grow a tail if we're not unique enough :x
2584 + $ref_id .= '-' while find_ref($ref_id);
2585 + print STDERR "Initializing parent: $ref_id\n";
2586 + my ($u, $p, $repo_id) = ($new_url, '', $ref_id);
2587 + if ($u =~ s#^\Q$url\E(/|$)##) {
2588 + $p = $u;
2589 + $u = $url;
2590 + $repo_id = $self->{repo_id};
2591 + }
2592 + $gs = Git::SVN->init($u, $p, $repo_id, $ref_id, 1);
2593 + }
2594 + $gs
2595 +}
2596 +
2597 sub check_author {
2598 my ($author) = @_;
2599 if (!defined $author || length $author == 0) {