Edit Rename Changes History Upload Download Back to Top

Store13 Commentary

13. Reverse search through the changes file. For example, you get a bad crash and haven't backed up your image or done fileouts for hours. It takes forever for VisualWorks to parse its way through the changes file before you can work with it. Ours run over 30 MB. If reverse search is too hard, at least provide an accelerated forward search in which you pass over everything prior to the last snapshot, or the last N snapshots. In other words, don't parse the first 29 MB if you're only interested in the last 1 MB.

Alan Knight--Good idea. Reverse search prior to the last snapshot is there already, it's called "Recover last changes". It only does one snapshot, though, and I've often wished for it to do N.

Steven Kelly--I've been making this change since VW 2.0 - when you choose "Recover last changes" it asks for (roughly) how many snapshots to look back, then shows a list of that many along with their dates and the position in the changes file. You choose one, and the changes since then are brought into the changes list. The code for 5i.3 is below.

Kernel.SourceFileManager class, utilities

findComment: aString in: aStream
	"Return the position in the stream of the end of the last occurrence of aString (presumably a snapshot message)"
	| firstChar endPosition position count index lastEnd str fmt snapshots lastEnds |
	fmt := SourceFileFormat formatForStream: aStream.
	str := fmt createMarkerString: aString.
	snapshots := (Dialog request: 'How far back do you want to look' initialAnswer: '3') asNumber.
	snapshots isInteger ifFalse: [snapshots := 1].
	firstChar := str first.
	aStream setToEnd.
	position := aStream position.
	lastEnds := SortedCollection new.
	lastEnd := nil.
	[endPosition := position.
	lastEnds size < snapshots and: [(position := endPosition - 5000 max: 0) < endPosition]]
		whileTrue:
			[aStream position: position.
			count := endPosition - position.
			[count > 0]
				whileTrue:
					[count := count - 1.
					aStream next = firstChar
						ifTrue:
							[index := 2.
							[index <= str size and: [(str at: index) = aStream next]]
								whileTrue: [index := index + 1].
							index > str size
								ifTrue: [lastEnd := aStream position. lastEnds add: lastEnd->(aStream next; nextChunk). aStream position: lastEnd]
								ifFalse: [aStream position: endPosition - count]]]].
	^(Dialog choose: 'Which position?' fromList: (lastEnds collect: [:x | x printString]) values: lastEnds lines: 10 cancel: [lastEnds last]) key


Edit Rename Changes History Upload Download Back to Top