提交 8e3f9b17 编写于 作者: S Sam Vilain 提交者: Eric Wong

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: NYuval Kogman <nothingmuch@woobling.org>
Signed-off-by: NSam Vilain <sam@vilain.net>
Acked-by: NEric Wong <normalperson@yhbt.net>

[ew: minor formatting changes]
上级 4c58a711
......@@ -2389,22 +2389,8 @@ sub find_parent_branch {
print STDERR "Found possible branch point: ",
"$new_url => ", $self->full_url, ", $r\n";
$branch_from =~ s#^/##;
my $gs = Git::SVN->find_by_url($new_url, $repos_root, $branch_from);
unless ($gs) {
my $ref_id = $self->{ref_id};
$ref_id =~ s/\@\d+$//;
$ref_id .= "\@$r";
# just grow a tail if we're not unique enough :x
$ref_id .= '-' while find_ref($ref_id);
print STDERR "Initializing parent: $ref_id\n";
my ($u, $p, $repo_id) = ($new_url, '', $ref_id);
if ($u =~ s#^\Q$url\E(/|$)##) {
$p = $u;
$u = $url;
$repo_id = $self->{repo_id};
}
$gs = Git::SVN->init($u, $p, $repo_id, $ref_id, 1);
}
my $gs = $self->other_gs($new_url, $url, $repos_root,
$branch_from, $r, $self->{ref_id});
my ($r0, $parent) = $gs->find_rev_before($r, 1);
{
my ($base, $head);
......@@ -2586,6 +2572,28 @@ sub parse_svn_date {
return $parsed_date;
}
sub other_gs {
my ($self, $new_url, $url, $repos_root,
$branch_from, $r, $old_ref_id) = @_;
my $gs = Git::SVN->find_by_url($new_url, $repos_root, $branch_from);
unless ($gs) {
my $ref_id = $old_ref_id;
$ref_id =~ s/\@\d+$//;
$ref_id .= "\@$r";
# just grow a tail if we're not unique enough :x
$ref_id .= '-' while find_ref($ref_id);
print STDERR "Initializing parent: $ref_id\n";
my ($u, $p, $repo_id) = ($new_url, '', $ref_id);
if ($u =~ s#^\Q$url\E(/|$)##) {
$p = $u;
$u = $url;
$repo_id = $self->{repo_id};
}
$gs = Git::SVN->init($u, $p, $repo_id, $ref_id, 1);
}
$gs
}
sub check_author {
my ($author) = @_;
if (!defined $author || length $author == 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册