git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] contrib/git-svn: version 0.10.0
  2006-02-26 10:22 ` [PATCH] contrib/git-svn: optimize sequential commits to svn Eric Wong
@ 2006-02-26 10:22   ` Eric Wong
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Wong @ 2006-02-26 10:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Eric Wong

New features deserve an increment of the minor version.  This will very
likely become 1.0.0 unless release-critical bugs are found.

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

 contrib/git-svn/git-svn.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

8d35c4193507147a6caa8a25b0ed1e5e9c43a49c
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index 29c8690..9f12836 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -8,7 +8,7 @@ use vars qw/	$AUTHOR $VERSION
 		$GIT_SVN_INDEX $GIT_SVN
 		$GIT_DIR $REV_DIR/;
 $AUTHOR = 'Eric Wong <normalperson@yhbt.net>';
-$VERSION = '0.9.1';
+$VERSION = '0.10.0';
 $GIT_DIR = $ENV{GIT_DIR} || "$ENV{PWD}/.git";
 $GIT_SVN = $ENV{GIT_SVN_ID} || 'git-svn';
 $GIT_SVN_INDEX = "$GIT_DIR/$GIT_SVN/index";
-- 
1.2.2.ga559

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] contrib/git-svn: optimize sequential commits to svn
  2006-02-26 10:22 [PATCH] contrib/git-svn: add show-ignore command Eric Wong
@ 2006-02-26 10:22 ` Eric Wong
  2006-02-26 10:22   ` [PATCH] contrib/git-svn: version 0.10.0 Eric Wong
  2006-02-26 22:53 ` [PATCH] contrib/git-svn: add show-ignore command Junio C Hamano
  1 sibling, 1 reply; 6+ messages in thread
From: Eric Wong @ 2006-02-26 10:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Eric Wong

Avoid running 'svn up' to a previous revision if we know the
revision we just committed is the first descendant of the
revision we came from.

This reduces the time to do a series of commits by about 25%.

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

 contrib/git-svn/git-svn.perl |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)

ea810425ed7d5d16c12b3f49246ba2a03ac3d23d
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index 84d43de..29c8690 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -30,6 +30,7 @@ use File::Basename qw/dirname basename/;
 use File::Path qw/mkpath/;
 use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
 use File::Spec qw//;
+use POSIX qw/strftime/;
 my $sha1 = qr/[a-f\d]{40}/;
 my $sha1_short = qr/[a-f\d]{6,40}/;
 my ($_revision,$_stdin,$_no_ignore_ext,$_no_stop_copy,$_help,$_rmdir,$_edit,
@@ -591,6 +592,7 @@ sub handle_rmdir {
 sub svn_commit_tree {
 	my ($svn_rev, $commit) = @_;
 	my $commit_msg = "$GIT_DIR/$GIT_SVN/.svn-commit.tmp.$$";
+	my %log_msg = ( msg => '' );
 	open my $msg, '>', $commit_msg  or croak $!;
 
 	chomp(my $type = `git-cat-file -t $commit`);
@@ -606,6 +608,7 @@ sub svn_commit_tree {
 			if (!$in_msg) {
 				$in_msg = 1 if (/^\s*$/);
 			} else {
+				$log_msg{msg} .= $_;
 				print $msg $_ or croak $!;
 			}
 		}
@@ -625,9 +628,30 @@ sub svn_commit_tree {
 			join("\n",@ci_output),"\n";
 	my ($rev_committed) = ($committed =~ /^Committed revision (\d+)\./);
 
-	# resync immediately
-	my @svn_up = (qw(svn up), "-r$svn_rev");
+	my @svn_up = qw(svn up);
 	push @svn_up, '--ignore-externals' unless $_no_ignore_ext;
+	if ($rev_committed == ($svn_rev + 1)) {
+		push @svn_up, "-r$rev_committed";
+		sys(@svn_up);
+		my $info = svn_info('.');
+		my $date = $info->{'Last Changed Date'} or die "Missing date\n";
+		if ($info->{'Last Changed Rev'} != $rev_committed) {
+			croak "$info->{'Last Changed Rev'} != $rev_committed\n"
+		}
+		my ($Y,$m,$d,$H,$M,$S,$tz) = ($date =~
+					/(\d{4})\-(\d\d)\-(\d\d)\s
+					 (\d\d)\:(\d\d)\:(\d\d)\s([\-\+]\d+)/x)
+					 or croak "Failed to parse date: $date\n";
+		$log_msg{date} = "$tz $Y-$m-$d $H:$M:$S";
+		$log_msg{author} = $info->{'Last Changed Author'};
+		$log_msg{revision} = $rev_committed;
+		$log_msg{msg} .= "\n";
+		my $parent = file_to_s("$REV_DIR/$svn_rev");
+		git_commit(\%log_msg, $parent, $commit);
+		return $rev_committed;
+	}
+	# resync immediately
+	push @svn_up, "-r$svn_rev";
 	sys(@svn_up);
 	return fetch("$rev_committed=$commit")->{revision};
 }
@@ -724,7 +748,7 @@ sub svn_info {
 	# only single-lines seem to exist in svn info output
 	while (<$info_fh>) {
 		chomp $_;
-		if (m#^([^:]+)\s*:\s*(\S*)$#) {
+		if (m#^([^:]+)\s*:\s*(\S.*)$#) {
 			$ret->{$1} = $2;
 			push @{$ret->{-order}}, $1;
 		}
-- 
1.2.2.ga559

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] contrib/git-svn: add show-ignore command
@ 2006-02-26 10:22 Eric Wong
  2006-02-26 10:22 ` [PATCH] contrib/git-svn: optimize sequential commits to svn Eric Wong
  2006-02-26 22:53 ` [PATCH] contrib/git-svn: add show-ignore command Junio C Hamano
  0 siblings, 2 replies; 6+ messages in thread
From: Eric Wong @ 2006-02-26 10:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Eric Wong

Recursively finds and lists the svn:ignore property on
directories.  The output is suitable for appending to the
$GIT_DIR/info/exclude file.

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

 contrib/git-svn/git-svn.perl |   25 +++++++++++++++++++++++++
 contrib/git-svn/git-svn.txt  |    7 +++++++
 2 files changed, 32 insertions(+), 0 deletions(-)

0858c770ef3e0f440c20a255baaf4792b3201813
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index a32ce15..84d43de 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -49,6 +49,7 @@ my %cmd = (
 	fetch => [ \&fetch, "Download new revisions from SVN" ],
 	init => [ \&init, "Initialize and fetch (import)"],
 	commit => [ \&commit, "Commit git revisions to SVN" ],
+	'show-ignore' => [ \&show_ignore, "Show svn:ignore listings" ],
 	rebuild => [ \&rebuild, "Rebuild git-svn metadata (after git clone)" ],
 	help => [ \&usage, "Show help" ],
 );
@@ -258,6 +259,30 @@ sub commit {
 
 }
 
+sub show_ignore {
+	require File::Find or die $!;
+	my $exclude_file = "$GIT_DIR/info/exclude";
+	open my $fh, '<', $exclude_file or croak $!;
+	chomp(my @excludes = (<$fh>));
+	close $fh or croak $!;
+	
+	$SVN_URL ||= file_to_s("$GIT_DIR/$GIT_SVN/info/url");
+	chdir $SVN_WC or croak $!;
+	my %ign;
+	File::Find::find({wanted=>sub{if(lstat $_ && -d _ && -d "$_/.svn"){
+		s#^\./##;
+		@{$ign{$_}} = safe_qx(qw(svn propget svn:ignore),$_);
+		}}, no_chdir=>1},'.');
+	
+	print "\n# /\n";
+	foreach (@{$ign{'.'}}) { print '/',$_ if /\S/ }
+	delete $ign{'.'};
+	foreach my $i (sort keys %ign) {
+		print "\n# ",$i,"\n";
+		foreach (@{$ign{$i}}) { print '/',$i,'/',$_ if /\S/ }
+	}
+}
+
 ########################### utility functions #########################
 
 sub setup_git_svn {
diff --git a/contrib/git-svn/git-svn.txt b/contrib/git-svn/git-svn.txt
index cf098d7..b4b7789 100644
--- a/contrib/git-svn/git-svn.txt
+++ b/contrib/git-svn/git-svn.txt
@@ -61,6 +61,11 @@ rebuild::
 	the directory/repository you're tracking has moved or changed
 	protocols.
 
+show-ignore::
+	Recursively finds and lists the svn:ignore property on
+	directories.  The output is suitable for appending to
+	the $GIT_DIR/info/exclude file.
+
 OPTIONS
 -------
 -r <ARG>::
@@ -152,6 +157,8 @@ Tracking and contributing to an Subversi
 	git commit git-svn-HEAD..my-branch
 # Something is committed to SVN, pull the latest into your branch::
 	git-svn fetch && git pull . git-svn-HEAD
+# Append svn:ignore settings to the default git exclude file:
+	git-svn show-ignore >> .git/info/exclude
 
 DESIGN PHILOSOPHY
 -----------------
-- 
1.2.2.ga559

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] contrib/git-svn: add show-ignore command
  2006-02-26 10:22 [PATCH] contrib/git-svn: add show-ignore command Eric Wong
  2006-02-26 10:22 ` [PATCH] contrib/git-svn: optimize sequential commits to svn Eric Wong
@ 2006-02-26 22:53 ` Junio C Hamano
  2006-02-26 23:46   ` Eric Wong
  1 sibling, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2006-02-26 22:53 UTC (permalink / raw)
  To: Eric Wong; +Cc: git

After Andrew Morten raised the issue, I've made sure I _really_
enable my pre-applypatch hook.

Please enable your pre-commit hook (comes with the distribution
as a sample hook) to catch these trailing whitespaces before
they hit your commit objects.

Applying 'contrib/git-svn: add show-ignore command'

*
* You have some suspicious patch lines:
*
* In contrib/git-svn/git-svn.perl
* trailing whitespace (line 268)
contrib/git-svn/git-svn.perl:268:	
* trailing whitespace (line 276)
contrib/git-svn/git-svn.perl:276:	

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] contrib/git-svn: add show-ignore command
  2006-02-26 22:53 ` [PATCH] contrib/git-svn: add show-ignore command Junio C Hamano
@ 2006-02-26 23:46   ` Eric Wong
  2006-02-27  0:16     ` Eric Wong
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Wong @ 2006-02-26 23:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano <junkio@cox.net> wrote:
> After Andrew Morten raised the issue, I've made sure I _really_
> enable my pre-applypatch hook.
> 
> Please enable your pre-commit hook (comes with the distribution
> as a sample hook) to catch these trailing whitespaces before
> they hit your commit objects.

Oops, sorry about this one.  I forgot it on the directory I was working
on at the time.  I've also added Dave Jones' whitespace hilighter lines
to my .vimrc as well.

-- 
Eric Wong

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] contrib/git-svn: add show-ignore command
  2006-02-26 23:46   ` Eric Wong
@ 2006-02-27  0:16     ` Eric Wong
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Wong @ 2006-02-27  0:16 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Recursively finds and lists the svn:ignore property on
directories.  The output is suitable for appending to the
$GIT_DIR/info/exclude file.

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

 Note: Whitespace cleaned

 contrib/git-svn/git-svn.perl |   25 +++++++++++++++++++++++++
 contrib/git-svn/git-svn.txt  |    7 +++++++
 2 files changed, 32 insertions(+), 0 deletions(-)

63b497ce5f0762cdfef3ef30ec658b8c98e1a144
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index a32ce15..3d855f1 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -49,6 +49,7 @@ my %cmd = (
 	fetch => [ \&fetch, "Download new revisions from SVN" ],
 	init => [ \&init, "Initialize and fetch (import)"],
 	commit => [ \&commit, "Commit git revisions to SVN" ],
+	'show-ignore' => [ \&show_ignore, "Show svn:ignore listings" ],
 	rebuild => [ \&rebuild, "Rebuild git-svn metadata (after git clone)" ],
 	help => [ \&usage, "Show help" ],
 );
@@ -258,6 +259,30 @@ sub commit {
 
 }
 
+sub show_ignore {
+	require File::Find or die $!;
+	my $exclude_file = "$GIT_DIR/info/exclude";
+	open my $fh, '<', $exclude_file or croak $!;
+	chomp(my @excludes = (<$fh>));
+	close $fh or croak $!;
+
+	$SVN_URL ||= file_to_s("$GIT_DIR/$GIT_SVN/info/url");
+	chdir $SVN_WC or croak $!;
+	my %ign;
+	File::Find::find({wanted=>sub{if(lstat $_ && -d _ && -d "$_/.svn"){
+		s#^\./##;
+		@{$ign{$_}} = safe_qx(qw(svn propget svn:ignore),$_);
+		}}, no_chdir=>1},'.');
+
+	print "\n# /\n";
+	foreach (@{$ign{'.'}}) { print '/',$_ if /\S/ }
+	delete $ign{'.'};
+	foreach my $i (sort keys %ign) {
+		print "\n# ",$i,"\n";
+		foreach (@{$ign{$i}}) { print '/',$i,'/',$_ if /\S/ }
+	}
+}
+
 ########################### utility functions #########################
 
 sub setup_git_svn {
diff --git a/contrib/git-svn/git-svn.txt b/contrib/git-svn/git-svn.txt
index cf098d7..b4b7789 100644
--- a/contrib/git-svn/git-svn.txt
+++ b/contrib/git-svn/git-svn.txt
@@ -61,6 +61,11 @@ rebuild::
 	the directory/repository you're tracking has moved or changed
 	protocols.
 
+show-ignore::
+	Recursively finds and lists the svn:ignore property on
+	directories.  The output is suitable for appending to
+	the $GIT_DIR/info/exclude file.
+
 OPTIONS
 -------
 -r <ARG>::
@@ -152,6 +157,8 @@ Tracking and contributing to an Subversi
 	git commit git-svn-HEAD..my-branch
 # Something is committed to SVN, pull the latest into your branch::
 	git-svn fetch && git pull . git-svn-HEAD
+# Append svn:ignore settings to the default git exclude file:
+	git-svn show-ignore >> .git/info/exclude
 
 DESIGN PHILOSOPHY
 -----------------
-- 
1.2.2.ga559

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-02-27  0:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-26 10:22 [PATCH] contrib/git-svn: add show-ignore command Eric Wong
2006-02-26 10:22 ` [PATCH] contrib/git-svn: optimize sequential commits to svn Eric Wong
2006-02-26 10:22   ` [PATCH] contrib/git-svn: version 0.10.0 Eric Wong
2006-02-26 22:53 ` [PATCH] contrib/git-svn: add show-ignore command Junio C Hamano
2006-02-26 23:46   ` Eric Wong
2006-02-27  0:16     ` Eric Wong

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).