Skip to contentSkip to conversation

Allow multiple tag and branch directories in git-svnimport

PATCH In review Stefan Sperling 2 participants 4 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow multiple tag and branch directories in git-svnimport

With this patch, users can specify colon-seperated lists of directories containing tags and branches, respectively.

This makes git-svnimport much more usable in the real world because there are Subversion repositories that use a deeper tag and branch hierarchy than the recommended hierarchy of

trunk/
tags/
branches/

The patch assumes my memleak fix patch from
http://marc.info/?l=git&m=118554191513822&w=2
but applies cleanly to current vanilla git head as well.

I'm not subscribed to the list so please Cc me in replies, thanks.

Documentation/git-svnimport.txt +11 -14
index e97d15e..2cfc407 100644
@@ -12,11 +12,11 @@ SYNOPSIS
 [verse]
 'git-svnimport' [ -o <branch-for-HEAD> ] [ -h ] [ -v ] [ -d | -D ]
 		[ -C <GIT_repository> ] [ -i ] [ -u ] [-l limit_rev]
-		[ -b branch_subdir ] [ -T trunk_subdir ] [ -t tag_subdir ]
-		[ -s start_chg ] [ -m ] [ -r ] [ -M regex ]
-		[ -I <ignorefile_name> ] [ -A <author_file> ]
-		[ -R <repack_each_revs>] [ -P <path_from_trunk> ]
-		<SVN_repository_URL> [ <path> ]
+		[ -b branch_subdir[:branch_subdir:...] ] [ -T trunk_subdir ]
+		[ -t tag_subdir[:tag_subdir:...] ] [ -s start_chg ] [ -m ]
+		[ -r ] [ -M regex ] [ -I <ignorefile_name> ]
+		[ -A <author_file> ] [ -R <repack_each_revs>]
+		[ -P <path_from_trunk> ] <SVN_repository_URL> [ <path> ]
 
 
 DESCRIPTION
@@ -26,11 +26,6 @@ repository, or incrementally import into an existing one.
 
 SVN access is done by the SVN::Perl module.
 
-git-svnimport assumes that SVN repositories are organized into one
-"trunk" directory where the main development happens, "branches/FOO"
-directories for branches, and "/tags/FOO" directories for tags.
-Other subdirectories are ignored.
-
 git-svnimport creates a file ".git/svn2git", which is required for
 incremental SVN imports.
 
@@ -53,11 +48,13 @@ When importing incrementally, you might need to edit the .git/svn2git file.
 -T <trunk_subdir>::
 	Name the SVN trunk. Default "trunk".
 
--t <tag_subdir>::
-	Name the SVN subdirectory for tags. Default "tags".
+-t <tag_subdir[:tag_subdir:..]>::
+	Colon-seperated list of names of subdirectories containing tags.
+	Default "tags".
 
--b <branch_subdir>::
-	Name the SVN subdirectory for branches. Default "branches".
+-b <branch_subdir[:branch_subdir:...]>::
+	Colon-seperated list of names of subdirectories containing branches.
+	Default "branches".
 
 -o <branch-for-HEAD>::
 	The 'trunk' branch from SVN is imported to the 'origin' branch within
git-svnimport.perl +71 -33

141 lines not on this page · raw message

Signature · 5 lines
Stefan Sperling <[email protected]>                 Software Developer
elego Software Solutions GmbH                            HRB 77719
Gustav-Meyer-Allee 25, Gebaeude 12        Tel:  +49 30 23 45 86 96 
13355 Berlin                              Fax:  +49 30 23 45 86 95
http://www.elego.de                 Geschaeftsfuehrer: Olaf Wagner
#1 lore raw
Quoted 1 line · Stefan Sperling

+my @tag_dirs = defined $opt_t ? split /:/,$opt_t : "tags";

^ ^^^^^

Quoted 1 line

+my @branch_dirs = defined $opt_b ? split /:/,$opt_b : "branches";

^ ^^^^^^^^^^

Ouch, just noticed it's a bad idea to try to initialise an array with a scalar. Sorry :-/

Updated diff:

Documentation/git-svnimport.txt +11 -14
index e97d15e..2cfc407 100644
@@ -12,11 +12,11 @@ SYNOPSIS
 [verse]
 'git-svnimport' [ -o <branch-for-HEAD> ] [ -h ] [ -v ] [ -d | -D ]
 		[ -C <GIT_repository> ] [ -i ] [ -u ] [-l limit_rev]
-		[ -b branch_subdir ] [ -T trunk_subdir ] [ -t tag_subdir ]
-		[ -s start_chg ] [ -m ] [ -r ] [ -M regex ]
-		[ -I <ignorefile_name> ] [ -A <author_file> ]
-		[ -R <repack_each_revs>] [ -P <path_from_trunk> ]
-		<SVN_repository_URL> [ <path> ]
+		[ -b branch_subdir[:branch_subdir:...] ] [ -T trunk_subdir ]
+		[ -t tag_subdir[:tag_subdir:...] ] [ -s start_chg ] [ -m ]
+		[ -r ] [ -M regex ] [ -I <ignorefile_name> ]
+		[ -A <author_file> ] [ -R <repack_each_revs>]
+		[ -P <path_from_trunk> ] <SVN_repository_URL> [ <path> ]
 
 
 DESCRIPTION
@@ -26,11 +26,6 @@ repository, or incrementally import into an existing one.
 
 SVN access is done by the SVN::Perl module.
 
-git-svnimport assumes that SVN repositories are organized into one
-"trunk" directory where the main development happens, "branches/FOO"
-directories for branches, and "/tags/FOO" directories for tags.
-Other subdirectories are ignored.
-
 git-svnimport creates a file ".git/svn2git", which is required for
 incremental SVN imports.
 
@@ -53,11 +48,13 @@ When importing incrementally, you might need to edit the .git/svn2git file.
 -T <trunk_subdir>::
 	Name the SVN trunk. Default "trunk".
 
--t <tag_subdir>::
-	Name the SVN subdirectory for tags. Default "tags".
+-t <tag_subdir[:tag_subdir:..]>::
+	Colon-seperated list of names of subdirectories containing tags.
+	Default "tags".
 
--b <branch_subdir>::
-	Name the SVN subdirectory for branches. Default "branches".
+-b <branch_subdir[:branch_subdir:...]>::
+	Colon-seperated list of names of subdirectories containing branches.
+	Default "branches".
 
 -o <branch-for-HEAD>::
 	The 'trunk' branch from SVN is imported to the 'origin' branch within
git-svnimport.perl +71 -33

141 lines not on this page · raw message

Signature · 5 lines
Stefan Sperling <[email protected]>                 Software Developer
elego Software Solutions GmbH                            HRB 77719
Gustav-Meyer-Allee 25, Gebaeude 12        Tel:  +49 30 23 45 86 96 
13355 Berlin                              Fax:  +49 30 23 45 86 95
http://www.elego.de                 Geschaeftsfuehrer: Olaf Wagner
#2 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Stefan" == Stefan Sperling <[email protected]> writes:

Quoted 1 line · Stefan Sperling
Quoted 1 line

+my @tag_dirs = defined $opt_t ? split /:/,$opt_t : "tags";

Stefan> ^ ^^^^^

Quoted 1 line
Quoted 1 line

+my @branch_dirs = defined $opt_b ? split /:/,$opt_b : "branches";

Stefan> ^ ^^^^^^^^^^

Stefan> Ouch, just noticed it's a bad idea to try to initialise Stefan> an array with a scalar. Sorry :-/

That's completely normal. Perl predictably promotes the single scalar to an array of one element. I wouldn't have even noticed it in a detailed code review, since it's so normal to do that.

In fact, the parens that you added do *not* make it a list. The parens are purely for precedence in:

    @a = (3, 5, 7);

because otherwise, the text:

    @a = 3, 5, 7;

would be parsed as:

    (@a = 3), 5, 7;

which would be pretty pointless. It's the *comma* in a list context that makes it a list.

So, your parens are not only uncommon, they are also completely ineffective, similar to replacing 2 + 3 with (2) + (3) :)

Signature · 4 lines
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
#3 lore raw
Quoted 7 lines · Randal L. Schwartz

Stefan> Ouch, just noticed it's a bad idea to try to initialise Stefan> an array with a scalar. Sorry :-/

That's completely normal. Perl predictably promotes the single scalar to an array of one element. I wouldn't have even noticed it in a detailed code review, since it's so normal to do that.

Quoted 5 lines

In fact, the parens that you added do *not* make it a list. The parens are purely for precedence

So, your parens are not only uncommon, they are also completely ineffective, similar to replacing 2 + 3 with (2) + (3) :)

Thanks for clarifying. Prior to hacking on git-svnimport my perl "skills" (if any) were strictly read-only. So I'm quite a noob wrt perl.
Feel free to nit the patch further :)

Signature · 5 lines
Stefan Sperling <[email protected]>                 Software Developer
elego Software Solutions GmbH                            HRB 77719
Gustav-Meyer-Allee 25, Gebaeude 12        Tel:  +49 30 23 45 86 96 
13355 Berlin                              Fax:  +49 30 23 45 86 95
http://www.elego.de                 Geschaeftsfuehrer: Olaf Wagner