Usage notes for OrcaScript commands with SVN/Git

You can use "scc connect offline" to compile the source code managed by the SVN/Git source control system in PowerBuilder 2019 R3; while you cannot use "scc connect" to connect with the SVN/Git server or get the source code from the server. Therefore, the following OrcaScript source control commands do not work with the SVN/Git solution in 2019 R3:

scc connect
scc get connect properties workspaceName
scc get latest version file_list [file_list ...]

The commands related with connecting to the server such as "scc set connect property userid userID", "scc set connect property password password" etc. will be simply ignored.

The following example shows you how to use the OrcaScript source control command to compile the source code from the SVN/Git source control system in 2019 R3.

start session 
scc set connect property localprojpath "D:\temp_svn" 
;localprojpath must point to the parent directory of ws_objects folder
scc set connect property logfile  "D:\temp_svn\svnorca.log" 
scc set connect property logappend false
scc set connect property deletetempfiles "true"
scc connect offline
scc set target "D:\temp_svn\datawindow_json.pbt" "refresh_all importonly"
scc exclude liblist "D:\temp_svn\pbsoapclient.pbd"
scc refresh target incremental
scc refresh target "3pass" 
build library "D:\temp_svn\datawindow_json.pbl" "" pbd 
build library "D:\temp_svn\appeon_workarounds.pbl" "" pbd
build library "D:\temp_svn\qa_frame.pbl" "" pbd
build executable "D:\temp_svn\datawindow_json.exe" "" "" "yyy"
scc close
end session
  • scc set connect property localprojpath -- Specifies the parent directory of the ws_objects folder. This example supposes ws_objects is located in D:\temp_svn.

  • scc connect offline -- Copies the objects from ws_objects up one level, that is, to the path specified in localprojpath (and it establishes no connection with the server).

    Important

    When you first upload a workspace to SVN or Git, all objects are generated under ws_objects which is a flat folder containing no sub-directories, therefore objects with the same name from different PBL files will be overwritten. If you have objects with the same name in different PBL files, make sure to rename the object before uploading it to SVN or Git.

  • scc set target -- Refreshes the object list in the PBL file according to the objects copied from ws_objects. The PBG file is no longer used by the SVN/Git solution to map and refresh objects in the PBL file.

  • scc exclude liblist -- Excludes any PBD files that are included in the current PBT, otherwise, an error will occur indicating that the corresponding PBG file cannot be found.

  • scc close -- Closes the session and clears the objects copied to the localprojpath path. The objects will not be cleared, if the OrcaScript commands are terminated by the user or by errors.

The following pseudocode shows you how to use the SVN/Git client tool to get the latest source code from the source control server via commands.

//generate bat file
long ll_file
string is_file
string ls_write
is_file = is_dirc+"\SvnGit.bat"
filedelete(is_file)
ll_file = fileopen(is_file,linemode!,write!,shared!,append!,encodingANSI!)
IF condition1 THEN  //SVN
  if  condition2 T then  // Checkout
      ls_write= "svn checkout ~""+ repository_url +"~" ~""+ checkout_directory +"~""
      //replace the variable "repository_url" and "checkout_directory"
  else   //Update
      ls_write = "svn update ~""+ checkout_directory +"~""
  end if
else  //Git
  if  condition2 T then //Checkout and switch branch
      ls_write = "git clone ~""+URL.text+"~" ~""+download_localpath.text+"~"~r~n"
      ls_write += "cd /d ~""+ download_localpath.text+"~"~r~n"
      ls_write +="git checkout ~"origin/"+sle_BranchName.text+"~""
  else  //Update and switch branch
      ls_write = "cd /d ~""+ download_localpath.text+"~"~r~n"
      ls_write += "git fetch origin ~""+sle_BranchName.Text +"~"~r~n"
      ls_write +="git checkout ~"origin/"+sle_BranchName.text+"~""
  end if
end if
filewrite(ll_file,ls_write)
fileclose(ll_file)

//Download files from svn or git server
run("~""+is_file+"~"")