1
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
Object subclass:#MCAncestry
|
|
4 |
instanceVariableNames:'ancestors stepChildren'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
609
|
7 |
category:'SCM-Monticello-Versioning'
|
1
|
8 |
!
|
|
9 |
|
|
10 |
MCAncestry comment:'Abstract superclass of records of ancestry.'
|
|
11 |
!
|
|
12 |
|
|
13 |
|
|
14 |
!MCAncestry class methodsFor:'as yet unclassified'!
|
|
15 |
|
|
16 |
new
|
|
17 |
^ self basicNew initialize
|
|
18 |
! !
|
|
19 |
|
|
20 |
!MCAncestry methodsFor:'ancestry'!
|
|
21 |
|
|
22 |
allAncestorsDo: aBlock
|
|
23 |
self ancestors do:
|
|
24 |
[:ea |
|
|
25 |
aBlock value: ea.
|
|
26 |
ea allAncestorsDo: aBlock]
|
|
27 |
!
|
|
28 |
|
|
29 |
allAncestorsOnPathTo: aVersionInfo
|
|
30 |
^ MCFilteredVersionSorter new
|
|
31 |
target: aVersionInfo;
|
|
32 |
addAllVersionInfos: self ancestors;
|
|
33 |
sortedVersionInfos
|
|
34 |
!
|
|
35 |
|
|
36 |
ancestorString
|
|
37 |
^ String streamContents:
|
|
38 |
[:s | self ancestors do: [:ea | s nextPutAll: ea name] separatedBy: [s nextPutAll: ', ']]
|
|
39 |
!
|
|
40 |
|
|
41 |
ancestors
|
|
42 |
^ ancestors ifNil: [#()]
|
|
43 |
!
|
|
44 |
|
|
45 |
ancestorsDoWhileTrue: aBlock
|
|
46 |
self ancestors do:
|
|
47 |
[:ea |
|
|
48 |
(aBlock value: ea) ifTrue:
|
|
49 |
[ea ancestorsDoWhileTrue: aBlock]]
|
|
50 |
!
|
|
51 |
|
|
52 |
breadthFirstAncestors
|
|
53 |
^ Array streamContents: [:s | self breadthFirstAncestorsDo: [:ea | s nextPut: ea]]
|
|
54 |
!
|
|
55 |
|
|
56 |
breadthFirstAncestorsDo: aBlock
|
|
57 |
| seen todo next |
|
|
58 |
seen _ Set with: self.
|
|
59 |
todo _ OrderedCollection with: self.
|
|
60 |
[todo isEmpty] whileFalse:
|
|
61 |
[next _ todo removeFirst.
|
|
62 |
next ancestors do:
|
|
63 |
[:ea |
|
|
64 |
(seen includes: ea) ifFalse:
|
|
65 |
[aBlock value: ea.
|
|
66 |
seen add: ea.
|
|
67 |
todo add: ea]]]
|
|
68 |
!
|
|
69 |
|
|
70 |
commonAncestorWith: aNode
|
|
71 |
| commonAncestors |
|
|
72 |
commonAncestors _ self commonAncestorsWith: aNode.
|
|
73 |
^ commonAncestors at: 1 ifAbsent: [nil]
|
|
74 |
!
|
|
75 |
|
|
76 |
commonAncestorsWith: aVersionInfo
|
|
77 |
|
|
78 |
| sharedAncestors mergedOrder sorter |
|
|
79 |
sorter _ MCVersionSorter new
|
|
80 |
addVersionInfo: self;
|
|
81 |
addVersionInfo: aVersionInfo.
|
|
82 |
mergedOrder _ sorter sortedVersionInfos.
|
|
83 |
sharedAncestors _ (sorter allAncestorsOf: self) intersection: (sorter allAncestorsOf: aVersionInfo).
|
|
84 |
^ mergedOrder select: [:ea | sharedAncestors includes: ea]
|
|
85 |
!
|
|
86 |
|
|
87 |
hasAncestor: aVersionInfo
|
|
88 |
^ self
|
|
89 |
hasAncestor: aVersionInfo
|
|
90 |
alreadySeen: OrderedCollection new
|
|
91 |
!
|
|
92 |
|
|
93 |
hasAncestor: aVersionInfo alreadySeen: aList
|
|
94 |
(aList includes: self) ifTrue: [^ false].
|
|
95 |
aList add: self.
|
|
96 |
|
|
97 |
^ self = aVersionInfo or: [self ancestors anySatisfy: [:ea | ea hasAncestor: aVersionInfo alreadySeen: aList]]
|
|
98 |
!
|
|
99 |
|
|
100 |
isRelatedTo: aVersionInfo
|
|
101 |
^ aVersionInfo timeStamp < self timeStamp
|
|
102 |
ifTrue: [self hasAncestor: aVersionInfo]
|
|
103 |
ifFalse: [aVersionInfo hasAncestor: self]
|
|
104 |
!
|
|
105 |
|
|
106 |
stepChildren
|
|
107 |
^ stepChildren ifNil: [#()]
|
|
108 |
!
|
|
109 |
|
|
110 |
stepChildrenString
|
|
111 |
^ String streamContents:
|
|
112 |
[:s | self stepChildren do: [:ea | s nextPutAll: ea name] separatedBy: [s nextPutAll: ', ']]
|
|
113 |
!
|
|
114 |
|
|
115 |
topologicalAncestors
|
|
116 |
| frontier f |
|
|
117 |
^ Array streamContents:
|
|
118 |
[:s |
|
|
119 |
frontier _ MCFrontier frontierOn: self.
|
|
120 |
[f _ frontier frontier.
|
|
121 |
s nextPutAll: f.
|
|
122 |
frontier removeAll: f.
|
|
123 |
f isEmpty] whileFalse]
|
|
124 |
!
|
|
125 |
|
|
126 |
trimAfterVersionInfo: aVersionInfo
|
|
127 |
aVersionInfo = self
|
|
128 |
ifTrue: [ancestors _ #()]
|
|
129 |
ifFalse:
|
|
130 |
[aVersionInfo date <= self date ifTrue:
|
|
131 |
[ancestors do: [:ea | ea trimAfterVersionInfo: aVersionInfo]]
|
|
132 |
]
|
|
133 |
!
|
|
134 |
|
|
135 |
withBreadthFirstAncestors
|
|
136 |
^ (Array with: self), self breadthFirstAncestors
|
|
137 |
! !
|
|
138 |
|
|
139 |
!MCAncestry methodsFor:'initializing'!
|
|
140 |
|
|
141 |
initialize
|
|
142 |
ancestors _ #().
|
|
143 |
stepChildren _ #()
|
|
144 |
! !
|
|
145 |
|
|
146 |
!MCAncestry class methodsFor:'documentation'!
|
|
147 |
|
|
148 |
version
|
609
|
149 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCAncestry.st,v 1.2 2012-09-11 21:20:19 cg Exp $'
|
1
|
150 |
! !
|