Eskil

Check-in [d0b5e344e7]
Login

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

Overview
Comment:Fourway work.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d0b5e344e71f0774a52752bc6f4240862dfef878f4d42df88ab7aacd4d8ce58c
User & Date: peter 2018-05-12 23:28:05.385
Context
2018-05-12
23:30
Bumped revision to 2.8.2 check-in: 97def5b85e user: peter tags: trunk
23:28
Fourway work. check-in: d0b5e344e7 user: peter tags: trunk
22:46
Working on fourway check-in: a608e48144 user: peter tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/eskil.syntax.
75
76
77
78
79
80
81

82
83
84
85
86
87
88
89
90

91
92
93
94
95
96
97
98
99

100
101
102
103
104
105
106
107
108

109
110
111
112
113
114
115
116
117
118

119
120
121
122
123
124
125
126
127

# Operators
##nagelfar syntax + x*
##nagelfar syntax - x x*
##nagelfar syntax * x*
##nagelfar syntax / x x*


# This is the annotation needed for this object definition

##nagelfar syntax eskilprint dc=_obj,eskilprint p*
##nagelfar option eskilprint -file -cpl -cpln -headsize -headleft -headright -headnpages -margin -paper
##nagelfar return eskilprint _obj,eskilprint
##nagelfar subcmd+ _obj,eskilprint text newLine

##nagelfar implicitvarns snit::type::eskilprint self\ _obj,eskilprint width height pdf hoy fontsize linesize nlines ox1 ox2 oy page options


# This is the annotation needed for this object definition

##nagelfar syntax DirDiff dc=_obj,DirDiff p*
###nagelfar option DirDiff
##nagelfar return DirDiff _obj,DirDiff
##nagelfar subcmd+ _obj,DirDiff text newLine

##nagelfar implicitvarns snit::widget::DirDiff self\ _obj,DirDiff statusVar hull win self tree nice


# 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
##nagelfar return ttk::entryX _obj,entryX
##nagelfar subcmd+ _obj,entryX text newLine

##nagelfar implicitvarns snit::widgetadaptor::ttk::entryX self\ _obj,entryX hull win self  options


# This is the annotation needed for this object definition

##nagelfar syntax FourWay dc=_obj,FourWay p*
###nagelfar option FourWay
##nagelfar return FourWay _obj,FourWay
###nagelfar subcmd+ _obj,FourWay text newLine

##nagelfar implicitvarns snit::widget::FourWay self\ _obj,FourWay fields files revs win hull








>









>









>









>










>







|

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132

# Operators
##nagelfar syntax + x*
##nagelfar syntax - x x*
##nagelfar syntax * x*
##nagelfar syntax / x x*

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

##nagelfar syntax eskilprint dc=_obj,eskilprint p*
##nagelfar option eskilprint -file -cpl -cpln -headsize -headleft -headright -headnpages -margin -paper
##nagelfar return eskilprint _obj,eskilprint
##nagelfar subcmd+ _obj,eskilprint text newLine

##nagelfar implicitvarns snit::type::eskilprint self\ _obj,eskilprint width height pdf hoy fontsize linesize nlines ox1 ox2 oy page options

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

##nagelfar syntax DirDiff dc=_obj,DirDiff p*
###nagelfar option DirDiff
##nagelfar return DirDiff _obj,DirDiff
##nagelfar subcmd+ _obj,DirDiff text newLine

##nagelfar implicitvarns snit::widget::DirDiff self\ _obj,DirDiff statusVar hull win self tree nice

##########################################################
# 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
##nagelfar return ttk::entryX _obj,entryX
##nagelfar subcmd+ _obj,entryX text newLine

##nagelfar implicitvarns snit::widgetadaptor::ttk::entryX self\ _obj,entryX hull win self  options

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

##nagelfar syntax FourWay dc=_obj,FourWay p*
###nagelfar option FourWay
##nagelfar return FourWay _obj,FourWay
###nagelfar subcmd+ _obj,FourWay text newLine

##nagelfar implicitvarns snit::widget::FourWay self\ _obj,FourWay fields files revs doingLine1 doingLine2 win hull

Changes to src/fourway.tcl.
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

82
83
84
85
86
87
88
89
90
91
92
93
        # Four files, with optional revision
        set fields {base1 change1 base2 change2}
    
        ttk::label $win.l1 -text "Base 1"
        ttk::label $win.l2 -text "Changed 1"
        ttk::label $win.l3 -text "Base 2"
        ttk::label $win.l4 -text "Changed 2"
        set txt1 "First diff is made from Base 1 to Changed 1.\n If a file is empty\
                  and have a revision, the other file name is used."
        addBalloon $win.l1 $txt1
        addBalloon $win.l2 $txt1
        set txt2 [string map {1 2 First Second} $txt1]
        addBalloon $win.l3 $txt2
        addBalloon $win.l4 $txt2

        ttk::label $win.el -text "File path"
        ttk::label $win.rl -text "Rev"
        addBalloon $win.rl "If you want to use a revisioned controlled file instead\n of\
                            the one on disk, add a revision here. E.g. 0 can be used\n for\
                            latest commited revision."

        set n 0
        foreach field $fields {
            incr n
            ttk::entryX $win.e$n -width 60 -textvariable [myvar files($field)]
            ttk::button $win.b$n -text "Browse" -command [mymethod browseFile $field]

            ttk::entryX $win.r$n -width 6 -textvariable  [myvar revs($field)]
        }

        ttk::button $win.bd -text "Diff" -command [mymethod doFourWayDiff] -underline 0 \
                -width 8
        bind $win <Alt-d> [list $win.bd invoke]

        grid x       $win.el x       $win.rl -sticky w  -padx 3 -pady 3
        grid $win.l1 $win.e1 $win.b1 $win.r1 -sticky we -padx 3 -pady 3
        grid $win.l2 $win.e2 $win.b2 $win.r2 -sticky we -padx 3 -pady 3
        grid $win.l3 $win.e3 $win.b3 $win.r3 -sticky we -padx 3 -pady {10 3}
        grid $win.l4 $win.e4 $win.b4 $win.r4 -sticky we -padx 3 -pady 3







|
|








|
|
|





|
>



|
|







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
        # Four files, with optional revision
        set fields {base1 change1 base2 change2}
    
        ttk::label $win.l1 -text "Base 1"
        ttk::label $win.l2 -text "Changed 1"
        ttk::label $win.l3 -text "Base 2"
        ttk::label $win.l4 -text "Changed 2"
        set txt1 "First diff is made from Base 1 to Changed 1.\n If a file is\
                  empty and have a revision, the other file name is used."
        addBalloon $win.l1 $txt1
        addBalloon $win.l2 $txt1
        set txt2 [string map {1 2 First Second} $txt1]
        addBalloon $win.l3 $txt2
        addBalloon $win.l4 $txt2

        ttk::label $win.el -text "File path"
        ttk::label $win.rl -text "Rev"
        addBalloon $win.rl "If you want to use a revisioned controlled file\
                            instead\n of the one on disk, add a revision here.\
                            E.g. 0 can be used\n for latest commited revision."

        set n 0
        foreach field $fields {
            incr n
            ttk::entryX $win.e$n -width 60 -textvariable [myvar files($field)]
            ttk::button $win.b$n -text "Browse" \
                    -command [mymethod browseFile $field]
            ttk::entryX $win.r$n -width 6 -textvariable  [myvar revs($field)]
        }

        ttk::button $win.bd -text "Diff" -command [mymethod doFourWayDiff] \
                -underline 0 -width 8
        bind $win <Alt-d> [list $win.bd invoke]

        grid x       $win.el x       $win.rl -sticky w  -padx 3 -pady 3
        grid $win.l1 $win.e1 $win.b1 $win.r1 -sticky we -padx 3 -pady 3
        grid $win.l2 $win.e2 $win.b2 $win.r2 -sticky we -padx 3 -pady 3
        grid $win.l3 $win.e3 $win.b3 $win.r3 -sticky we -padx 3 -pady {10 3}
        grid $win.l4 $win.e4 $win.b4 $win.r4 -sticky we -padx 3 -pady 3
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
            set todo [list $field]
        }
        foreach fn $files field $todo {
            # Loop until any list ends
            if {$fn eq "" || $field eq ""} break
            # Sanity check
            if {[file exists $fn]} {
                set fields($field) $fn
            }
        }
    }

    # Browse for file
    method browseFile {field} {
        set initDir [pwd]







|







123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
            set todo [list $field]
        }
        foreach fn $files field $todo {
            # Loop until any list ends
            if {$fn eq "" || $field eq ""} break
            # Sanity check
            if {[file exists $fn]} {
                set files($field) $fn
            }
        }
    }

    # Browse for file
    method browseFile {field} {
        set initDir [pwd]
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
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
199
        }
    }

    method doFourWayDiff {} {
        # Copy to local vars to be able to replace with defaults and parsed
        foreach field $fields {
            set filename($field) $files($field)
            set rev($field) $revs($field)
        }
        # Fill in defaults, if revisions are given for empty files
        foreach {from to} $fields {
            if {$filename($to) eq "" && $revs($to) ne ""} {
                set filename($to) $files($from)
            }
            if {$filename($from) eq "" && $revs($from) ne ""} {
                set filename($from) $files($to)
            }
        }
        # Remember originals for display, they might be replaced below
        foreach field $fields {
            set origfile($field) $filename($field)
            set origrev($field)  $rev($field)
        }
        # Figure out any revisions
        foreach field $fields {
            # TODO: Move this to helper function in rev.tcl
            if {$rev($field) ne ""} {
                set revtype($field) [detectRevSystem $filename($field)]
                if {$revtype($field) eq ""} {




                    # TODO error
                    set rev($field) ""
                    continue
                }
                set revList [list $rev($field)]
                set revList [eskil::rev::$revtype($field)::ParseRevs \
                                     $filename($field) $revList]
                if {[llength $revList] == 0} {




                    # TODO error
                    set rev($field) ""
                } else {
                    set rev($field) [lindex $revList 0]
                }
            }
            # Still a revision?
            if {$rev($field) ne ""} {







|

|

|


|














>
>
>
>
|







>
>
>
>
|







156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
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
199
200
201
202
203
204
205
206
207
208
        }
    }

    method doFourWayDiff {} {
        # Copy to local vars to be able to replace with defaults and parsed
        foreach field $fields {
            set filename($field) $files($field)
            set rev($field) [string trim $revs($field)]
        }
        # Fill in defaults, if only one file is given
        foreach {from to} $fields {
            if {$filename($to) eq ""} {
                set filename($to) $files($from)
            }
            if {$filename($from) eq ""} {
                set filename($from) $files($to)
            }
        }
        # Remember originals for display, they might be replaced below
        foreach field $fields {
            set origfile($field) $filename($field)
            set origrev($field)  $rev($field)
        }
        # Figure out any revisions
        foreach field $fields {
            # TODO: Move this to helper function in rev.tcl
            if {$rev($field) ne ""} {
                set revtype($field) [detectRevSystem $filename($field)]
                if {$revtype($field) eq ""} {
                    tk_messageBox -icon error -title "Eskil Error" \
                            -parent $win -message \
                            "Could not detect version system for file $filename($field)"
                    return
                    # TBD continue
                    set rev($field) ""
                    continue
                }
                set revList [list $rev($field)]
                set revList [eskil::rev::$revtype($field)::ParseRevs \
                                     $filename($field) $revList]
                if {[llength $revList] == 0} {
                    tk_messageBox -icon error -title "Eskil Error" \
                            -parent $win -message \
                            "Could not parse revision for file $filename($field)"
                    return
                    # TBD continue
                    set rev($field) ""
                } else {
                    set rev($field) [lindex $revList 0]
                }
            }
            # Still a revision?
            if {$rev($field) ne ""} {
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
        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 \
                                        $filename(base$side) $filename(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" {







|







217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
        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 \
                    $filename(base$side) $filename(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" {
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
        }
 
        # Output diff
        for {set t 0} {$t < $n1} {incr t} {
            gets $ch1 apa
            puts $ch "- $apa"
            incr doingLine1
         }
        for {set t 0} {$t < $n2} {incr t} {
            gets $ch2 apa
            puts $ch "+ $apa"
            incr doingLine2
         }
    }
}

proc makeFourWayWin {} {
    set t 1
    set top .fourway$t
    while {[winfo exists $top]} {
        incr t
        set top .fourway$t
    }
    FourWay $top
}







|




|












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
        }
 
        # Output diff
        for {set t 0} {$t < $n1} {incr t} {
            gets $ch1 apa
            puts $ch "- $apa"
            incr doingLine1
        }
        for {set t 0} {$t < $n2} {incr t} {
            gets $ch2 apa
            puts $ch "+ $apa"
            incr doingLine2
        }
    }
}

proc makeFourWayWin {} {
    set t 1
    set top .fourway$t
    while {[winfo exists $top]} {
        incr t
        set top .fourway$t
    }
    FourWay $top
}