46
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
MCMerger subclass:#MCThreeWayMerger
|
|
4 |
instanceVariableNames:'index operations provisions redundantAdds'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
690
|
7 |
category:'SCM-Monticello-Merging'
|
46
|
8 |
!
|
|
9 |
|
|
10 |
|
239
|
11 |
!MCThreeWayMerger class methodsFor:'initialization'!
|
|
12 |
|
|
13 |
new
|
|
14 |
^self basicNew initialize
|
|
15 |
! !
|
|
16 |
|
46
|
17 |
!MCThreeWayMerger class methodsFor:'as yet unclassified'!
|
|
18 |
|
|
19 |
base: aSnapshot patch: aPatch
|
|
20 |
aPatch isEmpty ifTrue: [MCNoChangesException signal].
|
|
21 |
^ self new
|
|
22 |
addBaseSnapshot: aSnapshot;
|
|
23 |
applyPatch: aPatch;
|
|
24 |
yourself
|
|
25 |
|
|
26 |
!
|
|
27 |
|
|
28 |
base: aSnapshot target: targetSnapshot ancestor: ancestorSnapshot
|
|
29 |
^ self base: aSnapshot patch: (targetSnapshot patchRelativeToBase: ancestorSnapshot)
|
|
30 |
! !
|
|
31 |
|
|
32 |
!MCThreeWayMerger methodsFor:'as yet unclassified'!
|
|
33 |
|
|
34 |
addBaseSnapshot: aSnapshot
|
|
35 |
aSnapshot definitions do:
|
|
36 |
[:ea |
|
|
37 |
index add: ea.
|
|
38 |
provisions addAll: ea provisions]
|
|
39 |
!
|
|
40 |
|
|
41 |
addDefinition: aDefinition
|
239
|
42 |
|
|
43 |
| op |
|
|
44 |
|
|
45 |
index
|
|
46 |
definitionLike: aDefinition
|
|
47 |
ifPresent: [:other |
|
|
48 |
(op := (self removalForDefinition: aDefinition))
|
|
49 |
ifNotNil:
|
|
50 |
[
|
|
51 |
self addOperation: (MCModification of: other to: aDefinition).
|
|
52 |
self removeOperation: op.
|
|
53 |
^ self].
|
|
54 |
other = aDefinition
|
|
55 |
ifFalse: [self addConflictWithOperation: (MCModification of: other to: aDefinition)]
|
|
56 |
ifTrue: [self redundantAdds add: aDefinition]]
|
|
57 |
ifAbsent: [self addOperation: (MCAddition of: aDefinition)]
|
|
58 |
|
|
59 |
"Modified: / 12-09-2010 / 17:39:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
46
|
60 |
!
|
|
61 |
|
|
62 |
addOperation: anOperation
|
|
63 |
self operations add: anOperation
|
|
64 |
!
|
|
65 |
|
|
66 |
applyPatch: aPatch
|
|
67 |
aPatch applyTo: self
|
|
68 |
!
|
|
69 |
|
|
70 |
applyTo: anObject
|
|
71 |
super applyTo: anObject.
|
|
72 |
self operations do: [:ea | ea applyTo: anObject]
|
|
73 |
!
|
|
74 |
|
|
75 |
baseSnapshot
|
|
76 |
^ (MCSnapshot fromDefinitions: index definitions)
|
|
77 |
!
|
|
78 |
|
|
79 |
initialize
|
239
|
80 |
super initialize.
|
|
81 |
index := MCDefinitionIndex new.
|
|
82 |
provisions := Set new
|
46
|
83 |
!
|
|
84 |
|
|
85 |
modificationConflictForDefinition: aDefinition
|
|
86 |
^ conflicts ifNotNil:
|
|
87 |
[conflicts detect:
|
|
88 |
[:ea | (ea definition isRevisionOf: aDefinition) and:
|
|
89 |
[ea operation isModification]] ifNone: []]
|
|
90 |
!
|
|
91 |
|
|
92 |
modifyDefinition: baseDefinition to: targetDefinition
|
|
93 |
index
|
|
94 |
definitionLike: baseDefinition
|
|
95 |
ifPresent: [:other | other = baseDefinition
|
|
96 |
ifTrue: [self addOperation: (MCModification of: baseDefinition to: targetDefinition)]
|
|
97 |
ifFalse: [other = targetDefinition
|
|
98 |
ifFalse: [self addConflictWithOperation:
|
|
99 |
(MCModification of: other to: targetDefinition)]]]
|
|
100 |
ifAbsent: [self addConflictWithOperation: (MCAddition of: targetDefinition)]
|
|
101 |
!
|
|
102 |
|
|
103 |
operations
|
239
|
104 |
^ operations ifNil: [operations := OrderedCollection new]
|
46
|
105 |
!
|
|
106 |
|
|
107 |
provisions
|
|
108 |
^ provisions
|
|
109 |
!
|
|
110 |
|
|
111 |
redundantAdds
|
239
|
112 |
^ redundantAdds ifNil: [redundantAdds := Set new]
|
46
|
113 |
!
|
|
114 |
|
|
115 |
removalForDefinition: aDefinition
|
|
116 |
^ operations ifNotNil:
|
|
117 |
[operations
|
|
118 |
detect: [:ea | (ea definition isRevisionOf: aDefinition) and: [ea isRemoval]]
|
|
119 |
ifNone: []]
|
|
120 |
!
|
|
121 |
|
|
122 |
removeConflict: aConflict
|
|
123 |
conflicts remove: aConflict
|
|
124 |
!
|
|
125 |
|
|
126 |
removeDefinition: aDefinition
|
|
127 |
index
|
|
128 |
definitionLike: aDefinition
|
239
|
129 |
ifPresent: [:other | | c | other = aDefinition
|
46
|
130 |
ifTrue:
|
239
|
131 |
[(c := self modificationConflictForDefinition: aDefinition)
|
|
132 |
ifNotNil:
|
|
133 |
[
|
46
|
134 |
self addOperation: c operation.
|
|
135 |
self removeConflict: c.
|
|
136 |
^ self].
|
|
137 |
(self redundantAdds includes: aDefinition)
|
|
138 |
ifFalse: [self addOperation: (MCRemoval of: aDefinition)]]
|
|
139 |
ifFalse:
|
|
140 |
[self addConflictWithOperation: (MCRemoval of: other)]]
|
|
141 |
ifAbsent: []
|
|
142 |
!
|
|
143 |
|
|
144 |
removeOperation: anOperation
|
|
145 |
operations remove: anOperation
|
|
146 |
! !
|
|
147 |
|
|
148 |
!MCThreeWayMerger class methodsFor:'documentation'!
|
|
149 |
|
|
150 |
version
|
690
|
151 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCThreeWayMerger.st,v 1.4 2012-09-11 21:29:38 cg Exp $'
|
239
|
152 |
!
|
|
153 |
|
|
154 |
version_CVS
|
690
|
155 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCThreeWayMerger.st,v 1.4 2012-09-11 21:29:38 cg Exp $'
|
239
|
156 |
!
|
|
157 |
|
|
158 |
version_SVN
|
|
159 |
^ '§Id: MCThreeWayMerger.st 17 2010-10-13 12:07:52Z vranyj1 §'
|
46
|
160 |
! !
|