All of lore.kernel.org
 help / color / mirror / Atom feed
* Move Git::SVN into its own .pm file
@ 2012-07-25  6:01 Michael G. Schwern
  2012-07-25  6:01 ` [PATCH 1/4] Extract some utilities from git-svn to allow extracting Git::SVN Michael G. Schwern
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Michael G. Schwern @ 2012-07-25  6:01 UTC (permalink / raw)
  To: git, gitster; +Cc: robbat2, bwalton, normalperson

This is a refactoring to move Git::SVN out of git-svn and into its own .pm file.
This will make it easier to work with and test.  This is just the extraction
with minimal work to keep all tests passing.

A couple of utility functions which were used by Git::SVN, git-svn and others
were also extracted from git-svn into a new Git::SVN::Utils.  Not the most
imaginitive name, but it's better than Git::SVN grabbing at git-svn internals
and it allows Git::SVN (and later other classes) to stand alone without git-svn.

Its was reworked to be done backwards (instead of extracting and then fixing the
resulting problems, the problems were fixed in place and then it's extracted) in
order to keep every commit passing tests and provide a useful history.  This was
something of a pain.

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

* [PATCH 1/4] Extract some utilities from git-svn to allow extracting Git::SVN.
  2012-07-25  6:01 Move Git::SVN into its own .pm file Michael G. Schwern
@ 2012-07-25  6:01 ` Michael G. Schwern
  2012-07-25 21:24   ` Eric Wong
  2012-07-25  6:01 ` [PATCH 2/4] Prepare Git::SVN for extraction into its own file Michael G. Schwern
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Michael G. Schwern @ 2012-07-25  6:01 UTC (permalink / raw)
  To: git, gitster; +Cc: robbat2, bwalton, normalperson, Michael G. Schwern

From: "Michael G. Schwern" <schwern@pobox.com>

Put them in a new module called Git::SVN::Utils.  Yeah, not terribly
original and it will be a dumping ground.  But its better than having
them in the main git-svn program.  At least they can be documented
and tested.

* fatal() is used by many classes.
* Change the $can_compress lexical into a function.

This should be enough to extract Git::SVN.

Signed-off-by: Michael G. Schwern <schwern@pobox.com>
---
 git-svn.perl                   | 34 +++++++++++++-----------
 perl/Git/SVN/Utils.pm          | 59 ++++++++++++++++++++++++++++++++++++++++++
 perl/Makefile                  |  1 +
 t/Git-SVN/00compile.t          |  8 ++++++
 t/Git-SVN/Utils/can_compress.t | 11 ++++++++
 t/Git-SVN/Utils/fatal.t        | 34 ++++++++++++++++++++++++
 6 files changed, 132 insertions(+), 15 deletions(-)
 create mode 100644 perl/Git/SVN/Utils.pm
 create mode 100644 t/Git-SVN/00compile.t
 create mode 100644 t/Git-SVN/Utils/can_compress.t
 create mode 100644 t/Git-SVN/Utils/fatal.t

diff --git a/git-svn.perl b/git-svn.perl
index 0b074c4..79fe4a4 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -10,6 +10,8 @@ use vars qw/	$AUTHOR $VERSION
 $AUTHOR = 'Eric Wong <normalperson@yhbt.net>';
 $VERSION = '@@GIT_VERSION@@';
 
+use Git::SVN::Utils qw(fatal can_compress);
+
 # From which subdir have we been invoked?
 my $cmd_dir_prefix = eval {
 	command_oneline([qw/rev-parse --show-prefix/], STDERR => 0)
@@ -35,8 +37,6 @@ $Git::SVN::Log::TZ = $ENV{TZ};
 $ENV{TZ} = 'UTC';
 $| = 1; # unbuffer STDOUT
 
-sub fatal (@) { print STDERR "@_\n"; exit 1 }
-
 # All SVN commands do it.  Otherwise we may die on SIGPIPE when the remote
 # repository decides to close the connection which we expect to be kept alive.
 $SIG{PIPE} = 'IGNORE';
@@ -66,7 +66,7 @@ sub _req_svn {
 		fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)";
 	}
 }
-my $can_compress = eval { require Compress::Zlib; 1};
+
 use Carp qw/croak/;
 use Digest::MD5;
 use IO::File qw//;
@@ -1578,7 +1578,7 @@ sub cmd_reset {
 }
 
 sub cmd_gc {
-	if (!$can_compress) {
+	if (!can_compress()) {
 		warn "Compress::Zlib could not be found; unhandled.log " .
 		     "files will not be compressed.\n";
 	}
@@ -2014,13 +2014,13 @@ sub md5sum {
 	} elsif (!$ref) {
 		$md5->add($arg) or croak $!;
 	} else {
-		::fatal "Can't provide MD5 hash for unknown ref type: '", $ref, "'";
+		fatal "Can't provide MD5 hash for unknown ref type: '", $ref, "'";
 	}
 	return $md5->hexdigest();
 }
 
 sub gc_directory {
-	if ($can_compress && -f $_ && basename($_) eq "unhandled.log") {
+	if (can_compress() && -f $_ && basename($_) eq "unhandled.log") {
 		my $out_filename = $_ . ".gz";
 		open my $in_fh, "<", $_ or die "Unable to open $_: $!\n";
 		binmode $in_fh;
@@ -2055,6 +2055,9 @@ use Time::Local;
 use Memoize;  # core since 5.8.0, Jul 2002
 use Memoize::Storable;
 use POSIX qw(:signal_h);
+
+use Git::SVN::Utils qw(fatal can_compress);
+
 my $can_use_yaml;
 BEGIN {
 	$can_use_yaml = eval { require Git::SVN::Memoize::YAML; 1};
@@ -2880,8 +2883,8 @@ sub assert_index_clean {
 		command_noisy('read-tree', $treeish);
 		$x = command_oneline('write-tree');
 		if ($y ne $x) {
-			::fatal "trees ($treeish) $y != $x\n",
-			        "Something is seriously wrong...";
+			fatal "trees ($treeish) $y != $x\n",
+			      "Something is seriously wrong...";
 		}
 	});
 }
@@ -3236,7 +3239,7 @@ sub mkemptydirs {
 	my %empty_dirs = ();
 	my $gz_file = "$self->{dir}/unhandled.log.gz";
 	if (-f $gz_file) {
-		if (!$can_compress) {
+		if (!can_compress()) {
 			warn "Compress::Zlib could not be found; ",
 			     "empty directories in $gz_file will not be read\n";
 		} else {
@@ -3919,7 +3922,7 @@ sub set_tree {
 	my ($self, $tree) = (shift, shift);
 	my $log_entry = ::get_commit_entry($tree);
 	unless ($self->{last_rev}) {
-		::fatal("Must have an existing revision to commit");
+		fatal("Must have an existing revision to commit");
 	}
 	my %ed_opts = ( r => $self->{last_rev},
 	                log => $log_entry->{log},
@@ -4348,6 +4351,7 @@ sub remove_username {
 package Git::SVN::Log;
 use strict;
 use warnings;
+use Git::SVN::Utils qw(fatal);
 use POSIX qw/strftime/;
 use constant commit_log_separator => ('-' x 72) . "\n";
 use vars qw/$TZ $limit $color $pager $non_recursive $verbose $oneline
@@ -4446,15 +4450,15 @@ sub config_pager {
 sub run_pager {
 	return unless defined $pager;
 	pipe my ($rfd, $wfd) or return;
-	defined(my $pid = fork) or ::fatal "Can't fork: $!";
+	defined(my $pid = fork) or fatal "Can't fork: $!";
 	if (!$pid) {
 		open STDOUT, '>&', $wfd or
-		                     ::fatal "Can't redirect to stdout: $!";
+		                     fatal "Can't redirect to stdout: $!";
 		return;
 	}
-	open STDIN, '<&', $rfd or ::fatal "Can't redirect stdin: $!";
+	open STDIN, '<&', $rfd or fatal "Can't redirect stdin: $!";
 	$ENV{LESS} ||= 'FRSX';
-	exec $pager or ::fatal "Can't run pager: $! ($pager)";
+	exec $pager or fatal "Can't run pager: $! ($pager)";
 }
 
 sub format_svn_date {
@@ -4603,7 +4607,7 @@ sub cmd_show_log {
 		} elsif ($::_revision =~ /^\d+$/) {
 			$r_min = $r_max = $::_revision;
 		} else {
-			::fatal "-r$::_revision is not supported, use ",
+			fatal "-r$::_revision is not supported, use ",
 				"standard 'git log' arguments instead";
 		}
 	}
diff --git a/perl/Git/SVN/Utils.pm b/perl/Git/SVN/Utils.pm
new file mode 100644
index 0000000..3d0bfa4
--- /dev/null
+++ b/perl/Git/SVN/Utils.pm
@@ -0,0 +1,59 @@
+package Git::SVN::Utils;
+
+use strict;
+use warnings;
+
+use base qw(Exporter);
+
+our @EXPORT_OK = qw(fatal can_compress);
+
+
+=head1 NAME
+
+Git::SVN::Utils - utility functions used across Git::SVN
+
+=head1 SYNOPSIS
+
+    use Git::SVN::Utils qw(functions to import);
+
+=head1 DESCRIPTION
+
+This module contains functions which are useful across many different
+parts of Git::SVN.  Mostly it's a place to put utility functions
+rather than duplicate the code or have classes grabbing at other
+classes.
+
+=head1 FUNCTIONS
+
+All functions can be imported only on request.
+
+=head3 fatal
+
+    fatal(@message);
+
+Display a message and exit with a fatal error code.
+
+=cut
+
+# Note: not certain why this is in use instead of die.  Probably because
+# the exit code of die is 255?  Doesn't appear to be used consistently.
+sub fatal (@) { print STDERR "@_\n"; exit 1 }
+
+
+=head3 can_compress
+
+    my $can_compress = can_compress;
+
+Returns true if Compress::Zlib is available, false otherwise.
+
+=cut
+
+my $can_compress;
+sub can_compress {
+    return $can_compress if defined $can_compress;
+
+    return $can_compress = eval { require Compress::Zlib; } ? 1 : 0;
+}
+
+
+1;
diff --git a/perl/Makefile b/perl/Makefile
index 6ca7d47..24a9f5a 100644
--- a/perl/Makefile
+++ b/perl/Makefile
@@ -31,6 +31,7 @@ modules += Git/SVN/Fetcher
 modules += Git/SVN/Editor
 modules += Git/SVN/Prompt
 modules += Git/SVN/Ra
+modules += Git/SVN/Utils
 
 $(makfile): ../GIT-CFLAGS Makefile
 	echo all: private-Error.pm Git.pm Git/I18N.pm > $@
diff --git a/t/Git-SVN/00compile.t b/t/Git-SVN/00compile.t
new file mode 100644
index 0000000..a7aa85a
--- /dev/null
+++ b/t/Git-SVN/00compile.t
@@ -0,0 +1,8 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+require_ok 'Git::SVN::Utils';
diff --git a/t/Git-SVN/Utils/can_compress.t b/t/Git-SVN/Utils/can_compress.t
new file mode 100644
index 0000000..d7b49b8
--- /dev/null
+++ b/t/Git-SVN/Utils/can_compress.t
@@ -0,0 +1,11 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More 'no_plan';
+
+use Git::SVN::Utils qw(can_compress);
+
+# !! is the "convert this to boolean" operator.
+is !!can_compress(), !!eval { require Compress::Zlib };
diff --git a/t/Git-SVN/Utils/fatal.t b/t/Git-SVN/Utils/fatal.t
new file mode 100644
index 0000000..b90746c
--- /dev/null
+++ b/t/Git-SVN/Utils/fatal.t
@@ -0,0 +1,34 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More 'no_plan';
+
+BEGIN {
+    # Override exit at BEGIN time before Git::SVN::Utils is loaded
+    # so it will see our local exit later.
+    *CORE::GLOBAL::exit = sub(;$) {
+        return @_ ? CORE::exit($_[0]) : CORE::exit();
+    };
+}
+
+use Git::SVN::Utils qw(fatal);
+
+# fatal()
+{
+    # Capture the exit code and prevent exit.
+    my $exit_status;
+    no warnings 'redefine';
+    local *CORE::GLOBAL::exit = sub { $exit_status = $_[0] || 0 };
+
+    # Trap fatal's message to STDERR
+    my $stderr;
+    close STDERR;
+    ok open STDERR, ">", \$stderr;
+
+    fatal "Some", "Stuff", "Happened";
+
+    is $stderr, "Some Stuff Happened\n";
+    is $exit_status, 1;
+}
-- 
1.7.11.1

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

* [PATCH 2/4] Prepare Git::SVN for extraction into its own file.
  2012-07-25  6:01 Move Git::SVN into its own .pm file Michael G. Schwern
  2012-07-25  6:01 ` [PATCH 1/4] Extract some utilities from git-svn to allow extracting Git::SVN Michael G. Schwern
@ 2012-07-25  6:01 ` Michael G. Schwern
  2012-07-25  6:01 ` [PATCH 4/4] Move initialization of Git::SVN variables into Git::SVN Michael G. Schwern
  2012-07-25 21:15 ` Move Git::SVN into its own .pm file Jonathan Nieder
  3 siblings, 0 replies; 12+ messages in thread
From: Michael G. Schwern @ 2012-07-25  6:01 UTC (permalink / raw)
  To: git, gitster; +Cc: robbat2, bwalton, normalperson, Michael G. Schwern

From: "Michael G. Schwern" <schwern@pobox.com>

This means it should be able to load without git-svn being loaded.

* Load Git.pm on its own and all the needed command functions.

* It needs to grab at a git-svn lexical $_prefix representing the --prefix
  option.  Provide opt_prefix() for that.  This is a refactoring artifact.
  The prefix should really be passed into Git::SVN->new.

* Unqualify unnecessarily fully qualified globals like
  $Git::SVN::default_repo_id.

* Lexically isolate the class just to make sure nothing is leaking out.
---
 git-svn.perl | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 79fe4a4..9cdf6fc 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -89,7 +89,7 @@ BEGIN {
 	foreach (qw/command command_oneline command_noisy command_output_pipe
 	            command_input_pipe command_close_pipe
 	            command_bidi_pipe command_close_bidi_pipe/) {
-		for my $package ( qw(Git::SVN::Migration Git::SVN::Log Git::SVN),
+		for my $package ( qw(Git::SVN::Migration Git::SVN::Log),
 			__PACKAGE__) {
 			*{"${package}::$_"} = \&{"Git::$_"};
 		}
@@ -109,6 +109,10 @@ my ($_stdin, $_help, $_edit,
 	$_merge, $_strategy, $_preserve_merges, $_dry_run, $_local,
 	$_prefix, $_no_checkout, $_url, $_verbose,
 	$_git_format, $_commit_url, $_tag, $_merge_info, $_interactive);
+
+# This is a refactoring artifact so Git::SVN can get at this git-svn switch.
+sub opt_prefix { return $_prefix || '' }
+
 $Git::SVN::_follow_parent = 1;
 $Git::SVN::Fetcher::_placeholder_filename = ".gitignore";
 $_q ||= 0;
@@ -2038,6 +2042,7 @@ sub gc_directory {
 	}
 }
 
+{
 package Git::SVN;
 use strict;
 use warnings;
@@ -2056,6 +2061,13 @@ use Memoize;  # core since 5.8.0, Jul 2002
 use Memoize::Storable;
 use POSIX qw(:signal_h);
 
+use Git qw(
+    command
+    command_oneline
+    command_noisy
+    command_output_pipe
+    command_close_pipe
+);
 use Git::SVN::Utils qw(fatal can_compress);
 
 my $can_use_yaml;
@@ -4280,12 +4292,13 @@ sub find_rev_after {
 sub _new {
 	my ($class, $repo_id, $ref_id, $path) = @_;
 	unless (defined $repo_id && length $repo_id) {
-		$repo_id = $Git::SVN::default_repo_id;
+		$repo_id = $default_repo_id;
 	}
 	unless (defined $ref_id && length $ref_id) {
-		$_prefix = '' unless defined($_prefix);
+		# Access the prefix option from the git-svn main program if it's loaded.
+		my $prefix = defined &::opt_prefix ? ::opt_prefix() : "";
 		$_[2] = $ref_id =
-		             "refs/remotes/$_prefix$Git::SVN::default_ref_id";
+		             "refs/remotes/$prefix$default_ref_id";
 	}
 	$_[1] = $repo_id;
 	my $dir = "$ENV{GIT_DIR}/svn/$ref_id";
@@ -4347,6 +4360,7 @@ sub uri_decode {
 sub remove_username {
 	$_[0] =~ s{^([^:]*://)[^@]+@}{$1};
 }
+}
 
 package Git::SVN::Log;
 use strict;
-- 
1.7.11.1

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

* [PATCH 4/4] Move initialization of Git::SVN variables into Git::SVN.
  2012-07-25  6:01 Move Git::SVN into its own .pm file Michael G. Schwern
  2012-07-25  6:01 ` [PATCH 1/4] Extract some utilities from git-svn to allow extracting Git::SVN Michael G. Schwern
  2012-07-25  6:01 ` [PATCH 2/4] Prepare Git::SVN for extraction into its own file Michael G. Schwern
@ 2012-07-25  6:01 ` Michael G. Schwern
  2012-07-25 21:15 ` Move Git::SVN into its own .pm file Jonathan Nieder
  3 siblings, 0 replies; 12+ messages in thread
From: Michael G. Schwern @ 2012-07-25  6:01 UTC (permalink / raw)
  To: git, gitster; +Cc: robbat2, bwalton, normalperson, Michael G. Schwern

From: "Michael G. Schwern" <schwern@pobox.com>

Also it can compile on its own now, yay!
---
 git-svn.perl          | 4 ----
 perl/Git/SVN.pm       | 9 +++++++--
 t/Git-SVN/00compile.t | 3 ++-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 4c77f69..ef10f6f 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -20,10 +20,7 @@ my $cmd_dir_prefix = eval {
 
 my $git_dir_user_set = 1 if defined $ENV{GIT_DIR};
 $ENV{GIT_DIR} ||= '.git';
-$Git::SVN::default_repo_id = 'svn';
-$Git::SVN::default_ref_id = $ENV{GIT_SVN_ID} || 'git-svn';
 $Git::SVN::Ra::_log_window_size = 100;
-$Git::SVN::_minimize_url = 'unset';
 
 if (! exists $ENV{SVN_SSH} && exists $ENV{GIT_SSH}) {
 	$ENV{SVN_SSH} = $ENV{GIT_SSH};
@@ -114,7 +111,6 @@ my ($_stdin, $_help, $_edit,
 # This is a refactoring artifact so Git::SVN can get at this git-svn switch.
 sub opt_prefix { return $_prefix || '' }
 
-$Git::SVN::_follow_parent = 1;
 $Git::SVN::Fetcher::_placeholder_filename = ".gitignore";
 $_q ||= 0;
 my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm
index c71c041..2e0d7f0 100644
--- a/perl/Git/SVN.pm
+++ b/perl/Git/SVN.pm
@@ -3,9 +3,9 @@ use strict;
 use warnings;
 use Fcntl qw/:DEFAULT :seek/;
 use constant rev_map_fmt => 'NH40';
-use vars qw/$default_repo_id $default_ref_id $_no_metadata $_follow_parent
+use vars qw/$_no_metadata
             $_repack $_repack_flags $_use_svm_props $_head
-            $_use_svnsync_props $no_reuse_existing $_minimize_url
+            $_use_svnsync_props $no_reuse_existing
 	    $_use_log_author $_add_author_from $_localtime/;
 use Carp qw/croak/;
 use File::Path qw/mkpath/;
@@ -30,6 +30,11 @@ BEGIN {
 	$can_use_yaml = eval { require Git::SVN::Memoize::YAML; 1};
 }
 
+our $_follow_parent  = 1;
+our $_minimize_url   = 'unset';
+our $default_repo_id = 'svn';
+our $default_ref_id  = $ENV{GIT_SVN_ID} || 'git-svn';
+
 my ($_gc_nr, $_gc_period);
 
 # properties that we do not log:
diff --git a/t/Git-SVN/00compile.t b/t/Git-SVN/00compile.t
index a7aa85a..97475d9 100644
--- a/t/Git-SVN/00compile.t
+++ b/t/Git-SVN/00compile.t
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 1;
+use Test::More tests => 2;
 
 require_ok 'Git::SVN::Utils';
+require_ok 'Git::SVN';
-- 
1.7.11.1

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

* Re: Move Git::SVN into its own .pm file
  2012-07-25  6:01 Move Git::SVN into its own .pm file Michael G. Schwern
                   ` (2 preceding siblings ...)
  2012-07-25  6:01 ` [PATCH 4/4] Move initialization of Git::SVN variables into Git::SVN Michael G. Schwern
@ 2012-07-25 21:15 ` Jonathan Nieder
  2012-07-25 21:56   ` Michael G Schwern
  3 siblings, 1 reply; 12+ messages in thread
From: Jonathan Nieder @ 2012-07-25 21:15 UTC (permalink / raw)
  To: Michael G. Schwern; +Cc: git, gitster, robbat2, bwalton, normalperson

Hi,

Michael G. Schwern wrote:

> This is a refactoring to move Git::SVN out of git-svn and into its own .pm file.
> This will make it easier to work with and test.  This is just the extraction
> with minimal work to keep all tests passing.

Patch 3 doesn't seem to have hit the list archive.  I am not
subscribed and was not cc-ed for some reason, so I do not have it.
I'd appreciate a copy if that's not too inconvenient.

Thanks,
Jonathan

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

* Re: [PATCH 1/4] Extract some utilities from git-svn to allow extracting Git::SVN.
  2012-07-25  6:01 ` [PATCH 1/4] Extract some utilities from git-svn to allow extracting Git::SVN Michael G. Schwern
@ 2012-07-25 21:24   ` Eric Wong
  2012-07-25 22:39     ` Michael G Schwern
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Wong @ 2012-07-25 21:24 UTC (permalink / raw)
  To: Michael G. Schwern; +Cc: git, gitster, robbat2, bwalton, Jonathan Nieder

"Michael G. Schwern" <schwern@pobox.com> wrote:
> From: "Michael G. Schwern" <schwern@pobox.com>
> 
> Put them in a new module called Git::SVN::Utils.  Yeah, not terribly
> original and it will be a dumping ground.  But its better than having
> them in the main git-svn program.  At least they can be documented
> and tested.
> 
> * fatal() is used by many classes.
> * Change the $can_compress lexical into a function.
> 
> This should be enough to extract Git::SVN.

Please keep Jonathan Cc:-ed, he's been very helpful with this series
(and very helpful in general :)

This series is mostly alright by me, a few minor comments inline.

> --- /dev/null
> +++ b/t/Git-SVN/00compile.t
> +
> +use Test::More tests => 1;

> +++ b/t/Git-SVN/Utils/fatal.t
> @@ -0,0 +1,34 @@
> +
> +use Test::More 'no_plan';

Didn't we agree to use done_testing()?   Perhaps (as you suggested) with
a private copy of Test::More?  It's probably easier to start using
done_testing() earlier rather than later.

> +BEGIN {
> +    # Override exit at BEGIN time before Git::SVN::Utils is loaded
> +    # so it will see our local exit later.
> +    *CORE::GLOBAL::exit = sub(;$) {
> +        return @_ ? CORE::exit($_[0]) : CORE::exit();
> +    };
> +}

For new code related to git-svn, please match the existing indentation
style (tabs) prevalent in git-svn.  Most of the Perl found in git also
uses tabs for indentation.

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

* Re: Move Git::SVN into its own .pm file
  2012-07-25 21:15 ` Move Git::SVN into its own .pm file Jonathan Nieder
@ 2012-07-25 21:56   ` Michael G Schwern
  0 siblings, 0 replies; 12+ messages in thread
From: Michael G Schwern @ 2012-07-25 21:56 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git, gitster, robbat2, bwalton, normalperson

[-- Attachment #1: Type: text/plain, Size: 904 bytes --]

On 2012.7.25 2:15 PM, Jonathan Nieder wrote:
> Michael G. Schwern wrote:
>> This is a refactoring to move Git::SVN out of git-svn and into its own .pm file.
>> This will make it easier to work with and test.  This is just the extraction
>> with minimal work to keep all tests passing.
> 
> Patch 3 doesn't seem to have hit the list archive.  I am not
> subscribed and was not cc-ed for some reason, so I do not have it.
> I'd appreciate a copy if that's not too inconvenient.

The patch was 136k.  I'm going to guess there's some old 50k filter somewhere
that blocked it.

<insert ironic statement about email based development here>

The patch is attached.


-- 
87. If the thought of something makes me giggle for longer than 15
    seconds, I am to assume that I am not allowed to do it.
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/list/

[-- Attachment #2: 0001-Extract-Git-SVN-from-git-svn-into-its-own-.pm-file.patch.gz --]
[-- Type: application/x-tar-gz, Size: 40861 bytes --]

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

* Re: [PATCH 1/4] Extract some utilities from git-svn to allow extracting Git::SVN.
  2012-07-25 21:24   ` Eric Wong
@ 2012-07-25 22:39     ` Michael G Schwern
  2012-07-25 23:08       ` Eric Wong
  0 siblings, 1 reply; 12+ messages in thread
From: Michael G Schwern @ 2012-07-25 22:39 UTC (permalink / raw)
  To: Eric Wong; +Cc: git, gitster, robbat2, bwalton, Jonathan Nieder

On 2012.7.25 2:24 PM, Eric Wong wrote:
> Please keep Jonathan Cc:-ed, he's been very helpful with this series
> (and very helpful in general :)

I will try.


>> +use Test::More 'no_plan';
> 
> Didn't we agree to use done_testing()?   Perhaps (as you suggested) with
> a private copy of Test::More?  It's probably easier to start using
> done_testing() earlier rather than later.

Yes, we agreed done_testing is the way forward.  Given how much work I've had
to do to get even basic patches in I decided to ditch anything extra.  That
includes adding a t/lib and I didn't want to make it silently depend on an
upgraded Test::More either.

There's not much difference if we do it later.  Switching to done_testing is
trivial.  I'd like to get the big class extractions in so code stops shifting
around, and worry about the minutia of test plans later.  If it happens before
I get to it, great!

PS  Those t/Git-SVN/ tests are not tied into the normal testing process.  I
felt writing the tests now was important and they could be integrated into the
test suite later.


>> +BEGIN {
>> +    # Override exit at BEGIN time before Git::SVN::Utils is loaded
>> +    # so it will see our local exit later.
>> +    *CORE::GLOBAL::exit = sub(;$) {
>> +        return @_ ? CORE::exit($_[0]) : CORE::exit();
>> +    };
>> +}
> 
> For new code related to git-svn, please match the existing indentation
> style (tabs) prevalent in git-svn.  Most of the Perl found in git also
> uses tabs for indentation.

About that.  I followed kernel style in existing code, but felt that new code
would do better to follow Perl style.  The existing Perl code mixes tabs and
spaces, so I felt it wasn't a strongly held style.  You'll get more Perl
programmers to work on the Perl code by following Perl style in the Perl code
rather than kernel style.

Alternatively, how about allowing emacs/vim configuration comments?  The
Kernel coding style doesn't allow them, how do you folks feel?  Then people
don't have to guess the style and reconfigure their editor, their editor will
do it for them.

The important thing is to have one less special thing a new-to-your-project
Perl programmer has to do.


-- 
ROCKS FALL! EVERYONE DIES!
	http://www.somethingpositive.net/sp05032002.shtml

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

* Re: [PATCH 1/4] Extract some utilities from git-svn to allow extracting Git::SVN.
  2012-07-25 22:39     ` Michael G Schwern
@ 2012-07-25 23:08       ` Eric Wong
  2012-07-26  0:01         ` Michael G Schwern
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Wong @ 2012-07-25 23:08 UTC (permalink / raw)
  To: Michael G Schwern; +Cc: git, gitster, robbat2, bwalton, Jonathan Nieder

Michael G Schwern <schwern@pobox.com> wrote:
> On 2012.7.25 2:24 PM, Eric Wong wrote:
> > Didn't we agree to use done_testing()?   Perhaps (as you suggested) with
> > a private copy of Test::More?  It's probably easier to start using
> > done_testing() earlier rather than later.
> 
> Yes, we agreed done_testing is the way forward.  Given how much work I've had
> to do to get even basic patches in I decided to ditch anything extra.  That
> includes adding a t/lib and I didn't want to make it silently depend on an
> upgraded Test::More either.

OK.

> >> +BEGIN {
> >> +    # Override exit at BEGIN time before Git::SVN::Utils is loaded
> >> +    # so it will see our local exit later.
> >> +    *CORE::GLOBAL::exit = sub(;$) {
> >> +        return @_ ? CORE::exit($_[0]) : CORE::exit();
> >> +    };
> >> +}
> > 
> > For new code related to git-svn, please match the existing indentation
> > style (tabs) prevalent in git-svn.  Most of the Perl found in git also
> > uses tabs for indentation.
> 
> About that.  I followed kernel style in existing code, but felt that new code
> would do better to follow Perl style.  The existing Perl code mixes tabs and
> spaces, so I felt it wasn't a strongly held style.  You'll get more Perl
> programmers to work on the Perl code by following Perl style in the Perl code
> rather than kernel style.

git-svn should be all tabs (though some spaces accidentally slipped in
over the years).  git maintainers are mostly C programmers used to tabs,
so non-C code should favor their expectations.

I also favor tabs since they're more space-efficient and leads to faster
"git grep" on large source trees (more important for bigger projects).
I remember many years ago "git grep" was shown to be ~20% faster on
a source tree with tabs.

(I'm neither a kernel hacker nor a regular Perl hacker)

> Alternatively, how about allowing emacs/vim configuration comments?  The
> Kernel coding style doesn't allow them, how do you folks feel?  Then people
> don't have to guess the style and reconfigure their editor, their editor will
> do it for them.

I don't like them, and I think others here frowns upon them, too.  They
take too much space and shows favor/preference towards certain editors.
It'll be a bigger problem if more editors become popular and we start
"supporting" them.

> The important thing is to have one less special thing a new-to-your-project
> Perl programmer has to do.

Historically git development has catered to C programmers used to tabs.
I think the mixing of indentation styles in current Perl files is the
most confusing.

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

* Re: [PATCH 1/4] Extract some utilities from git-svn to allow extracting Git::SVN.
  2012-07-25 23:08       ` Eric Wong
@ 2012-07-26  0:01         ` Michael G Schwern
  2012-07-26  0:25           ` Eric Wong
  2012-07-26  0:26           ` Jonathan Nieder
  0 siblings, 2 replies; 12+ messages in thread
From: Michael G Schwern @ 2012-07-26  0:01 UTC (permalink / raw)
  To: Eric Wong; +Cc: git, gitster, robbat2, bwalton, Jonathan Nieder

This is rapidly getting into the weeds.  Regardless of the debate below, what
would you like me to do?  Switch indentation to tabs and resubmit?  AFAIK only
the new tests are affected.


On 2012.7.25 4:08 PM, Eric Wong wrote:
>>>> +BEGIN {
>>>> +    # Override exit at BEGIN time before Git::SVN::Utils is loaded
>>>> +    # so it will see our local exit later.
>>>> +    *CORE::GLOBAL::exit = sub(;$) {
>>>> +        return @_ ? CORE::exit($_[0]) : CORE::exit();
>>>> +    };
>>>> +}
>>>
>>> For new code related to git-svn, please match the existing indentation
>>> style (tabs) prevalent in git-svn.  Most of the Perl found in git also
>>> uses tabs for indentation.
>>
>> About that.  I followed kernel style in existing code, but felt that new code
>> would do better to follow Perl style.  The existing Perl code mixes tabs and
>> spaces, so I felt it wasn't a strongly held style.  You'll get more Perl
>> programmers to work on the Perl code by following Perl style in the Perl code
>> rather than kernel style.
> 
> git-svn should be all tabs (though some spaces accidentally slipped in
> over the years).  git maintainers are mostly C programmers used to tabs,
> so non-C code should favor their expectations.

Perhaps this is self fulfilling.  Would you like to attract more Perl programmers?


> I also favor tabs since they're more space-efficient and leads to faster
> "git grep" on large source trees (more important for bigger projects).
> I remember many years ago "git grep" was shown to be ~20% faster on
> a source tree with tabs.

Storage costs a dime a gig.  One extra music file negates your space savings.
 I have more CPU power on my phone than I had on my desktop "many years ago".
 It doesn't matter if tabs make git-grep 20% faster because it's going to be
200ms vs 240ms.

Regardless, you don't choose your coding style because it's easier for the
computer.  You choose it because it makes the code easier for humans to work with.


> (I'm neither a kernel hacker nor a regular Perl hacker)
> 
>> Alternatively, how about allowing emacs/vim configuration comments?  The
>> Kernel coding style doesn't allow them, how do you folks feel?  Then people
>> don't have to guess the style and reconfigure their editor, their editor will
>> do it for them.
> 
> I don't like them, and I think others here frowns upon them, too.  They
> take too much space and shows favor/preference towards certain editors.
> It'll be a bigger problem if more editors become popular and we start
> "supporting" them.

What you say above is correct, but the extra space is not wasted.  It would be
like complaining about all the space that Documentation takes up, and that it
shows preference towards English.  Its *useful* to somebody not already using
your style.  It's useful for new-to-your-project folks.  It's also useful for
somebody switching between the C and Perl code (though a good editor should
already be set up to do C and Perl differently).

Are the editor wars still going on here?  Is somebody going to be *offended*
if their editor isn't represented?  If so, shouldn't they grow up?


>> The important thing is to have one less special thing a new-to-your-project
>> Perl programmer has to do.
> 
> Historically git development has catered to C programmers used to tabs.
> I think the mixing of indentation styles in current Perl files is the
> most confusing.

I agree that mixing the style within the Perl code isn't good.  Perl code can
very quickly be reformatted.  A basic perltidy config can help keep it that way.


-- 
Alligator sandwich, and make it snappy!

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

* Re: [PATCH 1/4] Extract some utilities from git-svn to allow extracting Git::SVN.
  2012-07-26  0:01         ` Michael G Schwern
@ 2012-07-26  0:25           ` Eric Wong
  2012-07-26  0:26           ` Jonathan Nieder
  1 sibling, 0 replies; 12+ messages in thread
From: Eric Wong @ 2012-07-26  0:25 UTC (permalink / raw)
  To: Michael G Schwern; +Cc: git, gitster, robbat2, bwalton, Jonathan Nieder

Michael G Schwern <schwern@pobox.com> wrote:
> This is rapidly getting into the weeds.  Regardless of the debate below, what
> would you like me to do?  Switch indentation to tabs and resubmit?  AFAIK only
> the new tests are affected.

Yes, unless Jonathan (or anybody else) has more comments.

> On 2012.7.25 4:08 PM, Eric Wong wrote:
> >>>> +BEGIN {
> >>>> +    # Override exit at BEGIN time before Git::SVN::Utils is loaded
> >>>> +    # so it will see our local exit later.
> >>>> +    *CORE::GLOBAL::exit = sub(;$) {
> >>>> +        return @_ ? CORE::exit($_[0]) : CORE::exit();
> >>>> +    };
> >>>> +}
> >>>
> >>> For new code related to git-svn, please match the existing indentation
> >>> style (tabs) prevalent in git-svn.  Most of the Perl found in git also
> >>> uses tabs for indentation.
> >>
> >> About that.  I followed kernel style in existing code, but felt that new code
> >> would do better to follow Perl style.  The existing Perl code mixes tabs and
> >> spaces, so I felt it wasn't a strongly held style.  You'll get more Perl
> >> programmers to work on the Perl code by following Perl style in the Perl code
> >> rather than kernel style.
> > 
> > git-svn should be all tabs (though some spaces accidentally slipped in
> > over the years).  git maintainers are mostly C programmers used to tabs,
> > so non-C code should favor their expectations.
> 
> Perhaps this is self fulfilling.  Would you like to attract more Perl
> programmers?

I prefer programmers not tied to a particular language.

> > I also favor tabs since they're more space-efficient and leads to faster
> > "git grep" on large source trees (more important for bigger projects).
> > I remember many years ago "git grep" was shown to be ~20% faster on
> > a source tree with tabs.
> 
> Storage costs a dime a gig.

It's also kernel page cache overhead.

> Regardless, you don't choose your coding style because it's easier for the
> computer.  You choose it because it makes the code easier for humans to work with.

Hard tabs also happen to be the default indent for my editor (which
is also a popular editor) and slightly easier for me.

> >> Alternatively, how about allowing emacs/vim configuration comments?  The
> >> Kernel coding style doesn't allow them, how do you folks feel?  Then people
> >> don't have to guess the style and reconfigure their editor, their editor will
> >> do it for them.
> > 
> > I don't like them, and I think others here frowns upon them, too.  They
> > take too much space and shows favor/preference towards certain editors.
> > It'll be a bigger problem if more editors become popular and we start
> > "supporting" them.
> 
> What you say above is correct, but the extra space is not wasted.  It would be
> like complaining about all the space that Documentation takes up, and that it
> shows preference towards English.  Its *useful* to somebody not already using
> your style.  It's useful for new-to-your-project folks.  It's also useful for
> somebody switching between the C and Perl code (though a good editor should
> already be set up to do C and Perl differently).
> 
> Are the editor wars still going on here?  Is somebody going to be *offended*
> if their editor isn't represented?  If so, shouldn't they grow up?

It's not about editor wars, but unnecessary code churn to accept/review
patches to support new editors, making it a maintenance burden.  Picking
up (and following) existing conventions within a project ought to be
common sense.

Anyways I don't speak for others, but seeing how we've gone all these
years without editor-specific comments, I don't believe other git devs
want them, either.

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

* Re: [PATCH 1/4] Extract some utilities from git-svn to allow extracting Git::SVN.
  2012-07-26  0:01         ` Michael G Schwern
  2012-07-26  0:25           ` Eric Wong
@ 2012-07-26  0:26           ` Jonathan Nieder
  1 sibling, 0 replies; 12+ messages in thread
From: Jonathan Nieder @ 2012-07-26  0:26 UTC (permalink / raw)
  To: Michael G Schwern; +Cc: Eric Wong, git, gitster, robbat2, bwalton

Michael G Schwern wrote:

> This is rapidly getting into the weeds.  Regardless of the debate below, what
> would you like me to do?  Switch indentation to tabs and resubmit?  AFAIK only
> the new tests are affected.

Yes, please do so at some point before the final submission.  (If
there's more feedback coming for this generation of the patches, no
need to resubmit right away unless you want to.  In general, when
getting review a useful strategy can be to discuss proposed changes
and batch them until the discussion seems to have died down and only
then resubmit the next version.)

If we want to switch indentation styles (not a traditional way to
start working with an existing project, but whatever), that would be a
separate change, affecting all the code consistently.

Thanks,
Jonathan

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

end of thread, other threads:[~2012-07-26  0:26 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-25  6:01 Move Git::SVN into its own .pm file Michael G. Schwern
2012-07-25  6:01 ` [PATCH 1/4] Extract some utilities from git-svn to allow extracting Git::SVN Michael G. Schwern
2012-07-25 21:24   ` Eric Wong
2012-07-25 22:39     ` Michael G Schwern
2012-07-25 23:08       ` Eric Wong
2012-07-26  0:01         ` Michael G Schwern
2012-07-26  0:25           ` Eric Wong
2012-07-26  0:26           ` Jonathan Nieder
2012-07-25  6:01 ` [PATCH 2/4] Prepare Git::SVN for extraction into its own file Michael G. Schwern
2012-07-25  6:01 ` [PATCH 4/4] Move initialization of Git::SVN variables into Git::SVN Michael G. Schwern
2012-07-25 21:15 ` Move Git::SVN into its own .pm file Jonathan Nieder
2012-07-25 21:56   ` Michael G Schwern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.