Skip to Main Content Skip to Search
Product Documentation

Interface with Source Control from Projects

Set Up Source Control with Projects

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:

If your project is under a supported source control tool, you can use these project features:

Register Model Files with Source Control Tools

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

Set Up Subversion

Install 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.

Register Model Files with Subversion

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:

  1. Locate your SVN config file, e.g., C:\Users\myusername\AppData\Roaming\Subversion\config.

  2. 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

Create Subversion Repository Structure

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:

  1. In Windows Explorer, right-click the folder where you want the repository and select TortoiseSVN > Create repository here. TortoiseSVN reports successful repository creation.

  2. Right-click the repository folder and select TortoiseSVN > Repo-browser.

  3. In the Repository Browser, right-click and select Create folder to add folders.

    Add folders named tags, trunk, and branch.

  4. 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.

Use Projects with Subversion

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:

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.

Set Up Local Version Control

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,

  1. Select the Source Control node in the Project tree.

  2. Under Available Source Control Integrations, select Local Version Control and click Reload.

To create a repository using Local Version Control,

  1. Select Simulink Project > Retrieve from Source Control

  2. In the Project Retriever, select the Source control integration Local Version Control.

  3. Next to Repository path click Change.

    The Select a Repository dialog box opens.

  4. Next to Create a new repository, click Create.

  5. 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.

  6. (Optional) In the Select a Repository dialog box, click Validate to check your new repository path is valid.

  7. Click OK to close the dialog box and return to the Project Retriever.

  8. To use your new repository, create a project sandbox and check files into the repository as follows:

    1. 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.

    2. 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.

    3. If you don't already have files in the sandbox folder, create or copy the files you want in the project to the folder.

    4. In the Project Tool All Files view, select files and right-click to Add to Project.

    5. 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.

Add or Change Project Source Control

Viewing Source Control Type and 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.

Adding, Changing or Removing Source Control

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.

Using Source Control Settings

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.

Tagging Files

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

Write a Source Control Adapter with the SDK

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.

  1. 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.

  2. Locate the new folder cm_adapter_SDK, and open the file cm_adapter_SDK_guide.pdf for instructions.

  


Related Products & Applications

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