Skip to content

Commit

Permalink
Move image hash and moved image handling to class side
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusDoe committed Nov 28, 2023
1 parent eaf7c78 commit 4efa656
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
image-hash
handleMovedImageFrom: oldHash to: newHash
| doMove |
doMove := (UIManager default
chooseFrom: {'I copied it.'. 'I moved it.'}
title:
'The image is not where it used to be. Did you move or copy it?', String cr,
'If in doubt, choose copy.')
= 2.
self allInstancesDo: [:each | each handleMovedImageFrom: oldHash to: newHash doMove: doMove].
9 changes: 9 additions & 0 deletions src/Squot.package/SqueakWorkingCopy.class/class/imageHash.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
image-hash
imageHash
| hash lastHash |
hash := self basicImageHash.
lastHash := self lastImageHash.
self lastImageHash: hash.
hash ~= lastHash ifTrue: [
self handleMovedImageFrom: lastHash to: hash].
^ hash
3 changes: 3 additions & 0 deletions src/Squot.package/SqueakWorkingCopy.class/class/initialize.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class initialization
initialize
self initializeLastImageHash.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
image-hash
lastImageHash: aString
LastImageHash := aString
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
image-hash
lastImageHash
^ LastImageHash
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
image-hash
handleMovedImageFrom: oldHash to: newHash
| doMove oldPrefix newPrefix oldRefs |
doMove := (UIManager default
chooseFrom: {'I copied it.'. 'I moved it.'}
title:
'The image is not where it used to be. Did you move or copy it?', String cr,
'If in doubt, choose copy.')
= 2.
handleMovedImageFrom: oldHash to: newHash doMove: doMove
| oldPrefix newPrefix oldRefs |
oldPrefix := self refsBaseNameForHash: oldHash.
newPrefix := self refsBaseNameForHash: newHash.
self withUnitOfWork: [
Expand All @@ -23,4 +17,7 @@ handleMovedImageFrom: oldHash to: newHash
and: [ref isSymbolic]
and: [(target := ref targetRef) startsWith: oldPrefix])
ifTrue: [
self unitOfWork updateSymbolicRef: ref name toRef: newPrefix, (target allButFirst: oldPrefix size) message: nil]]].
self unitOfWork
updateSymbolicRef: ref name
toRef: newPrefix, (target allButFirst: oldPrefix size)
message: nil]]].
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
image-hash
imageHash
| hash lastHash |
hash := self basicImageHash.
lastHash := self lastImageHash.
self lastImageHash: hash.
hash ~= lastHash ifTrue: [
self handleMovedImageFrom: lastHash to: hash].
^ hash
^ self class imageHash
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ initialize
self
materialized: Dictionary new;
mappers: OrderedCollection new;
credentials: Dictionary new;
initializeLastImageHash.
credentials: Dictionary new.

This file was deleted.

This file was deleted.

17 changes: 10 additions & 7 deletions src/Squot.package/SqueakWorkingCopy.class/methodProperties.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{
"class" : {
"basicImageHash" : "mad 11/28/2023 19:18",
"cloneFrom:to:named:" : "mad 9/19/2023 11:53",
"cloneFromUserAndRegister" : "mad 11/13/2023 12:09",
"defaultDirectoryForName:" : "mad 10/22/2023 00:24",
"doPostUpdateMigrations" : "mad 11/21/2023 16:06",
"gitSuffix" : "mad 11/13/2023 12:03",
"handleMovedImageFrom:to:" : "mad 11/28/2023 19:23",
"imageHash" : "mad 11/28/2023 19:18",
"initialize" : "mad 11/28/2023 19:20",
"initializeLastImageHash" : "mad 11/28/2023 19:18",
"isNameRegistered:" : "mad 9/19/2023 12:02",
"isRegistered:" : "mad 9/19/2023 12:20",
"lastImageHash" : "mad 11/28/2023 19:20",
"lastImageHash:" : "mad 11/28/2023 19:24",
"nameFromURL:" : "mad 11/13/2023 12:07",
"named:" : "mad 9/19/2023 12:04",
"newFromUserAndRegister" : "mad 10/22/2023 00:12",
Expand All @@ -26,7 +33,6 @@
"addMapper:" : "mad 9/20/2023 17:30",
"allMappers" : "mad 10/21/2023 22:58",
"allReferences" : "mad 9/13/2023 21:23",
"basicImageHash" : "mad 6/9/2023 19:05",
"branchName:" : "mad 6/4/2023 16:09",
"branchesBaseName" : "mad 6/4/2023 16:09",
"changeSetsFromCommit:toCommit:" : "mad 9/6/2023 19:28",
Expand Down Expand Up @@ -62,18 +68,17 @@
"gitInitialize" : "mad 6/4/2023 13:42",
"handleCredentialsDuring:" : "mad 9/18/2023 14:13",
"handleCredentialsDuring:ifCanceled:" : "mad 10/17/2023 12:11",
"handleMovedImageFrom:to:" : "mad 11/28/2023 19:12",
"handleMovedImageFrom:to:doMove:" : "mad 11/28/2023 19:25",
"headCommit" : "mad 6/3/2023 15:35",
"headCommitHash" : "mad 6/3/2023 15:34",
"headFSCommit" : "mad 10/21/2023 23:43",
"headRef" : "mad 6/4/2023 13:26",
"headRefBasename" : "mad 10/16/2023 22:47",
"headRefName" : "mad 10/16/2023 22:47",
"imageHash" : "mad 11/28/2023 18:18",
"imageHash" : "mad 11/28/2023 19:19",
"initialRemoteRefNameFor:" : "mad 9/18/2023 13:58",
"initialize" : "mad 9/18/2023 12:52",
"initialize" : "mad 11/28/2023 19:19",
"initializeHead" : "mad 6/10/2023 14:59",
"initializeLastImageHash" : "mad 6/9/2023 19:06",
"isHeadDetached" : "mad 10/24/2023 17:22",
"isImageClean" : "mad 11/7/2023 15:17",
"isReferencedByHead:" : "mad 10/16/2023 22:52",
Expand All @@ -83,8 +88,6 @@
"isSqueakBranchRef:" : "mad 6/4/2023 16:10",
"isSqueakRef:" : "mad 9/18/2023 13:58",
"isUnmappedPath:" : "mad 10/21/2023 23:03",
"lastImageHash" : "mad 6/9/2023 19:03",
"lastImageHash:" : "mad 6/9/2023 19:03",
"mappedPaths" : "mad 10/21/2023 22:58",
"mappers" : "mad 6/1/2023 22:35",
"mappers:" : "mad 10/19/2023 11:38",
Expand Down
3 changes: 1 addition & 2 deletions src/Squot.package/SqueakWorkingCopy.class/properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
"classinstvars" : [
"registry" ],
"classvars" : [
],
"LastImageHash" ],
"commentStamp" : "",
"instvars" : [
"name",
"fsgitRepository",
"materialized",
"mappers",
"lastImageHash",
"refsForCommits",
"credentials" ],
"name" : "SqueakWorkingCopy",
Expand Down

0 comments on commit 4efa656

Please sign in to comment.