Eskil

Check-in [97e70bc905]
Login

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

Overview
Comment:Refactor fourway code
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 97e70bc90561c9e150d871cbeaa9669945f6b6d80b40a31e9b8a0f95bcfa096c
User & Date: peter 2018-05-13 08:02:18
Context
2018-05-14
21:11
Added getChangedFiles APi to rev. Cleanup and testing of rev stuff. check-in: aef7106e32 user: peter tags: trunk
2018-05-13
08:02
Refactor fourway code check-in: 97e70bc905 user: peter tags: trunk
07:48
Refactor fourway code check-in: 2f4c54f97a user: peter tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/fourway.tcl.

234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256

257
258
259
260
261
262
263
264
























265


266

267
268
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
                # Replace with checkout copy
                set files($field) [tmpFile]
                eskil::rev::$revtype($field)::get $origfiles($field) \
                        $files($field) $revs($field)
            }
        }

        # 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)}

        # Do compare of files, to generate patches
        foreach side {1 2} {
            set differr [catch {DiffUtil::diffFiles {*}$opts \
                    $files(base$side) $files(change$side)} diffres]
            if {$differr != 0} {
                # TODO error
                return
            }
            set outfile($side) [tmpFile]
            set ch [open $outfile($side) w]

            foreach str {From To} field "base$side change$side" {
                set line "$str $origfiles($field)"
                if {$revs($field) ne ""} {
                    append line "  Revision $revs($field)"
                    if {$origrevs($field) ne $revs($field)} {
                        append line " ($origrevs($field))"
                    }
                }
























                puts $ch $line


            }

            puts $ch [string repeat "-" 78]
            if {[llength $diffres] == 0} {
            }
            set doingLine1 1
            set doingLine2 1
            set ch1 [open $files(base$side)]
            set ch2 [open $files(change$side)]
            set t 0
            foreach i $diffres {
                lassign $i line1 n1 line2 n2
                $self doText $ch $ch1 $ch2 $n1 $n2 $line1 $line2
            }
            $self doText $ch $ch1 $ch2 0 0 0 0
            close $ch1
            close $ch2
            close $ch
        }

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

    }

    # See dotext in eskil.tcl for more info since this is similar
    method doText {ch ch1 ch2 n1 n2 line1 line2} {
        if {$n1 == 0 && $n2 == 0} {
            # All blocks have been processed. Continue until end of file.
            # TBD context
            return
        }
        set limit 3
        if {($line1 - $doingLine1 < (2 * $limit + 2))} {







<
<
<
<
<
<


<
<
<
<
<
<
<
<
>








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
|
>
|
<
|
|
|
|
|
<
|
|
|
|
|
|
|
|
<
<
<
<
<



|







234
235
236
237
238
239
240






241
242








243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
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
                # Replace with checkout copy
                set files($field) [tmpFile]
                eskil::rev::$revtype($field)::get $origfiles($field) \
                        $files($field) $revs($field)
            }
        }







        # Do compare of files, to generate patches
        foreach side {1 2} {








            set header ""
            foreach str {From To} field "base$side change$side" {
                set line "$str $origfiles($field)"
                if {$revs($field) ne ""} {
                    append line "  Revision $revs($field)"
                    if {$origrevs($field) ne $revs($field)} {
                        append line " ($origrevs($field))"
                    }
                }
                append header $line\n
            }

            set outfile($side) [tmpFile]
            $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)}

        set differr [catch {DiffUtil::diffFiles {*}$opts \
                    $file1 $file2} diffres]
        set ch [open $outfile w]
        if {$differr != 0} {
            # TODO error
            puts $ch $diffres
            close $ch
            return
        }
        puts $ch [string trim $header]
        puts $ch [string repeat "-" 78]


        set doingLine1 1
        set doingLine2 1
        set ch1 [open $file1]
        set ch2 [open $file2]

        foreach i $diffres {
            lassign $i line1 n1 line2 n2
            $self DoText $ch $ch1 $ch2 $n1 $n2 $line1 $line2
        }
        $self DoText $ch $ch1 $ch2 0 0 0 0
        close $ch1
        close $ch2
        close $ch





    }

    # See dotext in eskil.tcl for more info since this is similar
    method DoText {ch ch1 ch2 n1 n2 line1 line2} {
        if {$n1 == 0 && $n2 == 0} {
            # All blocks have been processed. Continue until end of file.
            # TBD context
            return
        }
        set limit 3
        if {($line1 - $doingLine1 < (2 * $limit + 2))} {