# # # add_file "lib/perl/CachingAutomateStdio.pm" # content [6eea2e0d89c07113e0f94581fedf159344ad629a] # # patch "lib/perl/AdvancedFind.pm" # from [14153cb90a3c23bf51b2ee94628d9bd638f96a3b] # to [a92539ead0913127587e04bf47eaa93c502c13b9] # # patch "lib/perl/Common.pm" # from [0fd38de30c5209b3d6362e7402f2f2290b3553b1] # to [eb11c91dc157322174dace83836d130f7d673519] # # patch "lib/perl/Completion.pm" # from [2121039813f5af6b6e5c43a3fcf766a1fcfb4df9] # to [fa1ba99a0bbf5d894cfd75a3df2f844475853277] # # patch "lib/perl/WindowManager.pm" # from [ed8c682fdf90c643ae93d9f9064ee4b48a7e6f64] # to [41b8c9c3ed55d22a4a6e55a87f9d28c38f43cd40] # # patch "mtn-browse" # from [898df9702acc2eabd720d63386a89c79422b16b5] # to [7120b85f4c8a396c26251f3eb075013e53c19e12] # ============================================================ --- lib/perl/CachingAutomateStdio.pm 6eea2e0d89c07113e0f94581fedf159344ad629a +++ lib/perl/CachingAutomateStdio.pm 6eea2e0d89c07113e0f94581fedf159344ad629a @@ -0,0 +1,119 @@ +############################################################################## +# +# File Name - CachingAutomateStdio.pm +# +# Description - A class module that provides an interface to Monotone's +# automate stdio interface with caching of certain +# information (currently only branch lists). This class is +# derived from the Monotone::AutomateStdio class. +# +# Authors - A.E.Cooper. +# +# Legal Stuff - Copyright (c) 2007 Anthony Edward Cooper +# . +# +# This library is free software; you can redistribute it +# and/or modify it under the terms of the GNU Lesser General +# Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your +# option) any later version. +# +# This library is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU Lesser General Public License for +# more details. +# +# You should have received a copy of the GNU Lesser General +# Public License along with this library; if not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite +# 330, Boston, MA 02111-1307 USA. +# +############################################################################## +# +############################################################################## +# +# Package - CachingAutomateStdio +# +# Description - See above. +# +############################################################################## + + + +# ***** PACKAGE DECLARATION ***** + +package CachingAutomateStdio; + +# ***** DIRECTIVES ***** + +require 5.008005; + +use integer; +use strict; +use warnings; + +# ***** REQUIRED PACKAGES ***** + +# Monotone AutomateStdio module. + +use Monotone::AutomateStdio qw(:capabilities :severities); + +# ***** FUNCTIONAL PROTOTYPES ***** + +# Public methods. + +sub branches($$); + +# ***** PACKAGE INFORMATION ***** + +# We are derived from the Monotone::AutomateStdio class. + +use base qw(Monotone::AutomateStdio); + +*EXPORT = *Monotone::AutomateStdio::EXPORT; +*EXPORT_OK = *Monotone::AutomateStdio::EXPORT_OK; +*EXPORT_TAGS = *Monotone::AutomateStdio::EXPORT_TAGS; +our $VERSION = 0.01; +# +############################################################################## +# +# Routine - branches +# +# Description - Get a list of branches, caching the result. +# +# Data - $this : The object. +# $list : A reference to a list that is to contain the +# branch names. +# Return Value : True on success, otherwise false on failure. +# +############################################################################## + + + +sub branches($$) +{ + + my($this, $list) = @_; + + my $ret_val = 1; + + # If there is no cache or the mtn subprocess has been restarted, and hence + # the database has been reopened, then refresh the cache. + + if (! exists($this->{cached_branch_list}) + || ! exists($this->{cached_mtn_pid}) + || $this->{cached_mtn_pid} == 0 + || $this->{cached_mtn_pid} != $this->get_pid()) + { + $this->{cached_branch_list} = []; + $ret_val = $this->SUPER::branches($this->{cached_branch_list}); + $this->{cached_mtn_pid} = $this->get_pid(); + } + @$list = @{$this->{cached_branch_list}}; + + return $ret_val; + +} + +1; ============================================================ --- lib/perl/AdvancedFind.pm 14153cb90a3c23bf51b2ee94628d9bd638f96a3b +++ lib/perl/AdvancedFind.pm a92539ead0913127587e04bf47eaa93c502c13b9 @@ -964,7 +964,7 @@ sub update_advanced_find_state($$) # Remember the user can type in any old rubbish with advanced # queries! So protect ourselves. - Monotone::AutomateStdio->register_error_handler + CachingAutomateStdio->register_error_handler (MTN_SEVERITY_ALL, sub { my($severity, $message) = @_; @@ -987,8 +987,8 @@ sub update_advanced_find_state($$) $matches = scalar(@revision_ids); }; $err = $@; - Monotone::AutomateStdio->register_error_handler - (MTN_SEVERITY_ALL, \&mtn_error_handler); + CachingAutomateStdio->register_error_handler(MTN_SEVERITY_ALL, + \&mtn_error_handler); # If the query was valid then store it in the history. ============================================================ --- lib/perl/Common.pm 0fd38de30c5209b3d6362e7402f2f2290b3553b1 +++ lib/perl/Common.pm eb11c91dc157322174dace83836d130f7d673519 @@ -408,14 +408,13 @@ sub open_database($$$) # Ok it is a readable file, try and open it but deal with any # errors in a nicer way than normal. - Monotone::AutomateStdio->register_error_handler - (MTN_SEVERITY_ALL); + CachingAutomateStdio->register_error_handler(MTN_SEVERITY_ALL); eval { - $mtn_obj = Monotone::AutomateStdio->new($fname); + $mtn_obj = CachingAutomateStdio->new($fname); }; $err = $@; - Monotone::AutomateStdio->register_error_handler + CachingAutomateStdio->register_error_handler (MTN_SEVERITY_ALL, \&mtn_error_handler); if ($err ne "") { ============================================================ --- lib/perl/Completion.pm 2121039813f5af6b6e5c43a3fcf766a1fcfb4df9 +++ lib/perl/Completion.pm fa1ba99a0bbf5d894cfd75a3df2f844475853277 @@ -2,7 +2,7 @@ # # File Name - Completion.pm # -# Description - Class module that provides a basic auto-completion +# Description - A class module that provides a basic auto-completion # mechanism. # # Author - A.E.Cooper. @@ -53,10 +53,14 @@ use warnings; # ***** FUNCTIONAL PROTOTYPES ***** +# Constructor and destructor. + +sub new($;$); +sub DESTROY($); + # Public methods. sub get_completion($$$$); -sub new($;$); # ***** PACKAGE INFORMATION ***** ============================================================ --- lib/perl/WindowManager.pm ed8c682fdf90c643ae93d9f9064ee4b48a7e6f64 +++ lib/perl/WindowManager.pm 41b8c9c3ed55d22a4a6e55a87f9d28c38f43cd40 @@ -2,8 +2,9 @@ # # File Name - WindowManager.pm # -# Description - Class module that provides a class for managing application -# windows, i.e. their recycling, busy cursor management etc. +# Description - A class module for managing application windows, i.e. their +# recycling, busy cursor management and application help +# management. # # Author - A.E.Cooper. # @@ -80,16 +81,19 @@ my $singleton; # ***** FUNCTIONAL PROTOTYPES ***** +# Singleton instance constructor/accessor and destructor methods. + +sub instance($); +sub cleanup($); + # Public methods. sub activate_context_sensitive_help($$); sub allow_input($&); -sub cleanup($); sub cond_find($$&); sub display_window_help($$); sub find_unused($$); sub help_connect($$$$); -sub instance($); sub make_busy($$$;$); sub manage($$$$;$); sub reset_state($); ============================================================ --- mtn-browse 898df9702acc2eabd720d63386a89c79422b16b5 +++ mtn-browse 7120b85f4c8a396c26251f3eb075013e53c19e12 @@ -83,9 +83,9 @@ use lib File::Spec->catfile(LIB_DIR, "pe use lib File::Spec->catfile(LIB_DIR, "perl"); -# Monotone AutomateStdio module. +# Monotone AutomateStdio module (via derived caching class). -use Monotone::AutomateStdio qw(:capabilities :severities); +use CachingAutomateStdio qw(:capabilities :severities); # Modules specific to this application. @@ -202,9 +202,8 @@ sub view_button_clicked_cb($$); # Set up the default database locked and I/O wait handlers for the Monotone # class. - Monotone::AutomateStdio-> - register_db_locked_handler(\&mtn_db_locked_handler); - Monotone::AutomateStdio->register_io_wait_handler + CachingAutomateStdio->register_db_locked_handler(\&mtn_db_locked_handler); + CachingAutomateStdio->register_io_wait_handler (sub { WindowManager->instance()->update_gui(); }, 1); # Load in user preferences. @@ -270,7 +269,7 @@ sub view_button_clicked_cb($$); eval { my $db; - $mtn = Monotone::AutomateStdio->new(); + $mtn = CachingAutomateStdio->new(); $mtn->get_option(\$db, "database"); if ($user_preferences->{workspace}->{auto_select}) { @@ -284,7 +283,7 @@ sub view_button_clicked_cb($$); $branch = undef if (! defined($revision_id)); } $mtn = undef; - $mtn = Monotone::AutomateStdio->new($db); + $mtn = CachingAutomateStdio->new($db); }; } @@ -295,7 +294,7 @@ sub view_button_clicked_cb($$); eval { - $mtn = Monotone::AutomateStdio-> + $mtn = CachingAutomateStdio-> new($user_preferences->{default_mtn_db}); }; if ($@ ne "") @@ -315,8 +314,8 @@ sub view_button_clicked_cb($$); # Set up the error handlers for the Monotone class. - Monotone::AutomateStdio->register_error_handler(MTN_SEVERITY_ALL, - \&mtn_error_handler); + CachingAutomateStdio->register_error_handler(MTN_SEVERITY_ALL, + \&mtn_error_handler); # Create the browser window and display it. Please note that updating the # browser to reflect the current database or workspace is done in an idle