{"thread":{"id":"10038","subject":"git-svn and branches","startedAt":"2007-09-27T02:12:52Z","lastAt":"2007-09-28T17:19:59Z","messageCount":4,"participants":["Steven Walter","Sam Vilain","Eric Wong"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"54126","messageId":"20070927021252.GA23777@dervierte","threadId":"10038","inReplyTo":null,"subject":"git-svn and branches","fromName":"Steven Walter","fromEmail":"stevenrwalter@gmail.com","sentAt":"2007-09-27T02:12:52Z","receivedAt":"2007-09-27T02:12:52Z","isPatch":false,"sender":{"key":"stevenrwalter@gmail.com","avatar":"https://avatars.githubusercontent.com/u/79127?v=4"},"body":"I'm using git-svn to track a rather large subversion repository with a\nnon-standard layout.  In the past, I've only cared about trunk, but now\nI need to occasionally use branches, too.  By adding a second git-svn\nremote with the branch URL, I can fetch the branch, and git-svn is even\nintelligent enough to notice that the branch was copied off of trunk.\n\nHowever, git-svn also does a complete checkout for the first revision of\nthe branch.  By this, I mean it goes through shows \"A    file\" for every\nfile in the repository.  This takes quite a while, and seems rather\nunnecessary given that git-svn already noticed that the branch shares a\nhistory with trunk, which is already fetched.\n\nKnowing just enough of what git-svn is doing to be dangerous, I whipped\nup a short little patch.  This patch seems to work for the common case,\nand avoids fetching every file from subversion.  It does break\nsometimes, however, and I don't understand why.\n\nMaybe someone with a better grasps of the code can see what I did wrong,\nor suggest a better means to my end?\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 484b057..1bc92b6 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -1848,9 +1848,10 @@ sub find_parent_branch {\n                                              $self->full_url, $ed)\n                          or die \"SVN connection failed somewhere...\\n\";\n                } else {\n+                       $self->assert_index_clean($parent);\n                        print STDERR \"Following parent with do_update\\n\";\n                        $ed = SVN::Git::Fetcher->new($self);\n-                       $self->ra->gs_do_update($rev, $rev, $self, $ed)\n+                       $self->ra->gs_do_update($rev, $r0, $self, $ed)\n                          or die \"SVN connection failed somewhere...\\n\";\n                }\n                print STDERR \"Successfully followed parent\\n\";\n-- \n-Steven Walter <stevenrwalter@gmail.com>\n\"A human being should be able to change a diaper, plan an invasion,\nbutcher a hog, conn a ship, design a building, write a sonnet, balance\naccounts, build a wall, set a bone, comfort the dying, take orders,\ngive orders, cooperate, act alone, solve equations, analyze a new\nproblem, pitch manure, program a computer, cook a tasty meal, fight\nefficiently, die gallantly. Specialization is for insects.\"\n   -Robert Heinlein\n"},{"id":"54140","messageId":"46FB4F58.2080901@vilain.net","threadId":"10038","inReplyTo":"20070927021252.GA23777@dervierte","subject":"Re: git-svn and branches","fromName":"Sam Vilain","fromEmail":"sam@vilain.net","sentAt":"2007-09-27T06:36:08Z","receivedAt":"2007-09-27T06:36:08Z","isPatch":false,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"Steven Walter wrote:\n> Knowing just enough of what git-svn is doing to be dangerous, I\n> whipped up a short little patch.  This patch seems to work for the\n> common case, and avoids fetching every file from subversion.  It does\n> break sometimes, however, and I don't understand why.\n>\n> Maybe someone with a better grasps of the code can see what I did\n> wrong, or suggest a better means to my end?\n\nTry also with the SVN trunk - the do_switch API has recently been added\nand it also avoids this excess checkout.  I'm not sure why a solution\nlike you post isn't used, perhaps Eric can comment further.\n\nSam.\n\n> diff --git a/git-svn.perl b/git-svn.perl\n> index 484b057..1bc92b6 100755\n> --- a/git-svn.perl\n> +++ b/git-svn.perl\n> @@ -1848,9 +1848,10 @@ sub find_parent_branch {\n>                                               $self->full_url, $ed)\n>                           or die \"SVN connection failed somewhere...\\n\";\n>                 } else {\n> +                       $self->assert_index_clean($parent);\n>                         print STDERR \"Following parent with do_update\\n\";\n>                         $ed = SVN::Git::Fetcher->new($self);\n> -                       $self->ra->gs_do_update($rev, $rev, $self, $ed)\n> +                       $self->ra->gs_do_update($rev, $r0, $self, $ed)\n>                           or die \"SVN connection failed somewhere...\\n\";\n>                 }\n>                 print STDERR \"Successfully followed parent\\n\";\n"},{"id":"54143","messageId":"20070927072404.GB1782@hand.yhbt.net","threadId":"10038","inReplyTo":"20070927021252.GA23777@dervierte","subject":"Re: git-svn and branches","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2007-09-27T07:24:04Z","receivedAt":"2007-09-27T07:24:04Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Steven Walter <stevenrwalter@gmail.com> wrote:\n> I'm using git-svn to track a rather large subversion repository with a\n> non-standard layout.  In the past, I've only cared about trunk, but now\n> I need to occasionally use branches, too.  By adding a second git-svn\n> remote with the branch URL, I can fetch the branch, and git-svn is even\n> intelligent enough to notice that the branch was copied off of trunk.\n> \n> However, git-svn also does a complete checkout for the first revision of\n> the branch.  By this, I mean it goes through shows \"A    file\" for every\n> file in the repository.  This takes quite a while, and seems rather\n> unnecessary given that git-svn already noticed that the branch shares a\n> history with trunk, which is already fetched.\n> \n> Knowing just enough of what git-svn is doing to be dangerous, I whipped\n> up a short little patch.  This patch seems to work for the common case,\n> and avoids fetching every file from subversion.  It does break\n> sometimes, however, and I don't understand why.\n> \n> Maybe someone with a better grasps of the code can see what I did wrong,\n> or suggest a better means to my end?\n\nI believe your case handles where a branch is created directly from a\ntrunk copy with no file modifications in the branch, but not when a\nbranch is created and files are modified in the trunk (or branch) within\nthe same revision.  Is this what's happening?\n\nAdditionally, I think this breaks when an entire trunk or branch is\nmoved around because the original directory has moved or gone away:\n\n  /trunk => /project-a/trunk\n\nAnyways, as Sam said, newer SVN (1.4.4+) has a working do_switch()\nfunction and that code path will never be hit at all.\n\n> diff --git a/git-svn.perl b/git-svn.perl\n> index 484b057..1bc92b6 100755\n> --- a/git-svn.perl\n> +++ b/git-svn.perl\n> @@ -1848,9 +1848,10 @@ sub find_parent_branch {\n>                                               $self->full_url, $ed)\n>                           or die \"SVN connection failed somewhere...\\n\";\n>                 } else {\n> +                       $self->assert_index_clean($parent);\n>                         print STDERR \"Following parent with do_update\\n\";\n>                         $ed = SVN::Git::Fetcher->new($self);\n> -                       $self->ra->gs_do_update($rev, $rev, $self, $ed)\n> +                       $self->ra->gs_do_update($rev, $r0, $self, $ed)\n>                           or die \"SVN connection failed somewhere...\\n\";\n>                 }\n>                 print STDERR \"Successfully followed parent\\n\";\n\n-- \nEric Wong\n"},{"id":"54281","messageId":"20070928171959.GA21816@dervierte","threadId":"10038","inReplyTo":"20070927072404.GB1782@hand.yhbt.net","subject":"Re: git-svn and branches","fromName":"Steven Walter","fromEmail":"stevenrwalter@gmail.com","sentAt":"2007-09-28T17:19:59Z","receivedAt":"2007-09-28T17:19:59Z","isPatch":false,"sender":{"key":"stevenrwalter@gmail.com","avatar":"https://avatars.githubusercontent.com/u/79127?v=4"},"body":"On Thu, Sep 27, 2007 at 12:24:04AM -0700, Eric Wong wrote:\n> I believe your case handles where a branch is created directly from a\n> trunk copy with no file modifications in the branch, but not when a\n> branch is created and files are modified in the trunk (or branch) within\n> the same revision.  Is this what's happening?\n> \n> Additionally, I think this breaks when an entire trunk or branch is\n> moved around because the original directory has moved or gone away:\n> \n>   /trunk => /project-a/trunk\n> \n> Anyways, as Sam said, newer SVN (1.4.4+) has a working do_switch()\n> function and that code path will never be hit at all.\n\nI think you're right that my code would only handle a verbatim copy.  I\nmade a few changes and I think I have something that is more generally\nuseful.  Using a newer version of subversion isn't practical for me, as\nthis is a work situation where I don't have control of the workstations.\n\nOne criticism of the patch: the trees_match function probably needs to\nbe re-written.  My SVN::Perl-foo is weak.\n\nPatch to follow\n-- \n-Steven Walter <stevenrwalter@gmail.com>\n\"A human being should be able to change a diaper, plan an invasion,\nbutcher a hog, conn a ship, design a building, write a sonnet, balance\naccounts, build a wall, set a bone, comfort the dying, take orders,\ngive orders, cooperate, act alone, solve equations, analyze a new\nproblem, pitch manure, program a computer, cook a tasty meal, fight\nefficiently, die gallantly. Specialization is for insects.\"\n   -Robert Heinlein\n"}]}