Git development
 help / color / mirror / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: Andrew Myrick <amyrick@apple.com>
Cc: git@vger.kernel.org, Sam Vilain <sam@vilain.net>
Subject: Re: git-svn: handling merge-base failures
Date: Wed, 23 Dec 2009 20:57:51 +0000	[thread overview]
Message-ID: <20091223205751.GE13735@dcvr.yhbt.net> (raw)
In-Reply-To: <940F72F6-8FE5-42AE-84A1-8C4A77B57188@apple.com>

Andrew Myrick <amyrick@apple.com> wrote:
> On Dec 23, 2009, at 12:09 PM, Eric Wong wrote:
> > Andrew Myrick <amyrick@apple.com> wrote:
> >> One of my projects is failing to clone because merge-base is failing
> >> on one of the revisions; the branch is a partial branch, so merge-base
> >> can't find a common ancestor with trunk.  I'd like to catch the
> >> exception that command_oneline should throw when merge-base fails, but
> >> my perl is very rusty and I'm struggling to get git-svn.perl to grok
> >> the Git::Error::Command class.  What is the appropriate way to import
> >> that class?  Or more generally, is there a better solution to handling
> >> this error case?
> > 
> > Hi Andrew,
> > 
> > Git::Error::Command should be imported with the rest of Git.pm
> > 
> > It's a special way of doing exceptions in Perl which I don't see much
> > point of...  Looking at git-send-email as an example, it does this:
> > 
> > 	use Error qw(:try);
> > 	use Git;
> > 
> > 	try {
> > 		# something that will throw
> > 	} catch Git::Error::Command with {
> > 		# error handling
> > 	}
> 
> I looked at git-send-email's example, but I wanted to do a bit more:
> 	
> 	try {
> 		# command_oneline(...);
> 	} catch Git::Error::Command with {
> 		$E = shift;
> 		if ($E->value() == 1) {
> 			# do something
> 		} else {
> 			# do something else
> 		}
> 	}
>  	
> This is used in perl/Git.pm, but when I tried it in git-svn.perl, it
> fails with the error "Can't locate object method 'value' via package
> 'Git::SVN'".

That's strange.  I'm at a bit of a loss here so I'll wait for somebody
with more Perl knowledge than myself.

What happens when you dump @_ in your catch block?

	use Data::Dumper;
	try {
	} catch Git::Error::Command with {
		print STDERR Dumper(\@_);
	}

> Presumably $@ contains the Git::Error::Command object, which leaves me
> in the same spot, unfortunately.
> 
> > But yes, it is Perl after all and TMTOWTDI :)
> 
> Is there ever :)

Yes I'm lost here, too, so in these cases I default to putting
print statements everywhere and Data::Dumper :)

-- 
Eric Wong

  reply	other threads:[~2009-12-23 20:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-23 19:54 git-svn: handling merge-base failures Andrew Myrick
2009-12-23 20:09 ` Eric Wong
2009-12-23 20:18   ` Andrew Myrick
2009-12-23 20:57     ` Eric Wong [this message]
2010-01-04  1:37 ` Andrew Myrick
2010-01-04  3:45   ` Eric Wong
2010-01-04  4:43     ` Andrew Myrick

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=20091223205751.GE13735@dcvr.yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=amyrick@apple.com \
    --cc=git@vger.kernel.org \
    --cc=sam@vilain.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