partial svnimport [was: Re: [PATCH] git-svnimport: Parse log message for Signed-off-by: lines]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 17:33 Wed 06 Sep     , Matthias Urlichs wrote:
> Hi,
> 
> Sasha Khapyorsky:
> > At least I didn't succeed with reversed layout. With option
> > -T <trunk>/$project import works but only for trunk branch, attempts
> > to specify branch as -b <branches> or -b <branches>/$project don't help,
> > the same is with tags.
> > 
> That's true. The problem is that it wants the tag or branch name as the
> last component of the path.
> 
> A more generic solution would be to use wildcards in the branch/tag
> specification, to allow more than one wildcard, and to be able to
> specify the exact form of the branch or tag name on the git side.

Or perhaps just to specify path of the project (or sub-project) after
trunk/branches*/ . Like in this patch:


diff --git a/git-svnimport.perl b/git-svnimport.perl
index 988514e..86a6e8a 100755
--- a/git-svnimport.perl
+++ b/git-svnimport.perl
@@ -31,7 +31,8 @@ die "Need SVN:Core 1.2.1 or better" if $
 $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,$opt_r,$opt_I,$opt_A,$opt_s,$opt_l,$opt_d,$opt_D,$opt_S,$opt_F);
+    $opt_b,$opt_r,$opt_I,$opt_A,$opt_s,$opt_l,$opt_d,$opt_D,$opt_S,$opt_F,
+    $opt_P);
 
 sub usage() {
 	print STDERR <<END;
@@ -39,17 +40,19 @@ Usage: ${\basename $0}     # fetch/updat
        [-o branch-for-HEAD] [-h] [-v] [-l max_rev]
        [-C GIT_repository] [-t tagname] [-T trunkname] [-b branchname]
        [-d|-D] [-i] [-u] [-r] [-I ignorefilename] [-s start_chg]
-       [-m] [-M regex] [-A author_file] [-S] [-F] [SVN_URL]
+       [-m] [-M regex] [-A author_file] [-S] [-F] [-P project] [SVN_URL]
 END
 	exit(1);
 }
 
-getopts("A:b:C:dDFhiI:l:mM:o:rs:t:T:Suv") or usage();
+getopts("A:b:C:dDFhiI:l:mM:o:rs:t:T:SP:uv") or usage();
 usage if $opt_h;
 
 my $tag_name = $opt_t || "tags";
 my $trunk_name = $opt_T || "trunk";
 my $branch_name = $opt_b || "branches";
+my $project_name = $opt_P || "";
+$project_name = "/" . $project_name if ($project_name);
 
 @ARGV == 1 or @ARGV == 2 or usage();
 
@@ -356,11 +359,11 @@ sub revert_split_path($$) {
 	my $svnpath;
 	$path = "" if $path eq "/"; # this should not happen, but ...
 	if($branch eq "/") {
-		$svnpath = "$trunk_name/$path";
+		$svnpath = "$trunk_name$project_name/$path";
 	} elsif($branch =~ m#^/#) {
-		$svnpath = "$tag_name$branch/$path";
+		$svnpath = "$tag_name$branch$project_name/$path";
 	} else {
-		$svnpath = "$branch_name/$branch/$path";
+		$svnpath = "$branch_name/$branch$project_name/$path";
 	}
 
 	$svnpath =~ s#/+$##;
@@ -864,6 +867,20 @@ #	}
 	print "DONE: $revision $dest $cid\n" if $opt_v;
 }
 
+sub project_path($$)
+{
+	my ($path, $project) = @_;
+
+	$path = "/".$path unless ($path =~ m#^\/#) ;
+	return $1 if ($path =~ m#^$project\/(.*)$#);
+
+	$path =~ s#\.#\\\.#g;
+	$path =~ s#\+#\\\+#g;
+	return "/" if ($project =~ m#^$path.*$#);
+
+	return undef;
+}
+
 sub commit_all {
 	# Recursive use of the SVN connection does not work
 	local $svn = $svn2;
@@ -883,6 +900,10 @@ sub commit_all {
 	while(my($path,$action) = each %$changed_paths) {
 		($branch,$path) = split_path($revision,$path);
 		next if not defined $branch;
+		if ($project_name) {
+			$path = project_path($path, $project_name);
+			next if not defined $path;
+		}
 		$done{$branch}{$path} = $action;
 	}
 	while(($branch,$changed_paths) = each %done) {


(will submit if above is acceptable)

> All of this should be specified in the repository's git config file,
> not on the command line.

It is for incremental imports? So we will not need to reproduce exact
command line for each git-svnimport run? Good idea.

Sasha
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]