diff --git a/src/Squot.package/SquotFileTestHistorian.class/instance/version..st b/src/Squot.package/SquotFileTestHistorian.class/instance/version..st index 0abfd12ec..5ba8f41d5 100644 --- a/src/Squot.package/SquotFileTestHistorian.class/instance/version..st +++ b/src/Squot.package/SquotFileTestHistorian.class/instance/version..st @@ -1,5 +1,6 @@ Pur historian version: aVersion + aVersion ifNil: [^ self delete]. self file writeStreamDo: [:stream | stream nextPutAll: aVersion internalId]. \ No newline at end of file diff --git a/src/Squot.package/SquotFileTestHistorian.class/methodProperties.json b/src/Squot.package/SquotFileTestHistorian.class/methodProperties.json index d979b97e4..1da081fc0 100644 --- a/src/Squot.package/SquotFileTestHistorian.class/methodProperties.json +++ b/src/Squot.package/SquotFileTestHistorian.class/methodProperties.json @@ -9,5 +9,5 @@ "repository" : "jr 3/16/2019 17:42", "repository:" : "jr 3/16/2019 17:45", "version" : "jr 3/16/2019 17:51", - "version:" : "jr 3/16/2019 17:48", + "version:" : "jr 11/27/2022 18:59", "versionName" : "jr 3/16/2019 17:53" } } diff --git a/src/Squot.package/SquotWorkingCopy.class/instance/switchAndMoveUnsavedChangesOverTo..st b/src/Squot.package/SquotWorkingCopy.class/instance/switchAndMoveUnsavedChangesOverTo..st index 8239baa33..01adb80d3 100644 --- a/src/Squot.package/SquotWorkingCopy.class/instance/switchAndMoveUnsavedChangesOverTo..st +++ b/src/Squot.package/SquotWorkingCopy.class/instance/switchAndMoveUnsavedChangesOverTo..st @@ -1,7 +1,8 @@ switching historians switchAndMoveUnsavedChangesOverTo: aHistorian - | fromHistorian temporarySnapshot | + | fromHistorian fromVersion temporarySnapshot | fromHistorian := self loadedHistorian. + fromVersion := fromHistorian version ifNil: [SquotSnapshot empty]. (fromHistorian version = aHistorian version and: [(self repository hasTemporaryVersionsOn: aHistorian) not]) ifTrue: ["nothing needs to be modified in the store" @@ -23,7 +24,7 @@ switchAndMoveUnsavedChangesOverTo: aHistorian self privateLoadVersion: aHistorian version]. self withCurrentSnapshot: [self mergeTemporaryVersionsOn: aHistorian]. SquotProgress displayStatus: 'Restoring unsaved changes' during: - [self mergeSilently: temporarySnapshot basedOn: fromHistorian version + [self mergeSilently: temporarySnapshot basedOn: fromVersion onConflictsDo: [:merge | | accepted | [accepted := true. diff --git a/src/Squot.package/SquotWorkingCopy.class/instance/switchTo..st b/src/Squot.package/SquotWorkingCopy.class/instance/switchTo..st index e750093a1..fd4f7b78f 100644 --- a/src/Squot.package/SquotWorkingCopy.class/instance/switchTo..st +++ b/src/Squot.package/SquotWorkingCopy.class/instance/switchTo..st @@ -3,6 +3,7 @@ switchTo: aHistorian | fromHistorian originVersion targetVersion temporarySnapshot addedObjects mergeReaddedObjects | fromHistorian := self loadedHistorian. originVersion := fromHistorian version. + originVersion ifNil: [originVersion := SquotSnapshot empty]. targetVersion := aHistorian version. self withCurrentSnapshot: [self temporarilySaveChangesOn: fromHistorian]. SquotProgress displayStatus: 'Loading ', (targetVersion printStringLimitedTo: 100) during: diff --git a/src/Squot.package/SquotWorkingCopy.class/methodProperties.json b/src/Squot.package/SquotWorkingCopy.class/methodProperties.json index c6f7a39aa..0d63126fe 100644 --- a/src/Squot.package/SquotWorkingCopy.class/methodProperties.json +++ b/src/Squot.package/SquotWorkingCopy.class/methodProperties.json @@ -108,8 +108,8 @@ "snapshot" : "jr 11/22/2020 17:55", "store" : "jr 1/26/2017 14:48", "store:" : "jr 10/5/2020 00:00", - "switchAndMoveUnsavedChangesOverTo:" : "jr 1/13/2022 22:24", - "switchTo:" : "jr 1/22/2022 13:58", + "switchAndMoveUnsavedChangesOverTo:" : "jr 11/27/2022 18:54", + "switchTo:" : "jr 11/27/2022 18:45", "temporarilySaveChangesDuring:" : "jr 5/30/2019 00:24", "temporarilySaveChangesOn:" : "jr 9/13/2020 22:00", "unload" : "jr 1/26/2017 17:38", diff --git a/src/Squot.package/SquotWorkingCopyTest.class/instance/testSwitchAwayFromOrphanedBranch.st b/src/Squot.package/SquotWorkingCopyTest.class/instance/testSwitchAwayFromOrphanedBranch.st new file mode 100644 index 000000000..e19a7e43f --- /dev/null +++ b/src/Squot.package/SquotWorkingCopyTest.class/instance/testSwitchAwayFromOrphanedBranch.st @@ -0,0 +1,28 @@ +tests branch switching +testSwitchAwayFromOrphanedBranch + | class trackedObject existingHistorian orphanedHistorian | + "given" + repository withUnitOfWork: + [self suppressChangeNotificationsDuring: [class := classFactory newClass]. + class compileSilently: 'a ^ #originalReturnValue' classified: 'will not be changed'. + trackedObject := self addPackage. + workingCopy saveVersionWithMessage: 'initial version'. + existingHistorian := workingCopy loadedHistorian. + orphanedHistorian := repository historianNamed: 'newHistorian'. + workingCopy + loadedHistorian: orphanedHistorian; + loadedVersion: nil. + "when" + self suppressChangeNotificationsDuring: [workingCopy switchTo: existingHistorian]. + "then" + self assert: class new a == #originalReturnValue. + + + workingCopy + loadedHistorian: orphanedHistorian; + loadedVersion: nil. + "when" + self suppressChangeNotificationsDuring: + [workingCopy switchAndMoveUnsavedChangesOverTo: existingHistorian]. + "then" + self assert: class new a == #originalReturnValue]. \ No newline at end of file diff --git a/src/Squot.package/SquotWorkingCopyTest.class/methodProperties.json b/src/Squot.package/SquotWorkingCopyTest.class/methodProperties.json index 4d46e7695..205a59f86 100644 --- a/src/Squot.package/SquotWorkingCopyTest.class/methodProperties.json +++ b/src/Squot.package/SquotWorkingCopyTest.class/methodProperties.json @@ -60,6 +60,7 @@ "testSaveTimestampIsNow" : "jr 8/25/2020 19:13", "testSaveWithoutAddedArtifact" : "jr 4/18/2022 16:48", "testSwitchAndMoveOverToBranchAtSameVersion" : "jr 3/2/2020 23:23", + "testSwitchAwayFromOrphanedBranch" : "jr 11/27/2022 18:56", "testSwitchBranch" : "jr 3/2/2020 23:23", "testSwitchBranchAndMoveOverUnsavedChanges" : "jr 3/2/2020 23:37", "testSwitchBranchAndMoveOverUnsavedChangesInAddedArtifact" : "jr 1/2/2021 00:31",