Diff3TextView.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 30 Jan 2013 11:15:09 +0000
branchjv
changeset 12401 4714b9640528
parent 12261 b2a507f45d87
parent 11537 fea377e66bfd
child 12650 e0f607754b9a
permissions -rw-r--r--
Merged 235b77901045 and 8332590c5a41 (branch default)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
277
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
     3
              All Rights Reserved
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
2851
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
    12
"{ Package: 'stx:libtool' }"
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
    13
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
ThreeColumnTextView subclass:#Diff3TextView
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:'useColors showSeparators addedColor addedBgColor removedColor
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
		removedBgColor changedColor changedBgColor'
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	classVariableNames:''
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	poolDictionaries:''
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	category:'Views-Text'
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
2245
0d94b4d7d4bc comment
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    22
!Diff3TextView class methodsFor:'documentation'!
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
copyright
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
"
277
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
    26
 COPYRIGHT (c) 1995 by Claus Gittinger
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
    27
              All Rights Reserved
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 This software is furnished under a license and may be used
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 only in accordance with the terms of that license and with the
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 be provided or otherwise made available to, or used by, any
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 other person.  No title to or ownership of the software is
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 hereby transferred.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
"
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
!
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
documentation
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
"
277
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
    40
    a view showing merged diff3 (see rcsmerge / merge unix manual pages) output in a 
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    user-friendly form.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    The view is created and opened with:
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
277
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
    44
       d := Diff3TextView openOn:text label:l1 label:l2 label:l3.
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
277
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
    46
    and it will show the 3 versions side-by-side
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
    47
    Its main use is for the SourceCodeManager, to show merged sources after
b4b2782bc733 documentation
Claus Gittinger <cg@exept.de>
parents: 271
diff changeset
    48
    a failed checkin.
2245
0d94b4d7d4bc comment
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    49
0d94b4d7d4bc comment
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    50
    Notice:
0d94b4d7d4bc comment
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    51
        This has diff3 output (or cvs diff output) hardwired into it.
0d94b4d7d4bc comment
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    52
        Needs to be adapted, if that format ever changes.
0d94b4d7d4bc comment
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    53
0d94b4d7d4bc comment
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    54
    [see also:]
0d94b4d7d4bc comment
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    55
        TextView EditTextView DiffTextView
0d94b4d7d4bc comment
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    56
0d94b4d7d4bc comment
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    57
    [author:]
0d94b4d7d4bc comment
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    58
        Claus Gittinger
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
"
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
! !
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
12401
4714b9640528 Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12261 11537
diff changeset
    62
2245
0d94b4d7d4bc comment
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    63
!Diff3TextView class methodsFor:'instance creation'!
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
openOnMergedText:text label:firstLabel label:secondLabel label:thirdLabel
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    "open up a view showing firstText, secondText and thirdText side-by-side,
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
     and labels for all views."
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    |top v l1 l2 l3|
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    top := StandardSystemView label:'three texts'.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    l1 := Label label:firstLabel in:top.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    l1 origin:0.0@0.0 corner:0.33@(l1 height).
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    l2 := Label label:secondLabel in:top.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    l2 origin:0.33@0.0 corner:0.67@(l1 height).
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    l3 := Label label:thirdLabel in:top.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    l3 origin:0.67@0.0 corner:1.0@(l1 height).
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    v := HVScrollableView 
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
               for:self 
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
               miniScrollerH:true miniScrollerV:false
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
               in:top.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    v origin:0.0 @ (l1 height + ViewSpacing) corner:1.0 @ 1.0.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
    v scrolledView updateListsFromMergedText:text.
2245
0d94b4d7d4bc comment
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    86
0d94b4d7d4bc comment
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
    87
"/    self addNextPreviousButtons.
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    ^ top open
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    "
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
     ThreeColumnTextView
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
        openOn:('smalltalk.rc' asFilename contentsOfEntireFile)
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
        label:'smalltalk.rc'
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
        and:('display.rc' asFilename contentsOfEntireFile)
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
        label:'display.rc'
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
        and:('private.rc' asFilename contentsOfEntireFile)
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
        label:'private.rc'
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    "
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    "Modified: 12.12.1995 / 13:09:13 / cg"
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
! !
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
12401
4714b9640528 Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12261 11537
diff changeset
   103
2245
0d94b4d7d4bc comment
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   104
!Diff3TextView class methodsFor:'public helpers'!
713
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   105
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   106
emphasizeMergedDiff3Text:mergedText emphasize1:e1 emphasize2:e2 emphasizeSep:e3
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   107
    "given the merge()/rcsmerge() merged output (as created by 'cvs update'),
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   108
     create & return a text object which contains the conflicts 
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   109
     highlighted.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   110
     CAVEAT: this is a highly specialized method - probably not the right place
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   111
     for it here ..."
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   112
3703
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   113
    |dIdx dEnd state entry list skip l1 l2 buffer
2851
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   114
     sameAtStart sameAtEnd sepYourVersion sepOtherVersion sepLine|
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   115
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   116
    sepYourVersion  := '----- your version -----'.
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   117
    sepOtherVersion := '----- other version ----'.
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   118
    sepLine := '------------------------'.
713
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   119
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   120
    list := OrderedCollection new.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   121
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   122
    dIdx := 1.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   123
    dEnd := mergedText size + 1.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   124
    state := #initial.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   125
    [dIdx < dEnd] whileTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   126
        dIdx == dEnd ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   127
            "dummy cleanup entry"
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   128
            entry := nil.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   129
            state := #initial.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   130
        ] ifFalse:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   131
            entry := mergedText at:dIdx.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   132
            dIdx := dIdx + 1.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   133
        ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   134
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   135
        skip := false.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   136
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   137
        entry notNil ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   138
            (entry startsWith:'<<<<<<<') ifTrue:[
2851
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   139
                state := 1. skip := true. 
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   140
                l1 := OrderedCollection new.
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   141
                buffer := l1.
713
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   142
            ] ifFalse:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   143
                (entry startsWith:'|||||||') ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   144
                    state := 2. skip := true.
2851
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   145
                    buffer := nil.
713
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   146
                ] ifFalse:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   147
                    (entry startsWith:'=======') ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   148
                        state == 2 ifFalse:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   149
                            state := 23        "/ on both 2 and 3
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   150
                        ] ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   151
                            state := 3         "/ only in 3
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   152
                        ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   153
                        skip := true.
2851
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   154
                        l2 := OrderedCollection new.
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   155
                        buffer := l2.
713
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   156
                    ] ifFalse:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   157
                        (entry startsWith:'>>>>>>>') ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   158
                            state := #initial.
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   159
                            skip := true.
2851
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   160
                            buffer := nil.
713
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   161
                        ]
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   162
                    ]
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   163
                ]
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   164
            ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   165
2851
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   166
            state == #initial ifTrue:[
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   167
                l1 notNil ifTrue:[
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   168
                    "/ diff3-output is sometimes stupid; fix some here
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   169
                    sameAtStart := OrderedCollection new.
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   170
                    [l1 notEmpty and:[l2 notEmpty and:[l1 first = l2 first or:[l1 first withTabsExpanded = l2 first withTabsExpanded]]]] whileTrue:[
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   171
                        sameAtStart addLast:l1 removeFirst.
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   172
                        l2 removeFirst
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   173
                    ].
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   174
                    sameAtEnd := OrderedCollection new.
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   175
                    [l1 notEmpty and:[l2 notEmpty and:[l1 last = l2 last or:[l1 last withTabsExpanded = l2 last withTabsExpanded]]]] whileTrue:[
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   176
                        sameAtEnd addFirst:l1 removeLast.
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   177
                        l2 removeLast
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   178
                    ].
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   179
                    sameAtStart do:[:eachEntry | list add:eachEntry].
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   180
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   181
                    (l1 notEmpty or:[l2 notEmpty]) ifTrue:[
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   182
                        list add:(e3 isNil ifTrue:[sepYourVersion] ifFalse:[Text string:sepYourVersion emphasis:e3]).
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   183
                        l1 do:[:eachEntry | list add:(e1 isNil ifTrue:[eachEntry] ifFalse:[Text string:eachEntry emphasis:e1])].
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   184
                        list add:(e3 isNil ifTrue:[sepOtherVersion] ifFalse:[Text string:sepOtherVersion emphasis:e3]).
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   185
                        l2 do:[:eachEntry | list add:(e2 isNil ifTrue:[eachEntry] ifFalse:[Text string:eachEntry emphasis:e2])].
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   186
                        list add:(e3 isNil ifTrue:[sepLine] ifFalse:[Text string:sepLine emphasis:e3]).
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   187
                    ].
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   188
                    sameAtEnd do:[:eachEntry | list add:eachEntry].
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   189
                    l1 := l2 := nil.
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   190
                ].
713
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   191
            ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   192
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   193
            skip ifFalse:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   194
                state == #initial ifTrue:[
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   195
                    list add:entry
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   196
                ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   197
                state == 1 ifTrue:[
2851
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   198
                    l1 add:entry.
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   199
"/                    e1 notNil ifTrue:[
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   200
"/                        list add:(Text string:entry emphasis:e1)
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   201
"/                    ] ifFalse:[
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   202
"/                        list add:entry
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   203
"/                    ]
713
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   204
                ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   205
                (state == 3 or:[state == 23]) ifTrue:[
2851
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   206
                    l2 add:entry
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   207
"/                    e2 notNil ifTrue:[
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   208
"/                        list add:(Text string:entry emphasis:e2)
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   209
"/                    ] ifFalse:[
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   210
"/                        list add:entry
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   211
"/                    ]
713
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   212
                ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   213
            ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   214
        ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   215
    ].
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   216
2851
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   217
    l1 notNil ifTrue:[
3703
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   218
        state ~~ #initial ifTrue:[self error:'oops - bad state should not happen ...'].
2851
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   219
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   220
        "/ diff3-output is sometimes stupid; fix some here
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   221
        [l1 notEmpty and:[l2 notEmpty and:[l1 first = l2 first or:[l1 first withTabsExpanded = l2 first withTabsExpanded]]]] whileTrue:[l1 removeFirst. l2 removeFirst].
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   222
        [l1 notEmpty and:[l2 notEmpty and:[l1 last = l2 last or:[l1 last withTabsExpanded = l2 last withTabsExpanded]]]] whileTrue:[l1 removeLast. l2 removeLast].
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   223
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   224
        (l1 notEmpty or:[l2 notEmpty]) ifTrue:[
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   225
            list add:(e3 isNil ifTrue:[sepYourVersion] ifFalse:[Text string:sepYourVersion emphasis:e3]).
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   226
            l1 do:[:eachEntry | list add:(e1 isNil ifTrue:[eachEntry] ifFalse:[Text string:eachEntry emphasis:e1])].
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   227
            list add:(e3 isNil ifTrue:[sepOtherVersion] ifFalse:[Text string:sepOtherVersion emphasis:e3]).
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   228
            l2 do:[:eachEntry | list add:(e2 isNil ifTrue:[eachEntry] ifFalse:[Text string:eachEntry emphasis:e2])].
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   229
            list add:(e3 isNil ifTrue:[sepLine] ifFalse:[Text string:sepLine emphasis:e3]).
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   230
        ].
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   231
        l1 := l2 := nil.
1d2fabb348d2 better diff3-output processing
Claus Gittinger <cg@exept.de>
parents: 2245
diff changeset
   232
    ].
713
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   233
    ^ list
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   234
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   235
    "Created: 9.9.1996 / 19:54:00 / cg"
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   236
    "Modified: 9.9.1996 / 20:41:40 / cg"
11537
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   237
!
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   238
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   239
emphasizeMergedDiff3TextFromPerforce:mergedText origEmphasis:origEmphasize otherEmphasis:otherEmphasize yourEmphasis:yourEmphasize separatorEmphasis:separatorEmphasize
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   240
    "given the merge()/rcsmerge() merged output (as created by 'cvs update'),
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   241
     create & return a text object which contains the conflicts 
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   242
     highlighted.
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   243
     CAVEAT: this is a highly specialized method - probably not the right place
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   244
     for it here ..."
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   245
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   246
    |list origSeparator otherSeparator yourSeparator endSeparator line currentEmphasis nextEmphasis|
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   247
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   248
    list := StringCollection new.
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   249
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   250
    origSeparator := '>>>> ORIGINAL //'.
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   251
    otherSeparator := '==== THEIRS //'.
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   252
    yourSeparator := '==== YOURS //'.
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   253
    endSeparator := '<<<<'.
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   254
    mergedText do:[:aLine|
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   255
        line := aLine withoutTrailingSeparators.
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   256
        (aLine startsWith:origSeparator) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   257
            currentEmphasis := separatorEmphasize.
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   258
            nextEmphasis := origEmphasize.
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   259
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   260
            (aLine startsWith:otherSeparator) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   261
                currentEmphasis := separatorEmphasize.
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   262
                nextEmphasis := otherEmphasize.
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   263
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   264
                (aLine startsWith:yourSeparator) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   265
                    currentEmphasis := separatorEmphasize.
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   266
                    nextEmphasis := yourEmphasize.
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   267
                ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   268
                    (aLine startsWith:endSeparator) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   269
                        currentEmphasis := separatorEmphasize.
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   270
                        nextEmphasis := nil.
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   271
                    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   272
                        nextEmphasis := currentEmphasis.        
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   273
                    ].
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   274
                ].
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   275
            ].
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   276
        ].
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   277
        list add:(currentEmphasis isNil ifTrue:[aLine] ifFalse:[Text string:aLine emphasis:currentEmphasis]).
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   278
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   279
        currentEmphasis := nextEmphasis.        
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   280
    ].
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   281
    ^ list
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   282
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   283
    "Created: / 01-06-2012 / 10:44:31 / cg"
713
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   284
! !
bbed5ec2fbeb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 290
diff changeset
   285
12401
4714b9640528 Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12261 11537
diff changeset
   286
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
!Diff3TextView methodsFor:'initialization'!
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
initStyle
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    super initStyle.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
    showSeparators := false.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
3703
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   294
    useColors := true.
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
    useColors ifTrue:[
3703
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   296
        device hasColors ifTrue:[
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   297
            addedColor := Color black.
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   298
            addedBgColor := Color green.
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
3703
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   300
            removedColor := Color white.
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   301
            removedBgColor := Color red.
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
3703
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   303
            changedColor := Color white.
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   304
            changedBgColor := Color blue.
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   305
        ] ifFalse:[
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   306
            addedBgColor := removedBgColor := changedBgColor := Color black.
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   307
            addedColor := removedColor := changedColor := Color white.
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   308
        ]
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
    ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
    "Created: 16.11.1995 / 16:59:48 / cg"
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
    "Modified: 12.12.1995 / 12:25:55 / cg"
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
! !
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
12401
4714b9640528 Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12261 11537
diff changeset
   315
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
!Diff3TextView methodsFor:'private'!
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
updateListsFromMergedText:mergedText
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
    "given the merge()/rcsmerge() merged output (as created by 'cvs update'),
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
     update my views contents"
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
3703
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   322
    |idx1 idx2 idx3 dIdx dEnd state entry l1 l2 l3  
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
     textView1 textView2 textView3 skip max|
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
    textView1 := textViews at:1.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
    textView2 := textViews at:2.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
    textView3 := textViews at:3.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
    l1 := OrderedCollection new.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
    l2 := OrderedCollection new.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
    l3 := OrderedCollection new.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
    idx1 := 1.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
    idx2 := 1.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
    idx3 := 1.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
    dIdx := 1.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
    dEnd := mergedText size + 1.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
    state := #initial.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
    [dIdx < dEnd] whileTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
        dIdx == dEnd ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
            "dummy cleanup entry"
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
            entry := nil.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
            state := #initial.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
        ] ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
            entry := mergedText at:dIdx.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
            dIdx := dIdx + 1.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
        ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
        state == #initial ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
            "
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
             fill up to size difference from previous change
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
            "
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
            max := (l1 size max:l2 size) max:l3 size.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
            [l1 size < max] whileTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
                l1 add:nil
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
            ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
            [l2 size < max] whileTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
                l2 add:nil
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
            ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
            [l3 size < max] whileTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
                l3 add:nil
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
            ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
        
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
            "
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
             except for the first chunk, add a separating line
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
            "
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
            l1 size ~~ 0 ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
                showSeparators ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
                    l1 add:'--------'.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
                    l2 add:'--------'.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
                    l3 add:'--------'.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
                ]
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
            ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
        ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
        skip := false.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
        entry notNil ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
            (entry startsWith:'<<<<<<<') ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
                state := 1. skip := true.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
            ] ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
                (entry startsWith:'|||||||') ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
                    state := 2. skip := true.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
                ] ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
                    (entry startsWith:'=======') ifTrue:[
290
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   387
                        state == 2 ifFalse:[
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   388
                            state := 23        "/ on both 2 and 3
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   389
                        ] ifTrue:[
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   390
                            state := 3         "/ only in 3
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   391
                        ].
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   392
                        skip := true.
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
                    ] ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
                        (entry startsWith:'>>>>>>>') ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
                            state := #initial.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
                            skip := true.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
                        ]
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
                    ]
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
                ]
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
            ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
            skip ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
                (state == #initial or:[state == 1]) ifTrue:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
                    (useColors and:[state == 1]) ifTrue:[
3703
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   405
                        l1 add:(Text string:entry 
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   406
                                     emphasis:(Array with:(#color->changedColor)
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   407
                                                     with:(#backgroundColor->changedBgColor))).
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
                    ] ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
                        l1 add:entry
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
                    ]
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
                ].
290
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   412
                (state == #initial or:[state == 2 or:[state == 23]]) ifTrue:[
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   413
                    (useColors and:[state == 2 or:[state == 23]]) ifTrue:[
3703
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   414
                        l2 add:(Text string:entry 
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   415
                                     emphasis:(Array with:(#color->changedColor)
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   416
                                                     with:(#backgroundColor->changedBgColor))).
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
                    ] ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
                        l2 add:entry
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
                    ]
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
                ].
290
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   421
                (state == #initial or:[state == 3 or:[state == 23]]) ifTrue:[
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   422
                    (useColors and:[state == 3 or:[state == 23]]) ifTrue:[
3703
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   423
                        l3 add:(Text string:entry 
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   424
                                     emphasis:(Array with:(#color->changedColor)
97c92239e22f Use Text instead of ColoredListEntry
Stefan Vogel <sv@exept.de>
parents: 2852
diff changeset
   425
                                                     with:(#backgroundColor->changedBgColor))).
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
                    ] ifFalse:[
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
                        l3 add:entry
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
                    ]
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
                ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
            ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
        ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
    ].
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
        
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
    textView1 list:l1.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
    textView2 list:l2.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
    textView3 list:l3.
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
290
5b9361cfa7b8 oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   438
    "Modified: 13.12.1995 / 19:56:32 / cg"
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
! !
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
12401
4714b9640528 Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12261 11537
diff changeset
   441
2245
0d94b4d7d4bc comment
Claus Gittinger <cg@exept.de>
parents: 713
diff changeset
   442
!Diff3TextView class methodsFor:'documentation'!
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
version
11537
Claus Gittinger <cg@exept.de>
parents: 3703
diff changeset
   445
    ^ '$Header: /cvs/stx/stx/libtool/Diff3TextView.st,v 1.9 2012-06-01 10:44:15 cg Exp $'
12179
47f98e7d6de1 Improvments towards merge tool
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12125
diff changeset
   446
!
47f98e7d6de1 Improvments towards merge tool
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12125
diff changeset
   447
47f98e7d6de1 Improvments towards merge tool
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12125
diff changeset
   448
version_SVN
12261
b2a507f45d87 - Tools::ChangeSetBrowser2
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12254
diff changeset
   449
    ^ '$Id: Diff3TextView.st 8016 2012-07-18 09:57:46Z vranyj1 $'
271
16d2d5f9c31c intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
! !
12401
4714b9640528 Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12261 11537
diff changeset
   451