Skip to content

Commit e96bd1f

Browse files
committed
Improvements to instance-wide uncommitted queue
Editing the file will get rid of the warning. Also, warning can be disabled in configuration.
1 parent 4c2135b commit e96bd1f

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

cls/SourceControl/Git/Change.cls

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ ClassMethod RefreshUncommitted(Display = 0, IncludeRevert = 0, Output gitFiles,
185185
quit sc
186186
}
187187

188-
Query InstanceUncommitted() As %Query(ROWSPEC = "InternalName:%String,User:%String")
188+
Query InstanceUncommitted() As %Query(ROWSPEC = "InternalName:%String,User:%String,Namespace:%String")
189189
{
190190
}
191191

@@ -206,6 +206,7 @@ ClassMethod InstanceUncommittedExecute(ByRef qHandle As %Binary) As %Status
206206
while resultSet.%Next() {
207207
set qHandle("changes", $increment(qHandle("changes")), "InternalName") = resultSet.%GetData(1)
208208
set qHandle("changes", qHandle("changes"), "User") = resultSet.%GetData(2)
209+
set qHandle("changes", qHandle("changes"), "Namespace") = namespace
209210
}
210211
}
211212

@@ -216,7 +217,7 @@ ClassMethod InstanceUncommittedFetch(ByRef qHandle As %Binary, ByRef Row As %Lis
216217
{
217218
set i = qHandle("i")
218219
if $data(qHandle("changes",i))=10 {
219-
set Row = $listbuild(qHandle("changes", i, "InternalName"), qHandle("changes", i, "User"))
220+
set Row = $listbuild(qHandle("changes", i, "InternalName"), qHandle("changes", i, "User"), qHandle("changes", i, "Namespace"))
220221
}
221222
if i >= $get(qHandle("changes"),0) {
222223
set AtEnd = 1

cls/SourceControl/Git/Extension.cls

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,26 @@ XData Menu
4444

4545
Method UserAction(Type As %Integer, Name As %String, InternalName As %String, SelectedText As %String, ByRef Action As %String, ByRef Target As %String, ByRef Msg As %String, ByRef Reload As %Boolean) As %Status
4646
{
47+
set settings = ##class(SourceControl.Git.Settings).%New()
4748
// If namespace change event
4849
if Type = 1, Name = 5 {
4950
// reroute to Status menu option
5051
set Name = "%SourceMenu,Status"
5152
}
5253

5354
if (Type = 1) && (Name = 3) {
54-
set user = ""
55-
if ##class(SourceControl.Git.Utils).FileIsUncommitted(InternalName, .user) && (user '= $USERNAME){
56-
set Target = InternalName _ " is currently being modified by " _ user
57-
write !, Target
58-
set Action = 6
55+
if settings.warnInstanceWideUncommitted {
56+
// if item is being edited in a different namespace, opening it will display an alert. Editing in this namespace will remove the alert.
57+
set filename = ##class(SourceControl.Git.Utils).FullExternalName(.InternalName)
58+
do ##class(SourceControl.Git.Change).GetUncommitted(filename,.tAction)
59+
if '$data(tAction) {
60+
set user = "", inNamespace = ""
61+
if ##class(SourceControl.Git.Utils).InstanceWideUncommittedCheck(InternalName, .user, .inNamespace) {
62+
set Target = "Warning: Item " _ InternalName _ " is currently being modified by " _ user _ " in namespace " _ inNamespace _ "."
63+
write !, Target
64+
set Action = 6
65+
}
66+
}
5967
}
6068
}
6169

cls/SourceControl/Git/Settings.cls

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ Property defaultMergeBranch As %String [ InitialExpression = {##class(SourceCont
4747
/// Compile using the configured pull event handler when "Import All" is run
4848
Property compileOnImport As %Boolean [ InitialExpression = {##class(SourceControl.Git.Utils).CompileOnImport()} ];
4949

50+
/// Warn when an item has uncommitted changes in a different namespace in this instance
51+
Property warnInstanceWideUncommitted As %Boolean [ InitialExpression = {##class(SourceControl.Git.Utils).WarnInstanceWideUncommitted()} ];
52+
5053
Property Mappings [ MultiDimensional ];
5154

5255
Method %OnNew() As %Status
@@ -102,6 +105,7 @@ Method %Save() As %Status
102105
set @storage@("settings", "mappedItemsReadOnly") = ..mappedItemsReadOnly
103106
set @storage@("settings", "defaultMergeBranch") = ..defaultMergeBranch
104107
set @storage@("settings", "compileOnImport") = ..compileOnImport
108+
set @storage@("settings", "warnInstanceWideUncommitted") = ..warnInstanceWideUncommitted
105109
set @storage@("settings", "basicMode") = ..systemBasicMode
106110
if ..basicMode = "system" {
107111
kill @storage@("settings", "user", $username, "basicMode")
@@ -229,4 +233,3 @@ Method OnAfterConfigure() As %Boolean
229233
}
230234

231235
}
232-

cls/SourceControl/Git/Utils.cls

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ ClassMethod CompileOnImport() As %Boolean
158158
quit $get(@..#Storage@("settings","compileOnImport"),1)
159159
}
160160

161+
ClassMethod WarnInstanceWideUncommitted() As %Boolean
162+
{
163+
quit $get(@..#Storage@("settings","warnInstanceWideUncommitted"),1)
164+
}
165+
161166
ClassMethod NeedSettings() As %Boolean [ CodeMode = expression ]
162167
{
163168
(..TempFolder() = "") || (..GitBinPath() = "") || (..GitBinPath() = """")
@@ -2440,16 +2445,18 @@ ClassMethod GetGitEnabledNamespaces() As %String
24402445
quit enabledNamespaces
24412446
}
24422447

2443-
ClassMethod FileIsUncommitted(InternalName As %String, Output User) As %Boolean
2448+
/// Returns true if the given item has uncommitted changes on a different namespace in this instance.
2449+
ClassMethod InstanceWideUncommittedCheck(InternalName As %String, Output User, Output Namespace) As %Boolean
24442450
{
24452451
set isUncommitted = 0
24462452
set resultSet = ##class(SourceControl.Git.Change).InstanceUncommittedFunc()
24472453
throw:resultSet.%SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(resultSet.%SQLCODE,resultSet.%Message)
24482454
while resultSet.%Next() {
24492455
set fileName = resultSet.InternalName
2450-
if InternalName = fileName {
2456+
if (InternalName = fileName) && (resultSet.Namespace '= $namespace) {
24512457
set isUncommitted = 1
24522458
set User = resultSet.User
2459+
set Namespace = resultSet.Namespace
24532460
}
24542461
}
24552462

0 commit comments

Comments
 (0)