Changeset 10615

Show
Ignore:
Timestamp:
02/08/10 02:23:11 (5 weeks ago)
Author:
adamk
Message:

Added support for --reset to flush and reset the configuration to defaults, because the Swarm plugin is instantly segfaulting Padre at startup and I didn't want to have to keep resetting the configuration by hand all the time.

Location:
trunk/Padre
Files:
1 added
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/Padre/Changes

    r10613 r10615  
    2525      of the modules used by the Perl help provider run-time loaded (ADAMK) 
    2626    - Moved padre.exe build from bin to win32-loader folder since bin is a 
    27       bad location for putting the Padre win32 launcher code (SMUELLER, AZAWAWI) 
     27      bad path for putting the Padre win32 launcher code (SMUELLER, AZAWAWI) 
    2828    - Added "Open in File Browser" in the File and right-click menu (AZAWAWI) 
    29     - No need to launch a command shell to execute explorer.exe on win32 (AZAWAWI) 
     29    - No need to launch a command shell to execute explorer.exe on 
     30      win32 (AZAWAWI) 
    3031    - Added "Open with Default System Editor" in "File -> Open..." (AZAWAWI) 
     32    - Implemented padre --reset to flush and reset the current Padre 
     33      configuration in otherwise unrecoverable situations, such as now 
     34      when the Swarm plugin causes the slave-driver code to instantly 
     35      segfault at startup (ADAMK) 
    3136 
    32370.56 2010.02.01 
     
    5762      the invoker (AZAWAWI) 
    5863    - Disable debugger menu items when there is no document (AZAWAWI) 
    59     - Fixed a Padre debugger crash when an unsaved document is debugged (AZAWAWI) 
     64    - Fixed a Padre debugger crash when unsaved document is debugged (AZAWAWI) 
    6065    - Fixed Padre no-document crash with Find Next/Find Previous functionality 
    6166      (AZAWAWI) 
     
    205210    - Ctrl-Tab behaviour is now configurable (SEWI) 
    206211    - Rename Padre::Debug to Padre::Logger (SZABGAB) 
    207     - Reuse the comment field of the menu actions and show them in the toolbar (SZABGAB) 
     212    - Reuse the comment field of the menu actions and show them in 
     213      the toolbar (SZABGAB) 
    208214    - Add comment field to all the menu items that did not have yet (SZABGAB) 
    209215    - Integrated Padre::DB into the Padre::Locker API, so that we can do 
     
    212218      being done in a transaction, or were doing crazy bizarre things. Startup 
    213219      is now noticably faster (ADAMK) 
    214     - Added Preference setting to control autocomplete when editting a script rather than 
    215       a Module. (PLAVEN)       
     220    - Added Preference setting to control autocomplete when editting a 
     221      script rather than a Module. (PLAVEN)       
    216222 
    2172230.52 2009.12.14 
     
    347353    - Fixed ticket #627: Suggestion: Make it possible to copy 'Syntax Check' 
    348354      messages (AZAWAWI) 
    349     - require version 0.20 of Wx::Perl::ProcessStream to fix #628 (AZAWAWI, SZABGAB) 
     355    - Require version 0.20 of Wx::Perl::ProcessStream to fix #628 (AZAWAWI, SZABGAB) 
    350356    - Fixed ticket #493: splash image license not suitable for Debian (AZAWAWI) 
    351357    - Fixed t/86-service.t to work again on win32 (AZAWAWI) 
     
    11981204 
    119912050.04 2008.08.08 
    1200     - add Devel::PerlySense as prereq 
    1201     - stop checking for wx version for now 
    1202     - change the create_makefile_pl to passthrough as the traditional did not do the extra work done by Build.PL 
     1206    - Add Devel::PerlySense as prereq 
     1207    - Stop checking for wx version for now 
     1208    - Change the create_makefile_pl to passthrough as the traditional did 
     1209      not do the extra work done by Build.PL 
    12031210    - Mark the buffer that is unsaved with a star. 
    1204     - stop saving the content of the loaded file and use GetModify 
     1211    - Stop saving the content of the loaded file and use GetModify 
    12051212      to find out if the file has been modifyed since last save 
    1206     - replace the search_term by search_terms in the config file 
    1207     - allow remembering of search terms 
    1208     - replace the text dialog by a full dialog box and a Wx::ComboBox 
     1213    - Replace the search_term by search_terms in the config file 
     1214    - Allow remembering of search terms 
     1215    - Replace the text dialog by a full dialog box and a Wx::ComboBox 
    12091216    - Setup http://padre.perlide.org/ using trac 
    12101217    - Move the repository to http://svn.perlide.org/padre/ 
    12111218 
    121212190.03_02 2008.08.03 
    1213     - add experimental code for plugins 
    1214     - add experimental version of Padre::Plugin::PAR 
    1215     - fix the shortcuts of some of the menues in windows, thanks to Octavian Rasnita 
    1216     - replace the AppendSubMenu calls by Append calls to support older version of wxWidgets 
     1220    - Add experimental code for plugins 
     1221    - Add experimental version of Padre::Plugin::PAR 
     1222    - Fix the shortcuts of some of the menues in windows, thanks to Octavian Rasnita 
     1223    - Replace the AppendSubMenu calls by Append calls to support older version of wxWidgets 
    12171224 
    121812250.03_01 2008.07.31 
  • trunk/Padre/dev.pl

    r10519 r10615  
    1515use Getopt::Long (); 
    1616use vars qw{ 
     17        $USAGE 
    1718        $DEBUG 
    18         $TRACE 
    19         $DIE 
    2019        $PROFILE 
    2120        $PLUGINS 
    22         $USAGE 
    2321        $FULLTRACE 
    2422        $INVISIBLE 
     
    2725 
    2826BEGIN { 
     27        $USAGE     = 0; 
    2928        $DEBUG     = 0; 
    30         $DIE       = 0; 
    3129        $PROFILE   = 0; 
    3230        $PLUGINS   = 0; 
    33         $USAGE     = 0; 
    3431        $FULLTRACE = 0; 
    3532        $INVISIBLE = 0; 
    3633        @INCLUDE   = (); 
    3734        Getopt::Long::GetOptions( 
    38                 'usage|help' => \$USAGE, 
    39                 'debug|d'    => \$DEBUG, 
    40                 'trace'      => sub { 
    41                         $ENV{PADRE_DEBUG} = 1; 
    42                 }, 
    43                 'die'         => \$DIE, 
     35                'usage|help'  => \$USAGE, 
     36                'debug|d'     => \$DEBUG, 
     37                'trace'       => sub { $ENV{PADRE_DEBUG} = 1 }, 
     38                'die'         => sub { $ENV{PADRE_DIE}   = 1 }, 
    4439                'profile'     => \$PROFILE, 
    4540                'a'           => \$PLUGINS, 
     
    5045} 
    5146 
    52 $USAGE and usage(); 
    53  
    5447$ENV{PADRE_DEV}  = 1; 
    5548$ENV{PADRE_HOME} = $FindBin::Bin; 
    56 $ENV{PADRE_DIE}  = $DIE; 
    5749 
    5850use lib $FindBin::Bin, "$FindBin::Bin/lib"; 
     
    9082 
    9183if ($FULLTRACE) { 
    92         eval { require Devel::Trace; }; 
     84        eval { 
     85                require Devel::Trace; 
     86        }; 
    9387        if ($@) { 
    9488                print "Error while initilizing --fulltrace while trying to load Devel::Trace:\n" 
    9589                        . "$@Maybe Devel::Trace isn't installed?\n"; 
    96                 exit 1; 
     90                exit(1); 
    9791        } 
    9892        push @cmd, '-d:Trace'; 
     
    121115push @cmd, '--help' if $USAGE; 
    122116 
    123 $DEBUG and print "Running " . join( ' ', @cmd ) . "\n"; 
     117if ( $DEBUG ) { 
     118        print "Running " . join( ' ', @cmd ) . "\n"; 
     119} 
     120 
     121if ( $USAGE ) { 
     122        usage(); 
     123} 
    124124 
    125125system(@cmd); 
    126126 
    127127sub vmsgfmt { 
    128         msgfmt( 
    129                 {   in      => "$_[0]/share/locale/", 
    130                         verbose => 0, 
    131                 } 
    132         ); 
     128        msgfmt( { in => "$_[0]/share/locale/", verbose => 0 } ); 
    133129} 
    134130 
  • trunk/Padre/lib/Padre/Constant.pm

    r10436 r10615  
    102102); 
    103103 
    104 use constant LOG_FILE => File::Spec->catfile( CONFIG_DIR, 'debug.log' ); 
    105 use constant PLUGIN_DIR => File::Spec->catdir( CONFIG_DIR, 'plugins' ); 
    106 use constant PLUGIN_LIB => File::Spec->catdir( PLUGIN_DIR, 'Padre', 'Plugin' ); 
     104use constant LOG_FILE       => File::Spec->catfile( CONFIG_DIR, 'debug.log' ); 
     105use constant PLUGIN_DIR     => File::Spec->catdir( CONFIG_DIR, 'plugins' ); 
     106use constant PLUGIN_LIB     => File::Spec->catdir( PLUGIN_DIR, 'Padre', 'Plugin' ); 
    107107use constant CONFIG_HOST    => File::Spec->catfile( CONFIG_DIR, 'config.db' ); 
    108108use constant CONFIG_HUMAN   => File::Spec->catfile( CONFIG_DIR, 'config.yml' ); 
    109109use constant CONFIG_STARTUP => File::Spec->catfile( CONFIG_DIR, 'startup.yml' ); 
    110110 
    111 # Check and create the directories that need to exist 
    112 unless ( -e CONFIG_DIR or File::Path::mkpath(CONFIG_DIR) ) { 
    113         Carp::croak( "Cannot create config directory '" . CONFIG_DIR . "': $!" ); 
     111# Do the initialisation in a function, 
     112# so we can run it again later if needed. 
     113sub init { 
     114        # Check and create the directories that need to exist 
     115        unless ( -e CONFIG_DIR or File::Path::mkpath(CONFIG_DIR) ) { 
     116                Carp::croak( "Cannot create config directory '" . CONFIG_DIR . "': $!" ); 
     117        } 
     118        unless ( -e PLUGIN_LIB or File::Path::mkpath(PLUGIN_LIB) ) { 
     119                Carp::croak( "Cannot create plug-ins directory '" . PLUGIN_LIB . "': $!" ); 
     120        } 
    114121} 
    115 unless ( -e PLUGIN_LIB or File::Path::mkpath(PLUGIN_LIB) ) { 
    116         Carp::croak( "Cannot create plug-ins directory '" . PLUGIN_LIB . "': $!" ); 
     122 
     123BEGIN { 
     124        init(); 
    117125} 
    118126 
     
    132140# NOTE: The only reason this is here is that it is needed both during 
    133141# main configuration, and also during Padre::Startup. 
    134 use constant DEFAULT_SINGLEINSTANCE => ( WIN32 and not( $ENV{HARNESS_ACTIVE} or $^P ) ) ? 1 : 0; 
     142use constant DEFAULT_SINGLEINSTANCE => ( 
     143        WIN32 and not( $ENV{HARNESS_ACTIVE} or $^P ) 
     144) ? 1 : 0; 
    135145 
    136146use constant DEFAULT_SINGLEINSTANCE_PORT => 4444; 
    137  
    138  
    139  
    140  
    141  
    142 ##################################################################### 
    143 # Pseudo Constants 
    144  
    145 my $revision; 
    146  
    147 # Get the svn revision of the currently running Padre once: 
    148 # eval 'use constant PADRE_REVISION => Padre::Util::revision;'; 
    149 # This needs to be a pseudo constant as it requires Padre::Util which 
    150 # requires Padre::Constant (this module). 
    151 sub PADRE_REVISION () { 
    152  
    153         # Get and keep the revision at the first call of this pseudo-constant 
    154         # (usually at Padre start) 
    155         require Padre::Util; 
    156         $revision ||= Padre::Util::revision(); 
    157         return $revision; 
    158 } 
    159147 
    1601481; 
  • trunk/Padre/lib/Padre/Plugin/PopularityContest.pm

    r10436 r10615  
    229229 
    230230        # Versioning information 
    231         my $revision = Padre::Constant::PADRE_REVISION; 
     231        require Padre::Util::SVN; 
     232        my $revision = Padre::Util::SVN::padre_revision(); 
    232233        if ( defined $revision ) { 
    233234 
  • trunk/Padre/lib/Padre/Plugin/PopularityContest/Ping.pm

    r10436 r10615  
    2525                my $dir = $0; 
    2626                $dir =~ s/padre$//; 
    27                 my $revision = Padre::Util::svn_directory_revision($dir); 
    28                 if ( -d "$dir.svn" ) { 
    29                         $data{svn} = $revision; 
    30                 } 
     27                require Padre::Util::SVN; 
     28                my $revision = Padre::Util::SVN::directory_revision($dir); 
     29                $data{svn} = $revision if -d "$dir.svn"; 
    3130        } 
    3231 
     
    3635 
    3736        # Hand off to the parent constructor 
    38         return $class->SUPER::new( request => HTTP::Request->new( GET => $url->as_string ) ); 
     37        return $class->SUPER::new( 
     38                request => HTTP::Request->new( GET => $url->as_string ) 
     39        ); 
    3940} 
    4041 
  • trunk/Padre/lib/Padre/Task/HTTPClient.pm

    r10436 r10615  
    44use strict; 
    55use warnings; 
    6  
    7 use Padre::Constant; 
     6use Padre::Constant (); 
    87 
    98# Use all modules which may provide services for us: 
    109 
    1110our $VERSION = '0.56'; 
     11our @DRIVERS = qw{ 
     12        Padre::Task::HTTPClient::LWP 
     13}; 
    1214 
    1315=pod 
     
    4143 
    4244sub new { 
    43  
    4445        my $class = shift; 
    45  
    46         my %args = @_; 
    47  
    48         return if ( !defined( $args{URL} ) ) or ( $args{URL} eq '' ); 
     46        my %args  = @_; 
     47        unless ( defined $args{URL} and length $args{URL} ) { 
     48                return; 
     49        } 
    4950 
    5051        # Prepare information 
    51         $args{headers}->{'X-Padre'} ||= 'Padre version ' . $VERSION . ' ' . Padre::Constant::PADRE_REVISION; 
    52         $args{method} ||= 'GET'; 
    53  
    54         my $self; 
     52        require Padre::Util::SVN; 
     53        my $revision = Padre::Util::SVN::padre_version(); 
     54        $args{method}               ||= 'GET'; 
     55        $args{headers}->{'X-Padre'} ||= "Padre version $VERSION $revision"; 
    5556 
    5657        # Each module will be tested and the first working one should return 
    5758        # a object, all others should return nothing (undef) 
    58         for ('LWP') { 
    59  
    60                 #               require 'Padre/Task/HTTPClient/' . $_ . '.pm'; 
    61                 eval 'require Padre::Task::HTTPClient::' . $_; 
     59        foreach my $driver ( @DRIVERS ) { 
     60                eval "require $driver;"; 
    6261                next if $@; 
    63                 $self = "Padre::Task::HTTPClient::$_"->new(%args); 
    64                 next unless defined($self); 
     62                my $self = $driver->new(%args) or next; 
    6563                return $self; 
    6664        } 
    6765 
    6866        return; 
    69  
    7067} 
    7168 
  • trunk/Padre/lib/Padre/Util.pm

    r10436 r10615  
    535535} 
    536536 
    537 # TODO: A much better variant would be a constant set by svn. 
    538 sub revision { 
    539         if ( $0 =~ /padre$/ ) { 
    540                 my $dir = $0; 
    541                 $dir =~ s/padre$//; 
    542                 my $revision = Padre::Util::svn_directory_revision($dir); 
    543                 if ( -d "$dir.svn" ) { 
    544                         return 'r' . $revision; 
    545                 } 
    546         } 
    547         return; 
    548 } 
    549  
    5505371; 
    551538 
  • trunk/Padre/lib/Padre/Wx/Main.pm

    r10612 r10615  
    11761176 
    11771177sub refresh_title { 
    1178         my $self    = shift; 
    1179         my $config  = $self->{config}; 
    1180         my $current = $self->current; 
    1181  
    1182         my %variable_data = ( 
     1178        my $self     = shift; 
     1179        my $config   = $self->{config}; 
     1180        my $current  = $self->current; 
     1181        my %variable = ( 
    11831182                '%' => '%', 
    11841183                'v' => $Padre::VERSION, 
    1185                 'f' => '',             # Initlize space for filename 
    1186                 'b' => '',             # Initlize space for filename - basename 
    1187                 'd' => '',             # Initlize space for filename - dirname 
    1188                 'F' => '',             # Initlize space for filename relative to project dir 
    1189                 'p' => '',             # Initlize space for project name 
     1184                'f' => '',             # Initialize space for filename 
     1185                'b' => '',             # Initialize space for filename - basename 
     1186                'd' => '',             # Initialize space for filename - dirname 
     1187                'F' => '',             # Initialize space for filename relative to project dir 
     1188                'p' => '',             # Initialize space for project name 
    11901189        ); 
    11911190 
     
    11981197                my $document = $current->document; 
    11991198                my $file     = $document->file; 
    1200                 $variable_data{'f'} = $file->{filename}; 
    1201                 $variable_data{'b'} = $file->basename; 
    1202                 $variable_data{'d'} = $file->dirname; 
    1203  
    1204                 $variable_data{'F'} = $file->{filename}; 
     1199                $variable{'f'} = $file->{filename}; 
     1200                $variable{'b'} = $file->basename; 
     1201                $variable{'d'} = $file->dirname; 
     1202                $variable{'F'} = $file->{filename}; 
    12051203                my $project_dir = $document->project_dir; 
    12061204                if ( defined $project_dir ) { 
    12071205                        $project_dir = quotemeta $project_dir; 
    1208                         $variable_data{'F'} =~ s/^$project_dir//; 
     1206                        $variable{'F'} =~ s/^$project_dir//; 
    12091207                } 
    12101208        } 
     
    12151213                        'where id = ?', $self->ide->{session}, 
    12161214                ); 
    1217                 $variable_data{'p'} = $session->name; 
     1215                $variable{'p'} = $session->name; 
    12181216        } 
    12191217 
     
    12211219        $self->{title} = $config->main_title; 
    12221220 
    1223         my $Vars = join( '', keys(%variable_data) ); 
    1224  
    1225         $self->{title} =~ s/\%([$Vars])/$variable_data{$1}/g; 
    1226  
    1227         $self->{title} = 'Padre ' . $Padre::VERSION 
    1228                 if !defined( $self->{title} ); 
    1229  
    1230         my $revision = Padre::Constant::PADRE_REVISION; 
    1231         $self->{title} .= " SVN \@$revision (\$VERSION = $Padre::VERSION)" 
    1232                 if defined($revision); 
     1221        my $variables = join '', keys %variable; 
     1222        $self->{title} =~ s/\%([$variables])/$variable{$1}/g; 
     1223        unless ( defined $self->{title} ) { 
     1224                $self->{title} = "Padre $Padre::VERSION"; 
     1225        } 
     1226 
     1227        require Padre::Util::SVN; 
     1228        my $revision = Padre::Util::SVN::padre_revision(); 
     1229        if ( defined $revision ) { 
     1230                $self->{title} .= " SVN \@$revision (\$VERSION = $Padre::VERSION)"; 
     1231        } 
    12331232 
    12341233        if ( $self->GetTitle ne $self->{title} ) { 
  • trunk/Padre/script/padre

    r10259 r10615  
    44use strict; 
    55use warnings; 
    6 use File::Which  (); 
    7 use Getopt::Long (); 
    8 use Carp         (); 
     6use Carp (); 
    97 
    108local $| = 1; 
     
    1614# Must run using wxPerl on OS X. 
    1715if ( $^O eq 'darwin' and $^X !~ m{/wxPerl\.app/} ) { 
     16        require File::Which; 
    1817        my $perl = scalar File::Which::which('wxPerl'); 
    1918        chomp($perl); 
     
    2928# Handle special command line cases early, because options like --home 
    3029# MUST be processed before the Padre.pm library is loaded. 
    31 my $USAGE       = ''; 
    32 my $VERSION     = ''; 
    33 my $HOME        = undef; 
    34 my $SESSION     = undef; 
    35 my $PRELOAD     = undef; 
    36 my $DESKTOP     = undef; 
    37 my $ACTIONQUEUE = undef; 
    38 my $getopt      = Getopt::Long::GetOptions( 
     30require Getopt::Long; 
     31my $USAGE   = ''; 
     32my $VERSION = ''; 
     33my $HOME    = undef; 
     34my $RESET   = undef; 
     35my $SESSION = undef; 
     36my $PRELOAD = undef; 
     37my $DESKTOP = undef; 
     38my $ACTIONS = undef; 
     39my $getopt  = Getopt::Long::GetOptions( 
    3940        'help|usage'    => \$USAGE, 
    4041        'version'       => \$VERSION, 
    4142        'home=s'        => \$HOME, 
     43        'reset'         => \$RESET, 
    4244        'session=s'     => \$SESSION, 
    4345        'desktop'       => \$DESKTOP, 
    44         'actionqueue=s' => \$ACTIONQUEUE, 
    45  
    46         # Keep this secret for now --ADAMK 
    47         'preload' => \$PRELOAD, 
     46        'actionqueue=s' => \$ACTIONS, 
     47        'preload'       => \$PRELOAD, # Keep this sekrit for now --ADAMK 
    4848); 
    4949 
    50 if ( $USAGE or !$getopt ) { 
     50 
     51 
     52 
     53 
     54##################################################################### 
     55# Special Execution Modules 
     56 
     57# Padre command line usage 
     58if ( $USAGE or not $getopt ) { 
    5159        print <<"END_USAGE"; 
    5260Usage: $0 [FILENAMES] 
    5361 
    54 --home=dir          Forces Padre's "home" directory to a specific location 
    5562--help              Shows this help message 
     63--home=dir          Forces Padre "home" directory to a specific location 
     64--reset             Flush entire local config directory and reset to defaults 
    5665--session=name      Open given session during Padre startup 
    5766--version           Prints Padre version and quits 
     
    6372} 
    6473 
    65 local $ENV{PADRE_HOME} = defined($HOME) ? $HOME : $ENV{PADRE_HOME}; 
    66  
    67 # Special execution modes 
     74# Padre version 
    6875if ($VERSION) { 
    6976        my $msg = "Perl Application Development and Refactoring Environment $Padre::VERSION\n"; 
     
    8491} 
    8592 
     93# Lock in the home and constants, which are needed for everything else 
     94local $ENV{PADRE_HOME} = defined($HOME) ? $HOME : $ENV{PADRE_HOME}; 
     95require Padre::Constant; 
     96 
     97# Destroy and reinitialise our config directory 
     98if ($RESET) { 
     99        require File::Remove; 
     100        File::Remove::remove( \1, Padre::Constant::CONFIG_DIR() ); 
     101        Padre::Constant::init(); 
     102} 
     103 
    86104if ($DESKTOP) { 
    87105        require Padre::Desktop; 
    88106        unless ( Padre::Desktop::desktop() ) { 
    89                 warn "--desktop not implemented for " . $^O . "\n"; 
     107                warn "--desktop not implemented for $^O\n"; 
    90108        } 
    91109        exit(1); 
     
    97115# local $ENV{PADRE_PAR_PATH} = $ENV{PAR_TEMP} || ''; 
    98116 
    99 my %opts = ( 
    100         files       => \@ARGV, 
    101         session     => $SESSION, 
    102         actionqueue => $ACTIONQUEUE, 
    103 ); 
    104  
    105117# If we have an action queue then we are running for automation reasons. 
    106118# Avoid the startup logic and continue to the main startup. 
    107 unless ( defined $ACTIONQUEUE ) { 
     119unless ( defined $ACTIONS ) { 
    108120 
    109121        # Run the Padre startup sequence before we load the main application 
     
    125137 
    126138# Build the application 
    127 my $app = Padre->new(%opts); 
    128 unless ($app) { 
    129         die "Failed to create Padre instance"; 
    130 } 
     139my $ide = Padre->new( 
     140        files       => \@ARGV, 
     141        session     => $SESSION, 
     142        actionqueue => $ACTIONS, 
     143) or die "Failed to create Padre instance"; 
    131144 
    132145# Start the application 
    133 $app->run; 
     146$ide->run; 
    134147 
    135148# Copyright 2008-2010 The Padre development team as listed in Padre.pm.