svn import: skip initial revisions
authorMatthias Urlichs <smurf@smurf.noris.de>
Mon, 10 Oct 2005 13:14:21 +0000 (15:14 +0200)
committerMatthias Urlichs <smurf@smurf.noris.de>
Mon, 10 Oct 2005 13:14:21 +0000 (15:14 +0200)
Add a flag to skip initial revisions: some SVN repositories have
initial setup cruft in their logs which we might want to ignore.

Signed-Off-By: Matthias Urlichs <smurf@smurf.noris.de>
Documentation/git-svnimport.txt
git-svnimport.perl
index be03a65f8153c2a0fbce982cb1e8595c592f308f..a144c6c31ca9131b00be1585a785ede53f87a731 100644 (file)
@@ -12,7 +12,7 @@ SYNOPSIS
 'git-svnimport' [ -o <branch-for-HEAD> ] [ -h ] [ -v ]
                        [ -C <GIT_repository> ] [ -i ] [ -u ]
                        [ -b branch_subdir ] [ -t trunk_subdir ] [ -T tag_subdir ]
 'git-svnimport' [ -o <branch-for-HEAD> ] [ -h ] [ -v ]
                        [ -C <GIT_repository> ] [ -i ] [ -u ]
                        [ -b branch_subdir ] [ -t trunk_subdir ] [ -T tag_subdir ]
-                       [ -m ] [ -M regex ] [ <SVN_repository_URL> ]
+                       [ -s start_chg ] [ -m ] [ -M regex ] [ <SVN_repository_URL> ]
 
 
 DESCRIPTION
 
 
 DESCRIPTION
@@ -36,6 +36,11 @@ OPTIONS
         The GIT repository to import to.  If the directory doesn't
         exist, it will be created.  Default is the current directory.
 
         The GIT repository to import to.  If the directory doesn't
         exist, it will be created.  Default is the current directory.
 
+-s <start_rev>::
+        Start importing at this SVN change number. The  default is 1.
++
+When importing incementally, you might need to edit the .git/svn2git file.
+
 -i::
        Import-only: don't perform a checkout after importing.  This option
        ensures the working directory and cache remain untouched and will
 -i::
        Import-only: don't perform a checkout after importing.  This option
        ensures the working directory and cache remain untouched and will
index 10ffb5477ef172163147605f50d74e75f115f431..896222ba741e983b3f7b76feaeae268b250ace92 100755 (executable)
 $SIG{'PIPE'}="IGNORE";
 $ENV{'TZ'}="UTC";
 
 $SIG{'PIPE'}="IGNORE";
 $ENV{'TZ'}="UTC";
 
-our($opt_h,$opt_o,$opt_v,$opt_u,$opt_C,$opt_i,$opt_m,$opt_M,$opt_t,$opt_T,$opt_b);
+our($opt_h,$opt_o,$opt_v,$opt_u,$opt_C,$opt_i,$opt_m,$opt_M,$opt_t,$opt_T,$opt_b,$opt_s);
 
 sub usage() {
        print STDERR <<END;
 Usage: ${\basename $0}     # fetch/update GIT from CVS
        [-o branch-for-HEAD] [-h] [-v]
        [-C GIT_repository] [-t tagname] [-T trunkname] [-b branchname]
 
 sub usage() {
        print STDERR <<END;
 Usage: ${\basename $0}     # fetch/update GIT from CVS
        [-o branch-for-HEAD] [-h] [-v]
        [-C GIT_repository] [-t tagname] [-T trunkname] [-b branchname]
-       [-i] [-u] [-s subst] [-m] [-M regex] [SVN_URL]
+       [-i] [-u] [-s start_chg] [-m] [-M regex] [SVN_URL]
 END
        exit(1);
 }
 
 END
        exit(1);
 }
 
-getopts("b:C:hivmM:o:t:T:u") or usage();
+getopts("b:C:hivmM:o:s:t:T:u") or usage();
 usage if $opt_h;
 
 my $tag_name = $opt_t || "tags";
 usage if $opt_h;
 
 my $tag_name = $opt_t || "tags";
@@ -192,7 +192,7 @@ ($$)
 my $maxnum = 0;
 my $last_rev = "";
 my $last_branch;
 my $maxnum = 0;
 my $last_rev = "";
 my $last_branch;
-my $current_rev = 0;
+my $current_rev = $opt_s ? ($opt_s-1) : 0;
 unless(-d $git_dir) {
        system("git-init-db");
        die "Cannot init the GIT db at $git_tree: $?\n" if $?;
 unless(-d $git_dir) {
        system("git-init-db");
        die "Cannot init the GIT db at $git_tree: $?\n" if $?;
@@ -364,7 +364,7 @@ sub commit {
        }
 
        my $rev;
        }
 
        my $rev;
-       if(defined $parent) {
+       if($revision > $opt_s and defined $parent) {
                open(H,"git-rev-parse --verify $parent |");
                $rev = <H>;
                close(H) or do {
                open(H,"git-rev-parse --verify $parent |");
                $rev = <H>;
                close(H) or do {
@@ -377,7 +377,7 @@ sub commit {
                        return;
                }
                $rev = $branches{($parent eq $opt_o) ? "/" : $parent}{"LAST"};
                        return;
                }
                $rev = $branches{($parent eq $opt_o) ? "/" : $parent}{"LAST"};
-               if($revision != 1 and not $rev) {
+               if($revision != $opt_s and not $rev) {
                        print STDERR "$revision: do not know ancestor for '$parent'!\n";
                        return;
                }
                        print STDERR "$revision: do not know ancestor for '$parent'!\n";
                        return;
                }