From 3292ae4794012994560816e6111d27c809f5e86a Mon Sep 17 00:00:00 2001 From: Martin Langhoff Date: Sun, 4 Sep 2005 22:55:06 +1200 Subject: [PATCH] archimport autodetects import status, supports incremental imports If there is no GIT directory, archimport will assume it is an initial import. It now also supports incremental imports, skipping "seen" commits. You can now run it repeatedly to pull new commits from the Arch repository. Signed-off-by: Martin Langhoff Signed-off-by: Junio C Hamano --- git-archimport-script | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'git-archimport-script') diff --git a/git-archimport-script b/git-archimport-script index 6ff5d7dce0..3c8aab74be 100755 --- a/git-archimport-script +++ b/git-archimport-script @@ -49,12 +49,12 @@ $SIG{'PIPE'}="IGNORE"; $ENV{'TZ'}="UTC"; our($opt_h,$opt_v, $opt_T, - $opt_C,$opt_t, $opt_i); + $opt_C,$opt_t); sub usage() { print STDERR <{branch} = branchname($ps->{id}); @@ -201,14 +199,22 @@ foreach my $ps (@psets) { } die $! if $?; + # + # skip commits already in repo + # + if (ptag($ps->{id})) { + $opt_v && print "Skipping already imported: $ps->{id}\n"; + next; + } + # # create the branch if needed # - if ($ps->{type} eq 'i' && $importseen) { - die "Should not have more than one 'Initial import' per GIT import"; + if ($ps->{type} eq 'i' && !$import) { + die "Should not have more than one 'Initial import' per GIT import: $ps->{id}"; } - unless ($opt_i && !$importseen) { # skip for first commit + unless ($import) { # skip for import if ( -e ".git/refs/heads/$ps->{branch}") { # we know about this branch `git checkout $ps->{branch}`; @@ -225,13 +231,12 @@ foreach my $ps (@psets) { die $! if $?; } - # # Apply the import/changeset/merge into the working tree # if ($ps->{type} eq 'i' || $ps->{type} eq 't') { - $importseen = 1; apply_import($ps) or die $!; + $import=0; } elsif ($ps->{type} eq 's') { apply_cset($ps); } @@ -577,8 +582,6 @@ sub ptag { } else { # read # if the tag isn't there, return 0 unless ( -s ".git/archimport/tags/$tag") { - warn "Could not find tag $tag -- perhaps it isn't in the repos we have?\n" - if $opt_v; return 0; } open(C,"<.git/archimport/tags/$tag") -- cgit v1.3 From 52586ecb16f2158de29daabb0ed72b094ca8d5cc Mon Sep 17 00:00:00 2001 From: Martin Langhoff Date: Sun, 4 Sep 2005 22:55:29 +1200 Subject: [PATCH] archimport: avoid committing on an Arch tag Arch tags are full commits (without any changed files) as well. Trust Arch to have put an unchanged tree in place (which seems to do reliably), and just add a tag & new branch. Speeds up Arch imports significantly, and leaves history in a much saner state. Signed-off-by: Martin Langhoff Signed-off-by: Junio C Hamano --- git-archimport-script | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'git-archimport-script') diff --git a/git-archimport-script b/git-archimport-script index 3c8aab74be..8f475fd66d 100755 --- a/git-archimport-script +++ b/git-archimport-script @@ -227,6 +227,14 @@ foreach my $ps (@psets) { # find where we are supposed to branch from `git checkout -b $ps->{branch} $branchpoint`; + + # If we trust Arch with the fact that this is just + # a tag, and it does not affect the state of the tree + # then we just tag and move on + tag($ps->{id}, $branchpoint); + ptag($ps->{id}, $branchpoint); + print " * Tagged $ps->{id} at $branchpoint\n"; + next; } die $! if $?; } -- cgit v1.3