Eskil

Check-in [f73bd4abeb]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added changeset tool to fourway
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f73bd4abeba3c9951e66a5b091c57c3fd2ca37e3d579ff3f56aac94e9e4f0902
User & Date: peter 2018-05-14 22:41:10.272
Context
2018-05-21
15:45
Handle balloon over labelframe check-in: 2970b5118f user: peter tags: trunk
2018-05-14
22:41
Added changeset tool to fourway check-in: f73bd4abeb user: peter tags: trunk
21:12
Make sure tmp files are deleted. check-in: 3e288e8b7d user: peter tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to Changes.



1
2
3
4
5
6
7



2018-05-13
 Adjustments to fourway UI.

Released 2.8.2

2018-05-13
 Bumped revision to 2.8.2
>
>
>







1
2
3
4
5
6
7
8
9
10
2018-05-14
 Added changeset tool to fourway,

2018-05-13
 Adjustments to fourway UI.

Released 2.8.2

2018-05-13
 Bumped revision to 2.8.2
Changes to htdocs/changes.wiki.
1
2
3
4

5
6
7
8
9
10
11
<title>Changes</title>

Upcoming changes (not yet released):



Changes in v2.8.2 (2018-05-13):

  *  Added Fourway diff, for comparing changes.
  *  Bugfix in revision handling for Fossil.

Changes in v2.8.1 (2018-01-14):




>







1
2
3
4
5
6
7
8
9
10
11
12
<title>Changes</title>

Upcoming changes (not yet released):

  *  More features in Fourway diff.

Changes in v2.8.2 (2018-05-13):

  *  Added Fourway diff, for comparing changes.
  *  Bugfix in revision handling for Fossil.

Changes in v2.8.1 (2018-01-14):
Changes to src/fourway.tcl.
54
55
56
57
58
59
60





61
62
63
64
65
66
67
        menu $win.m.mf
        $win.m.mf add command -label "Close" -underline 0 \
                -command [list cleanupAndExit $win]
        $win.m.mf add separator
        $win.m.mf add command -label "Quit" -underline 0 \
                -command [list cleanupAndExit all]






        if {$::eskil(debug) == 1} {
            AddDebugMenu $win
        }
 
        # Four files, with optional revision
        set fields {base1 change1 base2 change2}
    







>
>
>
>
>







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
        menu $win.m.mf
        $win.m.mf add command -label "Close" -underline 0 \
                -command [list cleanupAndExit $win]
        $win.m.mf add separator
        $win.m.mf add command -label "Quit" -underline 0 \
                -command [list cleanupAndExit all]

        $win.m add cascade -menu $win.m.mt -label "Tools" -underline 0
        menu $win.m.mt
        $win.m.mt add command -label "Changeset" -underline 0 \
                -command [mymethod changeset]

        if {$::eskil(debug) == 1} {
            AddDebugMenu $win
        }
 
        # Four files, with optional revision
        set fields {base1 change1 base2 change2}
    
171
172
173
174
175
176
177




178
179
180
181
182
183
184
185
186
187
188
189
190
191


192
193
194
195
196
197
198
        if {$apa != ""} {
            set filesGui($field) $apa
        }
    }

    # Fill in working copies of variables
    method PrepareFw {} {




        # Copy to work vars to be able to replace with defaults and parsed
        foreach field $fields {
            set files($field) $filesGui($field)
            set revs($field) [string trim $revsGui($field)]
        }
        # Fill in defaults, if only one file is given
        foreach {from to} $fields {
            if {$files($to) eq ""} {
                set files($to) $filesGui($from)
            }
            if {$files($from) eq ""} {
                set files($from) $filesGui($to)
            }
        }


        # Remember originals for display, they might be replaced below
        foreach field $fields {
            set origfiles($field) $files($field)
            set origrevs($field)  $revs($field)
        }
        # Figure out any revisions
        foreach field $fields {







>
>
>
>














>
>







176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
        if {$apa != ""} {
            set filesGui($field) $apa
        }
    }

    # Fill in working copies of variables
    method PrepareFw {} {
        $self PrepareFw1
        $self PrepareFw2
    }
    method PrepareFw1 {} {
        # Copy to work vars to be able to replace with defaults and parsed
        foreach field $fields {
            set files($field) $filesGui($field)
            set revs($field) [string trim $revsGui($field)]
        }
        # Fill in defaults, if only one file is given
        foreach {from to} $fields {
            if {$files($to) eq ""} {
                set files($to) $filesGui($from)
            }
            if {$files($from) eq ""} {
                set files($from) $filesGui($to)
            }
        }
    }
    method PrepareFw2 {} {
        # Remember originals for display, they might be replaced below
        foreach field $fields {
            set origfiles($field) $files($field)
            set origrevs($field)  $revs($field)
        }
        # Figure out any revisions
        foreach field $fields {
222
223
224
225
226
227
228
229

230

231
232
233
234
235
236
237
                } else {
                    set revs($field) [lindex $revList 0]
                }
            }
        }
    }

    method doFourWayDiff {} {

        $self PrepareFw

        # Extract revisions
        foreach field $fields {
            if {$revs($field) ne ""} {
                # Replace with checkout copy
                set files($field) [tmpFile]
                eskil::rev::$revtype($field)::get $origfiles($field) \
                        $files($field) $revs($field)







|
>
|
>







233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
                } else {
                    set revs($field) [lindex $revList 0]
                }
            }
        }
    }

    method doFourWayDiff {{skipPrepare 0}} {
        if {!$skipPrepare} {
            $self PrepareFw
        }
        # Extract revisions
        foreach field $fields {
            if {$revs($field) ne ""} {
                # Replace with checkout copy
                set files($field) [tmpFile]
                eskil::rev::$revtype($field)::get $origfiles($field) \
                        $files($field) $revs($field)
256
257
258
259
260
261
262


































































































































263
264
265
266
267
268
269
            $self GenPatch $header $files(base$side) $files(change$side) \
                    $outfile($side)
        }

        # Now run a diff window with the patch files
        set top [newDiff $outfile(1) $outfile(2)]
    }



































































































































    method GenPatch {header file1 file2 outfile} {
        # Handle at least base options
        set opts $::Pref(ignore)
        if {$::Pref(nocase)} {lappend opts -nocase}
        if {$::Pref(noempty)} {lappend opts -noempty}
        if {$::Pref(pivot) > 0} {lappend opts -pivot $::Pref(pivot)}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
            $self GenPatch $header $files(base$side) $files(change$side) \
                    $outfile($side)
        }

        # Now run a diff window with the patch files
        set top [newDiff $outfile(1) $outfile(2)]
    }

    # Get the full change in other files corresponding to the ones listed
    method changeset {} {
        $self PrepareFw
        #catch {console show}
        foreach side {1 2} {
            set dir [file dirname $origfiles(base$side)]
            set revL {}
            set type  ""
            if {$revs(base$side) ne ""} {
                lappend revL $revs(base$side)
                set type $revtype(base$side)
            }
            if {$revs(change$side) ne ""} {
                lappend revL $revs(change$side)
                set type $revtype(change$side)
            }
            if {$type eq ""} {
                # TBD error?
                set changes($side) {}
            } else {
                #puts "Getting change list in $dir for $revL"
                set changes($side) [eskil::rev::${type}::getChangedFiles \
                                            $dir $revL]
                set changes($side) [lsort -dictionary $changes($side)]
                #puts [join $changes($side) \n]
            }
        }
        # Look for matching files in the two sets.
        set matching(1) {}
        set matching(2) {}
        # Gather tail data
        foreach side {1 2} {
            foreach f $changes($side) {
                set tail [file tail $f]
                lappend file($side,$tail) $f
                lappend file($side,nc,[string tolower $tail]) $f
            }
        }
        # 1. Unique case-insensitive match in tails
        foreach f1 $changes(1) {
            set tail [string tolower [file tail $f1]]
            if {[llength $file(1,nc,$tail)] == 1} {
                if {[info exists file(2,nc,$tail)]} {
                    if {[llength $file(2,nc,$tail)] == 1} {
                        set f2 [lindex $file(2,nc,$tail) 0]
                        lappend matching(1) $f1
                        lappend matching(2) $f2
                        set done($f1) 1
                        set done($f2) 1
                    }
                }
            }
        }
        # 2. Unique case-sensitive match in tails
        foreach f1 $changes(1) {
            if {[info exists done($f1)]} continue
            set tail [file tail $f1]
            if {[llength $file(1,$tail)] == 1} {
                if {[info exists file(2,$tail)]} {
                    if {[llength $file(2,$tail)] == 1} {
                        set f2 [lindex $file(2,$tail) 0]
                        if {[info exists done($f2)]} continue
                        lappend matching(1) $f1
                        lappend matching(2) $f2
                        set done($f1) 1
                        set done($f2) 1
                    }
                }
            }
        }
        # Rest in order
        foreach side {1 2} {
            set rest($side) {}
            foreach f $changes($side) {
                if {[info exists done($f)]} continue
                lappend rest($side) $f
            }
            lappend matching($side) {*}$rest($side)
        }

        set [myvar csList1] $matching(1)
        set [myvar csList2] $matching(2)

        #destroy $win.csf
        if {![winfo exists $win.csf]} {
            ttk::labelframe $win.csf -text "Change Set" -padding 3
            grid $win.csf -columnspan 4 -sticky news -padx 3 -pady 3
            grid rowconfigure $win $win.csf -weight 1

            listbox $win.csf.lb1 -height 20 -listvariable [myvar csList1] \
                    -exportselection 0
            bind $win.csf.lb1 <<ListboxSelect>> [mymethod csNewSelect]
            listbox $win.csf.lb2 -height 20 -listvariable [myvar csList2] \
                    -exportselection 0
            ttk::button $win.csf.bd -text "Diff" -width 8 \
                    -command [mymethod doChangesetDiff]
            grid $win.csf.lb1 $win.csf.lb2 -sticky news -padx 3 -pady 3
            grid $win.csf.bd  -            -padx 3 -pady 3
            grid rowconfigure $win.csf 0 -weight 1
            grid columnconfigure $win.csf all -weight 1 -uniform a
        }
    }
    method csNewSelect {} {
        set s1 [$win.csf.lb1 curselection]
        if {[llength $s1] != 1} return
        $win.csf.lb2 selection clear 0 end
        $win.csf.lb2 selection set $s1

    }

    method doChangesetDiff {} {
        variable csList1
        variable csList2
        set s1 [$win.csf.lb1 curselection]
        set s2 [$win.csf.lb2 curselection]
        if {[llength $s1] != 1} return
        if {[llength $s2] != 1} return
        set f(1) [lindex $csList1 $s1]
        set f(2) [lindex $csList2 $s2]
        puts "$f(1) vs $f(2)"
        
        $self PrepareFw1
        foreach side {1 2} {
            set files(base$side) $f($side)
            set files(change$side) $f($side)
        }
        $self PrepareFw2
        $self doFourWayDiff 1
    }

    method GenPatch {header file1 file2 outfile} {
        # Handle at least base options
        set opts $::Pref(ignore)
        if {$::Pref(nocase)} {lappend opts -nocase}
        if {$::Pref(noempty)} {lappend opts -noempty}
        if {$::Pref(pivot) > 0} {lappend opts -pivot $::Pref(pivot)}