Skip to content

Commit

Permalink
Merge pull request #447 from pharo-vcs/dev-0.5
Browse files Browse the repository at this point in the history
fixes restore clone
  • Loading branch information
estebanlm authored Aug 24, 2017
2 parents b7cc297 + 1407d94 commit 0624ced
Show file tree
Hide file tree
Showing 43 changed files with 193 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ changedFilesBetween: aCommitish and: otherCommitish
| fromTree toTree |

self withRepoDo: [ :repo | | diff |
fromTree := (LGitCommit of: repo fromId: (LGitId fromHexString: aCommitish id)) tree.
toTree := (LGitCommit of: repo fromId: (LGitId fromHexString: otherCommitish id)) tree.

diff := LGitDiff of: repo.
diff diffTree: fromTree toTree: toTree.
fromTree := (LGitCommit of: repo fromHexString: aCommitish id) tree.
toTree := (LGitCommit of: repo fromHexString: otherCommitish id) tree.
diff := fromTree diffTo: toTree.
^ diff files ]
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ cloneRepositoryFrom: aRemote branch: aBranchName
| repo cloneOptions |
repo := LGitRepository on: self location.
cloneOptions := LGitCloneOptions withCredentialsProvider: IceCredentialsProvider default.

cloneOptions checkoutOptions checkoutStrategy: LGitCheckoutStrategyEnum git_checkout_none.
repo clone: url options: cloneOptions.
aBranchName ifNotNil: [
repo checkout: aBranchName ].
repo checkout: (aBranchName ifNil: [
self branch
ifNotNil: [ :b | b name ]
ifNil: [ 'master' ] ]).

(LGitRemote of: repo named: 'origin')
lookup;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
private
compactIfNeeded
| newModelCache |
self models size > 250 ifFalse: [ ^ self ].
newModelCache := self models select: [ :each | each notNil ].
modelCache := newModelCache

"it looks like rehash will do what I need :)"
modelCache rehash
21 changes: 9 additions & 12 deletions Iceberg-UI.package/IceAbstractModel.class/class/modelFor..st
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
instance creation
modelFor: entity
| model |
"We are using WeakValueDictionary to keep this sinchronized (in case you have more than
one window open, you want always same model). Now, it has to be cleaned when windows are
no longer around, but associations will be nil... so we cannot use a simple ifAbsentPut:.
Yep, ugly... but effective."

model := self models at: entity name ifAbsent: [ nil ].
"We are using a WeakSet for keeping models because using a dictionary (sorted by
name) has problems when cleaning. This should be efficient enough, but we'll see."
model := self models
detect: [ :each | each notNil and: [ each entity name = entity name ] ]
ifNone: [ nil ].
^ model ifNil: [
self compactIfNeeded.
self models
at: entity name
put: (self basicNew
entity: entity;
initialize;
yourself) ]
self models add: (self basicNew
entity: entity;
initialize;
yourself) ]
2 changes: 1 addition & 1 deletion Iceberg-UI.package/IceAbstractModel.class/class/models.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ models
"since a repository can have same name as a package (and we keep models by name),
I need to keep this as an instance of class and not a variable (who would be
shared by all hierarchy and because of that prone to errors)"
^ modelCache ifNil: [ modelCache := WeakValueDictionary new ]
^ modelCache ifNil: [ modelCache := WeakSet new ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
initialization
invalidateOn: announcementType from: announcer
announcer subscribe: announcementType send: #reset to: self
announcer when: announcementType send: #reset to: self
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
private
configureRepository: aRepository
aRepository register
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ createRepository
location: self location;
subdirectory: subdirectory text;
createRepository.
repository register.
self configureRepository: repository.

self window delete.
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
actions
guessSubDirectory
"If a '.filetree' file, there is a high chance that this is a smalltalk code directory. In that case, the directory containing it is probably the subdirectory of the repository."

| location |
location := localDirectoryLocation location.
location files
detect: [ :file | file basename = '.filetree' ]
ifFound: [ :dir | subdirectory text: '' ]
ifNone: [ location directories do: [ :directory | directory files detect: [ :file | file basename = '.filetree' ] ifFound: [ :file | subdirectory text: directory basename ] ] ]
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ initialization
initializeWidgets
localDirectoryLocation := self instantiate: IceDirectoryModel.
localDirectoryLocation
onChoose: [ self guessSubDirectory ];
label: 'Local directory';
chooseTitle: 'Choose local repository';
location: self defaultLocation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ buildOn: aPresenter
onChangeOfPort: #entity act: [ :presentation |
self diff ifNotNil: [
self diff announcer
subscribe: IceChangeSetChanged
when: IceChangeSetChanged
send: #execute:
to: (IceChangesTreeResetSelectionHelper for: presentation) ] ];
yourself
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildOn: aPresenter
onChangeOfPort: #entity act: [ :presentation |
self diff ifNotNil: [
self diff announcer
subscribe: IceChangeSetChanged
when: IceChangeSetChanged
send: #execute:
to: (IceChangesTreeResetSelectionHelper for: presentation) ] ];
yourself
3 changes: 2 additions & 1 deletion Iceberg-UI.package/IceLocationModel.class/instance/choose.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ actions
choose
self chooseReference ifNotNil: [ :reference |
self location: reference.
self locationInput text: reference pathString ]
self locationInput text: reference pathString.
self onChoose ifNotNil: #value ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
hook
onChoose: aBlockClosure
"I allow to set a hook to execute when the user select a location."

chooseBlock := aBlockClosure
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
hook
onChoose
^ chooseBlock
3 changes: 2 additions & 1 deletion Iceberg-UI.package/IceLocationModel.class/properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"locationInput",
"chooseButton",
"label",
"chooseTitle"
"chooseTitle",
"chooseBlock"
],
"name" : "IceLocationModel",
"type" : "normal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ composeRepositories: repositories in: composite
table updateOn: MCPackageModified from: MCPackageManager announcer.

Iceberg announcer weak
subscribe: IceRepositoryCreated
when: IceRepositoryCreated
send: #execute:
to: (IceRepositoryUpdateHelper for: table).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ composeRepositoriesIn: composite
table updateOn: MCPackageModified from: MCPackageManager announcer.

Iceberg announcer weak
subscribe: IceRepositoryCreated
when: IceRepositoryCreated
send: #execute:
to: (IceRepositoryUpdateHelper for: table).

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
actions
restore
self repository backend cloneRepository.
self repository refresh.
(IceRestoreRepositoryModel repository: self repository) openWithSpec
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance creation
new
self error: 'Use #repository:'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
instance creation
repository: aRepository
^ self basicNew
initializeRepository: aRepository;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
private
configureRepository: aRepository
repository location = aRepository location
ifFalse: [ repository location: aRepository location ].
repository subdirectory = aRepository subdirectory
ifFalse: [ repository subdirectory: aRepository subdirectory ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
initialization
initializeRepository: aRepository
repository := aRepository.
self initialize.
repository location ifNotNil: [
remoteUrl text: repository origin url.
localDirectoryLocation location: repository location ].
subdirectory text: repository subdirectory
13 changes: 13 additions & 0 deletions Iceberg-UI.package/IceRestoreRepositoryModel.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"commentStamp" : "",
"super" : "IceCloneRepositoryModel",
"category" : "Iceberg-UI-View",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"repository"
],
"name" : "IceRestoreRepositoryModel",
"type" : "normal"
}
6 changes: 3 additions & 3 deletions Iceberg-UI.package/monticello.meta/categories.st
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SystemOrganization addCategory: #'Iceberg-UI'!
SystemOrganization addCategory: 'Iceberg-UI-Model'!
SystemOrganization addCategory: 'Iceberg-UI-Utils'!
SystemOrganization addCategory: 'Iceberg-UI-View'!
SystemOrganization addCategory: #'Iceberg-UI-Model'!
SystemOrganization addCategory: #'Iceberg-UI-Utils'!
SystemOrganization addCategory: #'Iceberg-UI-View'!
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
querying
mergeBaseWith: anotherCommit
^ self repository commitAt:
(self repository backend mergeBaseBetween: self id and: anotherCommit id)
(self repository mergeBaseBetween: self id and: anotherCommit id)
2 changes: 1 addition & 1 deletion Iceberg.package/IceDiff.class/instance/repository..st
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ accessing
repository: anObject
repository := anObject.
repository announcer weak
subscribe: IceCommited send: #refresh to: self
when: IceCommited send: #refresh to: self
Empty file.
5 changes: 5 additions & 0 deletions Iceberg.package/IceLog.class/class/for..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
instance creation
for: aRepository
^ self basicNew
initializeRepository: aRepository;
yourself
3 changes: 3 additions & 0 deletions Iceberg.package/IceLog.class/class/new.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance creation
new
self error: '#for:'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
private
cypressClassOrTraitName: aMethod
^ aMethod origin name, (self cypressMethodClassExtension: aMethod)

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
private
cypressMethodClassExtension: aMethod
aMethod isExtension ifTrue: [ ^ '.extension' ].
aMethod origin isTrait ifTrue: [ ^ '.trait' ].
^ '.class'
3 changes: 3 additions & 0 deletions Iceberg.package/IceLog.class/instance/cypressMethodName..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
private
cypressMethodName: aMethod
^ (MCFileTreeStCypressWriter fileNameForSelector: aMethod selector asString), '.st'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
private
cypressMethodSideName: aMethod
^ aMethod origin isClassSide
ifTrue: [ 'class' ]
ifFalse: [ 'instance' ]
3 changes: 3 additions & 0 deletions Iceberg.package/IceLog.class/instance/cypressPackageName..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
private
cypressPackageName: aPackage
^ aPackage name, '.package'
15 changes: 15 additions & 0 deletions Iceberg.package/IceLog.class/instance/fileNameForMethod..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
private
fileNameForMethod: aMethod
| path |

path := OrderedCollection new.
self repository subdirectory
ifNotEmpty: [ :subDir | path add: subDir ].
path
add: (self cypressPackageName: aMethod origin package);
add: (self cypressClassOrTraitName: aMethod);
add: (self cypressMethodSideName: aMethod);
add: (self cypressMethodName: aMethod).

^ String streamContents: [ :stream |
path asStringOn: stream delimiter: '/' ]
27 changes: 27 additions & 0 deletions Iceberg.package/IceLog.class/instance/historyOfMethod..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
accessing
historyOfMethod: aMethod
| path commit pathSpec options history |

path := self fileNameForMethod: aMethod.

commit := self repository branch lastCommit.
pathSpec := LGitPathSpec withAll: { path }.
options := LGitDiffOptions defaults.
options pathspec: (LGitStringArray withAll: { path }).

history := OrderedCollection new.
self repository newCommitWalk
fromCommit: commit;
rawResultsDo: [ :eachCommit | | parents tree |
parents := eachCommit numberOfParents.
tree := eachCommit tree.
parents = 0
ifTrue: [
(tree matchesPathSpec: pathSpec)
ifTrue: [ history add: eachCommit ] ]
ifFalse: [
eachCommit parents do: [ :eachParent | | diff |
diff := tree diffTo: eachParent tree options: options.
diff numberOfDeltas > 0
ifTrue: [ history add: eachCommit ] ] ] ].
^ history collect: [ :each | IceLibgitLocalRepository parseCommitInfo: each ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
initialization
initializeRepository: aRepository
repository := aRepository.
self initialize
3 changes: 3 additions & 0 deletions Iceberg.package/IceLog.class/instance/repository.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
repository
^ repository
13 changes: 13 additions & 0 deletions Iceberg.package/IceLog.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"commentStamp" : "",
"super" : "Object",
"category" : "Iceberg-Changes",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"repository"
],
"name" : "IceLog",
"type" : "normal"
}
3 changes: 3 additions & 0 deletions Iceberg.package/IceRepository.class/instance/log.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
log
^ IceLog for: self
14 changes: 7 additions & 7 deletions Iceberg.package/monticello.meta/categories.st
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SystemOrganization addCategory: #Iceberg!
SystemOrganization addCategory: 'Iceberg-Adapters'!
SystemOrganization addCategory: 'Iceberg-Announcements'!
SystemOrganization addCategory: 'Iceberg-Changes'!
SystemOrganization addCategory: 'Iceberg-Core'!
SystemOrganization addCategory: 'Iceberg-Core-Remotes'!
SystemOrganization addCategory: 'Iceberg-Errors'!
SystemOrganization addCategory: 'Iceberg-Security'!
SystemOrganization addCategory: #'Iceberg-Adapters'!
SystemOrganization addCategory: #'Iceberg-Announcements'!
SystemOrganization addCategory: #'Iceberg-Changes'!
SystemOrganization addCategory: #'Iceberg-Core'!
SystemOrganization addCategory: #'Iceberg-Core-Remotes'!
SystemOrganization addCategory: #'Iceberg-Errors'!
SystemOrganization addCategory: #'Iceberg-Security'!

0 comments on commit 0624ced

Please sign in to comment.