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 <normalperson@yhbt.net>
This commit is contained in:
parent
289370578c
commit
f0ecca1041
@ -93,16 +93,6 @@ remotes/git-svn.
|
|||||||
commit. All merging is assumed to have taken place
|
commit. All merging is assumed to have taken place
|
||||||
independently of git-svn functions.
|
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'::
|
'show-ignore'::
|
||||||
Recursively finds and lists the svn:ignore property on
|
Recursively finds and lists the svn:ignore property on
|
||||||
directories. The output is suitable for appending to
|
directories. The output is suitable for appending to
|
||||||
@ -322,9 +312,9 @@ config key: svn.followparent
|
|||||||
--no-metadata::
|
--no-metadata::
|
||||||
This gets rid of the git-svn-id: lines at the end of every commit.
|
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
|
If you lose your .git/svn/git-svn/.rev_db file, git-svn will not
|
||||||
you ever lose your .git/svn/git-svn/.rev_db file, you won't be
|
be able to rebuild it and you won't be able to fetch again,
|
||||||
able to fetch again, either. This is fine for one-shot imports.
|
either. This is fine for one-shot imports.
|
||||||
|
|
||||||
The 'git-svn log' command will not work on repositories using this,
|
The 'git-svn log' command will not work on repositories using this,
|
||||||
either.
|
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
|
Basic Examples
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
92
git-svn.perl
92
git-svn.perl
@ -106,9 +106,6 @@ my %cmd = (
|
|||||||
{ 'stdin|' => \$_stdin, %cmt_opts, %fc_opts, } ],
|
{ 'stdin|' => \$_stdin, %cmt_opts, %fc_opts, } ],
|
||||||
'show-ignore' => [ \&cmd_show_ignore, "Show svn:ignore listings",
|
'show-ignore' => [ \&cmd_show_ignore, "Show svn:ignore listings",
|
||||||
{ 'revision|r=i' => \$_revision } ],
|
{ '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,
|
'multi-init' => [ \&cmd_multi_init,
|
||||||
'Initialize multiple trees (like git-svnimport)',
|
'Initialize multiple trees (like git-svnimport)',
|
||||||
{ %multi_opts, %init_opts, %remote_opts,
|
{ %multi_opts, %init_opts, %remote_opts,
|
||||||
@ -166,7 +163,7 @@ usage(0) if $_help;
|
|||||||
version() if $_version;
|
version() if $_version;
|
||||||
usage(1) unless defined $cmd;
|
usage(1) unless defined $cmd;
|
||||||
load_authors() if $_authors;
|
load_authors() if $_authors;
|
||||||
unless ($cmd =~ /^(?:init|rebuild|multi-init|commit-diff)$/) {
|
unless ($cmd =~ /^(?:init|multi-init|commit-diff)$/) {
|
||||||
Git::SVN::Migration::migration_check();
|
Git::SVN::Migration::migration_check();
|
||||||
}
|
}
|
||||||
eval {
|
eval {
|
||||||
@ -211,47 +208,6 @@ sub version {
|
|||||||
exit 0;
|
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 {
|
sub do_git_init_db {
|
||||||
unless (-d $ENV{GIT_DIR}) {
|
unless (-d $ENV{GIT_DIR}) {
|
||||||
my @init_db = ('init');
|
my @init_db = ('init');
|
||||||
@ -863,6 +819,9 @@ sub new {
|
|||||||
$self->{url} = command_oneline('config', '--get',
|
$self->{url} = command_oneline('config', '--get',
|
||||||
"svn-remote.$repo_id.url") or
|
"svn-remote.$repo_id.url") or
|
||||||
die "Failed to read \"svn-remote.$repo_id.url\" in config\n";
|
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;
|
$self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -883,17 +842,6 @@ sub rel_path {
|
|||||||
$url;
|
$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 {
|
sub traverse_ignore {
|
||||||
my ($self, $fh, $path, $r) = @_;
|
my ($self, $fh, $path, $r) = @_;
|
||||||
$path =~ s#^/+##g;
|
$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:
|
# rev_db:
|
||||||
# Tie::File seems to be prone to offset errors if revisions get sparse,
|
# 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
|
# it's not that fast, either. Tie::File is also not in Perl 5.6. So
|
||||||
|
Loading…
Reference in New Issue
Block a user