The Trunk: UpdateStream-mt.12.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: UpdateStream-mt.12.mcz

commits-2
Marcel Taeumel uploaded a new version of UpdateStream to project The Trunk:
http://source.squeak.org/trunk/UpdateStream-mt.12.mcz

==================== Summary ====================

Name: UpdateStream-mt.12
Author: mt
Time: 17 September 2019, 9:14:46.838406 am
UUID: 727b9e66-27d3-244e-a219-f103de2d28b3
Ancestors: UpdateStream-tpr.11

Complements Tools-mt.891

=============== Diff against UpdateStream-tpr.11 ===============

Item was changed:
  ----- Method: FilePackage>>conflictsWithUpdatedMethods (in category '*UpdateStream-conflict checker') -----
  conflictsWithUpdatedMethods
  "Check this package for conflicts with methods in the image which are in newer updates."
 
  | localFileName stream updateNumberString updateNumber imageUpdateNumber updateNumberChangeSet conflicts fileStream |
 
  localFileName := FileDirectory localNameFor: fullName.
  stream := ReadStream on: sourceSystem.
  stream upToAll: 'latest update: #'.
  updateNumberString := stream upTo: $].
  stream close.
 
  fileStream := FileStream readOnlyFileNamed: fullName.
  (fileStream contentsOfEntireFile includes: Character linefeed)
+ ifTrue: [self notify:  'The changeset file ', localFileName, ' contains linefeeds.  Proceed if...
- ifTrue: [self notifyWithLabel:  'The changeset file ', localFileName, ' contains linefeeds.  Proceed if...
  you know that this is okay (e.g. the file contains raw binary data).'].
  fileStream close.
 
  updateNumberString isEmpty ifFalse: "remove prepended junk, if any"
  [updateNumberString := (updateNumberString findTokens: Character space) last].
  updateNumberString asInteger ifNil:
  [(self confirm: 'Error: ', localFileName, ' has no valid Latest Update number in its header.
  Do you want to enter an update number for this file?')
  ifFalse: [^ self]
  ifTrue: [updateNumberString := UIManager default
  request: 'Please enter the estimated update number (e.g. 4332).']].
  updateNumberString asInteger ifNil: [self inform: 'Conflict check cancelled.'. ^ self].
  updateNumber := updateNumberString asInteger.
 
  imageUpdateNumber := SystemVersion current highestUpdate.
  updateNumber > imageUpdateNumber ifTrue:
  [(self confirm: 'Warning: The update number for this file (#', updateNumberString, ')
  is greater than the highest update number for this image (#', imageUpdateNumber asString, ').
  This probably means you need to update your image.
  Should we proceed anyway as if the file update number is #', imageUpdateNumber asString, '?')
  ifTrue:
  [updateNumber := imageUpdateNumber.
  updateNumberString := imageUpdateNumber asString]
  ifFalse: [^ self]].
 
  updateNumberChangeSet := self findUpdateChangeSetMatching: updateNumber.
  updateNumberChangeSet ifNil: [^ self].
 
  Smalltalk isMorphic ifTrue: [self currentWorld findATranscript: self currentEvent].
  self class logCr; logCr; log: 'Checking ', localFileName, ' (#', updateNumberString, ') for method conflicts with changesets after ', updateNumberChangeSet name, ' ...'.
 
  conflicts := OrderedCollection new.
  self classes do: [:pseudoClass |
  (Array with: pseudoClass with: pseudoClass metaClass) do: [:classOrMeta |
  classOrMeta selectorsDo: [:selector | | conflict |
  conflict := self
  checkForMoreRecentUpdateThanChangeSet: updateNumberChangeSet
  pseudoClass: classOrMeta
  selector: selector.
  conflict ifNotNil: [conflicts add: conflict].
  ].
  ].
  ].
  self class logCr; log: conflicts size asString, (' conflict' asPluralBasedOn: conflicts), ' found.'; logCr.
  self class closeLog.
  ^ conflicts!

Item was changed:
  ----- Method: ServerDirectory>>putUpdate: (in category '*UpdateStream-updating') -----
  putUpdate: fileStrm
  "Put this file out as an Update on the servers of my group.  Each version of the system may have its own set of update files, or they may all share the same files.  'updates.list' holds the master list.  Each update is a fileIn whose name begins with a number.  See Utilities class readServerUpdatesThrough:saveLocally:updateImage:.
  When two sets of updates are stored on the same directory, one of them has a * in its
  serverUrls description.  When that is true, the first word of the description is put on
  the front of 'updates.list', and that index file is used."
 
  | myServers updateStrm newName response localName seq indexPrefix listContents version versIndex lastNum stripped |
  localName := fileStrm localName.
  fileStrm size = 0 ifTrue:
  [^ self inform: 'That file has zero bytes!!  May have a new name.'].
  (fileStrm contentsOfEntireFile includes: Character linefeed)
+ ifTrue: [self notify:  'That file contains linefeeds.  Proceed if...
- ifTrue: [self notifyWithLabel:  'That file contains linefeeds.  Proceed if...
  you know that this is okay (e.g. the file contains raw binary data).'].
  fileStrm reset.
  (self checkNames: {localName}) ifFalse: [^ nil]. "illegal characters"
  response := UIManager default chooseFrom: #('Install update' 'Cancel update')
  title: 'Do you really want to broadcast the file ', localName,
  '\to every Squeak user who updates from ' withCRs, self groupName, '?'.
  response = 1 ifFalse: [^ nil]. "abort"
 
  self openGroup.
  indexPrefix := (self groupName includes: $*)
  ifTrue: [(self groupName findTokens: ' ') first] "special for internal updates"
  ifFalse: ['']. "normal"
  myServers := self checkServersWithPrefix: indexPrefix
  andParseListInto: [:x | listContents := x].
  myServers size = 0 ifTrue: [self closeGroup.  ^ self].
 
  version := SystemVersion current version.
  versIndex := (listContents collect: [:pair | pair first]) indexOf: version.
  versIndex = 0 ifTrue:
  [self inform: 'There is no section in updates.list for your version'.
  self closeGroup.  ^ nil]. "abort"
 
  "A few affirmations..."
  versIndex < listContents size ifTrue:
  [(self confirm: 'This system, ', version ,
  ' is not the latest version.\Make update for an older version?' withCRs)
  ifFalse: [self closeGroup.  ^ nil]]. "abort"
  (listContents at: versIndex) last isEmpty ifTrue:
  [(self confirm: 'Please confirm that you mean to issue the first update for ' ,
  version , '\(otherwise something is wrong).' withCRs)
  ifFalse: [self closeGroup.  ^ nil]].
 
  "We now determine next update number to be max of entire index"
  lastNum := listContents inject: 0 into:
  [:max :pair | pair last isEmpty
  ifTrue: [max]
  ifFalse: [max max: pair last last initialIntegerOrNil]].
 
  "Save old copy of updates.list on local disk"
  FileDirectory default deleteFileNamed: indexPrefix , 'updates.list.bk'.
  UpdateStreamDownloader default writeList: listContents toStream: (FileStream fileNamed: indexPrefix , 'updates.list.bk').
 
  "append name to updates with new sequence number"
  seq := (lastNum + 1) printString padded: #left to: 4 with: $0.
  "strip off any old seq number"
  stripped := localName copyFrom: (localName  findFirst: [:c | c isDigit not]) to: localName size.
  newName := seq , stripped.
  listContents at: versIndex put:
  {version. (listContents at: versIndex) last copyWith: newName}.
 
  "Write a new copy on all servers..."
  updateStrm := ReadStream on:
  (String streamContents: [:s | Utilities writeList: listContents toStream: s]).
  myServers do:
  [:aServer |
  fileStrm reset. "reopen"
  aServer putFile: fileStrm named: newName retry: true.
  updateStrm reset.
  aServer putFile: updateStrm named: indexPrefix , 'updates.list' retry: true.
  Transcript show: 'Update succeeded on server ', aServer moniker; cr].
  self closeGroup.
 
  Transcript cr; show: 'Be sure to test your new update!!'; cr.
  "rename the file locally (may fail)"
  fileStrm directory rename: localName toBe: newName.
  !