# git-svn: handling merge-base failures

7 messages from 2009-12-23 to 2010-01-04. Participants: Andrew Myrick, Eric Wong.
Thread: https://gitlist.dev/t/22019

## Andrew Myrick, 2009-12-23 19:54

Subject: git-svn: handling merge-base failures
Message-ID: <931B0483-7628-488E-BB9F-C40346353149@apple.com>
URL: https://gitlist.dev/e/931B0483-7628-488E-BB9F-C40346353149%40apple.com

```
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, 2009-12-23 20:09

Subject: Re: git-svn: handling merge-base failures
Message-ID: <20091223200936.GA13735@dcvr.yhbt.net>
URL: https://gitlist.dev/e/20091223200936.GA13735%40dcvr.yhbt.net
In-Reply-To: <931B0483-7628-488E-BB9F-C40346353149@apple.com>

```
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
	}

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, 2009-12-23 20:18

Subject: Re: git-svn: handling merge-base failures
Message-ID: <940F72F6-8FE5-42AE-84A1-8C4A77B57188@apple.com>
URL: https://gitlist.dev/e/940F72F6-8FE5-42AE-84A1-8C4A77B57188%40apple.com
In-Reply-To: <20091223200936.GA13735@dcvr.yhbt.net>

```

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'".

> 
> 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, 2009-12-23 20:57

Subject: Re: git-svn: handling merge-base failures
Message-ID: <20091223205751.GE13735@dcvr.yhbt.net>
URL: https://gitlist.dev/e/20091223205751.GE13735%40dcvr.yhbt.net
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

```

## Andrew Myrick, 2010-01-04 01:37

Subject: Re: git-svn: handling merge-base failures
Message-ID: <7878A426-9D87-43B5-A10A-38F3C9369165@apple.com>
URL: https://gitlist.dev/e/7878A426-9D87-43B5-A10A-38F3C9369165%40apple.com
In-Reply-To: <931B0483-7628-488E-BB9F-C40346353149@apple.com>

```

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, 2010-01-04 03:45

Subject: Re: git-svn: handling merge-base failures
Message-ID: <20100104034540.GA4548@dcvr.yhbt.net>
URL: https://gitlist.dev/e/20100104034540.GA4548%40dcvr.yhbt.net
In-Reply-To: <7878A426-9D87-43B5-A10A-38F3C9369165@apple.com>

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

> 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, 2010-01-04 04:43

Subject: Re: git-svn: handling merge-base failures
Message-ID: <7B6F15D3-FCF3-4569-9617-62BA38C92B35@apple.com>
URL: https://gitlist.dev/e/7B6F15D3-FCF3-4569-9617-62BA38C92B35%40apple.com
In-Reply-To: <20100104034540.GA4548@dcvr.yhbt.net>

```

On Jan 3, 2010, at 7:45 PM, Eric Wong wrote:

> 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

```
