From 8e3f9b17a5186c8122eebf5cefdf6062a21f07d9 Mon Sep 17 00:00:00 2001 From: Sam Vilain Date: Tue, 26 Jun 2007 19:23:59 +1200 Subject: [PATCH] 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 Signed-off-by: Sam Vilain Acked-by: Eric Wong [ew: minor formatting changes] --- git-svn.perl | 40 ++++++++++++++++++++++++---------------- 1 file 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) { -- 2.11.4.GIT