Skip to content

Commit

Permalink
Merge pull request #1 from intersystems-ru/master
Browse files Browse the repository at this point in the history
last updates
  • Loading branch information
evshvarov committed Feb 15, 2016
2 parents d636940 + 0064207 commit bca7847
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 23 deletions.
7 changes: 5 additions & 2 deletions %SourceControl/Git.cls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<MenuItem Separator="true"/>
<MenuItem Name="%Export" Save = "001" />
<MenuItem Name="%Import" Save = "001" />
<MenuItem Name="%ImportForce" Save = "001" />
<MenuItem Separator="true"/>
<MenuItem Name="%OpenRepoFolder" Save = "001" />
</Menu>
Expand Down Expand Up @@ -80,7 +81,9 @@
set DisplayName = "Export All"
} elseif name = "%Import" {
set DisplayName = "Import All"
} elseif name = "%RepoStatus" && ##class(Utils).GitBinExists() {
} elseif name = "%ImportForce" {
set DisplayName = "Import All Force"
}elseif name = "%RepoStatus" && ##class(Utils).GitBinExists() {
set DisplayName = "Check for modifications"
}elseif name = "%OpenRepoFolder" {
set DisplayName = "Open Repo Folder"
Expand Down Expand Up @@ -162,7 +165,7 @@ to load the item from an external format.</Description>
<Implementation><![CDATA[
set InternalName = ##class(Utils).NormalizeInternalName(InternalName)
if ##class(Utils).IsInSourceControl(InternalName) {
quit ##class(Utils).LoadIfOutdated(InternalName)
quit ##class(Utils).ImportItem(InternalName)
}
quit $$$OK
]]></Implementation>
Expand Down
82 changes: 64 additions & 18 deletions %SourceControl/Git/Utils.cls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ Returns root temp folder</Description>
]]></Implementation>
</Method>

<Method name="GroupByFolder">
<ClassMethod>1</ClassMethod>
<CodeMode>expression</CodeMode>
<ReturnType>%String</ReturnType>
<Implementation><![CDATA[$Get(@..#Storage@("settings","groupByFolder"), 0)
]]></Implementation>
</Method>

<Method name="GitBinExists">
<ClassMethod>1</ClassMethod>
<ReturnType>%Boolean</ReturnType>
Expand Down Expand Up @@ -144,7 +152,6 @@ Returns root temp folder</Description>
<FormalSpec><![CDATA[&settings]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
// we change ^STORAGE to ^["InstallNamespace"]|STORAGE, so we store path to git.exe in one place
set @..InstallNamespaceStorage()@("%gitBinPath") = settings("gitBinPath")
kill @..InstallNamespaceStorage()@("%gitBinExists")
Expand All @@ -153,6 +160,7 @@ Returns root temp folder</Description>
set @..InstallNamespaceStorage()@("%defaultTemp") = ..AddSlash(settings("defaultTemp"))
set @..#Storage@("settings","namespaceTemp") = ..AddSlash(settings("namespaceTemp"))
set @..#Storage@("settings","groupByFolder") = $case(settings("groupByFolder"), "":"", :1)
]]></Implementation>
</Method>

Expand Down Expand Up @@ -226,13 +234,18 @@ Returns root temp folder</Description>
set ec = ..MakeError("Unable to create folder "_..TempFolder())
}
}elseif (menuItemName = "%Export") {
write "==export start==",!
set ec = ..ExportAll()
if ec {
write "Program export is done",!
write !,"==export done==",!
}
}elseif (menuItemName = "%Import") {
set ec = ..ImportAll()
set Reload = 1
}elseif (menuItemName = "%ImportForce") {
#define Force 1
set ec = ..ImportAll($$$Force)
set Reload = 1
}elseif (menuItemName = "%Clone") {
if ##class(%File).CreateDirectoryChain(..TempFolder()) {
// cleanup items info
Expand All @@ -249,7 +262,14 @@ Returns root temp folder</Description>
}elseif ..IsMenuGitCommand(menuItemName) {
set Action = 3
#dim command As %String = $ZConvert($Extract(menuItemName, 2, *), "L")
set Target = ..GitCommand(command)
set ec = $$$OK
if $Data(@..#Storage@("settings","hook"),hook)=1 {
set $ListBuild(class,method) = hook
set ec = $classmethod(class, method, command, InternalName)
}
if $$$ISOK(ec) {
set Target = ..GitCommand(command)
}
}
}elseif (menuName = "%SourceMenuContext") {
Expand Down Expand Up @@ -311,19 +331,26 @@ Returns root temp folder</Description>
#dim extension As %String = $ZConvert($Piece(name,".",$Length(name,".")),"L")
set $Piece(name,".",$Length(name,".")) = extension
#dim groupByFolder As %Boolean = ..GroupByFolder()
// we shall put classes in different folders
if extension = "cls" {
set name = $Translate( $Piece(name,".", 1, $Length(name,".")-1), ".", ..#Slash)_".cls"
set name = $Translate( $Piece(name,".", 1, $Length(name,".")-1), ".", ..#Slash)_".cls"
} elseif groupByFolder {
// If groupByFolder = 1 then we put inc, mac, int in corresponding folder, not in root.
// For example project.include.inc will be placed in project\include.inc.xml
set sep = $Case(extension, "dfi" : "-", : ".")
set name = $Translate( $Piece(name,".", 1, $Length(name,".")-1), sep, ..#Slash)_"." _ extension
}
// we shall delete csp-app from csp files
if $Extract(name, 1) = ..#Slash {
set $Extract(name, 1) = ""
}
if $Piece(name, ..#Slash, 1) = "csp" {
set $Piece(name, ..#Slash, 1, 2) = "csp"
}
//write "name=",name,!
//write "external name = ", $Translate(name," *?","___")_".xml", !
quit $Translate(name," *?","___")_".xml"
]]></Implementation>
</Method>
Expand Down Expand Up @@ -421,6 +448,9 @@ Returns root temp folder</Description>
quit:extension="csp" 0
#dim filename = $system.CSP.GetFileName(InternalName_"/")
if filename = "" && ($Extract(InternalName,1) '= "/") {
set filename = $system.CSP.GetFileName("/"_InternalName_"/")
}
quit filename'="" && ##class(%File).DirectoryExists(filename)
]]></Implementation>
</Method>
Expand Down Expand Up @@ -800,12 +830,13 @@ if temp file for InternalName not found return "0,0" in tempFileTSH</Description
for {
set item = $Order(^oddPROJECT(loadedProject,"Items",item))
quit:item=""
if $Data(^oddPROJECT(loadedProject,"Items",item,"CSP")) {
set type = $Order(^oddPROJECT(loadedProject,"Items",item,""))
if type = "CSP" || (type = "DIR") {
#dim newitem As %String = item
set $Piece(newitem,"/",1,2) = $Extract($system.CSP.GetDefaultApp($znspace),2,*)
if newitem '= item {
set ^oddPROJECT(loadedProject,"Items",newitem,"CSP") = ^oddPROJECT(loadedProject,"Items",item,"CSP")
kill ^oddPROJECT(loadedProject,"Items",item,"CSP")
set ^oddPROJECT(loadedProject,"Items",newitem,type) = ^oddPROJECT(loadedProject,"Items",item,type)
kill ^oddPROJECT(loadedProject,"Items",item,type)
set newCspApp = $Extract($system.CSP.GetDefaultApp($znspace),2,*)
set oldCspApp = $Piece(item,"/",1,2)
}
Expand All @@ -815,9 +846,12 @@ if temp file for InternalName not found return "0,0" in tempFileTSH</Description
]]></Implementation>
</Method>

<Method name="LoadIfOutdated">
<Method name="ImportItem">
<Description><![CDATA[
imports file if version in system is newer then version on disk.
if <var>force</var> = 1 then imports in any case.]]></Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>InternalName:%String</FormalSpec>
<FormalSpec>InternalName:%String,force:%Boolean=0</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
//WRITE "Before Load Of: ", InternalName, " ", ..IsInSourceControl(InternalName), !
Expand All @@ -826,16 +860,20 @@ if temp file for InternalName not found return "0,0" in tempFileTSH</Description
#dim fileTSH = ##class(%File).GetFileDateModified(filename)
#dim sc As %Status = $$$OK
if ..IsRoutineOutdated(InternalName) {
if ..IsRoutineOutdated(InternalName) || force {
set sc = $system.OBJ.Load(filename,"-l-d")
if sc {
set sc = ..UpdateRoutineTSH(InternalName, fileTSH)
if ..Type(InternalName) = "prj" {
set sc = $$$ADDSC(sc, ..FixProjectCspReferences(InternalName))
}
write InternalName," has been imported",!
} else {
write "ERROR importing" ,InternalName,!
do $system.Status.DisplayError(sc)
}
} else {
//WRITE "skip import -- same TS",!
write InternalName, " is newer than on-disk version, skipping import",!
}
Quit sc
]]></Implementation>
Expand Down Expand Up @@ -875,8 +913,11 @@ if temp file for InternalName not found return "0,0" in tempFileTSH</Description

<Method name="ImportRoutines">
<ClassMethod>1</ClassMethod>
<FormalSpec>force:%Boolean=0</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
write "==import start==", !
#dim err, itemList
kill err, itemList
Expand All @@ -893,7 +934,7 @@ if temp file for InternalName not found return "0,0" in tempFileTSH</Description
//w "item ",internalName," is not in source control, skipping",!
continue
}
#dim sc As %Status = ..LoadIfOutdated(internalName)
#dim sc As %Status = ..ImportItem(internalName, force)
if $$$ISERR(sc) {
set ec = $$$ADDSC(ec, sc)
}
Expand Down Expand Up @@ -933,7 +974,7 @@ if temp file for InternalName not found return "0,0" in tempFileTSH</Description
}
}
write "import done", !
write "==import done==", !
quit ec
]]></Implementation>
</Method>
Expand Down Expand Up @@ -985,7 +1026,7 @@ if temp file for InternalName not found return "0,0" in tempFileTSH</Description
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
#dim type = ..Type(InternalName)
//write "checking if we should export "_InternalName,!
if type = "pkg" {
$$$QuitOnError(..ExportRoutinesAux(..NameWithoutExtension(InternalName), "."))
}elseif type = "prj" && expand {
Expand All @@ -995,10 +1036,12 @@ if temp file for InternalName not found return "0,0" in tempFileTSH</Description
$$$QuitOnError(..ExportRoutinesAux(InternalName , "/"))
}else {
if ..IsTempFileOutdated(InternalName) {
write "exporting new version of ", InternalName, !
write "exporting new version of ", InternalName, !
#dim filename As %String = ..FullExternalName(InternalName)
$$$QuitOnError($system.OBJ.Export(InternalName, filename,"-d/diff"))
$$$QuitOnError(..UpdateRoutineTSH(InternalName, $Horolog))
} else {
write !,InternalName, " is not newer than on-disk version, skipping export"
}
}
quit $$$OK
Expand Down Expand Up @@ -1036,11 +1079,14 @@ if temp file for InternalName not found return "0,0" in tempFileTSH</Description
</Method>

<Method name="ImportAll">
<Description><![CDATA[
if <var>force</var> = 1 then we import item even if timestamp in system is newer]]></Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>force:%Boolean=0</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
$$$QuitOnError(..ImportSCList())
quit ..ImportRoutines()
quit ..ImportRoutines(force)
]]></Implementation>
</Method>

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Instead of your-git-server, your-git-login and your-git-password write actual va
20. Enter repository URL.
30. [If your TortoiseGit Version < 1.8.5] In appeared window TortoiseGit adds repository name to folder. You should delete it (Write c:\temp\git\user instead of c:\temp\git\user\reponame)
40. Press 'OK'.
50. Select menu Import All to load changes from temp folder to Caché.
50. Select menu Import All to load changes from temp folder to Caché. Import All compares timestamps of files and Caché items and import files only if they are newer then Caché versions. There is also Import All Force menu item that import files without any checks.

###Work Cycle
10. Choose menu item Pull.
Expand Down
2 changes: 1 addition & 1 deletion cache-tort-git.prj.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Project name="cache-tort-git" LastModified="2015-02-24 12:30:27.321554">
<Project name="cache-tort-git" LastModified="2016-01-29 14:34:24.339012" HttpServer="http://localhost:57780">
<Items>
<ProjectItem name="%SourceControl" type="PKG"></ProjectItem>
<ProjectItem name="csp/sys/gitprojectsettings.csp" type="CSP"></ProjectItem>
Expand Down
10 changes: 9 additions & 1 deletion csp/gitprojectsettings.csp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
znspace namespace
if $Data(%request.Data("gitsettings",1)) {
kill settings
for param="gitBinPath","defaultTemp","namespaceTemp" {
for param="gitBinPath","defaultTemp","namespaceTemp","groupByFolder" {
set settings(param) = $Get(%request.Data(param,1))
}
do ##class(%SourceControl.Git.Utils).UpdateSettings(.settings)
}
set gitBinPath = ##class(%SourceControl.Git.Utils).GitBinPath()
set defaultTemp = ##class(%SourceControl.Git.Utils).DefaultTemp()
set namespaceTemp = ##class(%SourceControl.Git.Utils).TempFolder()
set groupByFolder = ##class(%SourceControl.Git.Utils).GroupByFolder()
znspace oldNS
set:defaultTemp="" defaultTemp = "c:\temp\"
Expand All @@ -48,9 +49,16 @@ file does not found
<tr>
<td>Default path to temp folder<br/>(e.g. c:\temp)</td><td><input type="text" name="defaultTemp" size=40 value='#(..EscapeHTML(defaultTemp))#'/></td>
</tr>
<tr><th colspan="2">Settings for this namespace only</th>
</tr>
<tr>
<td>Temp folder for this namespace<br/>(e.g. c:\someproj\)</td><td><input type="text" name="namespaceTemp" size=40 value='#(..EscapeHTML(namespaceTemp))#'/></td>
</tr>
<!--
<tr>
<td>Group all items by folders</td><td><input type="checkbox" name="groupByFolder" size=40 #($case(groupByFolder,1:"checked",:""))#/></td>
</tr>
-->
</table>
<input type='submit' value = 'Save!'/>
</form>
Expand Down

0 comments on commit bca7847

Please sign in to comment.