git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael G. Schwern" <schwern@pobox.com>
To: git@vger.kernel.org, gitster@pobox.com
Cc: robbat2@gentoo.org, bwalton@artsci.utoronto.ca,
	normalperson@yhbt.net, jrnieder@gmail.com, schwern@pobox.com
Subject: [PATCH 1/8] Prepare Git::SVN::Log for extraction from git-svn.
Date: Thu, 26 Jul 2012 17:26:00 -0700	[thread overview]
Message-ID: <1343348767-86446-2-git-send-email-schwern@pobox.com> (raw)
In-Reply-To: <1343348767-86446-1-git-send-email-schwern@pobox.com>

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

* Load Git command functions itself.

* Can't access the git-svn switch lexical any more, but its only used by
  Git::SVN::Log so turn it into a Git::SVN::Log global.

* Load Git::SVN as needed.  No need to load it always, its only used twice.

* Moved a state variable to the routine it's used for. (Drive by refactoring)
---
 git-svn.perl | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index ef10f6f..e16475b 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -87,7 +87,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),
+		for my $package ( qw(Git::SVN::Migration),
 			__PACKAGE__) {
 			*{"${package}::$_"} = \&{"Git::$_"};
 		}
@@ -106,7 +106,7 @@ my ($_stdin, $_help, $_edit,
 	$_version, $_fetch_all, $_no_rebase, $_fetch_parent,
 	$_merge, $_strategy, $_preserve_merges, $_dry_run, $_local,
 	$_prefix, $_no_checkout, $_url, $_verbose,
-	$_git_format, $_commit_url, $_tag, $_merge_info, $_interactive);
+	$_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 || '' }
@@ -270,7 +270,7 @@ my %cmd = (
 		    { 'url' => \$_url, } ],
 	'blame' => [ \&Git::SVN::Log::cmd_blame,
 	            "Show what revision and author last modified each line of a file",
-		    { 'git-format' => \$_git_format } ],
+		    { 'git-format' => \$Git::SVN::Log::_git_format } ],
 	'reset' => [ \&cmd_reset,
 		     "Undo fetches back to the specified SVN revision",
 		     { 'revision|r=s' => \$_revision,
@@ -2044,11 +2044,14 @@ package Git::SVN::Log;
 use strict;
 use warnings;
 use Git::SVN::Utils qw(fatal);
+use Git qw(command command_oneline command_output_pipe command_close_pipe);
 use POSIX qw/strftime/;
 use constant commit_log_separator => ('-' x 72) . "\n";
 use vars qw/$TZ $limit $color $pager $non_recursive $verbose $oneline
             %rusers $show_commit $incremental/;
-my $l_fmt;
+
+# Option set in git-svn
+our $_git_format;
 
 sub cmt_showable {
 	my ($c) = @_;
@@ -2094,6 +2097,8 @@ sub git_svn_log_cmd {
 	}
 
 	my ($url, $rev, $uuid, $gs) = ::working_head_info($head);
+
+	require Git::SVN;
 	$gs ||= Git::SVN->_new;
 	my @cmd = (qw/log --abbrev-commit --pretty=raw --default/,
 	           $gs->refname);
@@ -2155,6 +2160,7 @@ sub run_pager {
 
 sub format_svn_date {
 	my $t = shift || time;
+	require Git::SVN;
 	my $gmoff = Git::SVN::get_tz($t);
 	return strftime("%Y-%m-%d %H:%M:%S $gmoff (%a, %d %b %Y)", localtime($t));
 }
@@ -2225,6 +2231,7 @@ sub process_commit {
 	return 1;
 }
 
+my $l_fmt;
 sub show_commit {
 	my $c = shift;
 	if ($oneline) {
-- 
1.7.11.1

  reply	other threads:[~2012-07-27  0:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-27  0:25 Extract remaining classes from git-svn Michael G. Schwern
2012-07-27  0:26 ` Michael G. Schwern [this message]
2012-07-27  0:26 ` [PATCH 2/8] Extract Git::SVN::Log " Michael G. Schwern
2012-07-27  0:26 ` [PATCH 3/8] Prepare Git::SVN::Migration for extraction " Michael G. Schwern
2012-07-27  0:26 ` [PATCH 4/8] Extract Git::SVN::Migration " Michael G. Schwern
2012-07-27  0:26 ` [PATCH 5/8] Load all the modules in one place and before running code Michael G. Schwern
2012-07-27  0:26 ` [PATCH 6/8] Move Git::IndexInfo into its own file Michael G. Schwern
2012-07-27  0:26 ` [PATCH 7/8] Extract Git::SVN::GlobSpec from git-svn Michael G. Schwern
2012-07-27  0:26 ` [PATCH 8/8] Fix indents to match style Michael G. Schwern
2012-07-27  0:27 ` Extract remaining classes from git-svn Michael G Schwern
2012-07-27 11:29   ` Erik Faye-Lund
2012-07-27 19:00     ` Michael G Schwern
2012-07-28  0:40 ` Eric Wong
2012-07-28  4:05   ` Junio C Hamano
2012-07-28  4:12     ` Eric Wong
2012-07-28  4:25       ` Junio C Hamano

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=1343348767-86446-2-git-send-email-schwern@pobox.com \
    --to=schwern@pobox.com \
    --cc=bwalton@artsci.utoronto.ca \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=normalperson@yhbt.net \
    --cc=robbat2@gentoo.org \
    /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).