~ubuntu-branches/ubuntu/saucy/padre/saucy-proposed

« back to all changes in this revision

Viewing changes to lib/Padre/Wx/Dialog/Patch.pm

  • Committer: Package Import Robot
  • Author(s): Dominique Dumont, gregor herrmann, Dominique Dumont
  • Date: 2012-01-04 12:04:20 UTC
  • mfrom: (1.3.3)
  • Revision ID: package-import@ubuntu.com-20120104120420-i5oybqwf91m1d3il
Tags: 0.92.ds1-1
[ gregor herrmann ]
* Remove debian/source/local-options; abort-on-upstream-changes
  and unapply-patches are default in dpkg-source since 1.16.1.
* Swap order of alternative (build) dependencies after the perl
  5.14 transition.

[ Dominique Dumont ]
* Imported Upstream version 0.92.ds1
* removed fix-spelling patch (applied upstream)
* lintian-override: use wildcard to avoid listing a gazillion files
* updated size of some 'not-real-man-page' entries
* rules: remove dekstop cruft (replaced by a file provided in debian
  directory)
* control: removed Breaks statement. Add /me to uploaders. Updated
  dependencies
* rules: make sure that non-DFSG file (i.e. the cute butterfly, sigh)
  is not distributed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package Padre::Wx::Dialog::Patch;
 
2
 
 
3
use 5.008;
 
4
use strict;
 
5
use warnings;
 
6
use File::Slurp           ();
 
7
use Padre::Wx             ();
 
8
use Padre::Wx::FBP::Patch ();
 
9
use Padre::Logger;
 
10
 
 
11
# use Data::Printer { caller_info => 1 };
 
12
 
 
13
our $VERSION = '0.92';
 
14
our @ISA     = qw{
 
15
        Padre::Wx::FBP::Patch
 
16
};
 
17
 
 
18
 
 
19
#######
 
20
# new
 
21
#######
 
22
sub new {
 
23
        my $class = shift;
 
24
        my $self  = $class->SUPER::new(@_);
 
25
 
 
26
        $self->CenterOnParent;
 
27
 
 
28
        $self->{action_request} = 'Patch';
 
29
        $self->{selection}      = 0;
 
30
 
 
31
        return $self;
 
32
}
 
33
 
 
34
#######
 
35
# Method run
 
36
#######
 
37
sub run {
 
38
        my $self    = shift;
 
39
        my $current = $self->current;
 
40
 
 
41
        # auto-fill dialogue
 
42
        $self->set_up();
 
43
 
 
44
        # TODO but I want nonModal, ie $self->Show;
 
45
        # Show the dialog
 
46
        my $result = $self->ShowModal;
 
47
 
 
48
        if ( $result == Wx::ID_CANCEL ) {
 
49
 
 
50
                # As we leave the Find dialog, return the user to the current editor
 
51
                # window so they don't need to click it.
 
52
                my $editor = $current->editor;
 
53
                $editor->SetFocus if $editor;
 
54
 
 
55
                # Clean up
 
56
                $self->Destroy;
 
57
 
 
58
                return;
 
59
        }
 
60
 
 
61
        return;
 
62
}
 
63
 
 
64
#######
 
65
# Method set_up
 
66
#######
 
67
sub set_up {
 
68
        my $self = shift;
 
69
 
 
70
        # test for local svn_local
 
71
        $self->test_svn();
 
72
 
 
73
        # generate open file bucket
 
74
        $self->current_files();
 
75
 
 
76
        # display default saved file lists
 
77
        $self->file_lists_saved();
 
78
 
 
79
        # display correct file-2 list
 
80
        $self->file2_list_type();
 
81
 
 
82
        $self->against->SetSelection(0);
 
83
 
 
84
        return;
 
85
}
 
86
 
 
87
#######
 
88
# Event Handler process_clicked
 
89
#######
 
90
sub process_clicked {
 
91
        my $self = shift;
 
92
 
 
93
        my $file1 = @{ $self->{file1_list_ref} }[ $self->file1->GetSelection() ];
 
94
        my $file2 = @{ $self->{file2_list_ref} }[ $self->file2->GetCurrentSelection() ];
 
95
 
 
96
        TRACE( '$self->file1->GetSelection(): ' . $self->file1->GetSelection() )               if DEBUG;
 
97
        TRACE( '$file1: ' . $file1 )                                                           if DEBUG;
 
98
        TRACE( '$self->file2->GetCurrentSelection(): ' . $self->file2->GetCurrentSelection() ) if DEBUG;
 
99
        TRACE( '$file2: ' . $file2 )                                                           if DEBUG;
 
100
        TRACE( $self->action->GetStringSelection() )                                           if DEBUG;
 
101
 
 
102
        if ( $self->action->GetStringSelection() eq 'Patch' ) {
 
103
                $self->apply_patch( $file1, $file2 );
 
104
        }
 
105
 
 
106
        if ( $self->action->GetStringSelection() eq 'Diff' ) {
 
107
                if ( $self->against->GetStringSelection() eq 'File-2' ) {
 
108
                        $self->make_patch_diff( $file1, $file2 );
 
109
                } elsif ( $self->against->GetStringSelection() eq 'SVN' ) {
 
110
                        $self->make_patch_svn($file1);
 
111
                }
 
112
        }
 
113
 
 
114
        # reset dialogue's display information
 
115
        $self->set_up;
 
116
 
 
117
        return;
 
118
}
 
119
 
 
120
#######
 
121
# Event Handler on_action
 
122
#######
 
123
sub on_action {
 
124
        my $self = shift;
 
125
 
 
126
        # re-generate open file bucket
 
127
        $self->current_files();
 
128
 
 
129
        if ( $self->action->GetStringSelection() eq 'Patch' ) {
 
130
 
 
131
                $self->{action_request} = 'Patch';
 
132
                $self->set_up;
 
133
                $self->against->Enable(0);
 
134
                $self->file2->Enable(1);
 
135
        } else {
 
136
 
 
137
                $self->{action_request} = 'Diff';
 
138
                $self->set_up;
 
139
                $self->against->Enable(1);
 
140
                $self->file2->Enable(1);
 
141
 
 
142
                # as we can not added items to a radio-box,
 
143
                # we can only enable & disable when radio-box enabled
 
144
                unless ( $self->{svn_local} ) {
 
145
                        $self->against->EnableItem( 1, 0 );
 
146
                }
 
147
                $self->against->SetSelection(0);
 
148
 
 
149
        }
 
150
        return;
 
151
}
 
152
 
 
153
#######
 
154
# Event Handler on_against
 
155
#######
 
156
sub on_against {
 
157
        my $self = shift;
 
158
 
 
159
        if ( $self->against->GetStringSelection() eq 'File-2' ) {
 
160
 
 
161
                # show saved files only
 
162
                $self->file2->Enable(1);
 
163
                $self->file_lists_saved();
 
164
 
 
165
        } elsif ( $self->against->GetStringSelection() eq 'SVN' ) {
 
166
 
 
167
                # SVN only display files that are part of a SVN
 
168
                $self->file2->Enable(0);
 
169
                $self->file1_list_svn();
 
170
        }
 
171
 
 
172
        return;
 
173
}
 
174
 
 
175
#######
 
176
# Method current_files
 
177
#######
 
178
sub current_files {
 
179
        my $self     = shift;
 
180
        my $main     = $self->main;
 
181
        my $current  = $main->current;
 
182
        my $notebook = $current->notebook;
 
183
        my @label    = $notebook->labels;
 
184
 
 
185
        # get last element # not size
 
186
        $self->{tab_cardinality} = $#label;
 
187
 
 
188
        # thanks Alias
 
189
        my @file_vcs = map { $_->project->vcs } $self->main->documents;
 
190
 
 
191
        # create a bucket for open file info, as only a current file bucket exist
 
192
        for ( 0 .. $self->{tab_cardinality} ) {
 
193
                $self->{open_file_info}->{$_} = (
 
194
                        {   'index'    => $_,
 
195
                                'URL'      => $label[$_][1],
 
196
                                'filename' => $notebook->GetPageText($_),
 
197
                                'changed'  => 0,
 
198
                                'vcs'      => $file_vcs[$_],
 
199
                        },
 
200
                );
 
201
 
 
202
                if ( $notebook->GetPageText($_) =~ /^\*/sxm ) {
 
203
                        TRACE("Found an unsaved file, will ignore: $notebook->GetPageText($_)") if DEBUG;
 
204
                        $self->{open_file_info}->{$_}->{'changed'} = 1;
 
205
                }
 
206
        }
 
207
 
 
208
        # nb enable Data::Printer above to use
 
209
        # p $self->{open_file_info};
 
210
 
 
211
        return;
 
212
}
 
213
 
 
214
#######
 
215
# Composed Method file2_list_type
 
216
#######
 
217
sub file2_list_type {
 
218
        my $self = shift;
 
219
 
 
220
        if ( $self->{action_request} eq 'Patch' ) {
 
221
 
 
222
                # update File-2 = *.patch
 
223
                $self->file2_list_patch();
 
224
        } else {
 
225
 
 
226
                # File-1 = File-2 = saved files
 
227
                $self->file_lists_saved();
 
228
        }
 
229
 
 
230
        return;
 
231
}
 
232
 
 
233
#######
 
234
# Composed Method file_lists_saved
 
235
#######
 
236
sub file_lists_saved {
 
237
        my $self = shift;
 
238
        my @file_lists_saved;
 
239
        for ( 0 .. $self->{tab_cardinality} ) {
 
240
                unless ( $self->{open_file_info}->{$_}->{'changed'}
 
241
                        || $self->{open_file_info}->{$_}->{'filename'} =~ /(patch|diff)$/sxm )
 
242
                {
 
243
                        push @file_lists_saved, $self->{open_file_info}->{$_}->{'filename'};
 
244
                }
 
245
        }
 
246
 
 
247
        TRACE("file_lists_saved: @file_lists_saved") if DEBUG;
 
248
 
 
249
        $self->file1->Clear;
 
250
        $self->file1->Append( \@file_lists_saved );
 
251
        $self->{file1_list_ref} = \@file_lists_saved;
 
252
        $self->set_selection_file1();
 
253
        $self->file1->SetSelection( $self->{selection} );
 
254
 
 
255
        $self->file2->Clear;
 
256
        $self->file2->Append( \@file_lists_saved );
 
257
        $self->{file2_list_ref} = \@file_lists_saved;
 
258
        $self->set_selection_file2();
 
259
        $self->file2->SetSelection( $self->{selection} );
 
260
 
 
261
        return;
 
262
}
 
263
 
 
264
#######
 
265
# Composed Method file2_list_patch
 
266
#######
 
267
sub file2_list_patch {
 
268
        my $self = shift;
 
269
 
 
270
        my @file2_list_patch;
 
271
        for ( 0 .. $self->{tab_cardinality} ) {
 
272
                if ( $self->{open_file_info}->{$_}->{'filename'} =~ /(patch|diff)$/sxm ) {
 
273
                        push @file2_list_patch, $self->{open_file_info}->{$_}->{'filename'};
 
274
                }
 
275
        }
 
276
 
 
277
        TRACE("file2_list_patch: @file2_list_patch") if DEBUG;
 
278
 
 
279
        $self->file2->Clear;
 
280
        $self->file2->Append( \@file2_list_patch );
 
281
        $self->{file2_list_ref} = \@file2_list_patch;
 
282
        $self->set_selection_file2();
 
283
        $self->file2->SetSelection( $self->{selection} );
 
284
 
 
285
        return;
 
286
}
 
287
 
 
288
#######
 
289
# Composed Method file1_list_svn
 
290
#######
 
291
sub file1_list_svn {
 
292
        my $self = shift;
 
293
 
 
294
        @{ $self->{file1_list_ref} } = ();
 
295
        for ( 0 .. $self->{tab_cardinality} ) {
 
296
                if (   ( $self->{open_file_info}->{$_}->{'vcs'} eq 'SVN' )
 
297
                        && !( $self->{open_file_info}->{$_}->{'changed'} )
 
298
                        && !( $self->{open_file_info}->{$_}->{'filename'} =~ /(patch|diff)$/sxm ) )
 
299
                {
 
300
                        push @{ $self->{file1_list_ref} }, $self->{open_file_info}->{$_}->{'filename'};
 
301
                }
 
302
        }
 
303
 
 
304
        TRACE("file1_list_svn: @{ $self->{file1_list_ref} }") if DEBUG;
 
305
 
 
306
        $self->file1->Clear;
 
307
        $self->file1->Append( $self->{file1_list_ref} );
 
308
        $self->set_selection_file1();
 
309
        $self->file1->SetSelection( $self->{selection} );
 
310
 
 
311
        return;
 
312
}
 
313
 
 
314
#######
 
315
# Composed Method set_selection_file1
 
316
#######
 
317
sub set_selection_file1 {
 
318
        my $self = shift;
 
319
        my $main = $self->main;
 
320
 
 
321
        $self->{selection} = 0;
 
322
        if ( $main->current->title =~ /(patch|diff)$/sxm ) {
 
323
 
 
324
                my @pathch_target = split( /\./, $main->current->title, 2 );
 
325
 
 
326
                # TODO this is a padre internal issue
 
327
                # remove obtuse leading space if exists
 
328
                $pathch_target[0] =~ s/^\p{Space}{1}//;
 
329
                TRACE("Looking for File-1 to apply a patch to: $pathch_target[0]") if DEBUG;
 
330
 
 
331
                # SetSelection should be Patch target file
 
332
                foreach ( 0 .. $#{ $self->{file1_list_ref} } ) {
 
333
 
 
334
                        # add optional leading space \p{Space}?
 
335
                        if ( @{ $self->{file1_list_ref} }[$_] =~ /^\p{Space}?$pathch_target[0]/ ) {
 
336
                                $self->{selection} = $_;
 
337
                                return;
 
338
                        }
 
339
                }
 
340
        } else {
 
341
 
 
342
                # SetSelection should be current file
 
343
                foreach ( 0 .. $#{ $self->{file1_list_ref} } ) {
 
344
 
 
345
                        if ( @{ $self->{file1_list_ref} }[$_] eq $main->current->title ) {
 
346
                                $self->{selection} = $_;
 
347
                                return;
 
348
                        }
 
349
                }
 
350
        }
 
351
 
 
352
        return;
 
353
}
 
354
 
 
355
#######
 
356
# Composed Method set_selection_file2
 
357
#######
 
358
sub set_selection_file2 {
 
359
        my $self = shift;
 
360
        my $main = $self->main;
 
361
 
 
362
        $self->{selection} = 0;
 
363
 
 
364
        # SetSelection should be current file
 
365
        foreach ( 0 .. $#{ $self->{file2_list_ref} } ) {
 
366
 
 
367
                if ( @{ $self->{file2_list_ref} }[$_] eq $main->current->title ) {
 
368
                        $self->{selection} = $_;
 
369
                        return;
 
370
                }
 
371
        }
 
372
 
 
373
        return;
 
374
}
 
375
 
 
376
#######
 
377
# Composed Method filename_url
 
378
#######
 
379
sub filename_url {
 
380
        my $self     = shift;
 
381
        my $filename = shift;
 
382
 
 
383
        # given tab name get url of file
 
384
        for ( 0 .. $self->{tab_cardinality} ) {
 
385
                if ( $self->{open_file_info}->{$_}->{'filename'} eq $filename ) {
 
386
                        return $self->{open_file_info}->{$_}->{'URL'};
 
387
                }
 
388
        }
 
389
        return;
 
390
}
 
391
 
 
392
########
 
393
# Method apply_patch
 
394
########
 
395
sub apply_patch {
 
396
        my $self       = shift;
 
397
        my $file1_name = shift;
 
398
        my $file2_name = shift;
 
399
        my $main       = $self->main;
 
400
 
 
401
        $main->show_output(1);
 
402
        my $output = $main->output;
 
403
        $output->clear;
 
404
 
 
405
        my ( $source, $diff );
 
406
 
 
407
        my $file1_url = $self->filename_url($file1_name);
 
408
        my $file2_url = $self->filename_url($file2_name);
 
409
 
 
410
        if ( -e $file1_url ) {
 
411
                TRACE("found file1 => $file1_name: $file1_url") if DEBUG;
 
412
                $source = File::Slurp::read_file($file1_url);
 
413
        }
 
414
 
 
415
        if ( -e $file2_url ) {
 
416
                TRACE("found file2 => $file2_name: $file2_url") if DEBUG;
 
417
                $diff = File::Slurp::read_file($file2_url);
 
418
                unless ( $file2_url =~ /(patch|diff)$/sxm ) {
 
419
                        $main->info( Wx::gettext('Patch file should end in .patch or .diff, you should reselect & try again') );
 
420
                        return;
 
421
                }
 
422
        }
 
423
 
 
424
        if ( -e $file1_url && -e $file2_url ) {
 
425
 
 
426
                require Text::Patch;
 
427
                my $our_patch;
 
428
                if ( eval { $our_patch = Text::Patch::patch( $source, $diff, { STYLE => 'Unified' } ) } ) {
 
429
 
 
430
                        TRACE($our_patch) if DEBUG;
 
431
 
 
432
                        # Open the patched file as a new file
 
433
                        $main->new_document_from_string( $our_patch => 'application/x-perl', );
 
434
                        $main->info( Wx::gettext('Patch successful, you should see a new tab in editor called Unsaved #') );
 
435
                } else {
 
436
                        TRACE("error trying to patch: $@") if DEBUG;
 
437
 
 
438
                        $output->AppendText("Patch Dialog failed to Complete.\n");
 
439
                        $output->AppendText("Your requested Action Patch, with following parameters.\n");
 
440
                        $output->AppendText("File-1: $file1_url \n");
 
441
                        $output->AppendText("File-2: $file2_url \n");
 
442
                        $output->AppendText("What follows is the error I received from Text::Patch::patch, if any: \n");
 
443
                        $output->AppendText($@);
 
444
 
 
445
                        $main->info(
 
446
                                Wx::gettext('Sorry, patch failed, are you sure your choice of files was correct for this action') );
 
447
                        return;
 
448
                }
 
449
        }
 
450
 
 
451
        return;
 
452
}
 
453
 
 
454
#######
 
455
# Method make_patch_diff
 
456
#######
 
457
sub make_patch_diff {
 
458
        my $self       = shift;
 
459
        my $file1_name = shift;
 
460
        my $file2_name = shift;
 
461
        my $main       = $self->main;
 
462
 
 
463
        $main->show_output(1);
 
464
        my $output = $main->output;
 
465
        $output->clear;
 
466
 
 
467
        my $file1_url = $self->filename_url($file1_name);
 
468
        my $file2_url = $self->filename_url($file2_name);
 
469
 
 
470
        if ( -e $file1_url ) {
 
471
                TRACE("found file1 => $file1_name: $file1_url") if DEBUG;
 
472
        }
 
473
 
 
474
        if ( -e $file2_url ) {
 
475
                TRACE("found file2 => $file2_name: $file2_url") if DEBUG;
 
476
        }
 
477
 
 
478
        if ( -e $file1_url && -e $file2_url ) {
 
479
                require Text::Diff;
 
480
                my $our_diff;
 
481
                if ( eval { $our_diff = Text::Diff::diff( $file1_url, $file2_url, { STYLE => 'Unified' } ) } ) {
 
482
                        TRACE($our_diff) if DEBUG;
 
483
 
 
484
                        my $patch_file = $file1_url . '.patch';
 
485
 
 
486
                        File::Slurp::write_file( $patch_file, $our_diff );
 
487
                        TRACE("writing file: $patch_file") if DEBUG;
 
488
 
 
489
                        $main->setup_editor($patch_file);
 
490
                        $main->info( sprintf(Wx::gettext('Diff successful, you should see a new tab in editor called %s'), $patch_file) );
 
491
                } else {
 
492
                        TRACE("error trying to patch: $@") if DEBUG;
 
493
 
 
494
                        $output->AppendText("Patch Dialog failed to Complete.\n");
 
495
                        $output->AppendText("Your requested Action Diff, with following parameters.\n");
 
496
                        $output->AppendText("File-1: $file1_url \n");
 
497
                        $output->AppendText("File-2: $file2_url \n");
 
498
                        $output->AppendText("What follows is the error I received from Text::Diff::diff, if any: \n");
 
499
                        $output->AppendText($@);
 
500
 
 
501
                        $main->info(
 
502
                                Wx::gettext('Sorry Diff Failed, are you sure your choice of files was correct for this action') );
 
503
                        return;
 
504
                }
 
505
        }
 
506
 
 
507
        return;
 
508
}
 
509
 
 
510
#######
 
511
# Composed Method test_svn
 
512
#######
 
513
sub test_svn {
 
514
        my $self = shift;
 
515
        my $main = $self->main;
 
516
 
 
517
        $self->{svn_local} = 0;
 
518
 
 
519
        my $svn_client_version   = 0;
 
520
        my $required_svn_version = '1.6.2';
 
521
 
 
522
        if ( File::Which::which('svn') ) {
 
523
 
 
524
                # test svn version
 
525
                if ( $svn_client_version = Padre::Util::run_in_directory_two('svn --version --quiet') ) {
 
526
                        chomp($svn_client_version);
 
527
 
 
528
                        require Sort::Versions;
 
529
 
 
530
                        # This is so much better, now we are testing for version as well
 
531
                        if ( Sort::Versions::versioncmp( $required_svn_version, $svn_client_version, ) == -1 ) {
 
532
                                TRACE("Found local SVN v$svn_client_version, good to go.") if DEBUG;
 
533
                                $self->{svn_local} = 1;
 
534
                                return;
 
535
                        } else {
 
536
                                TRACE("Found SVN v$svn_client_version but require v$required_svn_version") if DEBUG;
 
537
                                $main->info(
 
538
                                        sprintf(
 
539
                                                Wx::gettext('Warning: found SVN v%s but we require SVN v%s and it is now called "Apache Subversion"'),
 
540
                                                $svn_client_version,
 
541
                                                $required_svn_version
 
542
                                        )
 
543
                                );
 
544
                        }
 
545
                }
 
546
        }
 
547
        return;
 
548
}
 
549
 
 
550
#######
 
551
# Method make_patch_svn
 
552
# inspired by P-P-SVN
 
553
#######
 
554
sub make_patch_svn {
 
555
        my $self       = shift;
 
556
        my $file1_name = shift;
 
557
        my $main       = $self->main;
 
558
 
 
559
        $main->show_output(1);
 
560
        my $output = $main->output;
 
561
        $output->clear;
 
562
 
 
563
        my $file1_url = $self->filename_url($file1_name);
 
564
 
 
565
        TRACE("file1_url to svn: $file1_url") if DEBUG;
 
566
 
 
567
        # if (test_svn) {
 
568
        if ( $self->{svn_local} ) {
 
569
                TRACE('found local SVN, Good to go') if DEBUG;
 
570
                my $diff_str;
 
571
                if ( eval { $diff_str = qx{ svn diff $file1_url} } ) {
 
572
 
 
573
                        TRACE($diff_str) if DEBUG;
 
574
 
 
575
                        my $patch_file = $file1_url . '.patch';
 
576
 
 
577
                        File::Slurp::write_file( $patch_file, $diff_str );
 
578
                        TRACE("writing file: $patch_file") if DEBUG;
 
579
 
 
580
                        $main->setup_editor($patch_file);
 
581
                        $main->info( sprintf(Wx::gettext('SVN Diff successful. You should see a new tab in editor called %s.'), $patch_file) );
 
582
                } else {
 
583
                        TRACE("Error trying to get an SVN Diff: $@") if DEBUG;
 
584
 
 
585
                        $output->AppendText("Patch Dialog failed to Complete.\n");
 
586
                        $output->AppendText("Your requested Action Diff against SVN, with following parameters.\n");
 
587
                        $output->AppendText("File-1: $file1_url \n");
 
588
                        $output->AppendText("What follows is the error I received from SVN, if any: \n");
 
589
                        if ($@) {
 
590
                                $output->AppendText($@);
 
591
                        } else {
 
592
                                $output->AppendText(
 
593
                                        "Sorry, Diff to SVN failed. There are any diffrences in this file: $file1_name");
 
594
                        }
 
595
 
 
596
                        $main->info(
 
597
                                Wx::gettext('Sorry, Diff failed. Are you sure your have access to the repository for this action') );
 
598
                        return;
 
599
                }
 
600
        }
 
601
        return;
 
602
}
 
603
 
 
604
1;
 
605
 
 
606
__END__
 
607
 
 
608
=head1 NAME
 
609
 
 
610
Padre::Wx::Dialog::Patch - The Padre Patch dialog
 
611
 
 
612
=head1 DESCRIPTION
 
613
 
 
614
You will find more infomation in our L<wiki|http://padre.perlide.org/trac/wiki/Features/EditPatch/> pages.
 
615
 
 
616
A very simplistic tool, only works on open saved files, in the Padre editor.
 
617
 
 
618
Patch a single file, in the editor with a patch/diff file that is also open.
 
619
 
 
620
Diff between two open files, the resulting patch file will be in Unified form.
 
621
 
 
622
Diff a single file to svn, only display files that are part of an SVN already, the resulting patch file will be in Unified form.
 
623
 
 
624
All results will be a new Tab.
 
625
 
 
626
=head1 METHODS
 
627
 
 
628
=head2 new
 
629
 
 
630
Constructor. Should be called with C<$main> by C<Patch::load_dialog_main()>.
 
631
 
 
632
=head2 run
 
633
 
 
634
C<run> configures the dialogue for your environment
 
635
 
 
636
=head2 set_up
 
637
 
 
638
C<set_up> configures the dialogue for your environment
 
639
 
 
640
=head2 on_action
 
641
 
 
642
Event handler for action, adjust dialogue accordingly
 
643
 
 
644
=head2 on_against
 
645
 
 
646
Event handler for against, adjust dialogue accordingly
 
647
 
 
648
=head2 process_clicked
 
649
 
 
650
Event handler for process_clicked, perform your chosen action, all results go into a new tab in editor.
 
651
 
 
652
=head2 current_files
 
653
 
 
654
extracts file info from Padre about all open files in editor
 
655
 
 
656
=head2 apply_patch
 
657
 
 
658
A convenience method to apply patch to chosen file.
 
659
 
 
660
uses Text::Patch
 
661
 
 
662
=head2 make_patch_diff
 
663
 
 
664
A convenience method to generate a patch/diff file from two selected files.
 
665
 
 
666
uses Text::Diff
 
667
 
 
668
=head2 test_svn
 
669
 
 
670
test for a local copy of svn in Path and version greater than 1.6.2.
 
671
 
 
672
=head2 make_patch_svn
 
673
 
 
674
A convenience method to generate a patch/diff file from a selected file and svn if applicable,
 
675
ie file has been checked out.
 
676
 
 
677
=head2 file2_list_type
 
678
 
 
679
composed method
 
680
 
 
681
=head2 filename_url
 
682
 
 
683
composed method
 
684
 
 
685
=head2 set_selection_file1
 
686
 
 
687
composed method
 
688
 
 
689
=head2 set_selection_file2
 
690
 
 
691
composed method
 
692
 
 
693
=head2 file1_list_svn
 
694
 
 
695
composed method
 
696
 
 
697
=head2 file2_list_patch
 
698
 
 
699
composed method
 
700
 
 
701
=head2 file_lists_saved
 
702
 
 
703
composed method
 
704
 
 
705
=head1 BUGS AND LIMITATIONS
 
706
 
 
707
List Order is that of load order, if you move your Tabs the List Order will not follow suite.
 
708
 
 
709
If you have multiple files open with same name but with different paths only the first will get matched.
 
710
 
 
711
=head1 AUTHORS
 
712
 
 
713
BOWTIE E<lt>kevin.dawson@btclick.comE<gt>
 
714
 
 
715
Adam Kennedy E<lt>adamk@cpan.orgE<gt>
 
716
 
 
717
=head1 LICENSE AND COPYRIGHT
 
718
 
 
719
Copyright 2008-2011 The Padre development team as listed in Padre.pm.
 
720
 
 
721
This program is free software; you can redistribute
 
722
it and/or modify it under the same terms as Perl 5 itself.
 
723
 
 
724
The full text of the license can be found in the
 
725
LICENSE file included with this module.
 
726
 
 
727
=cut
 
728
 
 
729
# Copyright 2008-2011 The Padre development team as listed in Padre.pm.
 
730
# LICENSE
 
731
# This program is free software; you can redistribute it and/or
 
732
# modify it under the same terms as Perl 5 itself.