{"thread":{"id":"22448","subject":"[PATCH] git-svn: persistent memoization","startedAt":"2010-01-30T03:14:22Z","lastAt":"2010-02-05T10:02:31Z","messageCount":4,"participants":["Andrew Myrick","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"133072","messageId":"1264821262-28322-1-git-send-email-amyrick@apple.com","threadId":"22448","inReplyTo":null,"subject":"[PATCH] git-svn: persistent memoization","fromName":"Andrew Myrick","fromEmail":"amyrick@apple.com","sentAt":"2010-01-30T03:14:22Z","receivedAt":"2010-01-30T03:14:22Z","isPatch":true,"sender":{"key":"amyrick@apple.com","avatar":"https://avatars.githubusercontent.com/u/303045?v=4"},"body":"Make memoization of the svn:mergeinfo processing functions persistent with\nMemoize::Storable so that the memoization tables don't need to be regenerated\nevery time the user runs git-svn fetch.\n\nThe Memoize::Storable hashes are stored in ENV{GIT_DIR}/svn/caches.\n\nSigned-off-by: Andrew Myrick <amyrick@apple.com>\n---\n git-svn.perl |   42 +++++++++++++++++++++++++++++++++++++-----\n 1 files changed, 37 insertions(+), 5 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 1f201e4..f7a9410 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -1632,10 +1632,11 @@ use vars qw/$default_repo_id $default_ref_id $_no_metadata $_follow_parent\n             $_use_svnsync_props $no_reuse_existing $_minimize_url\n \t    $_use_log_author $_add_author_from $_localtime/;\n use Carp qw/croak/;\n-use File::Path qw/mkpath/;\n+use File::Path qw/mkpath make_path/;\n use File::Copy qw/copy/;\n use IPC::Open3;\n use Memoize;  # core since 5.8.0, Jul 2002\n+use Memoize::Storable;\n \n my ($_gc_nr, $_gc_period);\n \n@@ -3078,10 +3079,39 @@ sub has_no_changes {\n \t\tcommand_oneline(\"rev-parse\", \"$commit~1^{tree}\"));\n }\n \n-BEGIN {\n-\tmemoize 'lookup_svn_merge';\n-\tmemoize 'check_cherry_pick';\n-\tmemoize 'has_no_changes';\n+# The GIT_DIR environment variable is not always set until after the command\n+# line arguments are processed, so we can't memoize in a BEGIN block.\n+{\n+\tmy $memoized = 0;\n+\n+\tsub memoize_svn_mergeinfo_functions {\n+\t\treturn if $memoized;\n+\t\t$memoized = 1;\n+\n+\t\tmy $cache_path = \"$ENV{GIT_DIR}/svn/caches/\";\n+\t\tmake_path($cache_path) unless -d $cache_path;\n+\n+\t\ttie my %lookup_svn_merge_cache =>\n+\t\t\t'Memoize::Storable',\"$cache_path/lookup_svn_merge.db\", 'nstore';\n+\t\tmemoize 'lookup_svn_merge',\n+\t\t\tSCALAR_CACHE => 'FAULT',\n+\t\t\tLIST_CACHE => ['HASH' => \\%lookup_svn_merge_cache],\n+\t\t;\n+\n+\t\ttie my %check_cherry_pick_cache =>\n+\t\t\t'Memoize::Storable',\"$cache_path/check_cherry_pick.db\", 'nstore';\n+\t\tmemoize 'check_cherry_pick',\n+\t\t\tSCALAR_CACHE => 'FAULT',\n+\t\t\tLIST_CACHE => ['HASH' => \\%check_cherry_pick_cache],\n+\t\t;\n+\n+\t\ttie my %has_no_changes_cache =>\n+\t\t\t'Memoize::Storable',\"$cache_path/has_no_changes.db\", 'nstore';\n+\t\tmemoize 'has_no_changes',\n+\t\t\tSCALAR_CACHE => ['HASH' => \\%has_no_changes_cache],\n+\t\t\tLIST_CACHE => 'FAULT',\n+\t\t;\n+\t}\n }\n \n sub parents_exclude {\n@@ -3125,6 +3155,8 @@ sub find_extra_svn_parents {\n \tmy ($self, $ed, $mergeinfo, $parents) = @_;\n \t# aha!  svk:merge property changed...\n \n+\tmemoize_svn_mergeinfo_functions();\n+\n \t# We first search for merged tips which are not in our\n \t# history.  Then, we figure out which git revisions are in\n \t# that tip, but not this revision.  If all of those revisions\n-- \n1.6.6.1.4.g3df0a5.dirty\n"},{"id":"133217","messageId":"20100201040312.GA26199@dcvr.yhbt.net","threadId":"22448","inReplyTo":"1264821262-28322-1-git-send-email-amyrick@apple.com","subject":"Re: [PATCH] git-svn: persistent memoization","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2010-02-01T04:03:12Z","receivedAt":"2010-02-01T04:03:12Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Andrew Myrick <amyrick@apple.com> wrote:\n> Make memoization of the svn:mergeinfo processing functions persistent with\n> Memoize::Storable so that the memoization tables don't need to be regenerated\n> every time the user runs git-svn fetch.\n> \n> The Memoize::Storable hashes are stored in ENV{GIT_DIR}/svn/caches.\n\nHi Andrew,\n\nPerhaps \"$ENV{GIT_DIR}/svn/.caches\" is better here since older versions\nof git svn used \"$ENV{GIT_DIR}/svn/$refname\" in the top-level and\n\"caches\" may conflict with existing repos.\n\n> -use File::Path qw/mkpath/;\n> +use File::Path qw/mkpath make_path/;\n\nFile::Path::make_path is very recent not in Perls distributed by most\nvendors.  My 5.10.0 installation (Debian stable) doesn't have it, and I\nalso don't see a good reason to use it over the traditional mkpath.\n\nI think I'll squash the following patch and Ack.  Let me know if\nyou have any objections, thanks.!\n(also wraps long lines to 80 chars)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 0153439..265852f 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -1652,7 +1652,7 @@ use vars qw/$default_repo_id $default_ref_id $_no_metadata $_follow_parent\n             $_use_svnsync_props $no_reuse_existing $_minimize_url\n \t    $_use_log_author $_add_author_from $_localtime/;\n use Carp qw/croak/;\n-use File::Path qw/mkpath make_path/;\n+use File::Path qw/mkpath/;\n use File::Copy qw/copy/;\n use IPC::Open3;\n use Memoize;  # core since 5.8.0, Jul 2002\n@@ -3126,25 +3126,25 @@ sub has_no_changes {\n \t\treturn if $memoized;\n \t\t$memoized = 1;\n \n-\t\tmy $cache_path = \"$ENV{GIT_DIR}/svn/caches/\";\n-\t\tmake_path($cache_path) unless -d $cache_path;\n+\t\tmy $cache_path = \"$ENV{GIT_DIR}/svn/.caches/\";\n+\t\tmkpath([$cache_path]) unless -d $cache_path;\n \n-\t\ttie my %lookup_svn_merge_cache =>\n-\t\t\t'Memoize::Storable',\"$cache_path/lookup_svn_merge.db\", 'nstore';\n+\t\ttie my %lookup_svn_merge_cache => 'Memoize::Storable',\n+\t\t    \"$cache_path/lookup_svn_merge.db\", 'nstore';\n \t\tmemoize 'lookup_svn_merge',\n \t\t\tSCALAR_CACHE => 'FAULT',\n \t\t\tLIST_CACHE => ['HASH' => \\%lookup_svn_merge_cache],\n \t\t;\n \n-\t\ttie my %check_cherry_pick_cache =>\n-\t\t\t'Memoize::Storable',\"$cache_path/check_cherry_pick.db\", 'nstore';\n+\t\ttie my %check_cherry_pick_cache => 'Memoize::Storable',\n+\t\t    \"$cache_path/check_cherry_pick.db\", 'nstore';\n \t\tmemoize 'check_cherry_pick',\n \t\t\tSCALAR_CACHE => 'FAULT',\n \t\t\tLIST_CACHE => ['HASH' => \\%check_cherry_pick_cache],\n \t\t;\n \n-\t\ttie my %has_no_changes_cache =>\n-\t\t\t'Memoize::Storable',\"$cache_path/has_no_changes.db\", 'nstore';\n+\t\ttie my %has_no_changes_cache => 'Memoize::Storable',\n+\t\t    \"$cache_path/has_no_changes.db\", 'nstore';\n \t\tmemoize 'has_no_changes',\n \t\t\tSCALAR_CACHE => ['HASH' => \\%has_no_changes_cache],\n \t\t\tLIST_CACHE => 'FAULT',\n-- \nEric Wong\n"},{"id":"133264","messageId":"49FDA6F7-21D8-4280-A6A7-80EC2F749EA9@apple.com","threadId":"22448","inReplyTo":"20100201040312.GA26199@dcvr.yhbt.net","subject":"Re: [PATCH] git-svn: persistent memoization","fromName":"Andrew Myrick","fromEmail":"amyrick@apple.com","sentAt":"2010-02-01T16:44:43Z","receivedAt":"2010-02-01T16:44:43Z","isPatch":true,"sender":{"key":"amyrick@apple.com","avatar":"https://avatars.githubusercontent.com/u/303045?v=4"},"body":"\nOn Jan 31, 2010, at 8:03 PM, Eric Wong wrote:\n\n> Andrew Myrick <amyrick@apple.com> wrote:\n>> Make memoization of the svn:mergeinfo processing functions persistent with\n>> Memoize::Storable so that the memoization tables don't need to be regenerated\n>> every time the user runs git-svn fetch.\n>> \n>> The Memoize::Storable hashes are stored in ENV{GIT_DIR}/svn/caches.\n> \n> Hi Andrew,\n> \n> Perhaps \"$ENV{GIT_DIR}/svn/.caches\" is better here since older versions\n> of git svn used \"$ENV{GIT_DIR}/svn/$refname\" in the top-level and\n> \"caches\" may conflict with existing repos.\n> \n>> -use File::Path qw/mkpath/;\n>> +use File::Path qw/mkpath make_path/;\n> \n> File::Path::make_path is very recent not in Perls distributed by most\n> vendors.  My 5.10.0 installation (Debian stable) doesn't have it, and I\n> also don't see a good reason to use it over the traditional mkpath.\n> \n> I think I'll squash the following patch and Ack.  Let me know if\n> you have any objections, thanks.!\n> (also wraps long lines to 80 chars)\n\nMakes sense to me.  Thanks, Eric.\n\n-Andrew\n"},{"id":"133675","messageId":"20100205100230.GA16881@dcvr.yhbt.net","threadId":"22448","inReplyTo":"49FDA6F7-21D8-4280-A6A7-80EC2F749EA9@apple.com","subject":"Re: [PATCH] git-svn: persistent memoization","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2010-02-05T10:02:31Z","receivedAt":"2010-02-05T10:02:31Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Andrew Myrick <amyrick@apple.com> wrote:\n> On Jan 31, 2010, at 8:03 PM, Eric Wong wrote:\n> > Andrew Myrick <amyrick@apple.com> wrote:\n> >> Make memoization of the svn:mergeinfo processing functions persistent with\n> >> Memoize::Storable so that the memoization tables don't need to be regenerated\n> >> every time the user runs git-svn fetch.\n> >> \n> >> The Memoize::Storable hashes are stored in ENV{GIT_DIR}/svn/caches.\n> > \n> > Hi Andrew,\n> > \n> > Perhaps \"$ENV{GIT_DIR}/svn/.caches\" is better here since older versions\n> > of git svn used \"$ENV{GIT_DIR}/svn/$refname\" in the top-level and\n> > \"caches\" may conflict with existing repos.\n> > \n> >> -use File::Path qw/mkpath/;\n> >> +use File::Path qw/mkpath make_path/;\n> > \n> > File::Path::make_path is very recent not in Perls distributed by most\n> > vendors.  My 5.10.0 installation (Debian stable) doesn't have it, and I\n> > also don't see a good reason to use it over the traditional mkpath.\n> > \n> > I think I'll squash the following patch and Ack.  Let me know if\n> > you have any objections, thanks.!\n> > (also wraps long lines to 80 chars)\n> \n> Makes sense to me.  Thanks, Eric.\n\nHi Junio,\n\nI've acked and pushed this out to git://git.bogomips.org/git-svn\n\n  Andrew Myrick (1):\n        git-svn: persistent memoization\n\nSorry for the delay, my mind has slipped.  Thanks to Andrew\nfor the patch and reminder.\n\n-- \nEric Wong\n"}]}