Skip to content

Commit

Permalink
Fix #396: UndefinedObject errors when switching away from orphaned br…
Browse files Browse the repository at this point in the history
…anch

Treat the non-existent version of the orphaned branch like an empty project.

Object merging without a base is #notYetImplemented, hence I had to resort
to a package rather than a ValueHolder in the test case.

SquotFileTestHistorian could not accept nil as a version (here for the stash
historian for unsaved changes); have it delete the historian when the version
is set to nil.
  • Loading branch information
j4yk committed Nov 27, 2022
1 parent d9222c9 commit 9c3d011
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Pur historian
version: aVersion
aVersion ifNil: [^ self delete].
self file writeStreamDo:
[:stream |
stream nextPutAll: aVersion internalId].
Original file line number Diff line number Diff line change
Expand Up @@ -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" } }
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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].
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9c3d011

Please sign in to comment.