From: Eric Wong Date: Tue, 30 Jan 2007 21:11:14 +0000 (-0800) Subject: git-svn: remove the 'rebuild' command and make the functionality automatic X-Git-Tag: v1.5.1-rc1~207 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f0ecca1041aff2e1398edcdaf5f0ce08a96f5f0f;p=git.git git-svn: remove the 'rebuild' command and make the functionality automatic Since refs/remotes/* are not automatically cloned, we expect the user to be capable of copying those references themselves anyways. Also removed the documentation for --ignore-nodate while we're at it; it has also been made automatic. Signed-off-by: Eric Wong --- diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt index 6daba241e..22dd7b219 100644 --- a/Documentation/git-svn.txt +++ b/Documentation/git-svn.txt @@ -93,16 +93,6 @@ remotes/git-svn. commit. All merging is assumed to have taken place independently of git-svn functions. -'rebuild':: - Not a part of daily usage, but this is a useful command if - you've just cloned a repository (using gitlink:git-clone[1]) that was - tracked with git-svn. Unfortunately, git-clone does not clone - git-svn metadata and the svn working tree that git-svn uses for - its operations. This rebuilds the metadata so git-svn can - resume fetch operations. A Subversion URL may be optionally - specified at the command-line if the directory/repository you're - tracking has moved or changed protocols. - 'show-ignore':: Recursively finds and lists the svn:ignore property on directories. The output is suitable for appending to @@ -322,9 +312,9 @@ config key: svn.followparent --no-metadata:: This gets rid of the git-svn-id: lines at the end of every commit. - With this, you lose the ability to use the rebuild command. If - you ever lose your .git/svn/git-svn/.rev_db file, you won't be - able to fetch again, either. This is fine for one-shot imports. + If you lose your .git/svn/git-svn/.rev_db file, git-svn will not + be able to rebuild it and you won't be able to fetch again, + either. This is fine for one-shot imports. The 'git-svn log' command will not work on repositories using this, either. @@ -333,31 +323,6 @@ config key: svn.nometadata -- -COMPATIBILITY OPTIONS ---------------------- --- - ---upgrade:: -Only used with the 'rebuild' command. - -Run this if you used an old version of git-svn that used -"git-svn-HEAD" instead of "remotes/git-svn" as the branch -for tracking the remote. - ---ignore-nodate:: -Only used with the 'fetch' command. - -By default git-svn will crash if it tries to import a revision -from SVN which has '(no date)' listed as the date of the revision. -This is repository corruption on SVN's part, plain and simple. -But sometimes you really need those revisions anyway. - -If supplied git-svn will convert '(no date)' entries to the UNIX -epoch (midnight on Jan. 1, 1970). Yes, that's probably very wrong. -SVN was very wrong. - --- - Basic Examples ~~~~~~~~~~~~~~ diff --git a/git-svn.perl b/git-svn.perl index b0248c948..845f22af5 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -106,9 +106,6 @@ my %cmd = ( { 'stdin|' => \$_stdin, %cmt_opts, %fc_opts, } ], 'show-ignore' => [ \&cmd_show_ignore, "Show svn:ignore listings", { 'revision|r=i' => \$_revision } ], - rebuild => [ \&cmd_rebuild, "Rebuild git-svn metadata (after git clone)", - { 'copy-remote|remote=s' => \$_cp_remote, - 'upgrade' => \$_upgrade } ], 'multi-init' => [ \&cmd_multi_init, 'Initialize multiple trees (like git-svnimport)', { %multi_opts, %init_opts, %remote_opts, @@ -166,7 +163,7 @@ usage(0) if $_help; version() if $_version; usage(1) unless defined $cmd; load_authors() if $_authors; -unless ($cmd =~ /^(?:init|rebuild|multi-init|commit-diff)$/) { +unless ($cmd =~ /^(?:init|multi-init|commit-diff)$/) { Git::SVN::Migration::migration_check(); } eval { @@ -211,47 +208,6 @@ sub version { exit 0; } -sub cmd_rebuild { - my $url = shift; - my $gs = $url ? Git::SVN->init($url) - : eval { Git::SVN->new }; - $gs ||= Git::SVN->_new; - if (!verify_ref($gs->refname.'^0')) { - $gs->copy_remote_ref; - } - - my ($rev_list, $ctx) = command_output_pipe("rev-list", $gs->refname); - my $latest; - my $svn_uuid; - while (<$rev_list>) { - chomp; - my $c = $_; - fatal "Non-SHA1: $c\n" unless $c =~ /^$sha1$/o; - my ($url, $rev, $uuid) = cmt_metadata($c); - - # ignore merges (from set-tree) - next if (!defined $rev || !$uuid); - - # if we merged or otherwise started elsewhere, this is - # how we break out of it - if ((defined $svn_uuid && ($uuid ne $svn_uuid)) || - ($gs->{url} && $url && ($url ne $gs->{url}))) { - next; - } - - unless (defined $latest) { - if (!$gs->{url} && !$url) { - fatal "SVN repository location required\n"; - } - $gs = Git::SVN->init($url); - $latest = $rev; - } - $gs->rev_db_set($rev, $c); - print "r$rev = $c\n"; - } - command_close_pipe($rev_list, $ctx); -} - sub do_git_init_db { unless (-d $ENV{GIT_DIR}) { my @init_db = ('init'); @@ -863,6 +819,9 @@ sub new { $self->{url} = command_oneline('config', '--get', "svn-remote.$repo_id.url") or die "Failed to read \"svn-remote.$repo_id.url\" in config\n"; + if (-z $self->{db_path} && ::verify_ref($self->refname.'^0')) { + $self->rebuild; + } $self; } @@ -883,17 +842,6 @@ sub rel_path { $url; } -sub copy_remote_ref { - my ($self) = @_; - my $origin = $::_cp_remote ? $::_cp_remote : 'origin'; - my $ref = $self->refname; - if (command('ls-remote', $origin, $ref)) { - command_noisy('fetch', $origin, "$ref:$ref"); - } elsif ($::_cp_remote && !$::_upgrade) { - die "Unable to find remote reference: $ref on $origin\n"; - } -} - sub traverse_ignore { my ($self, $fh, $path, $r) = @_; $path =~ s#^/+##g; @@ -1359,6 +1307,38 @@ sub set_tree { } } +sub rebuild { + my ($self) = @_; + print "Rebuilding $self->{db_path} ...\n"; + my ($rev_list, $ctx) = command_output_pipe("rev-list", $self->refname); + my $latest; + my $full_url = $self->full_url; + my $svn_uuid; + while (<$rev_list>) { + chomp; + my $c = $_; + die "Non-SHA1: $c\n" unless $c =~ /^$::sha1$/o; + my ($url, $rev, $uuid) = ::cmt_metadata($c); + + # ignore merges (from set-tree) + next if (!defined $rev || !$uuid); + + # if we merged or otherwise started elsewhere, this is + # how we break out of it + if ((defined $svn_uuid && ($uuid ne $svn_uuid)) || + ($full_url && $url && ($url ne $full_url))) { + next; + } + $latest ||= $rev; + $svn_uuid ||= $uuid; + + $self->rev_db_set($rev, $c); + print "r$rev = $c\n"; + } + command_close_pipe($rev_list, $ctx); + print "Done rebuilding $self->{db_path}\n"; +} + # rev_db: # Tie::File seems to be prone to offset errors if revisions get sparse, # it's not that fast, either. Tie::File is also not in Perl 5.6. So