HistoryManager.st
author Claus Gittinger <cg@exept.de>
Fri, 15 Dec 1995 13:09:05 +0100
changeset 154 0478e111188d
parent 149 f7d66ab71259
child 178 daae23ef8c93
permissions -rw-r--r--
interest is written with one 'r' (shame on me)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46
claus
parents: 43
diff changeset
     1
"
claus
parents: 43
diff changeset
     2
 COPYRIGHT (c) 1995 by AEG Industry Automation
claus
parents: 43
diff changeset
     3
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents: 43
diff changeset
     4
	      All Rights Reserved
claus
parents: 43
diff changeset
     5
claus
parents: 43
diff changeset
     6
 This software is furnished under a license and may be used
claus
parents: 43
diff changeset
     7
 only in accordance with the terms of that license and with the
claus
parents: 43
diff changeset
     8
 inclusion of the above copyright notice.   This software may not
claus
parents: 43
diff changeset
     9
 be provided or otherwise made available to, or used by, any
claus
parents: 43
diff changeset
    10
 other person.  No title to or ownership of the software is
claus
parents: 43
diff changeset
    11
 hereby transferred.
claus
parents: 43
diff changeset
    12
"
claus
parents: 43
diff changeset
    13
120
950e4628d657 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 119
diff changeset
    14
Object subclass:#HistoryManager
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
    15
	instanceVariableNames:'historyMode'
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
    16
	classVariableNames:'TheOneAndOnlyInstance'
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
    17
	poolDictionaries:''
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
    18
	category:'System-Changes-History'
41
claus
parents:
diff changeset
    19
!
claus
parents:
diff changeset
    20
claus
parents:
diff changeset
    21
!HistoryManager class methodsFor:'documentation'!
claus
parents:
diff changeset
    22
46
claus
parents: 43
diff changeset
    23
copyright 
claus
parents: 43
diff changeset
    24
"
claus
parents: 43
diff changeset
    25
 COPYRIGHT (c) 1995 by AEG Industry Automation
claus
parents: 43
diff changeset
    26
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents: 43
diff changeset
    27
	      All Rights Reserved
claus
parents: 43
diff changeset
    28
claus
parents: 43
diff changeset
    29
 This software is furnished under a license and may be used
claus
parents: 43
diff changeset
    30
 only in accordance with the terms of that license and with the
claus
parents: 43
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
claus
parents: 43
diff changeset
    32
 be provided or otherwise made available to, or used by, any
claus
parents: 43
diff changeset
    33
 other person.  No title to or ownership of the software is
claus
parents: 43
diff changeset
    34
 hereby transferred.
claus
parents: 43
diff changeset
    35
"
claus
parents: 43
diff changeset
    36
!
claus
parents: 43
diff changeset
    37
41
claus
parents:
diff changeset
    38
documentation
claus
parents:
diff changeset
    39
"
claus
parents:
diff changeset
    40
    This class is part of the 
claus
parents:
diff changeset
    41
	       -----------------------
claus
parents:
diff changeset
    42
		HistoryManagerProject.
claus
parents:
diff changeset
    43
	       -----------------------
claus
parents:
diff changeset
    44
    It is used to create a multi user Smalltalk developers Environemt.
claus
parents:
diff changeset
    45
claus
parents:
diff changeset
    46
    All Methods and Classes in the system get a HistroyLine which contains a timestamp
claus
parents:
diff changeset
    47
    and the name of the Editor. This is acually the UniX loginname.
claus
parents:
diff changeset
    48
    The Manager registers all Classes in the System to get notifications on change.
claus
parents:
diff changeset
    49
46
claus
parents: 43
diff changeset
    50
    Author: Robert Sailer - AEG
41
claus
parents:
diff changeset
    51
"
claus
parents:
diff changeset
    52
!
claus
parents:
diff changeset
    53
claus
parents:
diff changeset
    54
examples
claus
parents:
diff changeset
    55
"
claus
parents:
diff changeset
    56
    HistoryManager new
claus
parents:
diff changeset
    57
"
claus
parents:
diff changeset
    58
    "Modified: 11.08.1995 / 16:50:47 / robert"
claus
parents:
diff changeset
    59
! !
claus
parents:
diff changeset
    60
claus
parents:
diff changeset
    61
!HistoryManager class methodsFor:'initialization'!
claus
parents:
diff changeset
    62
87
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
    63
initMe
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
    64
    "setup TheOneAndOnlyInstance (if not already present"
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
    65
    ^self new.
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
    66
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
    67
    "Modified: 14.08.1995 / 9:52:40 / robert"
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
    68
!
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
    69
41
claus
parents:
diff changeset
    70
initialize
claus
parents:
diff changeset
    71
    ""
claus
parents:
diff changeset
    72
    ObjectMemory addDependent: self.
claus
parents:
diff changeset
    73
claus
parents:
diff changeset
    74
    "Modified: 14.08.1995 / 9:49:56 / robert"
claus
parents:
diff changeset
    75
! !
claus
parents:
diff changeset
    76
claus
parents:
diff changeset
    77
!HistoryManager class methodsFor:'instance creation'!
claus
parents:
diff changeset
    78
claus
parents:
diff changeset
    79
new
46
claus
parents: 43
diff changeset
    80
    "because there can be only ONE HistoryManager, new must me redefiend"
41
claus
parents:
diff changeset
    81
claus
parents:
diff changeset
    82
    TheOneAndOnlyInstance isNil ifTrue:[
claus
parents:
diff changeset
    83
	TheOneAndOnlyInstance := super new initialize.
claus
parents:
diff changeset
    84
	HistoryLine initialize.
claus
parents:
diff changeset
    85
    ].
claus
parents:
diff changeset
    86
claus
parents:
diff changeset
    87
   ^ TheOneAndOnlyInstance
claus
parents:
diff changeset
    88
claus
parents:
diff changeset
    89
"
claus
parents:
diff changeset
    90
claus
parents:
diff changeset
    91
    HistoryManager new.
claus
parents:
diff changeset
    92
"
claus
parents:
diff changeset
    93
claus
parents:
diff changeset
    94
    "Modified: 11.08.1995 / 17:01:29 / robert"
claus
parents:
diff changeset
    95
! !
claus
parents:
diff changeset
    96
claus
parents:
diff changeset
    97
!HistoryManager class methodsFor:'accessing'!
claus
parents:
diff changeset
    98
claus
parents:
diff changeset
    99
instance
claus
parents:
diff changeset
   100
    "return the class variable"
claus
parents:
diff changeset
   101
claus
parents:
diff changeset
   102
    ^TheOneAndOnlyInstance
claus
parents:
diff changeset
   103
!
claus
parents:
diff changeset
   104
claus
parents:
diff changeset
   105
isActive 
claus
parents:
diff changeset
   106
    ^TheOneAndOnlyInstance notNil
claus
parents:
diff changeset
   107
claus
parents:
diff changeset
   108
    "Modified: 27.8.1995 / 00:32:12 / claus"
claus
parents:
diff changeset
   109
! !
claus
parents:
diff changeset
   110
claus
parents:
diff changeset
   111
!HistoryManager class methodsFor:'activation / deactivation'!
claus
parents:
diff changeset
   112
claus
parents:
diff changeset
   113
activate
claus
parents:
diff changeset
   114
    self new   "/ creating an instance activates me
claus
parents:
diff changeset
   115
!
claus
parents:
diff changeset
   116
claus
parents:
diff changeset
   117
deactivate
claus
parents:
diff changeset
   118
    Smalltalk allClassesDo:[:aClass |
claus
parents:
diff changeset
   119
	aClass removeDependent:TheOneAndOnlyInstance.
claus
parents:
diff changeset
   120
	aClass class removeDependent:TheOneAndOnlyInstance.
claus
parents:
diff changeset
   121
    ].
claus
parents:
diff changeset
   122
    TheOneAndOnlyInstance := nil.
claus
parents:
diff changeset
   123
claus
parents:
diff changeset
   124
"
claus
parents:
diff changeset
   125
    HistoryManager release
claus
parents:
diff changeset
   126
"
claus
parents:
diff changeset
   127
! !
claus
parents:
diff changeset
   128
87
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   129
!HistoryManager class methodsFor:'change and update'!
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   130
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   131
update: what
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   132
    (what == #restarted) ifTrue:[
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   133
	TheOneAndOnlyInstance notNil ifTrue:[
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   134
	    "
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   135
	     smalltalk is about to restart from an Image -
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   136
	    "
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   137
"/            'HistoryManager initialize (via update)' infoPrintNL.
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   138
	    self initMe.
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   139
	]
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   140
    ].
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   141
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   142
    "Modified: 27.8.1995 / 16:33:02 / claus"
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   143
! !
e0f5b58481a6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 82
diff changeset
   144
47
claus
parents: 46
diff changeset
   145
!HistoryManager class methodsFor:'helpers'!
claus
parents: 46
diff changeset
   146
claus
parents: 46
diff changeset
   147
getAllHistoriesFrom:someString
claus
parents: 46
diff changeset
   148
    "returns anArray of HistoryLines"
claus
parents: 46
diff changeset
   149
claus
parents: 46
diff changeset
   150
    |position aReadWriteStream firstFound nextFound  aHistoryString rcOC h|
claus
parents: 46
diff changeset
   151
claus
parents: 46
diff changeset
   152
    "read begining from the end and look there for the first comment character. If there's none return"
claus
parents: 46
diff changeset
   153
claus
parents: 46
diff changeset
   154
    rcOC := OrderedCollection new.
claus
parents: 46
diff changeset
   155
    position := someString size.
claus
parents: 46
diff changeset
   156
    firstFound := false.
claus
parents: 46
diff changeset
   157
    nextFound := false.
claus
parents: 46
diff changeset
   158
claus
parents: 46
diff changeset
   159
    someString reverseDo:[ :aChar|
claus
parents: 46
diff changeset
   160
	position := position - 1.
claus
parents: 46
diff changeset
   161
	aChar = $" ifTrue:[
claus
parents: 46
diff changeset
   162
	    firstFound ifTrue:[
claus
parents: 46
diff changeset
   163
		firstFound := false.
claus
parents: 46
diff changeset
   164
		nextFound := true.
claus
parents: 46
diff changeset
   165
	    ] ifFalse:[
claus
parents: 46
diff changeset
   166
		aReadWriteStream := ReadWriteStream on: String new.
claus
parents: 46
diff changeset
   167
		firstFound := true.
claus
parents: 46
diff changeset
   168
		nextFound := false.
claus
parents: 46
diff changeset
   169
	    ].
claus
parents: 46
diff changeset
   170
	].
claus
parents: 46
diff changeset
   171
	(firstFound and: [nextFound not]) ifTrue:[
claus
parents: 46
diff changeset
   172
	    "now collect all up to the next comment character"
claus
parents: 46
diff changeset
   173
	    aChar = $" ifFalse:[     
claus
parents: 46
diff changeset
   174
		aReadWriteStream nextPut: aChar.
claus
parents: 46
diff changeset
   175
	    ].
claus
parents: 46
diff changeset
   176
	].
claus
parents: 46
diff changeset
   177
	nextFound ifTrue:[
claus
parents: 46
diff changeset
   178
	    "End reached - now try to make a HistoryLine"
claus
parents: 46
diff changeset
   179
	    aHistoryString := (aReadWriteStream contents) reverse.
claus
parents: 46
diff changeset
   180
	    "
claus
parents: 46
diff changeset
   181
		Transcript showCr: aHistoryString.
claus
parents: 46
diff changeset
   182
	    "
claus
parents: 46
diff changeset
   183
	    h := HistoryLine fromString: aHistoryString at: position.
claus
parents: 46
diff changeset
   184
	    h notNil ifTrue:[
claus
parents: 46
diff changeset
   185
		rcOC add:h.
claus
parents: 46
diff changeset
   186
	    ].
claus
parents: 46
diff changeset
   187
"/            (aHistoryString startsWith: 'Modified:') ifTrue:[
claus
parents: 46
diff changeset
   188
"/                "a history line was found - now make a NewInstance of HistoryLine"
claus
parents: 46
diff changeset
   189
"/                rcOC add: ( HistoryLine fromString: aHistoryString at: position).
claus
parents: 46
diff changeset
   190
"/            ].
claus
parents: 46
diff changeset
   191
	    nextFound := false.
claus
parents: 46
diff changeset
   192
	].
claus
parents: 46
diff changeset
   193
    ].
claus
parents: 46
diff changeset
   194
claus
parents: 46
diff changeset
   195
    ^rcOC reverse  "the OrderedCollection with HistoryLines in the right order"
claus
parents: 46
diff changeset
   196
claus
parents: 46
diff changeset
   197
    "Modified: 21.12.1993 / 18:32:30 / M.Noell"
claus
parents: 46
diff changeset
   198
    "Modified: 9.8.1995 / 22:45:30 / R.Sailer"
claus
parents: 46
diff changeset
   199
    "Modified: 8.9.1995 / 17:54:33 / claus"
claus
parents: 46
diff changeset
   200
! !
claus
parents: 46
diff changeset
   201
41
claus
parents:
diff changeset
   202
!HistoryManager methodsFor:'accessing'!
claus
parents:
diff changeset
   203
claus
parents:
diff changeset
   204
historyMode
claus
parents:
diff changeset
   205
    "return historyMode"
claus
parents:
diff changeset
   206
claus
parents:
diff changeset
   207
    ^ historyMode
claus
parents:
diff changeset
   208
claus
parents:
diff changeset
   209
    "Modified: 11.08.1995 / 16:51:56 / robert"
claus
parents:
diff changeset
   210
!
claus
parents:
diff changeset
   211
claus
parents:
diff changeset
   212
historyMode:something
claus
parents:
diff changeset
   213
    "set historyMode"
claus
parents:
diff changeset
   214
claus
parents:
diff changeset
   215
    historyMode := something.
claus
parents:
diff changeset
   216
claus
parents:
diff changeset
   217
    "Modified: 11.08.1995 / 16:52:12 / robert"
claus
parents:
diff changeset
   218
! !
claus
parents:
diff changeset
   219
claus
parents:
diff changeset
   220
!HistoryManager methodsFor:'initialization'!
claus
parents:
diff changeset
   221
claus
parents:
diff changeset
   222
exclude
46
claus
parents: 43
diff changeset
   223
    "public - return an exclusionlist for some smalltalk classes which should not be notified or historisized"
41
claus
parents:
diff changeset
   224
claus
parents:
diff changeset
   225
    | oc |
claus
parents:
diff changeset
   226
        
claus
parents:
diff changeset
   227
    oc := OrderedCollection new.
claus
parents:
diff changeset
   228
    oc add: self.
claus
parents:
diff changeset
   229
claus
parents:
diff changeset
   230
    ^oc
claus
parents:
diff changeset
   231
claus
parents:
diff changeset
   232
    "Modified: 11.08.1995 / 17:02:18 / robert"
claus
parents:
diff changeset
   233
!
claus
parents:
diff changeset
   234
claus
parents:
diff changeset
   235
initialize
46
claus
parents: 43
diff changeset
   236
    "public - make me depend on all smalltalk classes (except the exclusionList)
claus
parents: 43
diff changeset
   237
     to be notified later about changes. This intercepts source installation and allows
claus
parents: 43
diff changeset
   238
     be to patch the source-string with a historyLine."
41
claus
parents:
diff changeset
   239
53
claus
parents: 48
diff changeset
   240
    |exclusionlist|
41
claus
parents:
diff changeset
   241
claus
parents:
diff changeset
   242
    super initialize.
claus
parents:
diff changeset
   243
    historyMode := true.
claus
parents:
diff changeset
   244
    exclusionlist := self exclude.
claus
parents:
diff changeset
   245
claus
parents:
diff changeset
   246
    Smalltalk allClasses do:[:aClass|
claus
parents:
diff changeset
   247
	"all classes should send a notification if changed"
claus
parents:
diff changeset
   248
	"aClass = self " false ifFalse: [
claus
parents:
diff changeset
   249
	    (exclusionlist includes: aClass) ifFalse:[
claus
parents:
diff changeset
   250
		aClass addDependent: self.
claus
parents:
diff changeset
   251
		aClass class addDependent: self.   "for class methods"
claus
parents:
diff changeset
   252
	    ].
claus
parents:
diff changeset
   253
	].
claus
parents:
diff changeset
   254
    ].
claus
parents:
diff changeset
   255
claus
parents:
diff changeset
   256
    ^self
claus
parents:
diff changeset
   257
claus
parents:
diff changeset
   258
    "Modified: 11.08.1995 / 17:12:51 / robert"
claus
parents:
diff changeset
   259
! !
claus
parents:
diff changeset
   260
claus
parents:
diff changeset
   261
!HistoryManager methodsFor:'updateHistory'!
claus
parents:
diff changeset
   262
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   263
addHistoryTo:someString forceModification:forceModification forceCreation:forceCreation
41
claus
parents:
diff changeset
   264
    "private - add a historyLine at end to the sourceCode;
140
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   265
     check for multiple lines of the same user and merge into one.
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   266
     If forceModification is true or a history already exists in someString,
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   267
     add a 'Modified' line; otherwise, add a 'Created' line."
41
claus
parents:
diff changeset
   268
53
claus
parents: 48
diff changeset
   269
    | histLines pos wStream sourceCode previousHistories
47
claus
parents: 46
diff changeset
   270
      newLine |
41
claus
parents:
diff changeset
   271
53
claus
parents: 48
diff changeset
   272
    "Check whether we want a history to be added"    
claus
parents: 48
diff changeset
   273
    historyMode ifFalse:[
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   274
        ^ someString
53
claus
parents: 48
diff changeset
   275
    ].
47
claus
parents: 46
diff changeset
   276
    previousHistories := self class getAllHistoriesFrom:someString.
41
claus
parents:
diff changeset
   277
claus
parents:
diff changeset
   278
    "extract source body."
claus
parents:
diff changeset
   279
    previousHistories isEmpty ifTrue: [
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   280
        sourceCode := someString withoutSeparators.
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   281
        forceModification ifTrue:[
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   282
            newLine := (HistoryLine new)
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   283
        ] ifFalse:[
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   284
            newLine := (HistoryLine newCreated).
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   285
        ]
41
claus
parents:
diff changeset
   286
    ] ifFalse: [
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   287
        pos := (previousHistories first) firstPositionInSourceCode.
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   288
        sourceCode := (someString copyFrom: 1 to: pos - 1) withoutSeparators.
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   289
        forceCreation ifTrue:[
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   290
            newLine := (HistoryLine newCreated).
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   291
        ] ifFalse:[
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   292
            newLine := (HistoryLine new)
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   293
        ]
41
claus
parents:
diff changeset
   294
    ].
claus
parents:
diff changeset
   295
claus
parents:
diff changeset
   296
    "add the actual user's historyLine."
47
claus
parents: 46
diff changeset
   297
    previousHistories add:newLine.
41
claus
parents:
diff changeset
   298
140
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   299
    "Filtering historyLines (each user with one entry)."
41
claus
parents:
diff changeset
   300
    histLines := HistoryLine filterHistoryLines: previousHistories.
claus
parents:
diff changeset
   301
claus
parents:
diff changeset
   302
    "create new body with added historyLine"
claus
parents:
diff changeset
   303
    wStream := WriteStream on: String new.
claus
parents:
diff changeset
   304
    wStream nextPutAll: sourceCode; cr.
claus
parents:
diff changeset
   305
claus
parents:
diff changeset
   306
    "append the historyLines to the source"
claus
parents:
diff changeset
   307
    wStream cr.
claus
parents:
diff changeset
   308
    histLines do: [:hl |
140
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   309
       wStream nextPutAll:hl printString; cr.
41
claus
parents:
diff changeset
   310
    ].
claus
parents:
diff changeset
   311
claus
parents:
diff changeset
   312
    ^wStream contents.
claus
parents:
diff changeset
   313
47
claus
parents: 46
diff changeset
   314
    "Modified: 11.8.1995 / 16:51:50 / robert"
claus
parents: 46
diff changeset
   315
    "Modified: 8.9.1995 / 17:55:38 / claus"
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   316
    "Modified: 13.12.1995 / 14:07:03 / cg"
41
claus
parents:
diff changeset
   317
!
claus
parents:
diff changeset
   318
53
claus
parents: 48
diff changeset
   319
addHistoryToHistoryMethodOf:aClass
claus
parents: 48
diff changeset
   320
    |cls historyMethod oldSource newSource|
claus
parents: 48
diff changeset
   321
claus
parents: 48
diff changeset
   322
    aClass isMeta ifFalse:[
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   323
        cls := aClass class.
53
claus
parents: 48
diff changeset
   324
    ] ifTrue:[
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   325
        cls := aClass
53
claus
parents: 48
diff changeset
   326
    ].
claus
parents: 48
diff changeset
   327
    historyMethod := cls compiledMethodAt: #history.
claus
parents: 48
diff changeset
   328
    historyMethod notNil ifTrue:[
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   329
        oldSource := historyMethod source.
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   330
        oldSource notNil ifTrue:[
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   331
            newSource := self addHistoryTo:oldSource forceModification:false forceCreation:false.
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   332
            historyMethod source:newSource.
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   333
        ]
53
claus
parents: 48
diff changeset
   334
    ]
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   335
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   336
    "Modified: 13.12.1995 / 14:05:30 / cg"
53
claus
parents: 48
diff changeset
   337
!
claus
parents: 48
diff changeset
   338
140
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   339
update:something with:someArgument from:changedObject
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   340
    "arrive here, whenever any class changed somehow.
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   341
     (something contains aSymbol describing what happened)"
41
claus
parents:
diff changeset
   342
140
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   343
    | sourceCode newMethod fileInOrRecompiling ignore selector oldMethod|
41
claus
parents:
diff changeset
   344
claus
parents:
diff changeset
   345
"/    changedObject == self ifTrue:[  "for development only"
claus
parents:
diff changeset
   346
"/        self halt.
claus
parents:
diff changeset
   347
"/        ^self.
claus
parents:
diff changeset
   348
"/    ].
46
claus
parents: 43
diff changeset
   349
140
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   350
    fileInOrRecompiling := Class updateChangeFileQuerySignal raise.
41
claus
parents:
diff changeset
   351
53
claus
parents: 48
diff changeset
   352
"/    changedObject isMeta ifTrue:[
43
claus
parents: 42
diff changeset
   353
"/        Transcript showCr: 'metaClass = ',  changedObject printString.
53
claus
parents: 48
diff changeset
   354
"/    ].
41
claus
parents:
diff changeset
   355
claus
parents:
diff changeset
   356
    fileInOrRecompiling ifFalse:[ 
42
claus
parents: 41
diff changeset
   357
"/        Transcript showCr: '* noChange in history'. 
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   358
        ^ self 
53
claus
parents: 48
diff changeset
   359
    ].
claus
parents: 48
diff changeset
   360
    historyMode ifFalse:[
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   361
        ^ self
41
claus
parents:
diff changeset
   362
    ].
claus
parents:
diff changeset
   363
claus
parents:
diff changeset
   364
    "
claus
parents:
diff changeset
   365
    Class Variables
claus
parents:
diff changeset
   366
    "
claus
parents:
diff changeset
   367
    (something == #definition) ifTrue:[
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   368
        "add handling for classes here ..."        
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   369
        "/ self addHistoryToHistoryMethodOf:changedObject.
41
claus
parents:
diff changeset
   370
    ].
claus
parents:
diff changeset
   371
claus
parents:
diff changeset
   372
    "this is a sub item of #definition"    
claus
parents:
diff changeset
   373
    (something == #classVariables) ifTrue:[
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   374
        "
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   375
        Transcript showCr: 'classVariables changed'.
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   376
        "
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   377
        "/ does not yet work;
154
0478e111188d interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
   378
        "/ (someArgument does not contain the class we are interested in)
140
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   379
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   380
        self addHistoryToHistoryMethodOf:changedObject.
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   381
        ^ self
41
claus
parents:
diff changeset
   382
    ].    
claus
parents:
diff changeset
   383
claus
parents:
diff changeset
   384
    "
140
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   385
     new Class creation
41
claus
parents:
diff changeset
   386
    "
140
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   387
    ((changedObject == Smalltalk) and:[something == #newClass]) ifTrue:[
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   388
        "/ 
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   389
        "/  add myself as dependents in order to get future change notifications
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   390
        "/ 
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   391
        someArgument addDependent: self.
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   392
        someArgument class addDependent: self.   "for class methods"
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   393
        someArgument history:(self addHistoryTo:String new forceModification:false forceCreation:false).  "append historyString for new class"
41
claus
parents:
diff changeset
   394
    ].
claus
parents:
diff changeset
   395
claus
parents:
diff changeset
   396
    "
140
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   397
     changed methods
41
claus
parents:
diff changeset
   398
    "
claus
parents:
diff changeset
   399
    changedObject isBehavior ifTrue:[
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   400
        something = #methodDictionary ifTrue:[
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   401
            someArgument isArray ifTrue:[
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   402
                selector := someArgument at:1.
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   403
                oldMethod := someArgument at:2
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   404
            ] ifFalse:[
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   405
                selector := someArgument
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   406
            ].
140
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   407
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   408
            "/
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   409
            "/ fetch sourceString of the method
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   410
            "/
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   411
            sourceCode := changedObject sourceCodeAt:selector.
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   412
            sourceCode isNil ifTrue:[
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   413
                "method has been deleted"
43
claus
parents: 42
diff changeset
   414
"/                Transcript showCr: 'method has been deleted'.
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   415
            ] ifFalse:[
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   416
                newMethod := changedObject compiledMethodAt:selector.
140
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   417
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   418
                oldMethod notNil ifTrue:[
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   419
                    (oldMethod source asString withTabsExpanded = sourceCode asString withTabsExpanded) ifTrue:[
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   420
                         "/ no change (accepted same code again ?)
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   421
                        ^ self
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   422
                    ].
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   423
                ].
140
8c22b3cf100d changed methods which had no history get a Modified string (instead of Created)
Claus Gittinger <cg@exept.de>
parents: 120
diff changeset
   424
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   425
                "/
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   426
                "/ dont add historylines to documentation methods ...
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   427
                "/
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   428
                (changedObject isMeta not
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   429
                or:[newMethod category ~= 'documentation']) ifTrue:[
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   430
                    sourceCode := self addHistoryTo:sourceCode forceModification:(oldMethod notNil) forceCreation:(oldMethod isNil).
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   431
                    newMethod source: sourceCode.
43
claus
parents: 42
diff changeset
   432
"/                Transcript showCr: 'history updated / added'.
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   433
                ]
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   434
            ].
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   435
            ^self
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   436
        ]. 
41
claus
parents:
diff changeset
   437
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   438
        something == #comment ifTrue:[
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   439
            "in someArgument steht jetzt der alte kommentar"
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   440
            ^ self.
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   441
        ] ifFalse:[
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   442
            "it is a class definition"
43
claus
parents: 42
diff changeset
   443
"/            Transcript show: 'Class definition: ', changedObject printString;cr.
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   444
            self addHistoryToHistoryMethodOf:changedObject.
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   445
        ].
41
claus
parents:
diff changeset
   446
    ].
claus
parents:
diff changeset
   447
claus
parents:
diff changeset
   448
    ^self
claus
parents:
diff changeset
   449
43
claus
parents: 42
diff changeset
   450
    "Modified: 27.8.1995 / 02:14:43 / claus"
149
f7d66ab71259 filter out previous Created line after a copy (get 2 of them after copyCategory in browser)
Claus Gittinger <cg@exept.de>
parents: 142
diff changeset
   451
    "Modified: 13.12.1995 / 14:06:20 / cg"
41
claus
parents:
diff changeset
   452
! !
claus
parents:
diff changeset
   453
119
1a9c5a761edf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 87
diff changeset
   454
!HistoryManager class methodsFor:'documentation'!
1a9c5a761edf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 87
diff changeset
   455
1a9c5a761edf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 87
diff changeset
   456
version
154
0478e111188d interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 149
diff changeset
   457
    ^ '$Header: /cvs/stx/stx/libbasic3/HistoryManager.st,v 1.18 1995-12-15 12:09:05 cg Exp $'
119
1a9c5a761edf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 87
diff changeset
   458
! !
41
claus
parents:
diff changeset
   459
HistoryManager initialize!