Skip to content

Commit

Permalink
Update users of IceTipStandardAction to use #newXAction + #executeWit…
Browse files Browse the repository at this point in the history
…hContext: pattern (fixes pharo-vcs#1779)

Fixes nil DNU #application errors for package reload/remove/unload, tag delete, and method version load.
Also remove extraneous IceRepositoryModified when the action already has #onSuccessRepositoryModified.
Add missing ^return in IceTipVersionHistoryModel>>retrieveHistory

Remove IceTipStandardAction>>execute: as execution without a context will ~always fail and the pattern is to assign the action first, then the context at time of execution. No references remain in Iceberg packages, and in fact all remaining references are self-sends, so clearly aren't sent to IceTipStandardAction.
  • Loading branch information
daniels220 committed Dec 16, 2023
1 parent 4733a87 commit 2174862
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 89 deletions.
6 changes: 3 additions & 3 deletions Iceberg-TipUI/IceTipInstallVersionCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ IceTipInstallVersionCommand class >> defaultName [
^ 'Install this version'
]

{ #category : 'execution' }
{ #category : 'executing' }
IceTipInstallVersionCommand >> execute [
self version install

self version newInstallAction executeWithContext: self context
]

{ #category : 'activation' }
Expand Down
4 changes: 1 addition & 3 deletions Iceberg-TipUI/IceTipLoadPackageCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ IceTipLoadPackageCommand >> canBeExecuted [
{ #category : 'executing' }
IceTipLoadPackageCommand >> execute [

self packageModel newLoadAction executeWithContext: self context.
Iceberg announcer announce:
(IceRepositoryModified for: self repository)
self packageModel newLoadAction executeWithContext: self context
]

{ #category : 'accessing' }
Expand Down
71 changes: 37 additions & 34 deletions Iceberg-TipUI/IceTipPackageModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -77,37 +77,54 @@ IceTipPackageModel >> newLoadAction [
yourself
]

{ #category : 'accessing' }
IceTipPackageModel >> packageName [
^ self entity packageName
{ #category : 'actions' }
IceTipPackageModel >> newReloadAction [

<noCache>
^ IceTipStandardAction new
repository: self entity repository;
message: ('Reloading package {1}' format: { self entity name });
onSuccessRepositoryModified;
action: [
Iceberg announcer
suspendAllForRepository: self entity repository
while: [ self entity reload ] ];
yourself
]

{ #category : 'actions' }
IceTipPackageModel >> reload [
<noCache>
IceTipPackageModel >> newRemoveAction [

IceTipStandardAction new
<noCache>
^IceTipStandardAction new
repository: self entity repository;
message: ('Reloading package {1}' format: { self entity name }) ;
message: ('Removing package {1}' format: { self entity name });
onSuccessRepositoryModified;
execute: [
Iceberg announcer
suspendAllForRepository: self entity repository
while: [ self entity reload ] ]
action: [
Iceberg announcer
suspendAllForRepository: self entity repository
while: [ self entity remove ] ];
yourself
]

{ #category : 'actions' }
IceTipPackageModel >> remove [
IceTipPackageModel >> newUnloadAction [

<noCache>
^ IceTipStandardAction new
repository: self entity repository;
message: ('Unloading package {1}' format: { self entity name });
onSuccessRepositoryModified;
action: [
Iceberg announcer
suspendAllForRepository: self entity repository
while: [ self entity unload ] ];
yourself
]

IceTipStandardAction new
repository: self entity repository;
message: ('Removing package {1}' format: { self entity name });
onSuccessRepositoryModified;
execute: [
Iceberg announcer
suspendAllForRepository: self entity repository
while: [ self entity remove ] ]
{ #category : 'accessing' }
IceTipPackageModel >> packageName [
^ self entity packageName
]

{ #category : 'accessing' }
Expand All @@ -129,17 +146,3 @@ IceTipPackageModel >> statusDecorator [
ifFalse: [ IceTipDescriptionDecorator notLoaded ].
^ super statusDecorator
]

{ #category : 'actions' }
IceTipPackageModel >> unload [
<noCache>

IceTipStandardAction new
repository: self entity repository;
message: ('Unloading package {1}' format: { self entity name });
onSuccessRepositoryModified;
execute: [
Iceberg announcer
suspendAllForRepository: self entity repository
while: [ self entity unload ] ]
]
4 changes: 1 addition & 3 deletions Iceberg-TipUI/IceTipReloadPackageCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ IceTipReloadPackageCommand >> canBeExecuted [
{ #category : 'executing' }
IceTipReloadPackageCommand >> execute [

self packageModel reload.
Iceberg announcer announce:
(IceRepositoryModified for: self repository)
self packageModel newReloadAction executeWithContext: self context.
]

{ #category : 'accessing' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ IceTipRemoveFromRepositoryPackageCommand class >> defaultName [
{ #category : 'executing' }
IceTipRemoveFromRepositoryPackageCommand >> execute [

self packageModel remove
self packageModel newRemoveAction executeWithContext: self context
]

{ #category : 'accessing' }
Expand Down
4 changes: 2 additions & 2 deletions Iceberg-TipUI/IceTipRemovePackageDialogPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Class {
IceTipRemovePackageDialogPresenter >> accept [

self removeFromRepositoryCheckbox state
ifTrue: [ self model remove ].
ifTrue: [ self model newRemoveAction executeWithContext: self ].
self unloadFromImageCheckbox state
ifTrue: [ self model unload ].
ifTrue: [ self model newUnloadAction executeWithContext: self ].
]

{ #category : 'accessing - ui' }
Expand Down
13 changes: 7 additions & 6 deletions Iceberg-TipUI/IceTipRepositoryModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,14 @@ IceTipRepositoryModel >> newAddRemoteActionName: aName url: anUrl [

{ #category : 'actions' }
IceTipRepositoryModel >> newCheckoutNewBranchNamed: aString inCommit: aCommit [
<noCache>

^ IceTipStandardAction new
repository: self entity;
message: ('Checking out new branch {1}' format: { aString });
onSuccessRepositoryModified;
action: [ self entity createBranch: aString inCommit: aCommit ]
<noCache>
^ IceTipStandardAction new
repository: self entity;
message: ('Checking out new branch {1}' format: { aString });
onSuccessRepositoryModified;
action: [ self entity createBranch: aString inCommit: aCommit ];
yourself
]

{ #category : 'actions' }
Expand Down
7 changes: 0 additions & 7 deletions Iceberg-TipUI/IceTipStandardAction.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ IceTipStandardAction >> do: aBlock [
self execute
]

{ #category : 'executing' }
IceTipStandardAction >> execute: aBlock [

self action: aBlock.
self execute
]

{ #category : 'accessing' }
IceTipStandardAction >> message [
^ message
Expand Down
23 changes: 12 additions & 11 deletions Iceberg-TipUI/IceTipTagModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ IceTipTagModel >> commitModels [
^ commits
]

{ #category : 'actions' }
IceTipTagModel >> delete [
<noCache>

IceTipStandardAction new
repository: self repositoryModel entity;
message: ('Removing tag {1}' format: { self name });
onSuccessRepositoryModified;
do: [ self repositoryModel entity removeTag: self entity ]
]

{ #category : 'accessing' }
IceTipTagModel >> description [

Expand All @@ -42,6 +31,18 @@ IceTipTagModel >> name [
^ self entity name
]

{ #category : 'actions' }
IceTipTagModel >> newDeleteAction [

<noCache>
^ IceTipStandardAction new
repository: self repositoryModel entity;
message: ('Removing tag {1}' format: { self name });
onSuccessRepositoryModified;
action: [ self entity delete ];
yourself
]

{ #category : 'actions' }
IceTipTagModel >> previewCheckout [
"this will open a 'checkout browser' that will allow user to validate the changes before
Expand Down
2 changes: 1 addition & 1 deletion Iceberg-TipUI/IceTipUnloadPackageCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ IceTipUnloadPackageCommand >> canBeExecuted [
{ #category : 'executing' }
IceTipUnloadPackageCommand >> execute [

self packageModel unload
self packageModel newUnloadAction executeWithContext: self context
]

{ #category : 'accessing' }
Expand Down
2 changes: 1 addition & 1 deletion Iceberg-TipUI/IceTipVersionHistoryModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ IceTipVersionHistoryModel >> name [
IceTipVersionHistoryModel >> retrieveHistory [

self repositoryModel checkMissing.
self application
^self application
informUser: ('Retrieving history of {1}' format: { self entity printString })
during: [ self repositoryModel entity log historyOfMethod: self entity ]
]
27 changes: 10 additions & 17 deletions Iceberg-TipUI/IceTipVersionModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,23 @@ Class {
#tag : 'Model'
}

{ #category : 'private' }
IceTipVersionModel >> basicInstall [
| definition |

definition := self entity definition.
definition realClass
compile: definition sourceCode
classified: definition category
]

{ #category : 'accessing' }
IceTipVersionModel >> commit [
^ self entity commit
]

{ #category : 'actions' }
IceTipVersionModel >> install [
<noCache>
IceTipVersionModel >> newInstallAction [

IceTipStandardAction new
repository: self repositoryModel entity;
message: ('Installing {1} - {2}' format: { self entity definition. self name });
onSuccessRepositoryModified;
execute: [ self basicInstall ]
<noCache>
^ IceTipStandardAction new
repository: self repositoryModel entity;
message: ('Installing {1} - {2}' format: {
self entity definition.
self name });
onSuccessRepositoryModified;
action: [ self entity install ];
yourself
]

{ #category : 'accessing' }
Expand Down
8 changes: 8 additions & 0 deletions Iceberg/IceLogVersion.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ IceLogVersion >> id [
^ self commit id
]

{ #category : 'actions' }
IceLogVersion >> install [

definition realClass
compile: definition sourceCode
classified: definition category
]

{ #category : 'accessing' }
IceLogVersion >> originMethod [
^ (Smalltalk at: self definition methodClass name) >> self definition selector
Expand Down

0 comments on commit 2174862

Please sign in to comment.