Skip to content

Commit 8e3f9b1

Browse files
samvEric Wong
authored andcommitted
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 <[email protected]> Signed-off-by: Sam Vilain <[email protected]> Acked-by: Eric Wong <[email protected]> [ew: minor formatting changes]
1 parent 4c58a71 commit 8e3f9b1

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

git-svn.perl

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,22 +2389,8 @@ sub find_parent_branch {
23892389
print STDERR "Found possible branch point: ",
23902390
"$new_url => ", $self->full_url, ", $r\n";
23912391
$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});
24082394
my ($r0, $parent) = $gs->find_rev_before($r, 1);
24092395
{
24102396
my ($base, $head);
@@ -2586,6 +2572,28 @@ sub parse_svn_date {
25862572
return $parsed_date;
25872573
}
25882574

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+
25892597
sub check_author {
25902598
my ($author) = @_;
25912599
if (!defined $author || length $author == 0) {

0 commit comments

Comments
 (0)