threads / discuss / 22019

git-svn: handling merge-base failures

Subject: git-svn: handling merge-base failures

## tl;dr

7 messages between Dec 23, 2009 and Jan 4, 2010.

replies: 6people: 2as markdown or json

Andrew Myrick· Dec 23, 2009, 19:54 UTC · lore
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?
-Andrew
Eric Wong· Dec 23, 2009, 20:09 UTC · re: Andrew Myrick · lore

Re: git-svn: handling merge-base failures

Andrew Myrick <amyrick@apple.com> wrote:
Show 8 quoted lines
> 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
	}
A more standard approach in Perl is just:
	eval {
		# something that will die
	};
	if ($@) {
		# error handling
	}
But yes, it is Perl after all and TMTOWTDI :)
-- 
Eric Wong
Andrew Myrick· Dec 23, 2009, 20:18 UTC · re: Eric Wong · lore

Re: git-svn: handling merge-base failures

On Dec 23, 2009, at 12:09 PM, Eric Wong wrote:
Show 25 quoted lines
> 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'".
Show 10 quoted lines
> 
> A more standard approach in Perl is just:
> 
> 	eval {
> 		# something that will die
> 	};
> 	if ($@) {
> 		# error handling
> 	}
> 
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 :)
-Andrew
Eric Wong· Dec 23, 2009, 20:57 UTC · re: Andrew Myrick · lore

Re: git-svn: handling merge-base failures

Andrew Myrick <amyrick@apple.com> wrote:
Show 43 quoted lines
> 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(\@_);
	}
Show 6 quoted lines
> 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
Andrew Myrick· Jan 4, 2010, 01:37 UTC · re: Andrew Myrick · lore

Re: git-svn: handling merge-base failures

On Dec 23, 2009, at 11:54 AM, Andrew Myrick 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,
Instead of using the Error.pm module, I was able to handle the exception with the more basic eval block.  However, there are some details here I would like to discuss with the community.
When git-svn fetches a partial branch, it appears to refetch all of the history of the subdirectory from which the branch was created.  This creates new commits for the old revisions, and these new commits exist as a separate history for the partial branch.   When git-svn fetches the revision at which this partial branch is merged back to trunk, git-svn attempts to run merge-base to find a common ancestor.  However, because the partial branch has its own history, the merge-base fails, and git-svn dies.
Naively handling the exception with an eval block and skipping the merge ticket works fine in that it brings us back to parity with git 1.6.5.7, but it means that the merge parent relationship between trunk and the partial branch is lost.  Is there any way to preserve this information, or does the separate commit history of the partial branch make it fundamentally impossible?
I've created a small svn repository that demonstrates this failure with git v1.6.6.  Its dump is attached.
-Andrew
Eric Wong· Jan 4, 2010, 03:45 UTC · re: Andrew Myrick · lore

Re: git-svn: handling merge-base failures

Andrew Myrick <amyrick@apple.com> wrote:
Show 26 quoted lines
> On Dec 23, 2009, at 11:54 AM, Andrew Myrick 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,
> 
> Instead of using the Error.pm module, I was able to handle the
> exception with the more basic eval block.  However, there are some
> details here I would like to discuss with the community.
> 
> When git-svn fetches a partial branch, it appears to refetch all of
> the history of the subdirectory from which the branch was created.
> This creates new commits for the old revisions, and these new commits
> exist as a separate history for the partial branch.   When git-svn
> fetches the revision at which this partial branch is merged back to
> trunk, git-svn attempts to run merge-base to find a common ancestor.
> However, because the partial branch has its own history, the
> merge-base fails, and git-svn dies.
> 
> Naively handling the exception with an eval block and skipping the
> merge ticket works fine in that it brings us back to parity with git
> 1.6.5.7, but it means that the merge parent relationship between trunk
> and the partial branch is lost.  Is there any way to preserve this
> information, or does the separate commit history of the partial branch
> make it fundamentally impossible?
Hi Andrew,

A method of preserving the $SVN_PATH <=> $PARENT@$REV mapping for reusing follow_parent-created branches is definitely desired.

I've just been lacking time and motivation these days with other projects taking priority. Help (even if it's just to refactor/cleanup existing code) would definitely be appreciated here.

> I've created a small svn repository that demonstrates this failure
> with git v1.6.6.  Its dump is attached.

Thanks. This (and a similar dump a few weeks back) will definitely come in handy for writing test cases and fixing this long-standing issue.

-- 
Eric Wong
Andrew Myrick· Jan 4, 2010, 04:43 UTC · re: Eric Wong · lore

Re: git-svn: handling merge-base failures

On Jan 3, 2010, at 7:45 PM, Eric Wong wrote:
Show 36 quoted lines
> Andrew Myrick <amyrick@apple.com> wrote:
>> On Dec 23, 2009, at 11:54 AM, Andrew Myrick 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,
>> 
>> Instead of using the Error.pm module, I was able to handle the
>> exception with the more basic eval block.  However, there are some
>> details here I would like to discuss with the community.
>> 
>> When git-svn fetches a partial branch, it appears to refetch all of
>> the history of the subdirectory from which the branch was created.
>> This creates new commits for the old revisions, and these new commits
>> exist as a separate history for the partial branch.   When git-svn
>> fetches the revision at which this partial branch is merged back to
>> trunk, git-svn attempts to run merge-base to find a common ancestor.
>> However, because the partial branch has its own history, the
>> merge-base fails, and git-svn dies.
>> 
>> Naively handling the exception with an eval block and skipping the
>> merge ticket works fine in that it brings us back to parity with git
>> 1.6.5.7, but it means that the merge parent relationship between trunk
>> and the partial branch is lost.  Is there any way to preserve this
>> information, or does the separate commit history of the partial branch
>> make it fundamentally impossible?
> 
> Hi Andrew,
> 
> A method of preserving the $SVN_PATH <=> $PARENT@$REV mapping for
> reusing follow_parent-created branches is definitely desired.
> 
> I've just been lacking time and motivation these days with other
> projects taking priority.  Help (even if it's just to refactor/cleanup
> existing code) would definitely be appreciated here.
Thanks for the explanation, Eric.  Unfortunately, I also don't have the time to commit to taking this on for the foreseeable future.  I'll try to get my existing patches out in the next couple of days that at least fix the regressions from 1.6.5.7.

Regards, Andrew

← back to recent threads