git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: git@vger.kernel.org
Cc: Marc Branchaud <marcnarc@xiplink.com>,
	Eric Wong <normalperson@yhbt.net>,
	Michael J Gruber <git@drmicha.warpmail.net>
Subject: [MONKEY PATCH] git-svn: allow two branch configurations
Date: Thu, 18 Jun 2009 16:31:03 +0200	[thread overview]
Message-ID: <1245335463-4488-1-git-send-email-git@drmicha.warpmail.net> (raw)
In-Reply-To: <4A3A4945.6050307@drmicha.warpmail.net>

This is a MONKEY PATCH which introduces a long option and config
variable "branchse" analogous to "branches", with a short option "-B".
It has the same meaning and can be used to accomadate svn repos with two
different branches subdirectories.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 git-svn.perl |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

Well, this is not a serious patch per se, but it shows that git-svn can
very well handle multiple branches configs once it is told to read and
use them. I don't think it's possible to do this with globs, and
extending globs to regexps looks like a more complicated approach
(although they are used internally).

I see two viable options for a real patch now:
- Extend $remote->branches to be an array and use "config --get-all" to
  read the config; do the same for tags.
- Use one single array for branches as well as tags.

Eric, which way do you prefer? The first one is simpler and may be even
doable for me. The second looks more complicated mainly because of "git
svn branch -t" (which element of the combined array is tags?), even
though it's more natural if one thinks about the way svn works.

Michael

diff --git a/git-svn.perl b/git-svn.perl
index 3301797..e6a9422 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -92,11 +92,12 @@ my %fc_opts = ( 'follow-parent|follow!' => \$Git::SVN::_follow_parent,
 		'localtime' => \$Git::SVN::_localtime,
 		%remote_opts );
 
-my ($_trunk, $_tags, $_branches, $_stdlayout);
+my ($_trunk, $_tags, $_branches, $_branchse, $_stdlayout);
 my %icv;
 my %init_opts = ( 'template=s' => \$_template, 'shared:s' => \$_shared,
                   'trunk|T=s' => \$_trunk, 'tags|t=s' => \$_tags,
                   'branches|b=s' => \$_branches, 'prefix=s' => \$_prefix,
+                  'branchse|B=s' => \$_branchse,
                   'stdlayout|s' => \$_stdlayout,
                   'minimize-url|m' => \$Git::SVN::_minimize_url,
 		  'no-metadata' => sub { $icv{noMetadata} = 1 },
@@ -358,7 +359,7 @@ sub init_subdir {
 sub cmd_clone {
 	my ($url, $path) = @_;
 	if (!defined $path &&
-	    (defined $_trunk || defined $_branches || defined $_tags ||
+	    (defined $_trunk || defined $_branches || defined $_branchse || defined $_tags ||
 	     defined $_stdlayout) &&
 	    $url !~ m#^[a-z\+]+://#) {
 		$path = $url;
@@ -375,7 +376,7 @@ sub cmd_init {
 		$_tags = 'tags' if (!defined $_tags);
 		$_branches = 'branches' if (!defined $_branches);
 	}
-	if (defined $_trunk || defined $_branches || defined $_tags) {
+	if (defined $_trunk || defined $_branches || defined $_branchse || defined $_tags) {
 		return cmd_multi_init(@_);
 	}
 	my $url = shift or die "SVN repository location required ",
@@ -800,7 +801,7 @@ sub cmd_proplist {
 
 sub cmd_multi_init {
 	my $url = shift;
-	unless (defined $_trunk || defined $_branches || defined $_tags) {
+	unless (defined $_trunk || defined $_branches || defined $_branchse || defined $_tags) {
 		usage(1);
 	}
 
@@ -825,9 +826,10 @@ sub cmd_multi_init {
 						   undef, $trunk_ref);
 		}
 	}
-	return unless defined $_branches || defined $_tags;
+	return unless defined $_branches || defined $_branchse || defined $_tags;
 	my $ra = $url ? Git::SVN::Ra->new($url) : undef;
 	complete_url_ls_init($ra, $_branches, '--branches/-b', $_prefix);
+	complete_url_ls_init($ra, $_branchse, '--branchse/-B', $_prefix);
 	complete_url_ls_init($ra, $_tags, '--tags/-t', $_prefix . 'tags/');
 }
 
@@ -1563,7 +1565,7 @@ sub fetch_all {
 	my $base = defined $fetch ? $head : 0;
 
 	# read the max revs for wildcard expansion (branches/*, tags/*)
-	foreach my $t (qw/branches tags/) {
+	foreach my $t (qw/branches branchse tags/) {
 		defined $remote->{$t} or next;
 		push @globs, $remote->{$t};
 		my $max_rev = eval { tmp_config(qw/--int --get/,
@@ -1609,7 +1611,7 @@ sub read_all_remotes {
 			$r->{$1}->{svm} = {};
 		} elsif (m!^(.+)\.url=\s*(.*)\s*$!) {
 			$r->{$1}->{url} = $2;
-		} elsif (m!^(.+)\.(branches|tags)=
+		} elsif (m!^(.+)\.(branches|branchse|tags)=
 		           (.*):refs/remotes/(.+)\s*$/!x) {
 			my ($p, $g) = ($3, $4);
 			my $rs = $r->{$1}->{$2} = {
@@ -1760,7 +1762,7 @@ sub find_by_url { # repos_root and, path are optional
 		next if defined $repos_root && $repos_root ne $u;
 
 		my $fetch = $remotes->{$repo_id}->{fetch} || {};
-		foreach (qw/branches tags/) {
+		foreach (qw/branches branchse tags/) {
 			resolve_local_globs($u, $fetch,
 			                    $remotes->{$repo_id}->{$_});
 		}
-- 
1.6.3.2.406.gd6a466

  parent reply	other threads:[~2009-06-18 14:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-12 21:46 git svn: Supporting multiple branch subdirs? Marc Branchaud
2009-06-13 11:46 ` Michael J Gruber
2009-06-15 17:29   ` Marc Branchaud
2009-06-17 14:25     ` Michael J Gruber
2009-06-17 15:25       ` Marc Branchaud
2009-06-18 14:03         ` Michael J Gruber
2009-06-18 14:28           ` Marc Branchaud
2009-06-18 16:00             ` Michael J Gruber
2009-06-18 14:31           ` Michael J Gruber [this message]
2009-06-22 14:50             ` [MONKEY PATCH] git-svn: allow two branch configurations Marc Branchaud
2009-06-23 17:02               ` [PATCH] git svn: Support multiple branch and tag paths in the svn repository Marc Branchaud
2009-06-25  9:36                 ` Eric Wong
2009-06-25 22:25                   ` Junio C Hamano
2009-06-26  0:33                     ` Eric Wong
2009-06-26  5:18                       ` Andreas Ericsson
2009-06-26 18:11                         ` Eric Wong
2009-06-26 19:20                   ` Marc Branchaud
2009-06-26 20:49                     ` [PATCH] git svn: Doc update for multiple branch and tag paths Marc Branchaud
2009-06-26 20:57                     ` [PATCH] git svn: Support multiple branch and tag paths in the svn repository Eric Wong
2009-06-26 21:08                       ` [PATCH] git svn: Fix t9138-multiple-branches to use svn_cmd and (cd ...) syntax Marc Branchaud
2009-06-26 21:54                         ` Eric Wong
2009-06-27 15:03                           ` Marc Branchaud
2009-06-27 22:08                             ` Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1245335463-4488-1-git-send-email-git@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=marcnarc@xiplink.com \
    --cc=normalperson@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).