Skip to content

Commit

Permalink
Implement moved image handling
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusDoe committed Nov 28, 2023
1 parent b711601 commit eaf7c78
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 9 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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.
oldPrefix := self refsBaseNameForHash: oldHash.
newPrefix := self refsBaseNameForHash: newHash.
self withUnitOfWork: [
oldRefs := self allReferences select: [:each | each startsWith: oldPrefix].
oldRefs do: [:oldRef | | newRef |
newRef := newPrefix, (oldRef allButFirst: oldPrefix size).
self unitOfWork
perform: (doMove ifTrue: [#moveRef:to:] ifFalse: [#copyRef:to:])
with: oldRef
with: newRef].
self allReferences do: [:each | | ref target |
ref := self unitOfWork ref: each.
((ref name startsWith: newPrefix)
and: [ref isSymbolic]
and: [(target := ref targetRef) startsWith: oldPrefix])
ifTrue: [
self unitOfWork updateSymbolicRef: ref name toRef: newPrefix, (target allButFirst: oldPrefix size) message: nil]]].
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
image-hash
imageHash
| hash |
| hash lastHash |
hash := self basicImageHash.
hash ~= self lastImageHash ifTrue: [self handleMovedImage].
lastHash := self lastImageHash.
self lastImageHash: hash.
hash ~= lastHash ifTrue: [
self handleMovedImageFrom: lastHash to: hash].
^ hash
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
refs
refsBaseName
^ 'refs/squeak/', self imageHash, '/'
^ self refsBaseNameForHash: self imageHash
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
refs
refsBaseNameForHash: aString
^ 'refs/squeak/', aString, '/'
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@
"gitInitialize" : "mad 6/4/2023 13:42",
"handleCredentialsDuring:" : "mad 9/18/2023 14:13",
"handleCredentialsDuring:ifCanceled:" : "mad 10/17/2023 12:11",
"handleMovedImage" : "mad 6/9/2023 19:05",
"handleMovedImageFrom:to:" : "mad 11/28/2023 19:12",
"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 6/9/2023 19:06",
"imageHash" : "mad 11/28/2023 18:18",
"initialRemoteRefNameFor:" : "mad 9/18/2023 13:58",
"initialize" : "mad 9/18/2023 12:52",
"initializeHead" : "mad 6/10/2023 14:59",
Expand Down Expand Up @@ -105,7 +105,8 @@
"pushRef:" : "mad 9/18/2023 20:07",
"refChanged:" : "mad 9/15/2023 11:05",
"refName:" : "mad 6/3/2023 14:17",
"refsBaseName" : "mad 6/3/2023 14:16",
"refsBaseName" : "mad 11/28/2023 15:33",
"refsBaseNameForHash:" : "mad 11/28/2023 15:32",
"refsForCommit:" : "mad 9/11/2023 16:54",
"refsForCommits" : "mad 9/11/2023 16:36",
"refsForCommits:" : "mad 9/11/2023 16:36",
Expand Down

0 comments on commit eaf7c78

Please sign in to comment.