From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Sperling Subject: Re: [PATCH] Allow multiple tag and branch directories in git-svnimport Date: Tue, 21 Aug 2007 19:38:38 +0200 Message-ID: <20070821173838.GC1721@jack.stsp.lan> References: <20070821170858.GA1721@jack.stsp.lan> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="vOmOzSkFvhd7u8Ms" Cc: subversion@elego.de To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Tue Aug 21 19:39:03 2007 Return-path: Envelope-to: gcvg-git@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1INXgx-0005dU-AV for gcvg-git@gmane.org; Tue, 21 Aug 2007 19:38:59 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759074AbXHURiy (ORCPT ); Tue, 21 Aug 2007 13:38:54 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758785AbXHURiy (ORCPT ); Tue, 21 Aug 2007 13:38:54 -0400 Received: from einhorn.in-berlin.de ([192.109.42.8]:46428 "EHLO einhorn.in-berlin.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757956AbXHURix (ORCPT ); Tue, 21 Aug 2007 13:38:53 -0400 X-Greylist: delayed 1455 seconds by postgrey-1.27 at vger.kernel.org; Tue, 21 Aug 2007 13:38:53 EDT X-Envelope-From: stsp@elego.de Received: from stsp.lan (stsp2.in-vpn.de [217.197.85.95]) (authenticated bits=128) by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id l7LHclRW016605 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 21 Aug 2007 19:38:48 +0200 Received: from jack.stsp.lan (stsp@localhost.stsp.lan [127.0.0.1]) by stsp.lan (8.14.1/8.14.0) with ESMTP id l7LHccdX010140; Tue, 21 Aug 2007 19:38:38 +0200 (CEST) Received: (from stsp@localhost) by jack.stsp.lan (8.14.1/8.14.0/Submit) id l7LHccZx003054; Tue, 21 Aug 2007 19:38:38 +0200 (CEST) X-Authentication-Warning: jack.stsp.lan: stsp set sender to stsp@elego.de using -f Mail-Followup-To: git@vger.kernel.org, subversion@elego.de Content-Disposition: inline In-Reply-To: <20070821170858.GA1721@jack.stsp.lan> User-Agent: Mutt/1.5.16 (2007-06-09) X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 Sender: git-owner@vger.kernel.org Precedence: bulk X-Mailing-List: git@vger.kernel.org Archived-At: --vOmOzSkFvhd7u8Ms Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 21, 2007 at 07:08:58PM +0200, Stefan Sperling wrote: > +my @tag_dirs =3D defined $opt_t ? split /:/,$opt_t : "tags"; ^ ^^^^^ > +my @branch_dirs =3D 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: diff --git a/Documentation/git-svnimport.txt b/Documentation/git-svnimport.= txt index e97d15e..2cfc407 100644 --- a/Documentation/git-svnimport.txt +++ b/Documentation/git-svnimport.txt @@ -12,11 +12,11 @@ SYNOPSIS [verse] 'git-svnimport' [ -o ] [ -h ] [ -v ] [ -d | -D ] [ -C ] [ -i ] [ -u ] [-l limit_rev] - [ -b branch_subdir ] [ -T trunk_subdir ] [ -t tag_subdir ] - [ -s start_chg ] [ -m ] [ -r ] [ -M regex ] - [ -I ] [ -A ] - [ -R ] [ -P ] - [ ] + [ -b branch_subdir[:branch_subdir:...] ] [ -T trunk_subdir ] + [ -t tag_subdir[:tag_subdir:...] ] [ -s start_chg ] [ -m ] + [ -r ] [ -M regex ] [ -I ] + [ -A ] [ -R ] + [ -P ] [ ] =20 =20 DESCRIPTION @@ -26,11 +26,6 @@ repository, or incrementally import into an existing one. =20 SVN access is done by the SVN::Perl module. =20 -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. =20 @@ -53,11 +48,13 @@ When importing incrementally, you might need to edit th= e .git/svn2git file. -T :: Name the SVN trunk. Default "trunk". =20 --t :: - Name the SVN subdirectory for tags. Default "tags". +-t :: + Colon-seperated list of names of subdirectories containing tags. + Default "tags". =20 --b :: - Name the SVN subdirectory for branches. Default "branches". +-b :: + Colon-seperated list of names of subdirectories containing branches. + Default "branches". =20 -o :: The 'trunk' branch from SVN is imported to the 'origin' branch within diff --git a/git-svnimport.perl b/git-svnimport.perl index fc9ea71..96f0926 100755 --- a/git-svnimport.perl +++ b/git-svnimport.perl @@ -38,9 +38,10 @@ sub usage() { print STDERR < 1, - "/$tag_name" =3D> 1, - "/$branch_name" =3D> 1 - ); - print STDERR "$rev: Unrecognized path: $path\n" unless (defined $no_erro= r{$path}); - return () + if (! $dir) { + my %no_error =3D ( "/" =3D> 1, "/tags" =3D> 1, "/branches" =3D> 1 ); + foreach (@tag_dirs) { + $no_error{"/$_"} =3D 1; + } + foreach (@branch_dirs) { + $no_error{"/$_"} =3D 1; + } + print STDERR "$rev: Could not determine tag or branch ", + "directory for path '$path'\n", + unless (defined $no_error{$path}); } if ($path eq "") { $path =3D "/"; } elsif ($project_name) { $path =3D project_path($path, $project_name); } - return ($branch,$path); + return ($dir,$path); } =20 sub branch_rev($$) { @@ -874,9 +889,32 @@ sub commit { =20 $dest =3D~ tr/_/\./ if $opt_u; =20 - system('git-tag', $dest, $cid) =3D=3D 0 - or die "Cannot create tag $dest: $!\n"; - + # Since we support multiple directories that host tags we + # must support repositories that contain the same tag name + # in different tag directories for whatever reason, + # e.g. tags/jim/1.0-rc3 and tags/huck/1.0-rc3 + # + # Also, because in Subversion a given tag directory could + # exist in revision A, be deleted in revision B and later + # recreated under the same name in revision C, we + # cannot guarantee that a tag is unique simply by + # looking at the tag's path. + # + # So if we fail to create the tag the first time, we try + # to create the tag with the same name except with the + # revision number of the current commit appended. + # Users can rename tags again later after the repository + # has been converted if they don't like this. + # It's still much better than failing to convert the + # repository alltogether. + if (system('git-tag', $dest, $cid) !=3D 0) { + print STDERR "Could not create tag $dest, ", + "trying to create tag $dest-r$revision ", + "instead\n"; + $dest =3D "$dest-r$revision"; + system('git-tag', $dest, $cid) =3D=3D 0 + or die "Cannot create tag $dest: $? $!\n"; + } print "Created tag '$dest' on '$branch'\n" if $opt_v; } $branches{$branch}{"LAST"} =3D $cid; --=20 Stefan Sperling Software Developer elego Software Solutions GmbH HRB 77719 Gustav-Meyer-Allee 25, Gebaeude 12 Tel: +49 30 23 45 86 96=20 13355 Berlin Fax: +49 30 23 45 86 95 http://www.elego.de Geschaeftsfuehrer: Olaf Wagner --vOmOzSkFvhd7u8Ms Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (OpenBSD) iD8DBQFGyyMe5dMCc/WdJfARAjfzAKDqNkfIuh88COoomxH530n6yQmagACg8xmX cwXfS4OF5jIwUQ2RYlPugkY= =Wd8Y -----END PGP SIGNATURE----- --vOmOzSkFvhd7u8Ms--