Tools__TextMergeInfo.st
branchjv
changeset 12202 eaa1f6cb6ce8
parent 12201 283826cb8bcc
child 12203 bcfd4488d8a2
equal deleted inserted replaced
12201:283826cb8bcc 12202:eaa1f6cb6ce8
    19 	poolDictionaries:''
    19 	poolDictionaries:''
    20 	category:'Interface-Diff'
    20 	category:'Interface-Diff'
    21 !
    21 !
    22 
    22 
    23 Object subclass:#LineInfo
    23 Object subclass:#LineInfo
    24 	instanceVariableNames:'line resolution conflict'
    24 	instanceVariableNames:'line resolution conflict offset'
    25 	classVariableNames:''
    25 	classVariableNames:''
    26 	poolDictionaries:''
    26 	poolDictionaries:''
    27 	privateIn:TextMergeInfo
    27 	privateIn:TextMergeInfo
    28 !
    28 !
    29 
    29 
    52 listInfos
    52 listInfos
    53     ^ listInfos
    53     ^ listInfos
    54 !
    54 !
    55 
    55 
    56 text
    56 text
    57     ^list asString
    57     ^(list reject:[:l|l isNil]) asString
    58 
    58 
    59     "Created: / 19-03-2012 / 14:58:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    59     "Created: / 19-03-2012 / 14:58:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    60 ! !
    60 ! !
    61 
    61 
    62 !TextMergeInfo methodsFor:'initialization'!
    62 !TextMergeInfo methodsFor:'initialization'!
    66     | t1c t2c  t3c merges lnr |
    66     | t1c t2c  t3c merges lnr |
    67 
    67 
    68     list := StringCollection new.
    68     list := StringCollection new.
    69     listInfos := OrderedCollection new.
    69     listInfos := OrderedCollection new.
    70 
    70 
    71     text1 isNil ifTrue:[ ^self ].
    71     t1c := (text1 ? #()) asStringCollection.
    72     text2 isNil ifTrue:[ ^self ].
    72     t2c := (text2 ? #()) asStringCollection.
    73     text2 isNil ifTrue:[ ^self ].
    73     t3c := (text3 ? #()) asStringCollection.
    74 
       
    75 
       
    76     t1c := text1 asStringCollection.
       
    77     t2c := text2 asStringCollection.
       
    78     t3c := text3 asStringCollection.
       
    79 
    74 
    80 
    75 
    81     merges := Diff3 new
    76     merges := Diff3 new
    82                     file0: t1c; "/Base version
    77                     file0: t1c; "/Base version
    83                     file1: t2c; "/A
    78                     file1: t2c; "/A
    91                 listInfos add: (LineInfo line: lnr resolution: #Merged ).
    86                 listInfos add: (LineInfo line: lnr resolution: #Merged ).
    92                 lnr := lnr + 1.
    87                 lnr := lnr + 1.
    93             ].
    88             ].
    94         ].
    89         ].
    95         merge key == #conflict ifTrue:[
    90         merge key == #conflict ifTrue:[
    96             merge value length timesRepeat:[
    91             1 to: merge value length do:[:i|
    97                 list add:nil. "/no resolution now"
    92                 list add:nil. "/no resolution now"
    98                 listInfos add: (LineInfo line: lnr resolution: #Conflict conflict: merge value).
    93                 listInfos add: (LineInfo line: lnr resolution: #Conflict conflict: merge value offset: i).
    99                 lnr := lnr + 1.
    94                 lnr := lnr + 1.
   100             ].
    95             ].
   101         ].
    96         ].
   102     ].
    97     ].
   103 
    98 
   115     1 to: list size do:[:lineNr|
   110     1 to: list size do:[:lineNr|
   116         | lineInfo |
   111         | lineInfo |
   117 
   112 
   118         lineInfo := listInfos at: lineNr.
   113         lineInfo := listInfos at: lineNr.
   119         lineInfo conflict notNil ifTrue:[
   114         lineInfo conflict notNil ifTrue:[
   120             self list at: lineNr put: (lineInfo conflict left first).
   115             self list at: lineNr put: (lineInfo conflict leftAt: lineInfo offset).
   121             lineInfo resolution: #MergedUsingA.
   116             lineInfo resolution: #MergedUsingA.
   122             changed := true
   117             changed := true
   123         ].
   118         ].
   124     ].
   119     ].
   125     changed ifTrue:[self changed: #resolution].
   120     changed ifTrue:[self changed: #resolution].
   134     1 to: list size do:[:lineNr|
   129     1 to: list size do:[:lineNr|
   135         | lineInfo |
   130         | lineInfo |
   136 
   131 
   137         lineInfo := listInfos at: lineNr.
   132         lineInfo := listInfos at: lineNr.
   138         lineInfo conflict notNil ifTrue:[
   133         lineInfo conflict notNil ifTrue:[
   139             self list at: lineNr put: (lineInfo conflict right first).
   134             self list at: lineNr put: (lineInfo conflict rightAt: lineInfo offset).
   140             lineInfo resolution: #MergedUsingB.
   135             lineInfo resolution: #MergedUsingB.
   141             changed := true
   136             changed := true
   142         ].
   137         ].
   143     ].
   138     ].
   144     changed ifTrue:[self changed: #resolution].
   139     changed ifTrue:[self changed: #resolution].
   156 ! !
   151 ! !
   157 
   152 
   158 !TextMergeInfo::LineInfo class methodsFor:'accessing'!
   153 !TextMergeInfo::LineInfo class methodsFor:'accessing'!
   159 
   154 
   160 line:lineArg resolution:resolutionArg
   155 line:lineArg resolution:resolutionArg
   161     ^self new line:lineArg resolution:resolutionArg conflict:nil
   156     ^self new line:lineArg resolution:resolutionArg conflict:nil offset: nil
   162 
   157 
   163     "Created: / 19-03-2012 / 15:04:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   158     "Created: / 19-03-2012 / 15:04:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   164 !
   159 !
   165 
   160 
   166 line:lineArg resolution:resolutionArg conflict:conflictArg 
   161 line:lineArg resolution:resolutionArg conflict:conflictArg 
   167 
   162 
   168     ^self new line:lineArg resolution:resolutionArg conflict:conflictArg
   163     ^self new line:lineArg resolution:resolutionArg conflict:conflictArg
   169 
   164 
   170     "Modified: / 19-03-2012 / 15:07:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   165     "Modified: / 19-03-2012 / 15:07:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   166 !
       
   167 
       
   168 line:lineArg resolution:resolutionArg conflict:conflictArg offset: offsetArg 
       
   169 
       
   170     ^self new line:lineArg resolution:resolutionArg conflict:conflictArg offset: offsetArg
       
   171 
       
   172     "Modified: / 19-03-2012 / 15:07:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   173     "Created: / 20-03-2012 / 20:42:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   171 ! !
   174 ! !
   172 
   175 
   173 !TextMergeInfo::LineInfo methodsFor:'accessing'!
   176 !TextMergeInfo::LineInfo methodsFor:'accessing'!
   174 
   177 
   175 color
   178 color
   192 line
   195 line
   193     ^ line
   196     ^ line
   194 !
   197 !
   195 
   198 
   196 line:lineArg resolution:resolutionArg
   199 line:lineArg resolution:resolutionArg
   197     self line:lineArg resolution:resolutionArg conflict:nil
   200     self line:lineArg resolution:resolutionArg conflict:nil offset: nil
   198 
   201 
   199     "Created: / 19-03-2012 / 15:04:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   202     "Created: / 19-03-2012 / 15:04:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   200 !
   203 !
   201 
   204 
   202 line:lineArg resolution:resolutionArg conflict:conflictArg 
   205 line:lineArg resolution:resolutionArg conflict:conflictArg offset: offsetArg
   203     line := lineArg.
   206     line := lineArg.
   204     resolution := resolutionArg.
   207     resolution := resolutionArg.
   205     conflict := conflictArg.
   208     conflict := conflictArg.
       
   209     offset := offsetArg
       
   210 
       
   211     "Created: / 20-03-2012 / 20:41:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   212 !
       
   213 
       
   214 offset
       
   215     ^ offset
   206 !
   216 !
   207 
   217 
   208 resolution
   218 resolution
   209     ^ resolution
   219     ^ resolution
   210 !
   220 !
   271 ! !
   281 ! !
   272 
   282 
   273 !TextMergeInfo class methodsFor:'documentation'!
   283 !TextMergeInfo class methodsFor:'documentation'!
   274 
   284 
   275 version_SVN
   285 version_SVN
   276     ^ '$Id: Tools__TextMergeInfo.st 7947 2012-03-20 16:59:54Z vranyj1 $'
   286     ^ '$Id: Tools__TextMergeInfo.st 7948 2012-03-21 01:52:35Z vranyj1 $'
   277 ! !
   287 ! !