=============== Summary ===============
Change Set: changeSetNameInUse
Date: 5 April 2022
Author: Christoph Thiede
When creating/filing a changeset with a name that is already in use, offer the user to append or overwrite the changeset instead canceling the operation. Also improves multilingual support.
To test this out, just file in this changeset a second time.
=============== Diff ===============
ChangeSet class>>basicNewChangeSet: {enumerating} · ct 4/5/2022 20:57 (changed)
basicNewChangeSet: newName
| newSet |
newName ifNil: [^ nil].
- (self named: newName) ifNotNil:
- [self inform: 'Sorry that name is already used'.
- ^ nil].
+ (self named: newName) ifNotNil: [:existing |
+ ((Project uiManager
+ chooseFromLabeledValues: (OrderedDictionary new
+ at: 'Append' translated put: [^ existing];
+ at: 'Overwrite' translated put: [self removeChangeSet: existing];
+ at: 'Cancel' translated put: nil;
+ yourself)
+ title: ('A changeset with the name <b>"{1}"</b> already exists.' translated asTextFromHtml format: {newName})) ifNil: [^ nil]) value].
newSet := self basicNewNamed: newName.
AllChangeSets add: newSet.
^ newSet
ChangeSet class>>newChangesFromStream:named: {services} · ct 4/5/2022 20:54 (changed)
newChangesFromStream: aStream named: aName
"File in the code from the stream into a new change set whose
name is derived from aName. Leave the 'current change set'
unchanged. Return the new change set or nil on failure."
| oldChanges newName newSet |
oldChanges := ChangeSet current.
PreviousSet := oldChanges name. "so a Bumper update can find it"
newName := aName sansPeriodSuffix.
newSet := self basicNewChangeSet: newName.
[ | newStream |newSet ifNotNil:[
(aStream respondsTo: #converter:) ifFalse: [
newStream := MultiByteBinaryOrTextStream with: (aStream contentsOfEntireFile).
newStream reset.
] ifTrue: [
newStream := aStream.
].
self newChanges: newSet.
newStream setConverterForCode.
- newStream fileInAnnouncing: 'Loading ', newName, '...'.
- Transcript cr; show: 'File ', aName, ' successfully filed in to change set ', newName].
+ newStream fileInAnnouncing: ('Loading {1}...' translated format: {newName}).
+ Transcript cr; show: ('File {1} successfully filed in to change set {2}' translated format: {aName. newName})].
aStream close] ensure: [self newChanges: oldChanges].
PreviousSet := nil.
^ newSet
---
Sent from Squeak Inbox Talk
["changeSetNameInUse.4.cs"]
["changeSetNameInUse.png"]