@@ -20,6 +20,7 @@ XData Menu
20
20
<MenuItem Name =" Revert" />
21
21
<MenuItem Name =" Commit" />
22
22
<MenuItem Separator =" true" />
23
+ <MenuItem Name =" Sync" />
23
24
<MenuItem Name =" Push" />
24
25
<MenuItem Name =" Fetch" />
25
26
<MenuItem Name =" Pull" />
@@ -55,9 +56,9 @@ Method UserAction(Type As %Integer, Name As %String, InternalName As %String, Se
55
56
quit $$$OK
56
57
}
57
58
58
- set InternalName = ##class (Utils ).NormalizeInternalName (InternalName )
59
+ set InternalName = ##class (SourceControl.Git. Utils ).NormalizeInternalName (InternalName )
59
60
set context = ##class (SourceControl.Git.PackageManagerContext ).ForInternalName (InternalName )
60
- set ec = ##class (Utils ).UserAction (InternalName , Name , .Target , .Action , .Reload )
61
+ set ec = ##class (SourceControl.Git. Utils ).UserAction (InternalName , Name , .Target , .Action , .Reload )
61
62
quit ec
62
63
}
63
64
@@ -68,9 +69,9 @@ Method AfterUserAction(Type As %Integer, Name As %String, InternalName As %Strin
68
69
if menu '= " %SourceMenu" , menu '=" %SourceContext" {
69
70
quit $$$OK
70
71
}
71
- set InternalName = ##class (Utils ).NormalizeInternalName (InternalName )
72
+ set InternalName = ##class (SourceControl.Git. Utils ).NormalizeInternalName (InternalName )
72
73
set context = ##class (SourceControl.Git.PackageManagerContext ).ForInternalName (InternalName )
73
- set ec = ##class (Utils ).AfterUserAction (Type , Name , InternalName , .Answer , .Msg , .Reload )
74
+ set ec = ##class (SourceControl.Git. Utils ).AfterUserAction (Type , Name , InternalName , .Answer , .Msg , .Reload )
74
75
quit ec
75
76
}
76
77
@@ -90,6 +91,7 @@ Method LocalizeName(name As %String) As %String
90
91
" SwitchBranch" :$$$Text(" @SwitchBranch@Check out an existing branch" ),
91
92
" Revert" :$$$Text(" @Revert@Discard changes to file" ),
92
93
" Commit" :$$$Text(" @Commit@Commit changes to file" ),
94
+ " Sync" :$$$Text(" @Sync@Sync" ),
93
95
" Push" :$$$Text(" @Push@Push to remote branch" ),
94
96
" Fetch" :$$$Text(" @Fetch@Fetch from remote" ),
95
97
" Pull" :$$$Text(" @Pull@Pull changes from remote branch" ),
@@ -99,36 +101,52 @@ Method LocalizeName(name As %String) As %String
99
101
100
102
Method OnSourceMenuItem (name As %String , ByRef Enabled As %String , ByRef DisplayName As %String , InternalName As %String ) As %Status
101
103
{
104
+
102
105
if name = " Settings" {
103
106
set Enabled = 1
104
107
quit $$$OK
105
108
}
106
- if ##class (Utils ).NeedSettings () {
109
+ if ##class (SourceControl.Git. Utils ).NeedSettings () {
107
110
set Enabled = -1
108
111
quit $$$OK
109
112
}
110
- if ##class (Utils ).IsNamespaceInGit () {
111
- if $listfind ($listbuild (" AddToSC" , " RemoveFromSC" , " Revert" , " Commit" ), name ) {
112
- quit ..OnSourceMenuContextItem (InternalName ,name ,.Enabled ,.DisplayName )
113
- }
114
- set Enabled = $CASE (name ,
115
- // cases
116
- " Status" : 1 ,
117
- " GitWebUI" : 1 ,
118
- " Export" : 1 ,
119
- " ExportForce" : 1 ,
120
- " Import" : 1 ,
121
- " ImportForce" : 1 ,
122
- " NewBranch" : 1 ,
123
- " SwitchBranch" : 1 ,
124
- " Push" : 1 ,
125
- " Fetch" : 1 ,
126
- " Pull" : 1 ,
127
- " " : 1 ,
128
- :-1 // default
129
- )
113
+ if ##class (SourceControl.Git.Utils ).IsNamespaceInGit () {
114
+
115
+ if $listfind ($listbuild (" AddToSC" , " RemoveFromSC" , " Revert" , " Commit" ), name ) {
116
+ quit ..OnSourceMenuContextItem (InternalName ,name ,.Enabled ,.DisplayName )
117
+ }
118
+
119
+ if ##class (SourceControl.Git.Utils ).BasicMode () {
120
+ set Enabled = $CASE (name ,
121
+ " Status" : 1 ,
122
+ " GitWebUI" : 1 ,
123
+ " Sync" : 1 ,
124
+ " " : 1 ,
125
+ :-1
126
+
127
+ )
128
+ } else {
129
+ set Enabled = $CASE (name ,
130
+ // cases
131
+ " Status" : 1 ,
132
+ " GitWebUI" : 1 ,
133
+ " Export" : 1 ,
134
+ " ExportForce" : 1 ,
135
+ " Import" : 1 ,
136
+ " ImportForce" : 1 ,
137
+ " NewBranch" : 1 ,
138
+ " SwitchBranch" : 1 ,
139
+ " Push" : 1 ,
140
+ " Fetch" : 1 ,
141
+ " Pull" : 1 ,
142
+ " Sync" : -1 ,
143
+ " " : 1 ,
144
+ :-1 // default
145
+ )
146
+ }
130
147
131
- } elseif ##class (Utils ).GitBinExists () {
148
+
149
+ } elseif ##class (SourceControl.Git.Utils ).GitBinExists () {
132
150
if name = " Init" {
133
151
} else {
134
152
set Enabled = -1
@@ -141,7 +159,7 @@ Method OnSourceMenuItem(name As %String, ByRef Enabled As %String, ByRef Display
141
159
142
160
Method OnSourceMenuContextItem (itemName As %String , menuItemName As %String , ByRef Enabled As %String , ByRef DisplayName As %String ) As %Status
143
161
{
144
- if (itemName = " " ) || '##class (Utils ).IsNamespaceInGit () {
162
+ if (itemName = " " ) || '##class (SourceControl.Git. Utils ).IsNamespaceInGit () {
145
163
set Enabled = -1
146
164
} elseif (($find (itemName ," ," ) > 0 ) || (##class (SourceControl.Git.Utils ).Type (itemName ) = " pkg" )) {
147
165
//if more than one item is selected, we can only add/remove, no diff or blame
@@ -150,16 +168,16 @@ Method OnSourceMenuContextItem(itemName As %String, menuItemName As %String, ByR
150
168
} elseif menuItemName = " Revert" {
151
169
set Enabled = 1
152
170
do ..GetStatus (.itemName , .isInSourceControl , .isEditable ,.isCheckedOut ,.userCheckedOut )
153
- if '(##class (Change ).IsUncommitted (##class (Utils ).FullExternalName (itemName ))) || ($username '= userCheckedOut ) {
171
+ if '(##class (SourceControl.Git. Change ).IsUncommitted (##class (SourceControl.Git. Utils ).FullExternalName (itemName ))) || ($username '= userCheckedOut ) {
154
172
set Enabled = 0
155
173
}
156
174
} elseif menuItemName = " Commit" {
157
175
set Enabled = 1
158
176
do ..GetStatus (.itemName , .isInSourceControl , .isEditable ,.isCheckedOut ,.userCheckedOut )
159
- if '(##class (Change ).IsUncommitted (##class (Utils ).FullExternalName (itemName ))) || ($username '= userCheckedOut ) {
177
+ if '(##class (SourceControl.Git. Change ).IsUncommitted (##class (SourceControl.Git. Utils ).FullExternalName (itemName ))) || ($username '= userCheckedOut ) {
160
178
set Enabled = 0
161
179
}
162
- } elseif ##class (Utils ).IsInSourceControl (itemName ) {
180
+ } elseif ##class (SourceControl.Git. Utils ).IsInSourceControl (itemName ) {
163
181
set Enabled = $case (menuItemName , " AddToSC" :-1 ,:1 )
164
182
} else {
165
183
set Enabled = $case (menuItemName , " AddToSC" :1 ,:-1 )
@@ -174,7 +192,7 @@ Method OnSourceMenuContextItem(itemName As %String, menuItemName As %String, ByR
174
192
/// this menu item from the list totally, 0 will gray the menu item out and the default 1 will display the menu item as normal.
175
193
Method OnMenuItem (MenuName As %String , InternalName As %String , SelectedText As %String , ByRef Enabled As %Boolean , ByRef DisplayName As %String ) As %Status
176
194
{
177
- set InternalName = ##class (Utils ).NormalizeInternalName (InternalName )
195
+ set InternalName = ##class (SourceControl.Git. Utils ).NormalizeInternalName (InternalName )
178
196
set context = ##class (SourceControl.Git.PackageManagerContext ).ForInternalName (InternalName )
179
197
180
198
#dim menu as %String = $piece (MenuName ," ," )
@@ -200,9 +218,9 @@ Method OnMenuItem(MenuName As %String, InternalName As %String, SelectedText As
200
218
Method OnBeforeLoad (InternalName As %String , verbose As %Boolean ) As %Status
201
219
{
202
220
set context = ##class (SourceControl.Git.PackageManagerContext ).ForInternalName (InternalName )
203
- set InternalName = ##class (Utils ).NormalizeInternalName (InternalName )
204
- if ##class (Utils ).IsInSourceControl (InternalName ) {
205
- quit ##class (Utils ).ImportItem (InternalName ,,0 )
221
+ set InternalName = ##class (SourceControl.Git. Utils ).NormalizeInternalName (InternalName )
222
+ if ##class (SourceControl.Git. Utils ).IsInSourceControl (InternalName ) {
223
+ quit ##class (SourceControl.Git. Utils ).ImportItem (InternalName ,,0 )
206
224
}
207
225
quit $$$OK
208
226
}
@@ -236,15 +254,17 @@ Method OnAfterSave(InternalName As %String, Object As %RegisteredObject = {$$$NU
236
254
{
237
255
set sc = $$$OK
238
256
try {
239
- set InternalName = ##class (Utils ).NormalizeInternalName (.InternalName )
257
+ set InternalName = ##class (SourceControl.Git. Utils ).NormalizeInternalName (.InternalName )
240
258
set context = ##class (SourceControl.Git.PackageManagerContext ).ForInternalName (InternalName )
241
- if ##class (Utils ).IsNamespaceInGit () && ..IsInSourceControl (InternalName ) {
242
- set filename = ##class (Utils ).FullExternalName (InternalName )
243
- $$$ThrowOnError(##class (Utils ).RemoveRoutineTSH (InternalName ))
244
- $$$ThrowOnError(##class (Utils ).ExportItem (InternalName ))
259
+ if ##class (SourceControl.Git. Utils ).IsNamespaceInGit () && ..IsInSourceControl (InternalName ) {
260
+ set filename = ##class (SourceControl.Git. Utils ).FullExternalName (InternalName )
261
+ $$$ThrowOnError(##class (SourceControl.Git. Utils ).RemoveRoutineTSH (InternalName ))
262
+ $$$ThrowOnError(##class (SourceControl.Git. Utils ).ExportItem (InternalName ))
245
263
if '##class (SourceControl.Git.Change ).IsUncommitted (filename ) {
246
264
$$$ThrowOnError(##class (SourceControl.Git.Change ).SetUncommitted (filename , " edit" , InternalName , $username , " " , 1 , " " , " " , 0 ))
247
265
}
266
+ } elseif ##class (SourceControl.Git.Utils ).BasicMode () {
267
+ do ..AddToSourceControl (InternalName )
248
268
}
249
269
} catch e {
250
270
do e .Log ()
@@ -262,7 +282,7 @@ Method OnAfterCompile(InternalName As %String) As %Status
262
282
/// Returns true if this item is in source control and false otherwise.
263
283
Method IsInSourceControl (InternalName As %String ) As %Boolean [ CodeMode = expression ]
264
284
{
265
- InternalName '=" " && ##class (Utils ).IsInSourceControl (##class (Utils ).NormalizeInternalName (InternalName ))
285
+ InternalName '=" " && ##class (SourceControl.Git. Utils ).IsInSourceControl (##class (SourceControl.Git. Utils ).NormalizeInternalName (InternalName ))
266
286
}
267
287
268
288
/// Called before an item is deleted.
@@ -273,10 +293,10 @@ Method OnBeforeDelete(InternalName As %String) As %Status
273
293
Throw ##class (%Exception.General ).%New (" Can't delete in locked environment" )
274
294
} else {
275
295
set context = ##class (SourceControl.Git.PackageManagerContext ).ForInternalName (InternalName )
276
- set InternalName = ##class (Utils ).NormalizeInternalName (InternalName )
277
- set Filename = ##class (Utils ).FullExternalName (InternalName )
278
- if ##class (Utils ).IsInSourceControl (InternalName ) && ##class (%File ).Exists (Filename ) {
279
- quit ##class (Change ).AddDeletedToUncommitted (Filename , InternalName )
296
+ set InternalName = ##class (SourceControl.Git. Utils ).NormalizeInternalName (InternalName )
297
+ set Filename = ##class (SourceControl.Git. Utils ).FullExternalName (InternalName )
298
+ if ##class (SourceControl.Git. Utils ).IsInSourceControl (InternalName ) && ##class (%File ).Exists (Filename ) {
299
+ quit ##class (SourceControl.Git. Change ).AddDeletedToUncommitted (Filename , InternalName )
280
300
}
281
301
quit $$$OK
282
302
}
@@ -286,9 +306,9 @@ Method OnBeforeDelete(InternalName As %String) As %Status
286
306
Method OnAfterDelete (InternalName As %String ) As %Status
287
307
{
288
308
set context = ##class (SourceControl.Git.PackageManagerContext ).ForInternalName (InternalName )
289
- set InternalName = ##class (Utils ).NormalizeInternalName (InternalName )
290
- if ##class (Utils ).IsInSourceControl (InternalName ) {
291
- quit ##class (Utils ).DeleteExternalFile (InternalName )
309
+ set InternalName = ##class (SourceControl.Git. Utils ).NormalizeInternalName (InternalName )
310
+ if ##class (SourceControl.Git. Utils ).IsInSourceControl (InternalName ) {
311
+ quit ##class (SourceControl.Git. Utils ).DeleteExternalFile (InternalName )
292
312
}
293
313
quit $$$OK
294
314
}
@@ -297,7 +317,7 @@ Method OnAfterDelete(InternalName As %String) As %Status
297
317
/// the routine/class/csp item. This is often a filename to write the file out to.
298
318
Method ExternalName (InternalName As %String ) As %String
299
319
{
300
- quit ##class (Utils ).ExternalName (InternalName )
320
+ quit ##class (SourceControl.Git. Utils ).ExternalName (InternalName )
301
321
}
302
322
303
323
Method IsReadOnly (InternalName As %String ) As %Boolean
0 commit comments