Skip to content

Commit

Permalink
Turn ref list into ref tree
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusDoe committed Oct 10, 2024
1 parent 6a8fe59 commit d2639bb
Show file tree
Hide file tree
Showing 78 changed files with 313 additions and 115 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
actions
actionRefreshRefTree
self changed: #refTreeRoots.
7 changes: 0 additions & 7 deletions src/GitS-Core.package/GSBrowser.class/instance/activeRef..st

This file was deleted.

4 changes: 3 additions & 1 deletion src/GitS-Core.package/GSBrowser.class/instance/activeRef.st
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
accessing
activeRef
^ activeRef
^ (self activeRefTreeMember ifNil: [^ nil]) isRef
ifTrue: [self activeRefTreeMember ref]
ifFalse: [nil]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
accessing
activeRefTreeMember: aRefTreeMember
self basicActiveRefTreeMember: aRefTreeMember.
self activeRefCommit ifNotNil: [:commit | self activeCommit: commit].
self
changed: #activeRefTreeMember;
changed: #commitList.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
activeRefTreeMember
^ activeRefTreeMember
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
basicActiveRefTreeMember: aRefTreeMember
activeRefTreeMember := aRefTreeMember
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ toolbuilder
buildProjectsAndRefsPanel: builder
^ GSGUIUtilities buildVerticalSplit: 0.5
of: (self buildProjectList: builder)
and: (self buildRefList: builder)
and: (self buildRefTree: builder)
with: builder
10 changes: 0 additions & 10 deletions src/GitS-Core.package/GSBrowser.class/instance/buildRefList..st

This file was deleted.

10 changes: 10 additions & 0 deletions src/GitS-Core.package/GSBrowser.class/instance/buildRefTree..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
toolbuilder
buildRefTree: builder
^ builder pluggableTreeSpec new
model: self;
roots: #refTreeRoots;
getSelected: #activeRefTreeMember;
setSelected: #activeRefTreeMember:;
nodeClass: GSRefTreeMemberWrapper;
menu: #refListMenu:;
yourself

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
accessing
ensureActiveRefTreeMemberIdentityIn: aCollection
"PluggableTreeMorph uses == to find the morph corresponding to the activeRef.
since the refList might reload the refs sometimes (producing new object identities for the
same ref name strings), ensure that activeRef is (identity-)included in refList (given as aCollection)"
self activeRefTreeMember ifNil: [^ self].
self activeRefTreeMember isRef ifFalse: [^ self activeRefTreeMember: nil].
aCollection
detect: [:each | each ref = self activeRefTreeMember ref]
ifFound: [:member | self basicActiveRefTreeMember: member]
ifNone: [self activeRefTreeMember: nil].
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ updating
everythingChanged
self
changed: #activeWorkingCopy;
changed: #refList;
changed: #refTreeRoots;
changed: #commitList;
activeRef: nil;
activeRefTreeMember: nil;
activeCommit: (self activeWorkingCopy ifNotNil: #headCommit).
10 changes: 0 additions & 10 deletions src/GitS-Core.package/GSBrowser.class/instance/refList.st

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ refListMenu: aMenu
addLine;

add: 'Refresh refs'
action: #actionRefreshRefList;

add: (self showGitRefs ifTrue: ['<yes>'] ifFalse: ['<no>']), 'Show git refs'
action: #toggleShowGitRefs.
action: #actionRefreshRefTree.

^ aMenu
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ui
refTreeRoots
| roots |
roots := self activeWorkingCopy ifNotNil: #refTreeRoots ifNil: [^ {}].
self ensureActiveRefTreeMemberIdentityIn: roots.
^ roots
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ updating
refsChanged
self
changed: #commitList;
changed: #refList.
changed: #refTreeRoots.

This file was deleted.

3 changes: 0 additions & 3 deletions src/GitS-Core.package/GSBrowser.class/instance/showGitRefs.st

This file was deleted.

This file was deleted.

25 changes: 12 additions & 13 deletions src/GitS-Core.package/GSBrowser.class/methodProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"actionPush:force:" : "mad 5/18/2024 11:31",
"actionRebaseOntoActiveCommit" : "mad 4/5/2024 19:33",
"actionRebaseOntoCommit:" : "mad 10/9/2024 16:01",
"actionRefreshRefList" : "mad 10/24/2023 19:54",
"actionRefreshRefTree" : "mad 10/10/2024 00:22",
"actionRemoveActiveProject" : "mad 9/21/2023 11:55",
"actionRenameActiveProject" : "mad 12/8/2023 18:46",
"actionResetToActiveCommit" : "mad 4/5/2024 19:34",
Expand All @@ -77,16 +77,18 @@
"activeCommit:" : "mad 5/15/2024 21:42",
"activeCommitIfNilInformAnd:" : "mad 4/5/2024 19:07",
"activeCommitInfo" : "mad 9/14/2023 19:29",
"activeRef" : "mad 9/14/2023 19:19",
"activeRef:" : "mad 5/15/2024 21:40",
"activeRef" : "mad 10/10/2024 01:00",
"activeRefCommit" : "mad 9/14/2023 19:24",
"activeRefIfNilInformAnd:" : "mad 4/5/2024 19:37",
"activeRefTreeMember" : "mad 10/10/2024 01:00",
"activeRefTreeMember:" : "mad 10/10/2024 01:00",
"activeWorkingCopy" : "mad 9/19/2023 12:38",
"activeWorkingCopy:" : "mad 4/10/2024 19:17",
"activeWorkingCopyIfNilInformAnd:" : "mad 4/5/2024 19:05",
"addMappersProjectListMenu:" : "mad 10/9/2024 16:01",
"basicActiveCommit:" : "mad 5/15/2024 21:42",
"basicActiveRef:" : "mad 5/15/2024 21:40",
"basicActiveRefTreeMember:" : "mad 10/10/2024 01:01",
"buildBranchButton:" : "mad 9/14/2023 19:42",
"buildButtons:" : "mad 10/9/2024 16:01",
"buildCommitButton:" : "mad 9/1/2023 14:07",
Expand All @@ -98,10 +100,10 @@
"buildMainLayout:" : "mad 10/9/2024 16:01",
"buildOtherButton:" : "mad 10/18/2023 15:38",
"buildProjectList:" : "mad 10/9/2024 16:01",
"buildProjectsAndRefsPanel:" : "mad 10/9/2024 16:01",
"buildProjectsAndRefsPanel:" : "mad 10/10/2024 00:56",
"buildPullButton:" : "mad 9/18/2023 16:19",
"buildPushButton:" : "mad 9/18/2023 14:11",
"buildRefList:" : "mad 10/9/2024 16:01",
"buildRefTree:" : "mad 10/10/2024 01:20",
"buildUpperLayout:" : "mad 10/9/2024 16:01",
"buildWindow:" : "mad 10/9/2024 16:01",
"buildWith:" : "mad 9/1/2023 14:44",
Expand All @@ -114,9 +116,9 @@
"doesRef:comeBeforeRef:" : "mad 9/19/2023 14:45",
"emptyCommit" : "mad 4/4/2024 23:07",
"ensureActiveCommitIdentityIn:" : "mad 5/15/2024 21:55",
"ensureActiveRefIdentityIn:" : "mad 5/15/2024 21:54",
"ensureActiveRefTreeMemberIdentityIn:" : "mad 10/10/2024 01:03",
"ensureHeadCommitMaterializedTo:" : "mad 10/9/2024 16:01",
"everythingChanged" : "mad 12/22/2023 17:59",
"everythingChanged" : "mad 10/10/2024 01:03",
"ifRepositoryDoesNotExist:" : "mad 11/30/2023 17:08",
"menu:forCommit:" : "mad 4/5/2024 20:19",
"menu:forCommit:ref:" : "mad 8/13/2024 18:05",
Expand Down Expand Up @@ -145,14 +147,11 @@
"parentForPick:" : "mad 4/5/2024 14:44",
"projectListMenu:" : "mad 10/9/2024 16:01",
"refChanged:" : "mad 5/15/2024 20:47",
"refList" : "mad 5/15/2024 21:43",
"refListMenu:" : "mad 4/5/2024 18:55",
"refListMenu:" : "mad 10/10/2024 00:22",
"refTreeRoots" : "mad 10/10/2024 00:21",
"refTypeName:" : "mad 11/29/2023 15:59",
"refsChanged" : "mad 5/15/2024 20:47",
"refsChanged" : "mad 10/10/2024 00:22",
"requestBranchNameFor:at:fromRef:" : "mad 4/5/2024 19:29",
"showGitRefs" : "mad 10/16/2023 21:39",
"showGitRefs:" : "mad 10/16/2023 21:50",
"toggleShowGitRefs" : "mad 10/16/2023 21:50",
"unitOfWork" : "mad 9/19/2023 12:37",
"update:" : "mad 5/15/2024 20:47",
"validateDialogHasNoConflicts:before:" : "mad 9/27/2023 16:11",
Expand Down
3 changes: 1 addition & 2 deletions src/GitS-Core.package/GSBrowser.class/properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"instvars" : [
"activeWorkingCopy",
"activeCommit",
"activeRef",
"showGitRefs" ],
"activeRefTreeMember" ],
"name" : "GSBrowser",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ref-tree
newRefTreeWithLabel: labelString ref: refString
^ GSRefTree new
workingCopy: self;
label: labelString;
ref: refString;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ref-tree
refTreeRoots
| other roots |
roots := {
'local branches' -> self branchesBaseName.
}, (self remoteNames collect: [:each |
('remote branches on {1}' format: {each printString})
-> (self remoteRefBaseName, each, $/)]), {
'external branches' -> self gitBranchesBaseName.
'tags' -> 'refs/tags/'.
} collect: [:each | self newRefTreeWithLabel: each key ref: each value].
other := self newRefTreeWithLabel: 'other refs' ref: ''.
self allReferences do: [:ref |
self flag: #todo. "handle HEAD refs and refs from other squeak images"
roots
detect: [:each | ref beginsWith: each ref]
ifFound: [:root | root add: (ref allButFirst: root ref size)]
ifNone: [other add: ref]].
roots := roots copyWith: other.
roots do: #compressChildren.
^ roots reject: #isEmpty
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@
"materializeCommit:" : "mad 9/6/2023 19:27",
"materializeHead" : "mad 8/24/2023 23:49",
"moveToNewRepositoryLocation:" : "mad 12/22/2023 17:50",
"newRefTreeWithLabel:ref:" : "mad 10/10/2024 00:55",
"pushRef:force:" : "mad 5/18/2024 11:31",
"refChanged:" : "mad 5/15/2024 21:20",
"refName:" : "mad 6/3/2023 14:17",
"refTreeRoots" : "mad 10/10/2024 01:14",
"refsBaseName" : "mad 11/28/2023 15:33",
"refsBaseNameForHash:" : "mad 11/28/2023 15:32",
"refsChanged" : "mad 5/15/2024 21:21",
Expand Down
Empty file.
5 changes: 5 additions & 0 deletions src/GitS-Core.package/GSRefTree.class/instance/add..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
adding
add: aString
(aString includes: $/)
ifTrue: [self addInTree: aString]
ifFalse: [self addRef: aString].
6 changes: 6 additions & 0 deletions src/GitS-Core.package/GSRefTree.class/instance/addInTree..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
adding
addInTree: aString
| split |
split := aString indexOf: $/.
(self getTree: (aString first: split - 1))
add: (aString allButFirst: split).
3 changes: 3 additions & 0 deletions src/GitS-Core.package/GSRefTree.class/instance/addRef..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
adding
addRef: aString
^ self children add: (self createRef: aString)
3 changes: 3 additions & 0 deletions src/GitS-Core.package/GSRefTree.class/instance/addTree..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
adding
addTree: aString
^ self children add: (self createTree: aString)
3 changes: 3 additions & 0 deletions src/GitS-Core.package/GSRefTree.class/instance/children..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
children: anObject
children := anObject
3 changes: 3 additions & 0 deletions src/GitS-Core.package/GSRefTree.class/instance/children.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
children
^ children
9 changes: 9 additions & 0 deletions src/GitS-Core.package/GSRefTree.class/instance/compress.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
compressing
compress
self compressChildren.
self children ifEmpty: [^ nil].
self children size = 1 ifTrue: [
^ self children first
prefixLabel: self label, $/;
yourself].
^ self
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
compressing
compressChildren
self children:
((self children
collect: [:each | each compress]
thenSelect: #notNil)
sorted: #label ascending).
7 changes: 7 additions & 0 deletions src/GitS-Core.package/GSRefTree.class/instance/createRef..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
adding
createRef: aString
^ GSRefWrapper new
workingCopy: self workingCopy;
label: aString;
ref: self ref, aString;
yourself
7 changes: 7 additions & 0 deletions src/GitS-Core.package/GSRefTree.class/instance/createTree..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
adding
createTree: aString
^ GSRefTree new
workingCopy: self workingCopy;
label: aString;
ref: self ref, aString, $/;
yourself
5 changes: 5 additions & 0 deletions src/GitS-Core.package/GSRefTree.class/instance/getTree..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
adding
getTree: aString
^ self children
detect: [:each | each isTree and: [each ref beginsWith: ('{1}/{2}/' format: {self ref. aString})]]
ifNone: [self addTree: aString]
4 changes: 4 additions & 0 deletions src/GitS-Core.package/GSRefTree.class/instance/initialize.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
initialize-release
initialize
super initialize.
self children: OrderedCollection new.
3 changes: 3 additions & 0 deletions src/GitS-Core.package/GSRefTree.class/instance/isEmpty.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
isEmpty
^ self children isEmpty
3 changes: 3 additions & 0 deletions src/GitS-Core.package/GSRefTree.class/instance/isTree.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
isTree
^ true
Loading

0 comments on commit d2639bb

Please sign in to comment.