-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
38 additions
and
9 deletions.
There are no files selected for viewing
3 changes: 0 additions & 3 deletions
3
src/Squot.package/SqueakWorkingCopy.class/instance/handleMovedImage.st
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
src/Squot.package/SqueakWorkingCopy.class/instance/handleMovedImageFrom.to..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]]]. |
6 changes: 4 additions & 2 deletions
6
src/Squot.package/SqueakWorkingCopy.class/instance/imageHash.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
2 changes: 1 addition & 1 deletion
2
src/Squot.package/SqueakWorkingCopy.class/instance/refsBaseName.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
refs | ||
refsBaseName | ||
^ 'refs/squeak/', self imageHash, '/' | ||
^ self refsBaseNameForHash: self imageHash |
3 changes: 3 additions & 0 deletions
3
src/Squot.package/SqueakWorkingCopy.class/instance/refsBaseNameForHash..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
refs | ||
refsBaseNameForHash: aString | ||
^ 'refs/squeak/', aString, '/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters