{"thread":{"id":"22019","subject":"git-svn: handling merge-base failures","startedAt":"2009-12-23T19:54:29Z","lastAt":"2010-01-04T04:43:52Z","messageCount":7,"participants":["Andrew Myrick","Eric Wong"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"130290","messageId":"931B0483-7628-488E-BB9F-C40346353149@apple.com","threadId":"22019","inReplyTo":null,"subject":"git-svn: handling merge-base failures","fromName":"Andrew Myrick","fromEmail":"amyrick@apple.com","sentAt":"2009-12-23T19:54:29Z","receivedAt":"2009-12-23T19:54:29Z","isPatch":false,"sender":{"key":"amyrick@apple.com","avatar":"https://avatars.githubusercontent.com/u/303045?v=4"},"body":"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?\n\n-Andrew"},{"id":"130292","messageId":"20091223200936.GA13735@dcvr.yhbt.net","threadId":"22019","inReplyTo":"931B0483-7628-488E-BB9F-C40346353149@apple.com","subject":"Re: git-svn: handling merge-base failures","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-12-23T20:09:36Z","receivedAt":"2009-12-23T20:09:36Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Andrew Myrick <amyrick@apple.com> wrote:\n> One of my projects is failing to clone because merge-base is failing\n> on one of the revisions; the branch is a partial branch, so merge-base\n> can't find a common ancestor with trunk.  I'd like to catch the\n> exception that command_oneline should throw when merge-base fails, but\n> my perl is very rusty and I'm struggling to get git-svn.perl to grok\n> the Git::Error::Command class.  What is the appropriate way to import\n> that class?  Or more generally, is there a better solution to handling\n> this error case?\n\nHi Andrew,\n\nGit::Error::Command should be imported with the rest of Git.pm\n\nIt's a special way of doing exceptions in Perl which I don't see much\npoint of...  Looking at git-send-email as an example, it does this:\n\n\tuse Error qw(:try);\n\tuse Git;\n\n\ttry {\n\t\t# something that will throw\n\t} catch Git::Error::Command with {\n\t\t# error handling\n\t}\n\nA more standard approach in Perl is just:\n\n\teval {\n\t\t# something that will die\n\t};\n\tif ($@) {\n\t\t# error handling\n\t}\n\nBut yes, it is Perl after all and TMTOWTDI :)\n\n-- \nEric Wong\n"},{"id":"130293","messageId":"940F72F6-8FE5-42AE-84A1-8C4A77B57188@apple.com","threadId":"22019","inReplyTo":"20091223200936.GA13735@dcvr.yhbt.net","subject":"Re: git-svn: handling merge-base failures","fromName":"Andrew Myrick","fromEmail":"amyrick@apple.com","sentAt":"2009-12-23T20:18:08Z","receivedAt":"2009-12-23T20:18:08Z","isPatch":false,"sender":{"key":"amyrick@apple.com","avatar":"https://avatars.githubusercontent.com/u/303045?v=4"},"body":"\nOn Dec 23, 2009, at 12:09 PM, Eric Wong wrote:\n\n> Andrew Myrick <amyrick@apple.com> wrote:\n>> One of my projects is failing to clone because merge-base is failing\n>> on one of the revisions; the branch is a partial branch, so merge-base\n>> can't find a common ancestor with trunk.  I'd like to catch the\n>> exception that command_oneline should throw when merge-base fails, but\n>> my perl is very rusty and I'm struggling to get git-svn.perl to grok\n>> the Git::Error::Command class.  What is the appropriate way to import\n>> that class?  Or more generally, is there a better solution to handling\n>> this error case?\n> \n> Hi Andrew,\n> \n> Git::Error::Command should be imported with the rest of Git.pm\n> \n> It's a special way of doing exceptions in Perl which I don't see much\n> point of...  Looking at git-send-email as an example, it does this:\n> \n> \tuse Error qw(:try);\n> \tuse Git;\n> \n> \ttry {\n> \t\t# something that will throw\n> \t} catch Git::Error::Command with {\n> \t\t# error handling\n> \t}\n\nI looked at git-send-email's example, but I wanted to do a bit more:\n\t\n\ttry {\n\t\t# command_oneline(...);\n\t} catch Git::Error::Command with {\n\t\t$E = shift;\n\t\tif ($E->value() == 1) {\n\t\t\t# do something\n\t\t} else {\n\t\t\t# do something else\n\t\t}\n\t}\n\t\nThis 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'\".\n\n> \n> A more standard approach in Perl is just:\n> \n> \teval {\n> \t\t# something that will die\n> \t};\n> \tif ($@) {\n> \t\t# error handling\n> \t}\n> \n\nPresumably $@ contains the Git::Error::Command object, which leaves me in the same spot, unfortunately.\n\n> But yes, it is Perl after all and TMTOWTDI :)\n\nIs there ever :)\n\n-Andrew\n"},{"id":"130295","messageId":"20091223205751.GE13735@dcvr.yhbt.net","threadId":"22019","inReplyTo":"940F72F6-8FE5-42AE-84A1-8C4A77B57188@apple.com","subject":"Re: git-svn: handling merge-base failures","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-12-23T20:57:51Z","receivedAt":"2009-12-23T20:57:51Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Andrew Myrick <amyrick@apple.com> wrote:\n> On Dec 23, 2009, at 12:09 PM, Eric Wong wrote:\n> > Andrew Myrick <amyrick@apple.com> wrote:\n> >> One of my projects is failing to clone because merge-base is failing\n> >> on one of the revisions; the branch is a partial branch, so merge-base\n> >> can't find a common ancestor with trunk.  I'd like to catch the\n> >> exception that command_oneline should throw when merge-base fails, but\n> >> my perl is very rusty and I'm struggling to get git-svn.perl to grok\n> >> the Git::Error::Command class.  What is the appropriate way to import\n> >> that class?  Or more generally, is there a better solution to handling\n> >> this error case?\n> > \n> > Hi Andrew,\n> > \n> > Git::Error::Command should be imported with the rest of Git.pm\n> > \n> > It's a special way of doing exceptions in Perl which I don't see much\n> > point of...  Looking at git-send-email as an example, it does this:\n> > \n> > \tuse Error qw(:try);\n> > \tuse Git;\n> > \n> > \ttry {\n> > \t\t# something that will throw\n> > \t} catch Git::Error::Command with {\n> > \t\t# error handling\n> > \t}\n> \n> I looked at git-send-email's example, but I wanted to do a bit more:\n> \t\n> \ttry {\n> \t\t# command_oneline(...);\n> \t} catch Git::Error::Command with {\n> \t\t$E = shift;\n> \t\tif ($E->value() == 1) {\n> \t\t\t# do something\n> \t\t} else {\n> \t\t\t# do something else\n> \t\t}\n> \t}\n>  \t\n> This is used in perl/Git.pm, but when I tried it in git-svn.perl, it\n> fails with the error \"Can't locate object method 'value' via package\n> 'Git::SVN'\".\n\nThat's strange.  I'm at a bit of a loss here so I'll wait for somebody\nwith more Perl knowledge than myself.\n\nWhat happens when you dump @_ in your catch block?\n\n\tuse Data::Dumper;\n\ttry {\n\t} catch Git::Error::Command with {\n\t\tprint STDERR Dumper(\\@_);\n\t}\n\n> Presumably $@ contains the Git::Error::Command object, which leaves me\n> in the same spot, unfortunately.\n> \n> > But yes, it is Perl after all and TMTOWTDI :)\n> \n> Is there ever :)\n\nYes I'm lost here, too, so in these cases I default to putting\nprint statements everywhere and Data::Dumper :)\n\n-- \nEric Wong\n"},{"id":"130741","messageId":"7878A426-9D87-43B5-A10A-38F3C9369165@apple.com","threadId":"22019","inReplyTo":"931B0483-7628-488E-BB9F-C40346353149@apple.com","subject":"Re: git-svn: handling merge-base failures","fromName":"Andrew Myrick","fromEmail":"amyrick@apple.com","sentAt":"2010-01-04T01:37:09Z","receivedAt":"2010-01-04T01:37:09Z","isPatch":false,"sender":{"key":"amyrick@apple.com","avatar":"https://avatars.githubusercontent.com/u/303045?v=4"},"body":"\nOn Dec 23, 2009, at 11:54 AM, Andrew Myrick wrote:\n> 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,\n\nInstead 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.\n\nWhen 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.\n\nNaively 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?\n\nI've created a small svn repository that demonstrates this failure with git v1.6.6.  Its dump is attached.\n\n-Andrew\n\n\n"},{"id":"130742","messageId":"20100104034540.GA4548@dcvr.yhbt.net","threadId":"22019","inReplyTo":"7878A426-9D87-43B5-A10A-38F3C9369165@apple.com","subject":"Re: git-svn: handling merge-base failures","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2010-01-04T03:45:41Z","receivedAt":"2010-01-04T03:45:41Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Andrew Myrick <amyrick@apple.com> wrote:\n> On Dec 23, 2009, at 11:54 AM, Andrew Myrick wrote:\n> > One of my projects is failing to clone because merge-base is failing\n> > on one of the revisions; the branch is a partial branch, so\n> > merge-base can't find a common ancestor with trunk.  I'd like to\n> > catch the exception that command_oneline should throw when\n> > merge-base fails,\n> \n> Instead of using the Error.pm module, I was able to handle the\n> exception with the more basic eval block.  However, there are some\n> details here I would like to discuss with the community.\n> \n> When git-svn fetches a partial branch, it appears to refetch all of\n> the history of the subdirectory from which the branch was created.\n> This creates new commits for the old revisions, and these new commits\n> exist as a separate history for the partial branch.   When git-svn\n> fetches the revision at which this partial branch is merged back to\n> trunk, git-svn attempts to run merge-base to find a common ancestor.\n> However, because the partial branch has its own history, the\n> merge-base fails, and git-svn dies.\n> \n> Naively handling the exception with an eval block and skipping the\n> merge ticket works fine in that it brings us back to parity with git\n> 1.6.5.7, but it means that the merge parent relationship between trunk\n> and the partial branch is lost.  Is there any way to preserve this\n> information, or does the separate commit history of the partial branch\n> make it fundamentally impossible?\n\nHi Andrew,\n\nA method of preserving the $SVN_PATH <=> $PARENT@$REV mapping for\nreusing follow_parent-created branches is definitely desired.\n\nI've just been lacking time and motivation these days with other\nprojects taking priority.  Help (even if it's just to refactor/cleanup\nexisting code) would definitely be appreciated here.\n\n> I've created a small svn repository that demonstrates this failure\n> with git v1.6.6.  Its dump is attached.\n\nThanks.  This (and a similar dump a few weeks back) will definitely\ncome in handy for writing test cases and fixing this long-standing\nissue.\n\n-- \nEric Wong\n"},{"id":"130743","messageId":"7B6F15D3-FCF3-4569-9617-62BA38C92B35@apple.com","threadId":"22019","inReplyTo":"20100104034540.GA4548@dcvr.yhbt.net","subject":"Re: git-svn: handling merge-base failures","fromName":"Andrew Myrick","fromEmail":"amyrick@apple.com","sentAt":"2010-01-04T04:43:52Z","receivedAt":"2010-01-04T04:43:52Z","isPatch":false,"sender":{"key":"amyrick@apple.com","avatar":"https://avatars.githubusercontent.com/u/303045?v=4"},"body":"\nOn Jan 3, 2010, at 7:45 PM, Eric Wong wrote:\n\n> Andrew Myrick <amyrick@apple.com> wrote:\n>> On Dec 23, 2009, at 11:54 AM, Andrew Myrick wrote:\n>>> One of my projects is failing to clone because merge-base is failing\n>>> on one of the revisions; the branch is a partial branch, so\n>>> merge-base can't find a common ancestor with trunk.  I'd like to\n>>> catch the exception that command_oneline should throw when\n>>> merge-base fails,\n>> \n>> Instead of using the Error.pm module, I was able to handle the\n>> exception with the more basic eval block.  However, there are some\n>> details here I would like to discuss with the community.\n>> \n>> When git-svn fetches a partial branch, it appears to refetch all of\n>> the history of the subdirectory from which the branch was created.\n>> This creates new commits for the old revisions, and these new commits\n>> exist as a separate history for the partial branch.   When git-svn\n>> fetches the revision at which this partial branch is merged back to\n>> trunk, git-svn attempts to run merge-base to find a common ancestor.\n>> However, because the partial branch has its own history, the\n>> merge-base fails, and git-svn dies.\n>> \n>> Naively handling the exception with an eval block and skipping the\n>> merge ticket works fine in that it brings us back to parity with git\n>> 1.6.5.7, but it means that the merge parent relationship between trunk\n>> and the partial branch is lost.  Is there any way to preserve this\n>> information, or does the separate commit history of the partial branch\n>> make it fundamentally impossible?\n> \n> Hi Andrew,\n> \n> A method of preserving the $SVN_PATH <=> $PARENT@$REV mapping for\n> reusing follow_parent-created branches is definitely desired.\n> \n> I've just been lacking time and motivation these days with other\n> projects taking priority.  Help (even if it's just to refactor/cleanup\n> existing code) would definitely be appreciated here.\n\nThanks 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.\n\nRegards,\nAndrew\n"}]}