| Contents | Index |
| On this page… |
|---|
Set Up Source Control with Projects Register Model Files with Source Control Tools |
Many capabilities of the Simulink Project Tool enable you to work with an external source control tool.
Projects automatically recognize supported source control applications when you create a new project in a folder under source control and click Detect.
Simulink projects contain interfaces to:
Apache Subversion (SVN) — Client must support the command-line interface. See Set Up Subversion.
A built-in Local Version Control tool.
Project examples use the light-weight local version control tool so you can try out source control operations. The local version control tool is designed for a single user for demonstration purposes only. See Set Up Local Version Control.
If your project is under a supported source control tool, you can use these project features:
If you use third-party source control tools, be sure to register your model file extensions (.mdl and .slx) as binary formats. If you do not, these third-party tools might corrupt your model files when you submit them, by changing end-of-line characters, expanding tokens, keyword substitution, or attempting to automerge. This can occur whether you use the source control tools outside of Simulink or if you try submitting files from the Simulink Project Tool without first registering your file formats.
You should also check other file extensions are registered as binary to avoid corruption at check-in for files such as .mat, .xlsx, .jpg, .pdf, .docx, etc.
For instructions, see Register Model Files with Subversion
Projects contain an interface to any Apache Subversion (SVN) client that supports the command-line interface. Install an SVN client that supports the command-line interface, then you can use SVN with the Simulink Project Tool.
TortoiseSVN does not support the command-line interface. However you can continue to use TortoiseSVN from Windows Explorer after installing another SVN client that supports the command-line interface. Ensure that the major version numbers match, e.g. both clients should be SVN 1.5, or SVN 1.6 etc.
You can find Subversion clients on this Web page: http://subversion.apache.org/packages.html.
If you do not register your model file extension as binary, Apache Subversion may add annotations to conflicted Simulink files and attempt automerge. This corrupts model files so you cannot load the models in Simulink.
To avoid this problem when using Subversion, follow these steps to register your file extensions:
Locate your SVN config file, e.g., C:\Users\myusername\AppData\Roaming\Subversion\config.
Add the following lines to the end of the config file, and SVN will no longer add annotations to Simulink files on conflict, and will never attempt an automerge.
*.mdl = svn:mime-type= application/octet-stream *.mat = svn:mime-type=application/octet-stream *.slx = svn:mime-type= application/octet-stream
To enable tagging within projects when using SVN, create your repository with the standard tags, trunk, and branch folders, and check out from trunk. This structure is recommended by the Subversion project. See the Web page: http://svn.apache.org/repos/asf/subversion/trunk/doc/user/svn-best-practices.html.
If you have installed the TortoiseSVN client for use with Microsoft Windows Explorer, you can follow these steps:
In Windows Explorer, right-click the folder where you want the repository and select TortoiseSVN > Create repository here. TortoiseSVN reports successful repository creation.
Right-click the repository folder and select TortoiseSVN > Repo-browser.
In the Repository Browser, right-click and select Create folder to add folders.
Add folders named tags, trunk, and branch.
When you check out files to your sandbox from the repository, check out from trunk. When you use either SVN Checkout in Windows, or Retrieve from Source Control in the project tool, select /trunk in the repository path, e.g., file:///C:/Work/repository/trunk.
After you create a repository with this structure, you can use the Tag button in the Project Source Control node to add tags to all your project files. Tag errors if you do not create a tags folder in your repository.
After you install an SVN client that supports the command-line interface, then the Simulink Project Tool can interface to SVN. To use SVN in your project:
Create a new project in a folder under SVN source control and click Detect. See Create a New Project to Manage Existing Files.
Alternatively, put the project under SVN source control later by using the Source Control node in the Project tree. Under Available Source Control Integrations, select Basic SVN Integration and click Reload. See Add or Change Project Source Control.
If you try to rename a file in a project under SVN source control, and the folder name contains an @ character, you see an error because command-line SVN treats all characters after the @ symbol to be a peg revision value.
The Simulink Project Tool includes a light-weight local version control tool so you can try out source control operations.
To add the local version control to a newly created project or an existing one,
Select the Source Control node in the Project tree.
Under Available Source Control Integrations, select Local Version Control and click Reload.
To create a repository using Local Version Control,
Select Simulink Project > Retrieve from Source Control
In the Project Retriever, select the Source control integration Local Version Control.
Next to Repository path click Change.
The Select a Repository dialog box opens.
Next to Create a new repository, click Create.
In the file browser, choose a location for your Local Version Control repository, specify a file name for your database .db file and click Save.
(Optional) In the Select a Repository dialog box, click Validate to check your new repository path is valid.
Click OK to close the dialog box and return to the Project Retriever.
To use your new repository, create a project sandbox and check files into the repository as follows:
Specify a new Sandbox folder in the Project Retriever, leave your new repository in the Repository path field and click Retrieve. You can use a sandbox folder that already contains files or add files to the folder later.
You are prompted to create a new project in the folder. Name your project and click Detect to put the project under Local Version Control.
If you don't already have files in the sandbox folder, create or copy the files you want in the project to the folder.
In the Project Tool All Files view, select files and right-click to Add to Project.
When you are ready to check in files to your Local Version Control repository, select the Modified Files view and click Commit Modified Files. Enter a comment if desired and click Submit. The project checks in the modified files to your new repository.

The Source Control node in the project tree shows details of the detected source control tool, the adapter interfacing to source control in your current project, and the repository location.
You can add source control to a newly created project or an existing one, by selecting an available source control tool from the list and clicking Reload.
Use this control to remove a project from source control by selecting No source control integration. For example this might be useful when you are preparing a project to create a template from it.
Autocheckout project definition files You can select the check box if you want the project to automatically check out project definition files, but there is a risk of unintentionally checking out files.
Caution To avoid unintentionally checking out files, do not select this checkbox. Instead, let the project notify you and offer to check out definition files only when you need to. |
Use tags to identify specific revisions of all project files. In the Source Control node, click the Tag button under Project Source Control Actions. Specify the text for the tag. This adds your tag to every project file.
Not every source control has the concept of tags. To use tags with SVN, see Create Subversion Repository Structure
Simulink provides a Software Development Kit (SDK) you can use to integrate Simulink Projects with third-party source control tools.
The SDK provides instructions for writing an adapter to a source control tool that has a published API that can be called from Java™.
You must create a jar file which implements a collection of Java interfaces and a Java Manifest file which defines a set of required properties.
The SDK also provides example source code, Javadoc, and files for validating, building, and testing your source control adapter. Build and test your own interfaces using the example as a guide, then you can use your source control adapter with Simulink Projects.
To extract the contents of the SDK, enter:
run(fullfile(matlabroot,'toolbox','simulink','simulink','slproject',...
'adapterSDK','extractSDK'))Select a folder to place the cm_adapter_SDK folder and files inside, and click OK.
Locate the new folder cm_adapter_SDK, and open the file cm_adapter_SDK_guide.pdf for instructions.
![]() | Create Shortcuts to Set Up Projects and Run Frequent Tasks | Retrieve and Check Out Files Under Source Control | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |