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