@@ -93,22 +93,21 @@ Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef Display
93
93
if '(##class (Change ).IsUncommitted (##class (Utils ).FullExternalName (InternalName ))) || ($username '= userCheckedOut ) {
94
94
set Enabled = 0
95
95
}
96
- }elseif name = " %Push" {
96
+ } elseif name = " %Push" {
97
97
// TODO: Only display if there are no files checked out by other users
98
98
set Enabled = 1
99
99
set DisplayName = " Push"
100
- }elseif name = " %Fetch" {
100
+ } elseif name = " %Fetch" {
101
101
set Enabled = 1
102
102
set DisplayName = " Fetch"
103
- }elseif name = " %Pull" {
103
+ } elseif name = " %Pull" {
104
104
set Enabled = 1
105
105
set DisplayName = " Pull"
106
- }elseif ##class (Utils ).IsMenuGitCommand (name ) && ##class (Utils ).GitBinExists () {
106
+ } elseif ##class (Utils ).IsMenuGitCommand (name ) && ##class (Utils ).GitBinExists () {
107
107
set DisplayName = $case (name ," %StashSave" :" Stash save" ,
108
108
" %StashPop" :" Stash pop" ,
109
109
:$Extract (name , 2 , *))
110
- }
111
- else {
110
+ } else {
112
111
set Enabled = -1
113
112
}
114
113
} elseif ##class (Utils ).GitBinExists () {
@@ -132,9 +131,9 @@ Method OnSourceMenuContextItem(itemName As %String, menuItemName As %String, ByR
132
131
133
132
if (itemName = " " ) || '##class (Utils ).IsNamespaceInGit () {
134
133
set Enabled = -1
135
- }elseif $F (itemName ," ," ) > 0 { //if more than one item is selected, we can only add/remove, no diff or blame
134
+ } elseif $F (itemName ," ," ) > 0 { //if more than one item is selected, we can only add/remove, no diff or blame
136
135
set Enabled = $case (menuItemName ," %AddToSC" :1 ," %RemoveFromSC" :1 ,:-1 )
137
- }elseif ##class (Utils ).IsInSourceControl (##class (Utils ).NormalizeInternalName (itemName )) {
136
+ } elseif ##class (Utils ).IsInSourceControl (##class (Utils ).NormalizeInternalName (itemName )) {
138
137
set Enabled = $Case (menuItemName , " %AddToSC" :-1 ,:1 )
139
138
} else {
140
139
set Enabled = $Case (menuItemName , " %AddToSC" :1 ,:-1 )
@@ -161,10 +160,10 @@ Method OnMenuItem(MenuName As %String, InternalName As %String, SelectedText As
161
160
162
161
if menu = " %SourceMenu" {
163
162
set ec = ..OnSourceMenuItem (name , .Enabled , .DisplayName , InternalName )
164
- }elseif menu = " %SourceContext" {
163
+ } elseif menu = " %SourceContext" {
165
164
set ec = ..OnSourceMenuContextItem (InternalName , name , .Enabled , .DisplayName )
166
165
}
167
- Quit ec
166
+ quit ec
168
167
}
169
168
170
169
/// This is called before the actual load of data to give the chance
@@ -205,7 +204,7 @@ Method OnAfterSave(InternalName As %String, Object As %RegisteredObject = {$$$NU
205
204
/// Called after the compile of the item is done.
206
205
Method OnAfterCompile (InternalName As %String ) As %Status
207
206
{
208
- Quit ..OnAfterSave (InternalName )
207
+ quit ..OnAfterSave (InternalName )
209
208
}
210
209
211
210
/// Returns true if this item is in source control and false otherwise.
@@ -228,7 +227,12 @@ Method OnAfterDelete(InternalName As %String) As %Status
228
227
/// the routine/class/csp item. This is often a filename to write the file out to.
229
228
Method ExternalName (InternalName As %String ) As %String
230
229
{
231
- Quit ##class (Utils ).Name (InternalName )
230
+ quit ##class (Utils ).Name (InternalName )
231
+ }
232
+
233
+ Method IsReadOnly (InternalName As %String ) As %Boolean
234
+ {
235
+ quit ##class (SourceControl.Git.Utils ).Locked ()
232
236
}
233
237
234
238
/// Check the status of the given item
@@ -237,42 +241,41 @@ Method ExternalName(InternalName As %String) As %String
237
241
Method GetStatus (InternalName As %String , ByRef IsInSourceControl As %Boolean , ByRef Editable As %Boolean , ByRef IsCheckedOut As %Boolean , ByRef UserCheckedOut As %String ) As %Status
238
242
{
239
243
#; Quit ##super(InternalName,.IsInSourceControl,.Editable,.IsCheckedOut,.UserCheckedOut)
240
- Set Editable =1 ,IsCheckedOut =1 ,UserCheckedOut =" "
241
- Set filename =##class (SourceControl.Git.Utils ).FullExternalName (InternalName )
242
- Set IsInSourceControl =(filename '=" " &&($$$FileExists(filename )))
243
- If filename =" " Quit $$$OK
244
- If InternalName =" " Quit $$$OK
245
- #; If the file does not exist then it must be a new item so it is editable.
246
- If '$$$FileExists(filename ) {
247
- Set IsCheckedOut =0
248
- }
249
- do ##class (Utils ).GitStatus (.files )
250
- if $Get (files (InternalName )) '= " " {
251
- ///it's in source control, checked out, and should be locked to editing by other users
252
- ///find out who has it edited
253
- set IsCheckedOut =1
254
- Set sc =##class (SourceControl.Git.Change ).GetUncommitted (filename ,.tAction ,.tInternalName ,.UncommittedUser ,.tSource ,.UncommittedLastUpdated )
255
- If $$$ISOK(sc ) {
256
- if ($D (tAction )&&(UncommittedUser '=$USERNAME )){
257
- Set msg =" NOTICE: " _InternalName _" is currently checked out by user '" _UncommittedUser _" ', and was last updated at " _UncommittedLastUpdated
258
- Write !,msg
259
- Set Editable =0
260
- Set IsInSourceControl =0 ;set this to 0 to prevent user from being prompted to Check Out file
261
- }
262
- Set UserCheckedOut =UncommittedUser
263
- }
264
- }
265
- // If it doesn't show up in git status, there are no uncommitted changes so it should not be locked or checked out by any user
266
- else {
267
- set Editable =1 , IsCheckedOut =0 , UserCheckedOut =" "
268
- if ##class (SourceControl.Git.Change ).IsUncommitted (filename ){
269
- #; Remove the item from the list of uncommitted changes;
270
- Set sc =##class (SourceControl.Git.Change ).RemoveUncommitted (filename ,1 ,1 )
271
- If $$$ISERR(sc ) Write " Error removing uncommitted file " _filename _" - " _$System .OBJ .DisplayError (sc )
244
+ set Editable ='..IsReadOnly (),IsCheckedOut =1 ,UserCheckedOut =" "
245
+ set filename =##class (SourceControl.Git.Utils ).FullExternalName (InternalName )
246
+ set IsInSourceControl =(filename '=" " &&($$$FileExists(filename )))
247
+ if filename =" " Quit $$$OK
248
+ if InternalName =" " Quit $$$OK
249
+ #; If the file does not exist then it must be a new item so it is editable.
250
+ if '$$$FileExists(filename ) {
251
+ set IsCheckedOut =0
252
+ }
253
+ do ##class (Utils ).GitStatus (.files )
254
+ if $Get (files (InternalName )) '= " " {
255
+ ///it's in source control, checked out, and should be locked to editing by other users
256
+ ///find out who has it edited
257
+ set IsCheckedOut =1
258
+ set sc =##class (SourceControl.Git.Change ).GetUncommitted (filename ,.tAction ,.tInternalName ,.UncommittedUser ,.tSource ,.UncommittedLastUpdated )
259
+ if $$$ISOK(sc ) {
260
+ if ($D (tAction )&&(UncommittedUser '=$USERNAME )){
261
+ set msg =" NOTICE: " _InternalName _" is currently checked out by user '" _UncommittedUser _" ', and was last updated at " _UncommittedLastUpdated
262
+ write !,msg
263
+ set Editable =0
264
+ set IsInSourceControl =0 ;set this to 0 to prevent user from being prompted to Check Out file
272
265
}
266
+ set UserCheckedOut =UncommittedUser
267
+ }
268
+ } else {
269
+ // If it doesn't show up in git status, there are no uncommitted changes so it should not be locked or checked out by any user
270
+ set Editable =1 , IsCheckedOut =0 , UserCheckedOut =" "
271
+ if ##class (SourceControl.Git.Change ).IsUncommitted (filename ){
272
+ #; Remove the item from the list of uncommitted changes;
273
+ set sc =##class (SourceControl.Git.Change ).RemoveUncommitted (filename ,1 ,1 )
274
+ if $$$ISERR(sc ) Write " Error removing uncommitted file " _filename _" - " _$System .OBJ .DisplayError (sc )
273
275
}
274
-
275
- Quit $$$OK
276
+ }
277
+
278
+ quit $$$OK
276
279
}
277
280
278
281
}
0 commit comments