[squeak-dev] The Inbox: Monticello-mt.633.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu May 12 16:07:42 UTC 2016
Marcel Taeumel uploaded a new version of Monticello to project The Inbox:
http://source.squeak.org/inbox/Monticello-mt.633.mcz
==================== Summary ====================
Name: Monticello-mt.633
Author: mt
Time: 12 May 2016, 6:07:39.136671 pm
UUID: 1b562f44-5a2e-e246-9a4f-edac73fc2c54
Ancestors: Monticello-mt.632
Adds a directory repository with support for a relative path. This allows more copying images and files around while keeping Monticello working. The path is relative to "FileDirectory default".
=============== Diff against Monticello-mt.632 ===============
Item was changed:
----- Method: MCDirectoryRepository>>allFileNames (in category 'accessing') -----
allFileNames
+ ^self directory entries
- ^directory entries
sort: [ :a :b | a modificationTime >= b modificationTime ];
replace: [ :ea | ea name asMCVersionName ]!
Item was changed:
----- Method: MCDirectoryRepository>>description (in category 'accessing') -----
description
+ ^ self directory pathName!
- ^ directory pathName!
Item was changed:
----- Method: MCDirectoryRepository>>hash (in category 'comparing') -----
hash
+ ^ self directory pathName hash!
- ^ directory pathName hash!
Item was changed:
----- Method: MCDirectoryRepository>>isValid (in category 'accessing') -----
isValid
+ ^ self directory exists!
- ^directory exists!
Item was changed:
----- Method: MCDirectoryRepository>>readStreamForFileNamed:do: (in category 'accessing') -----
readStreamForFileNamed: aString do: aBlock
| file val |
+ file := FileStream readOnlyFileNamed: (self directory fullNameFor: aString).
- file := FileStream readOnlyFileNamed: (directory fullNameFor: aString).
val := aBlock value: file.
file close.
^ val!
Item was changed:
----- Method: MCDirectoryRepository>>writeStreamForFileNamed:replace:do: (in category 'accessing') -----
writeStreamForFileNamed: aString replace: aBoolean do: aBlock
| file sel |
sel := aBoolean ifTrue: [#forceNewFileNamed:] ifFalse: [#newFileNamed:].
+ file := FileStream perform: sel with: (self directory fullNameFor: aString).
- file := FileStream perform: sel with: (directory fullNameFor: aString).
aBlock value: file.
file close.!
Item was added:
+ MCDirectoryRepository subclass: #MCRelativeDirectoryRepository
+ instanceVariableNames: 'relativePath'
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Monticello-Repositories'!
+
+ !MCRelativeDirectoryRepository commentStamp: 'mt 5/12/2016 17:39' prior: 0!
+ Path is relative to "FileDirectory default".!
Item was added:
+ ----- Method: MCRelativeDirectoryRepository class>>description (in category 'configuring') -----
+ description
+ ^ 'directory (relative)'!
Item was added:
+ ----- Method: MCRelativeDirectoryRepository>>description (in category 'accessing') -----
+ description
+
+ ^ self relativePath!
Item was added:
+ ----- Method: MCRelativeDirectoryRepository>>directory (in category 'accessing') -----
+ directory
+
+ ^ self isConsistent
+ ifTrue: [directory]
+ ifFalse: [directory := FileDirectory default directoryNamed: self relativePath]!
Item was added:
+ ----- Method: MCRelativeDirectoryRepository>>directory: (in category 'accessing') -----
+ directory: aDirectory
+
+ directory := aDirectory.
+
+ self relativePath: (FileDirectory default relativeNameIfAbsoluteFor: aDirectory fullName).!
Item was added:
+ ----- Method: MCRelativeDirectoryRepository>>isConsistent (in category 'testing') -----
+ isConsistent
+
+ ^ (directory notNil
+ and: [(FileDirectory default relativeNameIfAbsoluteFor: directory fullName) = self relativePath])
+ and: [directory exists]!
Item was added:
+ ----- Method: MCRelativeDirectoryRepository>>relativePath (in category 'accessing') -----
+ relativePath
+
+ ^ relativePath copyReplaceAll: '/' with: FileDirectory slash!
Item was added:
+ ----- Method: MCRelativeDirectoryRepository>>relativePath: (in category 'accessing') -----
+ relativePath: aString
+
+ relativePath := aString copyReplaceAll: '\' with: '/'.!
Item was changed:
----- Method: MCSubDirectoryRepository>>allDirectories (in category 'enumeration') -----
allDirectories
| remaining dir dirs |
remaining := OrderedCollection new.
dirs := OrderedCollection new.
+ remaining addLast: self directory.
- remaining addLast: directory.
[remaining isEmpty]
whileFalse: [dir := remaining removeFirst.
dirs add: dir.
dir entries
do: [:ent | ent isDirectory
ifTrue: [remaining
addLast: (dir directoryNamed: ent name)]]].
^ dirs!
Item was changed:
----- Method: MCSubDirectoryRepository>>description (in category 'user interface') -----
description
+ ^ self directory pathName, FileDirectory slash, '*'!
- ^ directory pathName, FileDirectory slash, '*'!
Item was changed:
----- Method: MCSubDirectoryRepository>>findFullNameForWriting: (in category 'as yet unclassified') -----
findFullNameForWriting: aBaseName
| possible split prefix fpattern now |
+ split := self directory splitNameVersionExtensionFor: aBaseName.
- split := directory splitNameVersionExtensionFor: aBaseName.
fpattern := split first, '*'.
possible := SortedCollection sortBlock: [ :a :b |
a first = b first
ifTrue: [ a second = b second
ifFalse: [ a second < b second ]
ifTrue: [ a third fullName size < b third fullName size ]]
ifFalse: [ a first > b first ] ].
now := Time totalSeconds.
+ prefix := self directory pathParts size.
- prefix := directory pathParts size.
self allDirectories do: [:dir | | parts dirScore fileScore |
parts := dir pathParts allButFirst: prefix.
dirScore := (parts select: [ :part | fpattern match: part ]) size.
fileScore := (dir entries collect: [ :ent |
(ent isDirectory not and: [ fpattern match: ent name ])
ifFalse: [ SmallInteger maxVal ]
ifTrue: [ now - ent modificationTime ]]). "minimum age"
fileScore := fileScore isEmpty ifTrue: [ SmallInteger maxVal ]
ifFalse: [ fileScore min ].
possible add: { dirScore. fileScore. dir } ].
^ (possible first third) fullNameFor: aBaseName!
More information about the Squeak-dev
mailing list
|