From bcb1e80b5f9f73d26719f9fb7c205036e42998ce Mon Sep 17 00:00:00 2001 From: isc-svelury <91484958+isc-svelury@users.noreply.github.com> Date: Thu, 10 Feb 2022 14:22:52 -0500 Subject: [PATCH 1/8] Create TestFile.cls Created a new file to test new Pull behaviour --- cls/SourceControl/Git/TestFile.cls | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 cls/SourceControl/Git/TestFile.cls diff --git a/cls/SourceControl/Git/TestFile.cls b/cls/SourceControl/Git/TestFile.cls new file mode 100644 index 00000000..9ce8d0a4 --- /dev/null +++ b/cls/SourceControl/Git/TestFile.cls @@ -0,0 +1,5 @@ +/// Class to test Git Pull behaviour +Class SourceControl.Git.TestFile Extends %RegisteredObject +{ + +} From e0bd40caa727893de65fb8b69469feefaae1d01f Mon Sep 17 00:00:00 2001 From: Sarmishta Velury Date: Tue, 15 Feb 2022 13:51:38 -0500 Subject: [PATCH 2/8] Remove workaround for .pkg files for VS Code --- cls/SourceControl/Git/Extension.cls | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/cls/SourceControl/Git/Extension.cls b/cls/SourceControl/Git/Extension.cls index 0ed86fd5..0da823d1 100644 --- a/cls/SourceControl/Git/Extension.cls +++ b/cls/SourceControl/Git/Extension.cls @@ -47,10 +47,7 @@ Method UserAction(Type As %Integer, Name As %String, InternalName As %String, Se if menu '= "%SourceMenu", menu'="%SourceContext" { quit $$$OK } - do $System.OBJ.GetPackageList(.files,InternalName) - if ($DATA(files) '= 0) { - set InternalName = ($piece($order(files("")), ".", 1)_".pkg") - } + set InternalName = ##class(Utils).NormalizeInternalName(InternalName) set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(InternalName) set ec = ##class(Utils).UserAction(InternalName, Name, .Target, .Action, .Reload) @@ -164,14 +161,6 @@ Method OnSourceMenuContextItem(itemName As %String, menuItemName As %String, ByR /// 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. Method OnMenuItem(MenuName As %String, InternalName As %String, SelectedText As %String, ByRef Enabled As %Boolean, ByRef DisplayName As %String) As %Status { - - if (InternalName '= ""){ - do $System.OBJ.GetPackageList(.files,InternalName) - if ($DATA(files) '= 0) { - set InternalName = ($piece($order(files("")), ".", 1)_".pkg") - } - } - set InternalName = ##class(Utils).NormalizeInternalName(InternalName) set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(InternalName) From c89c5dc90b6b299b4ca8bbd1d8efd0901272a2dd Mon Sep 17 00:00:00 2001 From: isc-svelury <91484958+isc-svelury@users.noreply.github.com> Date: Tue, 15 Feb 2022 16:21:08 -0500 Subject: [PATCH 3/8] Update TestFile.cls --- cls/SourceControl/Git/TestFile.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cls/SourceControl/Git/TestFile.cls b/cls/SourceControl/Git/TestFile.cls index 9ce8d0a4..f3b7fac8 100644 --- a/cls/SourceControl/Git/TestFile.cls +++ b/cls/SourceControl/Git/TestFile.cls @@ -1,5 +1,5 @@ /// Class to test Git Pull behaviour Class SourceControl.Git.TestFile Extends %RegisteredObject { - + // Comment to test git pull } From ea629179f73d6dced83a87e41a530544b5efcef5 Mon Sep 17 00:00:00 2001 From: isc-svelury <91484958+isc-svelury@users.noreply.github.com> Date: Tue, 15 Feb 2022 16:36:43 -0500 Subject: [PATCH 4/8] Delete TestFile.cls --- cls/SourceControl/Git/TestFile.cls | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 cls/SourceControl/Git/TestFile.cls diff --git a/cls/SourceControl/Git/TestFile.cls b/cls/SourceControl/Git/TestFile.cls deleted file mode 100644 index f3b7fac8..00000000 --- a/cls/SourceControl/Git/TestFile.cls +++ /dev/null @@ -1,5 +0,0 @@ -/// Class to test Git Pull behaviour -Class SourceControl.Git.TestFile Extends %RegisteredObject -{ - // Comment to test git pull -} From 1bf0eab76949f314e8c1c0f5bd48ad5c405a47dc Mon Sep 17 00:00:00 2001 From: isc-svelury <91484958+isc-svelury@users.noreply.github.com> Date: Tue, 15 Feb 2022 16:37:57 -0500 Subject: [PATCH 5/8] Create TestFile2.cls --- cls/SourceControl/Git/TestFile2.cls | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 cls/SourceControl/Git/TestFile2.cls diff --git a/cls/SourceControl/Git/TestFile2.cls b/cls/SourceControl/Git/TestFile2.cls new file mode 100644 index 00000000..94b5e0f7 --- /dev/null +++ b/cls/SourceControl/Git/TestFile2.cls @@ -0,0 +1,5 @@ +/// Another class to test Git Pull behaviour +Class SourceControl.Git.TestFile2 Extends %RegisteredObject +{ + +} From 7d92a75679006f38d322e70dfb62fa343aa0c509 Mon Sep 17 00:00:00 2001 From: Sarmishta Velury Date: Wed, 16 Feb 2022 11:48:43 -0500 Subject: [PATCH 6/8] Remove sc-list and change add/remove from source control behavior for packages --- cls/SourceControl/Git/Extension.cls | 4 +- cls/SourceControl/Git/TestFile2.cls | 5 - cls/SourceControl/Git/Utils.cls | 181 ++++++++++++++-------------- 3 files changed, 91 insertions(+), 99 deletions(-) delete mode 100644 cls/SourceControl/Git/TestFile2.cls diff --git a/cls/SourceControl/Git/Extension.cls b/cls/SourceControl/Git/Extension.cls index 0da823d1..31e2a219 100644 --- a/cls/SourceControl/Git/Extension.cls +++ b/cls/SourceControl/Git/Extension.cls @@ -132,7 +132,9 @@ Method OnSourceMenuContextItem(itemName As %String, menuItemName As %String, ByR { if (itemName = "") || '##class(Utils).IsNamespaceInGit() { set Enabled = -1 - } elseif $find(itemName,",") > 0 { //if more than one item is selected, we can only add/remove, no diff or blame + } elseif (($find(itemName,",") > 0) || (##class(SourceControl.Git.Utils).Type(itemName) = "pkg")) { + //if more than one item is selected, we can only add/remove, no diff or blame + // if a package is selected we should show options to add missing items and remove exisiting ones set Enabled = $case(menuItemName,"AddToSC":1,"RemoveFromSC":1,:-1) } elseif menuItemName = "Revert" { set Enabled = 1 diff --git a/cls/SourceControl/Git/TestFile2.cls b/cls/SourceControl/Git/TestFile2.cls deleted file mode 100644 index 94b5e0f7..00000000 --- a/cls/SourceControl/Git/TestFile2.cls +++ /dev/null @@ -1,5 +0,0 @@ -/// Another class to test Git Pull behaviour -Class SourceControl.Git.TestFile2 Extends %RegisteredObject -{ - -} diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index a0da16f9..c629732a 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -10,8 +10,6 @@ Parameter InstallNamespace = "%SYS"; Parameter Slash = {$case($system.Version.GetOS(),"Windows":"\",:"/")}; /// Name of the file with version controlled items -Parameter SCListFilename = "sc-list.txt"; - Parameter GitMenuItems = ",Settings,Commit,Pull,Fetch,Push,Revert,"; Parameter ImportAfterGitMenuItems = ",Commit,Pull,Fetch,Push,"; @@ -336,9 +334,14 @@ ClassMethod Pull(remote As %String = "origin") As %Status while (outStream.AtEnd = 0) { set file = outStream.ReadLine() set modification = ##class(SourceControl.Git.Modification).%New() - set modification.changeType = $piece(file, " ", 1) - set modification.externalName = $zstrip($piece(file," ",2,*),"force = 1 then we export item even if timestamp in system is older ClassMethod ExportAll(force As %Boolean = 0) As %Status { - $$$QuitOnError(..ExportRoutines(force)) - quit ..ExportSCList() + quit ..ExportRoutines(force) } /// if force = 1 then we import item even if timestamp in system is newer ClassMethod ImportAll(force As %Boolean = 0) As %Status { - $$$QuitOnError(..ImportSCList()) quit ..ImportRoutines(force) } @@ -1203,58 +1250,6 @@ ClassMethod ExportRoutines(force As %Boolean = 0) As %Status quit ec } -ClassMethod ExportSCList() As %Status -{ - #dim filename = ..TempFolder()_..#SCListFilename - #dim file as %File = ##class(%File).%New(filename) - #dim item as %String = "" - #dim defaultCspApp as %String = $system.CSP.GetDefaultApp($znspace) - $$$QuitOnError(file.Open("WSN")) - - for { - set item = $order(@..#Storage@("items",item)) - quit:item="" - #dim fixedItem as %String = item - if $extract(fixedItem, 1, $length(defaultCspApp)) = defaultCspApp { - set $extract(fixedItem, 1, $length(defaultCspApp)) = "" - } - - do file.WriteLine(fixedItem) - - } - $$$QuitOnError(file.%Save()) - do file.Close() - kill file - - do ..RunGitWithArgs(.errStream, .outStream, "add", ..#SCListFilename) - do errStream.OutputToDevice() - do outStream.OutputToDevice() - quit $$$OK -} - -ClassMethod ImportSCList() As %Status -{ - #dim filename = ..TempFolder()_..#SCListFilename - #dim file as %File = ##class(%File).%New(filename) - #dim defaultCspApp as %String = $system.CSP.GetDefaultApp($znspace) - #dim eol as %Boolean - - $$$QuitOnError(file.Open("R", 10)) - - #dim a - while 'file.AtEnd { - #dim s as %String = file.ReadLine(,,.eol) - continue:s="" - #dim item as %String = $replace(s, "", defaultCspApp) - set a(..NormalizeExtension(item)) = "" - } - kill @..#Storage("items") - merge @..#Storage("items") = a - do file.Close() - kill file - quit $$$OK -} - /// returns true if directory was deleted ClassMethod RemoveFolderIfEmpty(path As %String) As %Boolean { From 010b0b9af5e63ec25bd93320b8bc2e92f22ec5ab Mon Sep 17 00:00:00 2001 From: Sarmishta Velury Date: Wed, 16 Feb 2022 11:50:36 -0500 Subject: [PATCH 7/8] Delete sc-list.txt --- sc-list.txt | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 sc-list.txt diff --git a/sc-list.txt b/sc-list.txt deleted file mode 100644 index 143893bf..00000000 --- a/sc-list.txt +++ /dev/null @@ -1,17 +0,0 @@ -SourceControl.Git.API.CLS -SourceControl.Git.Change.CLS -SourceControl.Git.Extension.CLS -SourceControl.Git.Modification.CLS -SourceControl.Git.PackageManagerContext.CLS -SourceControl.Git.PullEventHandler.CLS -SourceControl.Git.PullEventHandler.Default.CLS -SourceControl.Git.PullEventHandler.IncrementalLoad.CLS -SourceControl.Git.PullEventHandler.PackageManager.CLS -SourceControl.Git.Settings.CLS -SourceControl.Git.StreamServer.CLS -SourceControl.Git.Utils.CLS -SourceControl.Git.WebUIDriver.CLS -SourceControl.Git.inc -SourceControl.Git.pkg -SourceControl.pkg -UnitTest.SourceControl.Git.pkg From 82664d2df236ad8d0782a8b94d4131b8630bff64 Mon Sep 17 00:00:00 2001 From: Sarmishta Velury Date: Wed, 16 Feb 2022 11:56:18 -0500 Subject: [PATCH 8/8] Remove external file deletion handling from incremental load pull event handler --- .../Git/PullEventHandler/IncrementalLoad.cls | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls b/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls index 27ae47ca..43a4aaca 100644 --- a/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls +++ b/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls @@ -16,37 +16,6 @@ Method OnPull() As %Status set internalName = ..ModifiedFiles(i).internalName if ((internalName = "") && (..ModifiedFiles(i).changeType '= "D")) { write ..ModifiedFiles(i).externalName, " was not imported into the database and will not be compiled. ", ! - } elseif ..ModifiedFiles(i).changeType = "D" { - #dim type as %String = ##class(SourceControl.Git.Utils).Type(internalName) - #dim name as %String = ##class(SourceControl.Git.Utils).NameWithoutExtension(internalName) - #dim deleted as %Boolean = 1 - write ! - - if type = "prj" { - set loadSC = $$$ADDSC(loadSC, $system.OBJ.DeleteProject(name)) - }elseif type = "cls" { - set loadSC = $$$ADDSC(loadSC, $system.OBJ.Delete(internalName)) - }elseif $listfind($listbuild("mac","int","inc","bas","mvb","mvi","dfi"), type) > 0 { - set loadSC = $$$ADDSC(loadSC, ##class(%Routine).Delete(internalName)) - }elseif type = "csp" { - #dim filename = $system.CSP.GetFileName(internalName) - if ##class(%File).Exists(filename) && '##class(%File).Delete(filename) { - set loadSC = $$$ADDSC(loadSC, ##class(SourceControl.Git.Utils).MakeError("Error while removing "_internalName)) - } - } else { - set deleted = 0 - } - - if deleted && loadSC { - do ##class(SourceControl.Git.Utils).RemoveRoutineTSH(internalName) - } else { - if +$system.Status.GetErrorCodes(loadSC) '= $$$ClassDoesNotExist { - write "Error: could not delete ", internalName, ! - } else { - // if something we wanted to delete is already deleted -- good! - set loadSC = $$$OK - } - } } else { set compilelist(internalName) = "" set nFiles = nFiles + 1 @@ -62,4 +31,3 @@ Method OnPull() As %Status } } -