diff options
author | Sam Vilain <sam@vilain.net> | 2007-06-26 11:23:59 +0400 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-02-11 13:00:42 +0300 |
commit | 8e3f9b17a5186c8122eebf5cefdf6062a21f07d9 (patch) | |
tree | 558d2848cd6b4807b4f17e3265671d38b5f67278 | |
parent | 4c58a7111d9fb4f62ca041fc73e8aec0a2f9c800 (diff) |
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]
-rwxr-xr-x | git-svn.perl | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/git-svn.perl b/git-svn.perl index bebcbdea20..b0ae05bc40 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -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) { |