Eskil

Check-in [c6bb079eec]
Login

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

Overview
Comment:Handle NodeStatus in a variable, for speed.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c6bb079eec016156b97759442a415a7c7c524b5c911ed550bbada9575560ef4c
User & Date: peter 2018-10-20 20:29:08
Context
2019-02-04
15:52
Handle a dir name with -review. check-in: 8ecbca03a0 user: peter tags: trunk
2018-10-20
20:29
Handle NodeStatus in a variable, for speed. check-in: c6bb079eec user: peter tags: trunk
20:28
Handle different user name. check-in: bc38ecca6e user: peter tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/dirdiff.tcl.

307
308
309
310
311
312
313

314
315

316
317
318
319
320
321
322
...
462
463
464
465
466
467
468

469
470
471
472
473
474
475
...
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
...
858
859
860
861
862
863
864

865
866
867
868
869
870
871
872
...
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
...
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
...
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
....
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
....
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074

    variable AfterId ""
    variable DebugCh ""
    variable DebugTime {}
    variable PauseBgProcessing 0
    variable ScheduledRestart 0
    variable AfterTime 1

    variable IdleQueue {}
    variable IdleQueueArr

    variable leftMark ""
    variable rightMark ""
    variable leftDir ""
    variable rightDir ""
    variable protect {left 0 right 0}

    constructor {args} {
................................................................................
        if {$d1 eq $d2} {
            $tree cellconfigure $topIndex,structure -text $d1
        } else {
            $tree cellconfigure $topIndex,structure -text "$d1 vs $d2"
        }
        $tree cellconfigure $topIndex,structure -image $::img(open)
        $tree rowattrib $topIndex type directory

        $self SetNodeStatus $topIndex empty
        $tree rowattrib $topIndex leftfull $leftDir
        $tree rowattrib $topIndex rightfull $rightDir

        $self UpdateDirNode $topIndex
    }

................................................................................
    method PruneEqual {} {
        $self busyCursor
        set todo [$tree childkeys root]
        while {[llength $todo] > 0} {
            set todoNow $todo
            set todo {}
            foreach node $todoNow {
                set status [$tree rowattrib $node status]
                if {$status eq "equal"} {
                    $tree delete $node
                } else {
                    lappend todo {*}[$tree childkeys $node]
                }
            }
        }
................................................................................
            }
            if {$sts} {
                lappend errors $node $err
                break
            }
            # Work for at least 200 ms to keep things efficient
            set post [clock clicks -milliseconds]

            if {($post - $pre) > 200} break
        }
        #if {($post - $pre) > 1000} {
            #puts "[expr $post - $pre] ms for [$tree set $node leftfull]"
        #}

        # Update the status variable to track progress
        if {$options(-statusvar) ne ""} {
................................................................................
            set statusvar ""
            set AfterId ""
        }
    }

    method SetNodeStatus {node status} {
        variable color
        set old [$tree rowattrib $node status]
        if {$old eq $status} return
        $tree rowattrib $node status $status
        $tree rowconfigure $node -foreground $color($status) \
                -selectforeground $color($status)
        #puts "Set [$tree item $node -text] to $status"

        # Loop through children to update parent
        set parent [$tree parentkey $node]
        if {$parent eq "" || $parent eq "root"} { return }
................................................................................

        # If this is only present on one side, there is no need to update
        set lf [$tree rowattrib $parent leftfull]
        set rf [$tree rowattrib $parent rightfull]
        if {$lf eq "" || $rf eq ""} { return }

        # If parent is being filled, do not update yet
        if {[$tree rowattrib $parent status] eq "unknown2"} {
            return
        }
        set pstatus equal
        foreach child [$tree childkeys $parent] {
            set status [$tree rowattrib $child status]
            switch $status {
                unknown - unknown2 {
                    set pstatus unknown
                }
                new - old - change {
                    set pstatus change
                    break
................................................................................
        $self SetNodeStatus $parent $pstatus
    }

    method UpdateDirNode {node} {
        if {[$tree rowattrib $node type] ne "directory"} {
            return
        }
        if {[$tree rowattrib $node status] ne "empty"} {
            #puts "Dir [$tree set $node leftfull] already done"
            return
        }
        $tree delete [$tree childkeys $node]

        set leftfull [$tree rowattrib $node leftfull]
        set rightfull [$tree rowattrib $node rightfull]
................................................................................
            # TODO: Configurable large file value?
            if {$size1 > 1000000 && $size2 > 1000000} {
                set largeFile 1
            }
        }
        set id [$tree insertchild $node end $values]
        $tree rowattrib $id type $type
        $tree rowattrib $id status unknown
        $tree rowattrib $id leftfull $df1
        $tree rowattrib $id rightfull $df2
        $tree rowattrib $id largefile $largeFile
        if {$type ne "directory"} {
            if {$type eq "link"} {
                $tree cellconfigure $id,structure -image $::img(link)
            } else {
................................................................................
            $self SetNodeStatus $id new
        } elseif {$size2 == ""} {
            $self SetNodeStatus $id old
        } else {
            $self SetNodeStatus $id unknown
            $self AddNodeToIdle $id
        }
        return [$tree rowattrib $id status]
    }

    method addCmdCol {tbl row col w} {
        variable widgets
        set key [$tree getfullkeys $row]
        set status [$tree rowattrib $row status]
        set type   [$tree rowattrib $row type]
        set lf [$tree rowattrib $row leftfull]
        set rf [$tree rowattrib $row rightfull]
        set bg [$tbl cget -background]
        ttk::style configure Apa.TFrame -background $bg
        ttk::style configure Apa.My.Toolbutton -background $bg
        ttk::frame $w -style Apa.TFrame







>


>







 







>







 







|







 







>
|







 







|

|







 







|




|







 







|







 







|







 







|





|







307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
...
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
...
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
...
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
...
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
...
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
...
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
....
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
....
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078

    variable AfterId ""
    variable DebugCh ""
    variable DebugTime {}
    variable PauseBgProcessing 0
    variable ScheduledRestart 0
    variable AfterTime 1
    variable WorkTime 200
    variable IdleQueue {}
    variable IdleQueueArr
    variable NodeStatus
    variable leftMark ""
    variable rightMark ""
    variable leftDir ""
    variable rightDir ""
    variable protect {left 0 right 0}

    constructor {args} {
................................................................................
        if {$d1 eq $d2} {
            $tree cellconfigure $topIndex,structure -text $d1
        } else {
            $tree cellconfigure $topIndex,structure -text "$d1 vs $d2"
        }
        $tree cellconfigure $topIndex,structure -image $::img(open)
        $tree rowattrib $topIndex type directory
        set NodeStatus($topIndex) ""
        $self SetNodeStatus $topIndex empty
        $tree rowattrib $topIndex leftfull $leftDir
        $tree rowattrib $topIndex rightfull $rightDir

        $self UpdateDirNode $topIndex
    }

................................................................................
    method PruneEqual {} {
        $self busyCursor
        set todo [$tree childkeys root]
        while {[llength $todo] > 0} {
            set todoNow $todo
            set todo {}
            foreach node $todoNow {
                set status $NodeStatus($node)
                if {$status eq "equal"} {
                    $tree delete $node
                } else {
                    lappend todo {*}[$tree childkeys $node]
                }
            }
        }
................................................................................
            }
            if {$sts} {
                lappend errors $node $err
                break
            }
            # Work for at least 200 ms to keep things efficient
            set post [clock clicks -milliseconds]
            #puts "$pre $post [expr {$post - $pre}]"
            if {($post - $pre) > $WorkTime} break
        }
        #if {($post - $pre) > 1000} {
            #puts "[expr $post - $pre] ms for [$tree set $node leftfull]"
        #}

        # Update the status variable to track progress
        if {$options(-statusvar) ne ""} {
................................................................................
            set statusvar ""
            set AfterId ""
        }
    }

    method SetNodeStatus {node status} {
        variable color
        set old $NodeStatus($node)
        if {$old eq $status} return
        set NodeStatus($node) $status
        $tree rowconfigure $node -foreground $color($status) \
                -selectforeground $color($status)
        #puts "Set [$tree item $node -text] to $status"

        # Loop through children to update parent
        set parent [$tree parentkey $node]
        if {$parent eq "" || $parent eq "root"} { return }
................................................................................

        # If this is only present on one side, there is no need to update
        set lf [$tree rowattrib $parent leftfull]
        set rf [$tree rowattrib $parent rightfull]
        if {$lf eq "" || $rf eq ""} { return }

        # If parent is being filled, do not update yet
        if {$NodeStatus($parent) eq "unknown2"} {
            return
        }
        set pstatus equal
        foreach child [$tree childkeys $parent] {
            set status $NodeStatus($child)
            switch $status {
                unknown - unknown2 {
                    set pstatus unknown
                }
                new - old - change {
                    set pstatus change
                    break
................................................................................
        $self SetNodeStatus $parent $pstatus
    }

    method UpdateDirNode {node} {
        if {[$tree rowattrib $node type] ne "directory"} {
            return
        }
        if {$NodeStatus($node) ne "empty"} {
            #puts "Dir [$tree set $node leftfull] already done"
            return
        }
        $tree delete [$tree childkeys $node]

        set leftfull [$tree rowattrib $node leftfull]
        set rightfull [$tree rowattrib $node rightfull]
................................................................................
            # TODO: Configurable large file value?
            if {$size1 > 1000000 && $size2 > 1000000} {
                set largeFile 1
            }
        }
        set id [$tree insertchild $node end $values]
        $tree rowattrib $id type $type
        set NodeStatus($id) unknown
        $tree rowattrib $id leftfull $df1
        $tree rowattrib $id rightfull $df2
        $tree rowattrib $id largefile $largeFile
        if {$type ne "directory"} {
            if {$type eq "link"} {
                $tree cellconfigure $id,structure -image $::img(link)
            } else {
................................................................................
            $self SetNodeStatus $id new
        } elseif {$size2 == ""} {
            $self SetNodeStatus $id old
        } else {
            $self SetNodeStatus $id unknown
            $self AddNodeToIdle $id
        }
        return $NodeStatus($id)
    }

    method addCmdCol {tbl row col w} {
        variable widgets
        set key [$tree getfullkeys $row]
        set status $NodeStatus($key)
        set type   [$tree rowattrib $row type]
        set lf [$tree rowattrib $row leftfull]
        set rf [$tree rowattrib $row rightfull]
        set bg [$tbl cget -background]
        ttk::style configure Apa.TFrame -background $bg
        ttk::style configure Apa.My.Toolbutton -background $bg
        ttk::frame $w -style Apa.TFrame

Changes to src/eskil.syntax.

103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# This is the annotation needed for this object definition

##nagelfar syntax DirCompareTree dc=_obj,DirCompareTree p*
##nagelfar option DirCompareTree -leftdirvariable -rightdirvariable -statusvar
##nagelfar return DirCompareTree _obj,DirCompareTree
##nagelfar subcmd+ _obj,DirCompareTree text newLine

##nagelfar implicitvarns snit::widget::DirCompareTree self\ _obj,DirCompareTree hull win self tree hsb vsb options AfterId PauseBgProcessing IdleQueue IdleQueueArr leftMark rightMark leftDir rightDir protect ScheduledRestart img AfterTime DebugCh DebugTime

##########################################################
# This is the annotation needed for this object definition

##nagelfar syntax ttk::entryX dc=_obj,entryX p*
##nagelfar option ttk::entryX -width -textvariable -style
##nagelfar option ttk::entryX\ -textvariable n







|







103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# This is the annotation needed for this object definition

##nagelfar syntax DirCompareTree dc=_obj,DirCompareTree p*
##nagelfar option DirCompareTree -leftdirvariable -rightdirvariable -statusvar
##nagelfar return DirCompareTree _obj,DirCompareTree
##nagelfar subcmd+ _obj,DirCompareTree text newLine

##nagelfar implicitvarns snit::widget::DirCompareTree self\ _obj,DirCompareTree hull win self tree hsb vsb options AfterId PauseBgProcessing IdleQueue IdleQueueArr leftMark rightMark leftDir rightDir protect ScheduledRestart img AfterTime DebugCh DebugTime NodeStatus WorkTime

##########################################################
# This is the annotation needed for this object definition

##nagelfar syntax ttk::entryX dc=_obj,entryX p*
##nagelfar option ttk::entryX -width -textvariable -style
##nagelfar option ttk::entryX\ -textvariable n