support > faqs > Simple Version Control

Although Programmer Studio provides an open interface to external version control systems, many new users are keen to explore the benefits of version control before deciding on the product or solution to use. This technical note is provided as an example of what may be achieved using simple command files or scripts.

Scenario

The file foo.c is located in the directory /src. This is the "production" version of the source file and must not be modified. When opened for reference, the file should always be opened as read-only. If any changes need to be made to this file, the file is first copied to the directory /dev where the file is opened as editable.

Solution

A command file is created which accepts a single parameter, a filename. The command file performs two tasks, checking for the existence of the file /dev/<parameter> and if the file does not exist, copy the file /src/<parameter> to /dev/<parameter>. In the event that the destination file already exists the command file displays an error message.

From the command prompt, ensuring that /src is the current directory, the command file is tested by adding the parameter foo.c.

A new Version Control System profile is created in Programmer Studio, MyVCS. In the commands list, the item Check Out is checked and the command file is specified with the parameter <f>. The <f> is evaluated to the filename against which the command is executed.

In a sample project, the file /src/foo.c is added. In the Project settings for this file, the VCS tab specifies MyVCS as the version control system. In the alternate check out directory field, the directory /dev is specified.

When the file foo.c is opened from the project, Programmer Studio will first check for the existence of the file /dev/foo.c (as specified by the alternate check out directory field). If this file exists, the file is opened for editing. If the file does not exist, the file /src/foo.c is opened as read-only.

The user can choose to begin working on a editable version of foo.c be selecting Check Out from the project menu or the code editor context (right-click) menu. This will then execute the command file created on the server which should check and then create a working copy of the source code in the /dev directory. If the command file is succesful, the working copy of the file is then automatically opened.

Conclusion

This scenario and solution is intentionally simple. It is provided as an example of what can be achieved using Programmer Studio's open version control interface. This solution can be expanded in many ways, for example supporting multiple users and submitting changes for review.

 

 
Copyright ©2008 Whisper Technology Limited. All rights reserved.