@matheusbsbs / matheus-bagliano / commits / f0ecca1041
Fork 0

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>

Eric Wong committed Jan 30, 2007 at 13:11 UTC f0ecca1041aff2e1398edcdaf5f0ce08a96f5f0f
2 files changed +39 -94
Documentation/git-svn.txt
+3 -38
@@ -93,16 +93,6 @@ remotes/git-svn.
93 commit. All merging is assumed to have taken place
94 independently of git-svn functions.
95
96 -'rebuild'::
97 - Not a part of daily usage, but this is a useful command if
98 - you've just cloned a repository (using gitlink:git-clone[1]) that was
99 - tracked with git-svn. Unfortunately, git-clone does not clone
100 - git-svn metadata and the svn working tree that git-svn uses for
101 - its operations. This rebuilds the metadata so git-svn can
102 - resume fetch operations. A Subversion URL may be optionally
103 - specified at the command-line if the directory/repository you're
104 - tracking has moved or changed protocols.
105 -
96 'show-ignore'::
97 Recursively finds and lists the svn:ignore property on
98 directories. The output is suitable for appending to
@@ -322,9 +312,9 @@ config key: svn.followparent
312 --no-metadata::
313 This gets rid of the git-svn-id: lines at the end of every commit.
314
325 - With this, you lose the ability to use the rebuild command. If
326 - you ever lose your .git/svn/git-svn/.rev_db file, you won't be
327 - able to fetch again, either. This is fine for one-shot imports.
315 + If you lose your .git/svn/git-svn/.rev_db file, git-svn will not
316 + be able to rebuild it and you won't be able to fetch again,
317 + either. This is fine for one-shot imports.
318
319 The 'git-svn log' command will not work on repositories using this,
320 either.
@@ -333,31 +323,6 @@ config key: svn.nometadata
323
324 --
325
336 -COMPATIBILITY OPTIONS
337 ----------------------
338 ---
339 -
340 ---upgrade::
341 -Only used with the 'rebuild' command.
342 -
343 -Run this if you used an old version of git-svn that used
344 -"git-svn-HEAD" instead of "remotes/git-svn" as the branch
345 -for tracking the remote.
346 -
347 ---ignore-nodate::
348 -Only used with the 'fetch' command.
349 -
350 -By default git-svn will crash if it tries to import a revision
351 -from SVN which has '(no date)' listed as the date of the revision.
352 -This is repository corruption on SVN's part, plain and simple.
353 -But sometimes you really need those revisions anyway.
354 -
355 -If supplied git-svn will convert '(no date)' entries to the UNIX
356 -epoch (midnight on Jan. 1, 1970). Yes, that's probably very wrong.
357 -SVN was very wrong.
358 -
359 ---
360 -
326 Basic Examples
327 ~~~~~~~~~~~~~~
328
git-svn.perl
+36 -56
@@ -106,9 +106,6 @@ my %cmd = (
106 { 'stdin|' => \$_stdin, %cmt_opts, %fc_opts, } ],
107 'show-ignore' => [ \&cmd_show_ignore, "Show svn:ignore listings",
108 { 'revision|r=i' => \$_revision } ],
109 - rebuild => [ \&cmd_rebuild, "Rebuild git-svn metadata (after git clone)",
110 - { 'copy-remote|remote=s' => \$_cp_remote,
111 - 'upgrade' => \$_upgrade } ],
109 'multi-init' => [ \&cmd_multi_init,
110 'Initialize multiple trees (like git-svnimport)',
111 { %multi_opts, %init_opts, %remote_opts,
@@ -166,7 +163,7 @@ usage(0) if $_help;
163 version() if $_version;
164 usage(1) unless defined $cmd;
165 load_authors() if $_authors;
169 -unless ($cmd =~ /^(?:init|rebuild|multi-init|commit-diff)$/) {
166 +unless ($cmd =~ /^(?:init|multi-init|commit-diff)$/) {
167 Git::SVN::Migration::migration_check();
168 }
169 eval {
@@ -211,47 +208,6 @@ sub version {
208 exit 0;
209 }
210
214 -sub cmd_rebuild {
215 - my $url = shift;
216 - my $gs = $url ? Git::SVN->init($url)
217 - : eval { Git::SVN->new };
218 - $gs ||= Git::SVN->_new;
219 - if (!verify_ref($gs->refname.'^0')) {
220 - $gs->copy_remote_ref;
221 - }
222 -
223 - my ($rev_list, $ctx) = command_output_pipe("rev-list", $gs->refname);
224 - my $latest;
225 - my $svn_uuid;
226 - while (<$rev_list>) {
227 - chomp;
228 - my $c = $_;
229 - fatal "Non-SHA1: $c\n" unless $c =~ /^$sha1$/o;
230 - my ($url, $rev, $uuid) = cmt_metadata($c);
231 -
232 - # ignore merges (from set-tree)
233 - next if (!defined $rev || !$uuid);
234 -
235 - # if we merged or otherwise started elsewhere, this is
236 - # how we break out of it
237 - if ((defined $svn_uuid && ($uuid ne $svn_uuid)) ||
238 - ($gs->{url} && $url && ($url ne $gs->{url}))) {
239 - next;
240 - }
241 -
242 - unless (defined $latest) {
243 - if (!$gs->{url} && !$url) {
244 - fatal "SVN repository location required\n";
245 - }
246 - $gs = Git::SVN->init($url);
247 - $latest = $rev;
248 - }
249 - $gs->rev_db_set($rev, $c);
250 - print "r$rev = $c\n";
251 - }
252 - command_close_pipe($rev_list, $ctx);
253 -}
254 -
211 sub do_git_init_db {
212 unless (-d $ENV{GIT_DIR}) {
213 my @init_db = ('init');
@@ -863,6 +819,9 @@ sub new {
819 $self->{url} = command_oneline('config', '--get',
820 "svn-remote.$repo_id.url") or
821 die "Failed to read \"svn-remote.$repo_id.url\" in config\n";
822 + if (-z $self->{db_path} && ::verify_ref($self->refname.'^0')) {
823 + $self->rebuild;
824 + }
825 $self;
826 }
827
@@ -883,17 +842,6 @@ sub rel_path {
842 $url;
843 }
844
886 -sub copy_remote_ref {
887 - my ($self) = @_;
888 - my $origin = $::_cp_remote ? $::_cp_remote : 'origin';
889 - my $ref = $self->refname;
890 - if (command('ls-remote', $origin, $ref)) {
891 - command_noisy('fetch', $origin, "$ref:$ref");
892 - } elsif ($::_cp_remote && !$::_upgrade) {
893 - die "Unable to find remote reference: $ref on $origin\n";
894 - }
895 -}
896 -
845 sub traverse_ignore {
846 my ($self, $fh, $path, $r) = @_;
847 $path =~ s#^/+##g;
@@ -1359,6 +1307,38 @@ sub set_tree {
1307 }
1308 }
1309
1310 +sub rebuild {
1311 + my ($self) = @_;
1312 + print "Rebuilding $self->{db_path} ...\n";
1313 + my ($rev_list, $ctx) = command_output_pipe("rev-list", $self->refname);
1314 + my $latest;
1315 + my $full_url = $self->full_url;
1316 + my $svn_uuid;
1317 + while (<$rev_list>) {
1318 + chomp;
1319 + my $c = $_;
1320 + die "Non-SHA1: $c\n" unless $c =~ /^$::sha1$/o;
1321 + my ($url, $rev, $uuid) = ::cmt_metadata($c);
1322 +
1323 + # ignore merges (from set-tree)
1324 + next if (!defined $rev || !$uuid);
1325 +
1326 + # if we merged or otherwise started elsewhere, this is
1327 + # how we break out of it
1328 + if ((defined $svn_uuid && ($uuid ne $svn_uuid)) ||
1329 + ($full_url && $url && ($url ne $full_url))) {
1330 + next;
1331 + }
1332 + $latest ||= $rev;
1333 + $svn_uuid ||= $uuid;
1334 +
1335 + $self->rev_db_set($rev, $c);
1336 + print "r$rev = $c\n";
1337 + }
1338 + command_close_pipe($rev_list, $ctx);
1339 + print "Done rebuilding $self->{db_path}\n";
1340 +}
1341 +
1342 # rev_db:
1343 # Tie::File seems to be prone to offset errors if revisions get sparse,
1344 # it's not that fast, either. Tie::File is also not in Perl 5.6. So