[squeak-dev] Review Request: changeSetNameInUse.4.cs

christoph.thiede at student.hpi.uni-potsdam.de christoph.thiede at student.hpi.uni-potsdam.de
Tue Apr 5 18:58:53 UTC 2022

=============== 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220405/5123bae4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: changeSetNameInUse.4.cs
Type: application/octet-stream
Size: 2151 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220405/5123bae4/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: changeSetNameInUse.png
Type: application/octet-stream
Size: 9035 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220405/5123bae4/attachment-0001.obj>

More information about the Squeak-dev mailing list