Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.Opens in a new tab

For information on migrating to InterSystems IRISOpens in a new tab, see Why Migrate to InterSystems IRIS?

Studio.SourceControl.Example

class Studio.SourceControl.Example extends %Studio.SourceControl.Base

This is an example source control class. It is not intended for use on a real system, but as a code sample showing some useful techniques.

In this example each item in Cache is also stored as an XML file in the filesystem and these external files are assumed to be version controlled by a tool. So every time you load an item this will read the latest version of the item from the file, and when you save this item it will be written back to the XML file.

In addition, if you check an item out then an entry will be added to a global in Cache to show that this item is checked out, and when you check it in the global entry will be removed. Typically the checkout/checkin would call the external source control package, but setting the global shows the general principle.

Method Inventory

Methods

method CheckIn(InternalName As %String, Description As %String) as %Status
Check this routine/class/csp file into source control.
method CheckOut(InternalName As %String, Description As %String) as %Status
Check this routine/class/csp file out of source control.
method ExternalName(InternalName As %String) as %String
This assumes that your directory structure starts with a directory for the type of each item and then has subdirectories for each '.' in the item name with a base directory added to the start. So 'User.MyClass.cls' maps to 'cls/User/MyClass.xml'. You can pick whatever structure you prefer. This example is designed for Windows filenames, you will need to modify it to support Unix or VMS filenames.
method GetStatus(InternalName As %String, ByRef IsInSourceControl As %Boolean, ByRef Editable As %Boolean, ByRef IsCheckedOut As %Boolean, ByRef UserCheckedOut As %String) as %Status
Inherited description: Return information about this entity.
method IsInSourceControl(InternalName As %String) as %Boolean
Inherited description: Returns true if this item is in source control and false otherwise.
method OnAfterCompile(InternalName As %String) as %Status
Compilation can change a class as it can update the storage information. As such we need to check if the item has changed and save it out again if it has, this is already done by OnAfterSave() so just call this.
method OnAfterSave(InternalName As %String, Object As %RegisteredObject) as %Status
After saving an item in Cache we write this out to the XML file so the external source control tool can see what changes we have made.
method OnBeforeLoad(InternalName As %String) as %Status
Before loading any item we check to see if we have a later version in the XML file and if so this is loaded. Note the use of the timestamps in ^MySourceControl is just a performance optimzation to avoid loading the file where it is not needed. We have the '0' subscript which tracks the modified time on the file to avoid loading it when the file has not changed, and the '1' subscript tracks the timestamp on the item in Cache so we do not save it if it is up to date.

Inherited Members

Inherited Properties

Inherited Methods

FeedbackOpens in a new tab