author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 16 Mar 2012 22:44:50 +0000 | |
branch | jv |
changeset 12190 | 2a77dea2eceb |
parent 12182 | 38a7a48ccbff |
child 12225 | 60dfd3fa018d |
permissions | -rw-r--r-- |
12181
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
1 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
2 |
Copyright (c) 2007-2012 Tony Garnock-Jones |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
3 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
4 |
This code is based on Squeak's DiffMerge package |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
5 |
written by Tony Garnock-Jones. Original project's web site: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
6 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
7 |
http://www.squeaksource.com/DiffMerge |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
8 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
9 |
Permission is hereby granted, free of charge, to any person |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
10 |
obtaining a copy of this software and associated documentation |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
11 |
files (the 'Software'), to deal in the Software without |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
12 |
restriction, including without limitation the rights to use, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
13 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
14 |
copies of the Software, and to permit persons to whom the |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
15 |
Software is furnished to do so, subject to the following |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
16 |
conditions: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
17 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
18 |
The above copyright notice and this permission notice shall be |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
19 |
included in all copies or substantial portions of the Software. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
20 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
21 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
22 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
23 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
24 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
25 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
26 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
27 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
28 |
OTHER DEALINGS IN THE SOFTWARE. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
29 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
30 |
"{ Package: 'stx:libtool' }" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
31 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
32 |
Object subclass:#Diff2 |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
33 |
instanceVariableNames:'file1 file2' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
34 |
classVariableNames:'' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
35 |
poolDictionaries:'' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
36 |
category:'Collections-Sequenceable-Diff2' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
37 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
38 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
39 |
Object subclass:#Chunk |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
40 |
instanceVariableNames:'offset length' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
41 |
classVariableNames:'' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
42 |
poolDictionaries:'' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
43 |
privateIn:Diff2 |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
44 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
45 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
46 |
Diff2 subclass:#HuntMcilroy |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
47 |
instanceVariableNames:'lcs' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
48 |
classVariableNames:'' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
49 |
poolDictionaries:'' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
50 |
privateIn:Diff2 |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
51 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
52 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
53 |
Object subclass:#Candidate |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
54 |
instanceVariableNames:'file1index file2index chain' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
55 |
classVariableNames:'' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
56 |
poolDictionaries:'' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
57 |
privateIn:Diff2::HuntMcilroy |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
58 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
59 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
60 |
Diff2 subclass:#MyersUkkonen |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
61 |
instanceVariableNames:'lcs' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
62 |
classVariableNames:'' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
63 |
poolDictionaries:'' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
64 |
privateIn:Diff2 |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
65 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
66 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
67 |
Object subclass:#Patch |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
68 |
instanceVariableNames:'chunks snippets' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
69 |
classVariableNames:'' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
70 |
poolDictionaries:'' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
71 |
privateIn:Diff2 |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
72 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
73 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
74 |
Diff2 comment:'Generic diff/comm utilities. Agnostic as to the longestCommonSubsequence algorithm used. Instance Variables file1: <SequenceableCollection> One of the two files to compare. file2: <SequenceableCollection> The other of the files to compare. -- Copyright (c) 2008 Tony Garnock-Jones <tonyg@lshift.net> Copyright (c) 2008 LShift Ltd. <query@lshift.net> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,including without limitation the rights to use, copy, modify, merge,publish, distribute, sublicense, and/or sell copies of the Software,and to permit persons to whom the Software is furnished to do so,subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ' |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
75 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
76 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
77 |
!Diff2 class methodsFor:'documentation'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
78 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
79 |
copyright |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
80 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
81 |
Copyright (c) 2007-2012 Tony Garnock-Jones |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
82 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
83 |
This code is based on Squeak's DiffMerge package |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
84 |
written by Tony Garnock-Jones. Original project's web site: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
85 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
86 |
http://www.squeaksource.com/DiffMerge |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
87 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
88 |
Permission is hereby granted, free of charge, to any person |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
89 |
obtaining a copy of this software and associated documentation |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
90 |
files (the 'Software'), to deal in the Software without |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
91 |
restriction, including without limitation the rights to use, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
92 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
93 |
copies of the Software, and to permit persons to whom the |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
94 |
Software is furnished to do so, subject to the following |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
95 |
conditions: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
96 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
97 |
The above copyright notice and this permission notice shall be |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
98 |
included in all copies or substantial portions of the Software. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
99 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
100 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
101 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
102 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
103 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
104 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
105 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
106 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
107 |
OTHER DEALINGS IN THE SOFTWARE. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
108 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
109 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
110 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
111 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
112 |
documentation |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
113 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
114 |
Generic diff/comm utilities. Agnostic as to the longestCommonSubsequence algorithm used. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
115 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
116 |
Instance Variables |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
117 |
file1: <SequenceableCollection> One of the two files to compare. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
118 |
file2: <SequenceableCollection> The other of the files to compare. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
119 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
120 |
[author:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
121 |
Tony Garnock-Jones <tonyg@lshift.com> |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
122 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
123 |
[instance variables:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
124 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
125 |
[class variables:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
126 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
127 |
[see also:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
128 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
129 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
130 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
131 |
|
12190
2a77dea2eceb
Improvements in Diff3CodeiView2 - now it highlights differences
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12182
diff
changeset
|
132 |
!Diff2 class methodsFor:'instance creation'! |
2a77dea2eceb
Improvements in Diff3CodeiView2 - now it highlights differences
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12182
diff
changeset
|
133 |
|
2a77dea2eceb
Improvements in Diff3CodeiView2 - now it highlights differences
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12182
diff
changeset
|
134 |
new |
2a77dea2eceb
Improvements in Diff3CodeiView2 - now it highlights differences
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12182
diff
changeset
|
135 |
"I'm abstract, so instantiate some default here" |
2a77dea2eceb
Improvements in Diff3CodeiView2 - now it highlights differences
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12182
diff
changeset
|
136 |
|
2a77dea2eceb
Improvements in Diff3CodeiView2 - now it highlights differences
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12182
diff
changeset
|
137 |
^self == Diff2 ifTrue:[ |
2a77dea2eceb
Improvements in Diff3CodeiView2 - now it highlights differences
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12182
diff
changeset
|
138 |
HuntMcilroy new |
2a77dea2eceb
Improvements in Diff3CodeiView2 - now it highlights differences
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12182
diff
changeset
|
139 |
] ifFalse:[ |
2a77dea2eceb
Improvements in Diff3CodeiView2 - now it highlights differences
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12182
diff
changeset
|
140 |
self basicNew initialize |
2a77dea2eceb
Improvements in Diff3CodeiView2 - now it highlights differences
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12182
diff
changeset
|
141 |
] |
2a77dea2eceb
Improvements in Diff3CodeiView2 - now it highlights differences
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12182
diff
changeset
|
142 |
|
2a77dea2eceb
Improvements in Diff3CodeiView2 - now it highlights differences
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12182
diff
changeset
|
143 |
"Created: / 16-03-2012 / 20:16:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2a77dea2eceb
Improvements in Diff3CodeiView2 - now it highlights differences
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12182
diff
changeset
|
144 |
! ! |
2a77dea2eceb
Improvements in Diff3CodeiView2 - now it highlights differences
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12182
diff
changeset
|
145 |
|
12181
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
146 |
!Diff2 class methodsFor:'accessing'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
147 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
148 |
HuntMcilroy |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
149 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
150 |
^HuntMcilroy |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
151 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
152 |
"Created: / 16-03-2012 / 18:54:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
153 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
154 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
155 |
MyersUkkonen |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
156 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
157 |
^MyersUkkonen |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
158 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
159 |
"Created: / 16-03-2012 / 18:54:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
160 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
161 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
162 |
!Diff2 methodsFor:'accessing'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
163 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
164 |
file1 |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
165 |
^ file1 |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
166 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
167 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
168 |
file1: anObject |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
169 |
file1 := anObject. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
170 |
self emptyCaches. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
171 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
172 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
173 |
file2 |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
174 |
^ file2 |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
175 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
176 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
177 |
file2: anObject |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
178 |
file2 := anObject. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
179 |
self emptyCaches. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
180 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
181 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
182 |
!Diff2 methodsFor:'diffing'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
183 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
184 |
comm |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
185 |
"Returns a collection of similarities and differences between the two files. Each entry in the resulting collection is either (#common -> {...}) or (#different -> ({...} -> {...}))." |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
186 |
| result common p1 p2 | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
187 |
result := OrderedCollection new. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
188 |
p1 := 0. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
189 |
p2 := 0. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
190 |
common := OrderedCollection new. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
191 |
self longestCommonSubsequence do: [:entry | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
192 |
common := self maybeAddCommonBlock: common to: result |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
193 |
p1: p1 p2: p2 limit1: entry key limit2: entry value. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
194 |
common add: (self file1 at: entry key). |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
195 |
p1 := entry key. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
196 |
p2 := entry value.]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
197 |
common := self maybeAddCommonBlock: common to: result |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
198 |
p1: p1 p2: p2 limit1: file1 size + 1 limit2: file2 size + 1. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
199 |
self addCommonBlock: common ifNonEmptyTo: result. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
200 |
^ result asArray |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
201 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
202 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
203 |
diff |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
204 |
"Returns a DiffPatch instance that can be used in future to transform file1 into file2." |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
205 |
| p | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
206 |
p := Diff2::Patch new. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
207 |
p initChunks: self diffIndices file1: file1 file2: file2. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
208 |
^ p |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
209 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
210 |
"Modified: / 16-03-2012 / 19:16:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
211 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
212 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
213 |
diffIndices |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
214 |
"Returns a collection of (DiffChunk -> DiffChunk) associations mapping differing regions of file1 and file2 onto each other." |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
215 |
| result p1 p2 | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
216 |
result := OrderedCollection new. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
217 |
p1 := 0. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
218 |
p2 := 0. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
219 |
self longestCommonSubsequence do: [:entry | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
220 |
self maybeAddDiffChunkTo: result p1: p1 p2: p2 limit1: entry key limit2: entry value. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
221 |
p1 := entry key. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
222 |
p2 := entry value.]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
223 |
self maybeAddDiffChunkTo: result p1: p1 p2: p2 limit1: file1 size + 1 limit2: file2 size + 1. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
224 |
^ result asArray |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
225 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
226 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
227 |
longestCommonSubsequence |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
228 |
"The longestCommonSubsequence (LCS) algorithm is at the heart of a diff/comm algorithm." |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
229 |
self subclassResponsibility. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
230 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
231 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
232 |
!Diff2 methodsFor:'private'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
233 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
234 |
addCommonBlock: aSubCollection ifNonEmptyTo: aCollection |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
235 |
^ aSubCollection isEmpty |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
236 |
ifFalse: [aCollection add: #common -> aSubCollection asArray. OrderedCollection new] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
237 |
ifTrue: [aSubCollection] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
238 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
239 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
240 |
emptyCaches |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
241 |
"Subclasses should implement this to clear any cached state they may have built up." |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
242 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
243 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
244 |
maybeAddCommonBlock: common to: result p1: p1 p2: p2 limit1: limit1 limit2: limit2 |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
245 |
"For internal use by comm." |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
246 |
((p1 + 1 ~= limit1) or: [p2 + 1 ~= limit2]) |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
247 |
ifTrue: [| newCommon | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
248 |
newCommon := self addCommonBlock: common ifNonEmptyTo: result. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
249 |
result add: #different -> ((file1 copyFrom: p1 + 1 to: limit1 - 1) -> |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
250 |
(file2 copyFrom: p2 + 1 to: limit2 - 1)). |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
251 |
^ newCommon] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
252 |
ifFalse: [^ common]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
253 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
254 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
255 |
maybeAddDiffChunkTo: result p1: p1 p2: p2 limit1: limit1 limit2: limit2 |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
256 |
"For internal use by diffIndices." |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
257 |
((p1 + 1 ~= limit1) or: [p2 + 1 ~= limit2]) |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
258 |
ifTrue: [result add: ((Diff2::Chunk offset: p1 + 1 length: limit1 - p1 - 1) -> |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
259 |
(Diff2::Chunk offset: p2 + 1 length: limit2 - p2 - 1))]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
260 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
261 |
"Modified: / 16-03-2012 / 19:13:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
262 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
263 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
264 |
!Diff2::Chunk class methodsFor:'as yet unclassified'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
265 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
266 |
negativeSize: s |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
267 |
"Returns a pseudo-chunk with *negative* length, useful as a kind of zero for destructiveMergeWith: operations intended to build up coverage over some set of chunks." |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
268 |
^ self new offset: s + 1; length: s negated |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
269 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
270 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
271 |
offset: o length: l |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
272 |
^ self new offset: o; length: l |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
273 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
274 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
275 |
!Diff2::Chunk class methodsFor:'documentation'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
276 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
277 |
copyright |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
278 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
279 |
Copyright (c) 2007-2012 Tony Garnock-Jones |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
280 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
281 |
This code is based on Squeak's DiffMerge package |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
282 |
written by Tony Garnock-Jones. Original project's web site: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
283 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
284 |
http://www.squeaksource.com/DiffMerge |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
285 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
286 |
Permission is hereby granted, free of charge, to any person |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
287 |
obtaining a copy of this software and associated documentation |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
288 |
files (the 'Software'), to deal in the Software without |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
289 |
restriction, including without limitation the rights to use, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
290 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
291 |
copies of the Software, and to permit persons to whom the |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
292 |
Software is furnished to do so, subject to the following |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
293 |
conditions: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
294 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
295 |
The above copyright notice and this permission notice shall be |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
296 |
included in all copies or substantial portions of the Software. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
297 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
298 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
299 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
300 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
301 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
302 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
303 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
304 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
305 |
OTHER DEALINGS IN THE SOFTWARE. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
306 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
307 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
308 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
309 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
310 |
documentation |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
311 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
312 |
A DiffChunk represents a span of items within a collection (e.g. a collection of lines representing a text file). |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
313 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
314 |
Instance Variables |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
315 |
length: <Integer> Count of lines within the chunk; 0 is permitted |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
316 |
offset: <Integer> Index of first line within the chunk; 1-based |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
317 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
318 |
[author:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
319 |
Tony Garnock-Jones <tonyg@lshift.com> |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
320 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
321 |
[instance variables:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
322 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
323 |
[class variables:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
324 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
325 |
[see also:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
326 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
327 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
328 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
329 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
330 |
!Diff2::Chunk methodsFor:'accessing'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
331 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
332 |
correctForSkewFrom: smallerChunk to: biggerChunk |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
333 |
"Given a biggerChunk that definitely contains smallerChunk but might have an extra head or tail, updates the receiver to include such an extra head or tail." |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
334 |
| headSize tailSize | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
335 |
headSize := smallerChunk offset - biggerChunk offset. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
336 |
tailSize := biggerChunk lastIndex - smallerChunk lastIndex. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
337 |
offset := offset - headSize. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
338 |
length := length + headSize + tailSize. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
339 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
340 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
341 |
destructiveMergeWith: aChunk |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
342 |
| newLastIndex | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
343 |
newLastIndex := self lastIndex max: aChunk lastIndex. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
344 |
offset := offset min: aChunk offset. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
345 |
length := newLastIndex - offset + 1. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
346 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
347 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
348 |
lastIndex |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
349 |
"Returns the rightmost index contained in my range. (Offset is the leftmost index.) If my length is zero, will return an index lower than my offset." |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
350 |
^ offset + length - 1 |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
351 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
352 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
353 |
length |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
354 |
^ length |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
355 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
356 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
357 |
length: anObject |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
358 |
length := anObject |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
359 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
360 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
361 |
offset |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
362 |
^ offset |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
363 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
364 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
365 |
offset: anObject |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
366 |
offset := anObject |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
367 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
368 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
369 |
printOn: aStream |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
370 |
aStream |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
371 |
nextPut: $(; |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
372 |
nextPutAll: self class name; |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
373 |
nextPutAll: ' offset: '; |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
374 |
nextPutAll: self offset asString; |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
375 |
nextPutAll: ' length: '; |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
376 |
nextPutAll: self length asString; |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
377 |
nextPut: $). |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
378 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
379 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
380 |
!Diff2::Chunk methodsFor:'as yet unclassified'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
381 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
382 |
extractFrom: aCollection |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
383 |
"Extracts a subcollection from aCollection corresponding to my offset and length." |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
384 |
^ aCollection copyFrom: offset to: offset + length - 1. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
385 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
386 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
387 |
!Diff2::Chunk methodsFor:'comparing'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
388 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
389 |
< aDiffChunk |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
390 |
"Used to sort changed chunks during three-way merge; see Diff3" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
391 |
^ self offset < aDiffChunk offset |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
392 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
393 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
394 |
= otherChunk |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
395 |
^ (otherChunk isKindOf: Diff2::Chunk) and: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
396 |
[(self offset = otherChunk offset) and: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
397 |
[(self length = otherChunk length)]] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
398 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
399 |
"Modified: / 16-03-2012 / 19:13:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
400 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
401 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
402 |
!Diff2::HuntMcilroy class methodsFor:'documentation'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
403 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
404 |
copyright |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
405 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
406 |
Copyright (c) 2007-2012 Tony Garnock-Jones |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
407 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
408 |
This code is based on Squeak's DiffMerge package |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
409 |
written by Tony Garnock-Jones. Original project's web site: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
410 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
411 |
http://www.squeaksource.com/DiffMerge |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
412 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
413 |
Permission is hereby granted, free of charge, to any person |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
414 |
obtaining a copy of this software and associated documentation |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
415 |
files (the 'Software'), to deal in the Software without |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
416 |
restriction, including without limitation the rights to use, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
417 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
418 |
copies of the Software, and to permit persons to whom the |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
419 |
Software is furnished to do so, subject to the following |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
420 |
conditions: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
421 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
422 |
The above copyright notice and this permission notice shall be |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
423 |
included in all copies or substantial portions of the Software. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
424 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
425 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
426 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
427 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
428 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
429 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
430 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
431 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
432 |
OTHER DEALINGS IN THE SOFTWARE. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
433 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
434 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
435 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
436 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
437 |
documentation |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
438 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
439 |
A HuntMcilroyDiff provides a longestCommonSubsequence algorithm following Hunt and McIlroy 1976 for use by the methods on GenericDiff. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
440 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
441 |
J. W. Hunt and M. D. McIlroy, An algorithm for differential file comparison, Bell Telephone Laboratories CSTR #41 (1976). |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
442 |
http://www.cs.dartmouth.edu/~doug/ |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
443 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
444 |
Instance Variables |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
445 |
lcs: cached longest common subsequence |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
446 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
447 |
[author:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
448 |
Tony Garnock-Jones <tonyg@lshift.com> |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
449 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
450 |
[instance variables:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
451 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
452 |
[class variables:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
453 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
454 |
[see also:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
455 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
456 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
457 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
458 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
459 |
!Diff2::HuntMcilroy methodsFor:'accessing'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
460 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
461 |
emptyCaches |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
462 |
lcs := nil. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
463 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
464 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
465 |
!Diff2::HuntMcilroy methodsFor:'diffing'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
466 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
467 |
longestCommonSubsequence |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
468 |
| equivalenceClasses candidates | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
469 |
lcs ifNotNil: [ ^ lcs ]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
470 |
equivalenceClasses := self computeEquivalenceClasses. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
471 |
candidates := OrderedCollection with: (Candidate new |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
472 |
file1index: 0 |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
473 |
file2index: 0 |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
474 |
chain: nil). |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
475 |
file1 withIndexDo: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
476 |
[ :line :file1index | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
477 |
self |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
478 |
mergeCandidates: candidates |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
479 |
file1index: file1index |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
480 |
file2indices: (equivalenceClasses |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
481 |
at: line |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
482 |
ifAbsent: #()) ]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
483 |
lcs := self postprocessCandidateChain: candidates. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
484 |
^ lcs |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
485 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
486 |
"Modified: / 16-03-2012 / 19:14:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
487 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
488 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
489 |
!Diff2::HuntMcilroy methodsFor:'private'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
490 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
491 |
computeEquivalenceClasses |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
492 |
| result | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
493 |
result := Dictionary new. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
494 |
file2 withIndexDo: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
495 |
[ :line :index | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
496 |
(result |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
497 |
at: line |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
498 |
ifAbsentPut: [ OrderedCollection new ]) add: index ]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
499 |
^ result |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
500 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
501 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
502 |
findCandidateFrom: candidates forLine: file2index startingAt: lowIndex |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
503 |
"Find the index k in the given subrange of candidates where file2index falls strictly between the file2indexes of the kth and k+1th candidates. If no such k exists, return 0." |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
504 |
(lowIndex to: candidates size) do: [ :k | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
505 |
(candidates at: k) file2index >= file2index ifTrue: [^ 0]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
506 |
(k = candidates size or: [ (candidates at: k + 1) file2index > file2index ]) |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
507 |
ifTrue: [^ k] ]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
508 |
^ 0 |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
509 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
510 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
511 |
mergeCandidates: candidates file1index: file1index file2indices: file2indices |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
512 |
| r c s newCandidate | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
513 |
r := 1. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
514 |
c := candidates at: r. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
515 |
file2indices do: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
516 |
[ :file2index | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
517 |
s := self findCandidateFrom: candidates forLine: file2index startingAt: r. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
518 |
s > 0 ifTrue: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
519 |
[ newCandidate := Candidate new |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
520 |
file1index: file1index |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
521 |
file2index: file2index |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
522 |
chain: (candidates at: s). |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
523 |
self storeCandidate: c at: r in: candidates. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
524 |
c := newCandidate. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
525 |
r := s + 1. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
526 |
"optimise by leaving early if s was the end of the candidates list, since none of the subsequent file2indices will have a place to go" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
527 |
s = candidates size ifTrue: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
528 |
[ self storeCandidate: c at: r in: candidates. ^ self ] ] ]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
529 |
self storeCandidate: c at: r in: candidates. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
530 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
531 |
"Modified (format): / 16-03-2012 / 19:08:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
532 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
533 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
534 |
postprocessCandidateChain: candidates |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
535 |
| result c | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
536 |
result := OrderedCollection new. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
537 |
c := candidates at: candidates size. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
538 |
[ c chain notNil ] whileTrue: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
539 |
[ result add: c file1index -> c file2index. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
540 |
c := c chain ]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
541 |
^ result reversed. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
542 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
543 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
544 |
storeCandidate: c at: r in: candidates |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
545 |
r > candidates size ifTrue: [candidates add: c] ifFalse: [candidates at: r put: c]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
546 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
547 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
548 |
!Diff2::HuntMcilroy::Candidate class methodsFor:'documentation'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
549 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
550 |
copyright |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
551 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
552 |
Copyright (c) 2007-2012 Tony Garnock-Jones |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
553 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
554 |
This code is based on Squeak's DiffMerge package |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
555 |
written by Tony Garnock-Jones. Original project's web site: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
556 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
557 |
http://www.squeaksource.com/DiffMerge |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
558 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
559 |
Permission is hereby granted, free of charge, to any person |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
560 |
obtaining a copy of this software and associated documentation |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
561 |
files (the 'Software'), to deal in the Software without |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
562 |
restriction, including without limitation the rights to use, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
563 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
564 |
copies of the Software, and to permit persons to whom the |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
565 |
Software is furnished to do so, subject to the following |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
566 |
conditions: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
567 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
568 |
The above copyright notice and this permission notice shall be |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
569 |
included in all copies or substantial portions of the Software. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
570 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
571 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
572 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
573 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
574 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
575 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
576 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
577 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
578 |
OTHER DEALINGS IN THE SOFTWARE. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
579 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
580 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
581 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
582 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
583 |
documentation |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
584 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
585 |
HuntMcilroyDiffCandidate is used internally by HuntMcilroyDiff. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
586 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
587 |
[author:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
588 |
Tony Garnock-Jones <tonyg@kcbbs.gen.nz> |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
589 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
590 |
[instance variables:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
591 |
chain: Link to next candidate in chain. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
592 |
file1index: Position in file1. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
593 |
file2index: Position in file2. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
594 |
[class variables:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
595 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
596 |
[see also:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
597 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
598 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
599 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
600 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
601 |
!Diff2::HuntMcilroy::Candidate methodsFor:'accessing'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
602 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
603 |
chain |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
604 |
^ chain |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
605 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
606 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
607 |
file1index |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
608 |
^ file1index |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
609 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
610 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
611 |
file2index |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
612 |
^ file2index |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
613 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
614 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
615 |
!Diff2::HuntMcilroy::Candidate methodsFor:'as yet unclassified'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
616 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
617 |
file1index: f1 file2index: f2 chain: c |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
618 |
file1index := f1. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
619 |
file2index := f2. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
620 |
chain := c. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
621 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
622 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
623 |
!Diff2::MyersUkkonen class methodsFor:'documentation'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
624 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
625 |
copyright |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
626 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
627 |
Copyright (c) 2007-2012 Tony Garnock-Jones |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
628 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
629 |
This code is based on Squeak's DiffMerge package |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
630 |
written by Tony Garnock-Jones. Original project's web site: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
631 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
632 |
http://www.squeaksource.com/DiffMerge |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
633 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
634 |
Permission is hereby granted, free of charge, to any person |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
635 |
obtaining a copy of this software and associated documentation |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
636 |
files (the 'Software'), to deal in the Software without |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
637 |
restriction, including without limitation the rights to use, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
638 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
639 |
copies of the Software, and to permit persons to whom the |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
640 |
Software is furnished to do so, subject to the following |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
641 |
conditions: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
642 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
643 |
The above copyright notice and this permission notice shall be |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
644 |
included in all copies or substantial portions of the Software. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
645 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
646 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
647 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
648 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
649 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
650 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
651 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
652 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
653 |
OTHER DEALINGS IN THE SOFTWARE. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
654 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
655 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
656 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
657 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
658 |
documentation |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
659 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
660 |
I implement a modified version of Myers' greedy lcs algorithm described in http://xmailserver.org/diff2.pdf. A similar version written in C can be found here http://research.janelia.org/myers/Papers/file.comparison.pdf. Ukkonen's version can be found here http://www.cs.helsinki.fi/u/ukkonen/InfCont85.PDF. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
661 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
662 |
[author:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
663 |
Tony Garnock-Jones <tonyg@lshift.com> |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
664 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
665 |
[instance variables:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
666 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
667 |
[class variables:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
668 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
669 |
[see also:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
670 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
671 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
672 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
673 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
674 |
!Diff2::MyersUkkonen methodsFor:'accessing'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
675 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
676 |
emptyCaches |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
677 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
678 |
lcs := nil |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
679 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
680 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
681 |
!Diff2::MyersUkkonen methodsFor:'diffing'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
682 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
683 |
longestCommonSubsequence |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
684 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
685 |
^lcs ifNil: [ |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
686 |
lcs := (Array streamContents: [ :stream | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
687 |
| list | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
688 |
list := self calculateLcs. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
689 |
[ list == nil ] whileFalse: [ |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
690 |
stream nextPut: (list at: 1) -> (list at: 2). |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
691 |
list := list at: 3 ] ]) reverse ] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
692 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
693 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
694 |
!Diff2::MyersUkkonen methodsFor:'private'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
695 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
696 |
calculateLcs |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
697 |
"I find one of the longest common subsequences of my the arguments. I assume that none of my arguments are empty. I return nil or an Array which represents a list. The first two elements are the matching line numbers, the last is the next node in the list or nil if there are no more elements. The list containts the longest common subsequence. I'm a modified version of the greedy lcs algorithm from the 6th page of 'An O(ND) Difference Algorithm and Its Variations (1986)' by Eugene W. Myers" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
698 |
|
12182 | 699 |
| n m v lcss max | |
700 |
n := file1 size. |
|
701 |
m := file2 size. |
|
702 |
max := m + n. |
|
703 |
v := Array new: 2 * max + 1. |
|
704 |
v at: max + 2 put: 0. |
|
705 |
lcss := Array new: 2 * max + 1. |
|
706 |
0 to: max do: [ :d | |
|
707 |
d negated to: d by: 2 do: [ :k | |
|
708 |
| index chain x y | |
|
709 |
(k + d = 0 or: [ k ~= d and: [ (v at: max + k ) < (v at: max + k + 2) ] ]) |
|
12181
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
710 |
ifTrue: [ |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
711 |
index := max + k + 2. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
712 |
x := v at: index ] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
713 |
ifFalse: [ |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
714 |
index := max + k. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
715 |
x := (v at: index) + 1 ]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
716 |
chain := lcss at: index. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
717 |
y := x - k. |
12182 | 718 |
[ x < n and: [ y < m and: [ (file1 at: x + 1) = (file2 at: y + 1) ] ] ] whileTrue: [ |
719 |
chain := Array with: (x := x + 1) with: (y := y + 1) with: chain. |
|
720 |
]. |
|
12181
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
721 |
(x >= n and: [ y >= m ]) ifTrue: [ |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
722 |
^chain ]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
723 |
v at: max + k + 1 put: x. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
724 |
lcss at: max + k + 1 put: chain ] ]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
725 |
self error |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
726 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
727 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
728 |
!Diff2::Patch class methodsFor:'documentation'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
729 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
730 |
copyright |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
731 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
732 |
Copyright (c) 2007-2012 Tony Garnock-Jones |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
733 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
734 |
This code is based on Squeak's DiffMerge package |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
735 |
written by Tony Garnock-Jones. Original project's web site: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
736 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
737 |
http://www.squeaksource.com/DiffMerge |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
738 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
739 |
Permission is hereby granted, free of charge, to any person |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
740 |
obtaining a copy of this software and associated documentation |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
741 |
files (the 'Software'), to deal in the Software without |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
742 |
restriction, including without limitation the rights to use, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
743 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
744 |
copies of the Software, and to permit persons to whom the |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
745 |
Software is furnished to do so, subject to the following |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
746 |
conditions: |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
747 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
748 |
The above copyright notice and this permission notice shall be |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
749 |
included in all copies or substantial portions of the Software. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
750 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
751 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
752 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
753 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
754 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
755 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
756 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
757 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
758 |
OTHER DEALINGS IN THE SOFTWARE. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
759 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
760 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
761 |
! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
762 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
763 |
documentation |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
764 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
765 |
A DiffPatch has a collection of DiffChunks, and a collection of corresponding |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
766 |
SequenceableCollection snippets. It can be used to patch a file (= SequenceableCollection) |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
767 |
forwards or backwards. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
768 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
769 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
770 |
[author:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
771 |
Tony Garnock-Jones <tonyg@lshift.com> |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
772 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
773 |
[instance variables:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
774 |
chunks: <SequenceableCollection of DiffChunk->DiffChunk> |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
775 |
snippets: <SequenceableCollection of SequenceableCollection->SequenceableCollection> |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
776 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
777 |
[class variables:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
778 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
779 |
[see also:] |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
780 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
781 |
" |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
782 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
783 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
784 |
!Diff2::Patch methodsFor:'accessing'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
785 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
786 |
applyTo: file |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
787 |
"Applies this patch to the given collection. Makes no sanity checks on the contents of the collection - simply blindly applies the chunks and snippets to its argument." |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
788 |
| result commonOffset | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
789 |
result := OrderedCollection new. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
790 |
commonOffset := 1. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
791 |
chunks with: snippets do: [:chunk :snippet | |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
792 |
result addAll: (file copyFrom: commonOffset to: chunk key offset - 1). |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
793 |
result addAll: (snippet value). |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
794 |
commonOffset := chunk key offset + chunk key length]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
795 |
result addAll: (file copyFrom: commonOffset to: file size). |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
796 |
^ result as: file species. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
797 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
798 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
799 |
!Diff2::Patch methodsFor:'as yet unclassified'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
800 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
801 |
initChunks: c file1: f1 file2: f2 |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
802 |
chunks := c. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
803 |
snippets := c collect: [:entry | (entry key extractFrom: f1) -> (entry value extractFrom: f2)]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
804 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
805 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
806 |
!Diff2::Patch methodsFor:'selecting'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
807 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
808 |
invert |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
809 |
"Causes this patch to invert itself; if previously it represented the changes from file1 to file2, after being sent #invert, it will represent the changes from file2 to file1. After inversion, calling #applyTo: on file2 will yield file1, rather than the other way around." |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
810 |
chunks do: [:entry | entry key: entry value value: entry key]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
811 |
snippets do: [:entry | entry key: entry value value: entry key]. |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
812 |
! ! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
813 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
814 |
!Diff2 class methodsFor:'documentation'! |
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
815 |
|
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
816 |
version_SVN |
12190
2a77dea2eceb
Improvements in Diff3CodeiView2 - now it highlights differences
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12182
diff
changeset
|
817 |
^ '$Id: Diff2.st 7936 2012-03-16 22:44:50Z vranyj1 $' |
12181
c6d6a0a83faa
Integrated Diff2 and Diff3 written by Tony Garnock-Jones
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff
changeset
|
818 |
! ! |