git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
SKSasha Khapyorsky <sashak@voltaire.com>
Date
Sep 28, 2006, 19:44 UTC
Message-ID
<20060928194457.GE10617@sashak.voltaire.com>
In-Reply-To
<20060906153314.GE6999@kiste.smurf.noris.de>
Hi,
On 17:33 Wed 06 Sep     , Matthias Urlichs wrote:
Show 14 quoted lines
> 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
Previous: Matthias Urlichs
Message 7 of 7 in “git-svnimport: Parse log message for Signed-off-by: lines”
  1. git-svnimport: Parse log message for Signed-off-by: linesSasha Khapyorsky, Sep 5, 2006
  2. Junio C HamanoSep 5, 2006
  3. Sasha KhapyorskySep 5, 2006
  4. Junio C HamanoSep 5, 2006
  5. Sasha KhapyorskySep 6, 2006
  6. Matthias UrlichsSep 6, 2006
  7. partial svnimport [was: Re: [PATCH] git-svnimport: Parse log message for Signed-off-by: lines]Sasha Khapyorsky, Sep 28, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.