MATLAB® provides built-in SVN integration for use with Subversion® (SVN) sandboxes and repositories. Because the implementation is built in to MATLAB, you do not need to install SVN. The built-in SVN integration supports secure logins. This integration ignores any existing SVN installation.
To use the version of SVN provided with MATLAB, when you retrieve a file from source control, select
SVN
in the Source control
integration list. For instructions, see Check Out from SVN Repository. When you create a new sandbox using the
MATLAB built-in SVN integration, the new sandbox uses the latest version of
SVN provided by MATLAB.
Caution
Before using source control, you must register binary files with the source control tools to avoid corruption. See Register Binary Files with SVN.
If you need to use a version of SVN other than the built-in version, you can
create a repository using the Command-Line SVN Integration
(compatibility mode)
Source control integration option, but you must also install a
command-line SVN client.
Command-line SVN integration communicates with any Subversion (SVN) client that supports the command-line interface.
With Command-Line SVN Integration (compatibility mode)
,
if you try to rename a file or folder to a name that contains an @ character, an
error occurs because command-line SVN treats all characters after the @ symbol as a
peg revision value.
If you use third-party source control tools, you must register your MATLAB and Simulink® file extensions such as .mlx
, .mat
,
.fig
, .mlapp
, .mdl
,
.slx
, .mdlp
, .slxp
,
.sldd
, and .p
as binary formats. If you do not
register the extensions, these tools can corrupt your files when you submit them by changing
end-of-line characters, expanding tokens, substituting keywords, or attempting to automerge.
Corruption can occur whether you use the source control tools outside of MATLAB or if you try submitting files from MATLAB without first registering your file formats.
Also check that other file extensions are registered as binary to avoid corruption at
check-in. Check and register files such as MEX-files, .xlsx
,
.jpg
, .pdf
, .docx
, etc.
You must register binary files if you use any version of SVN, including the built-in SVN integration provided by MATLAB. If you do not register your extensions as binary, SVN might add annotations to conflicted MATLAB files and attempt automerge. To avoid this problem when using SVN, register file extensions.
Locate your SVN config
file. Look for the file in
these locations:
C:\Users\
or myusername
\AppData\Roaming\Subversion\configC:\Documents and
Settings\
on Windows®myusername
\Application
Data\Subversion\config
~/.subversion
on Linux® or macOS
If you do not find a config
file, create a new one.
See Create SVN Config File.
If you find an existing config
file, you have
previously installed SVN. Edit the config
file. See
Update Existing SVN Config File.
If you do not find an SVN config
file, create a
text file containing these lines:
[miscellany] enable-auto-props = yes [auto-props] *.mlx = svn:mime-type=application/octet-stream *.mat = svn:mime-type=application/octet-stream *.fig = svn:mime-type=application/octet-stream *.mdl = svn:mime-type=application/octet-stream *.slx = svn:mime-type= application/octet-stream *.mlapp = svn:mime-type= application/octet-stream *.p = svn:mime-type=application/octet-stream *.mdlp = svn:mime-type=application/octet-stream *.slxp = svn:mime-type=application/octet-stream *.sldd = svn:mime-type=application/octet-stream *.slxc = svn:mime-type=application/octet-stream *.mlproj = svn:mime-type=application/octet-stream *.mldatx = svn:mime-type=application/octet-stream *.slreqx = svn:mime-type=application/octet-stream *.sfx = svn:mime-type=application/octet-stream *.sltx = svn:mime-type=application/octet-stream
Check for other file types you use that you also need to register as
binary to avoid corruption at check-in. Check for files such as
MEX-files (.mexa64
, .mexmaci64
,
.mexw64
), .xlsx
,
.jpg
, .pdf
,
.docx
, etc. Add a line to the
config
file for each file type you need.
Examples:
*.mexa64 = svn:mime-type=application/octet-stream *.mexw64 = svn:mime-type=application/octet-stream *.mexmaci64 = svn:mime-type=application/octet-stream *.xlsx = svn:mime-type=application/octet-stream *.docx = svn:mime-type=application/octet-stream *.pdf = svn:mime-type=application/octet-stream *.jpg = svn:mime-type=application/octet-stream *.png = svn:mime-type=application/octet-stream
Name the file config
and save it in the appropriate location:
C:\Users\
or myusername
\AppData\Roaming\Subversion\configC:\Documents and
Settings\
on Windowsmyusername
\Application
Data\Subversion\config
~/.subversion
on Linux or macOS.
After you create the SVN config
file, SVN treats new files
with these extensions as binary. If you already have binary files in
repositories, see Register Files Already in Repositories.
If you find an existing config
file, you have previously
installed SVN. Edit the config
file to register files as
binary.
Edit the config
file in a text editor.
Locate the [miscellany]
section, and verify the
following line enables auto-props
with
yes
:
enable-auto-props = yes
#
). Config files can contain example lines that
are commented out. If there is a #
character at the
beginning of the line, delete it.Locate the [auto-props]
section. Ensure that
[auto-props]
is not commented. If there is a
#
character at the beginning, delete it.
Add the following lines at the end of the
[auto-props]
section:
*.mlx = svn:mime-type=application/octet-stream *.mat = svn:mime-type=application/octet-stream *.fig = svn:mime-type=application/octet-stream *.mdl = svn:mime-type=application/octet-stream *.slx = svn:mime-type= application/octet-stream *.mlapp = svn:mime-type= application/octet-stream *.p = svn:mime-type=application/octet-stream *.mdlp = svn:mime-type=application/octet-stream *.slxp = svn:mime-type=application/octet-stream *.sldd = svn:mime-type=application/octet-stream *.slxc = svn:mime-type=application/octet-stream *.mlproj = svn:mime-type=application/octet-stream *.mldatx = svn:mime-type=application/octet-stream *.slreqx = svn:mime-type=application/octet-stream *.sfx = svn:mime-type=application/octet-stream *.sltx = svn:mime-type=application/octet-stream
Check for other file types you use that you also need to register as
binary to avoid corruption at check-in. Check for files such as
MEX-files (.mexa64
, .mexmaci64
,
.mexw64
), .xlsx
,
.jpg
, .pdf
,
.docx
, etc. Add a line to the
config
file for each file type you use.
Examples:
*.mexa64 = svn:mime-type=application/octet-stream *.mexw64 = svn:mime-type=application/octet-stream *.mexmaci64 = svn:mime-type=application/octet-stream *.xlsx = svn:mime-type=application/octet-stream *.docx = svn:mime-type=application/octet-stream *.pdf = svn:mime-type=application/octet-stream *.jpg = svn:mime-type=application/octet-stream *.png = svn:mime-type=application/octet-stream
Save the config
file.
After you create or update the SVN config
file, SVN treats
new files as binary. If you already have files in repositories, register them as
described in Register Files Already in Repositories.
Caution
Changing your SVN config
file does not affect files
already committed to an SVN repository. If a file is not registered as
binary, use svn propset
to manually register the files as
binary.
To manually register a file in a repository as binary, use the following command with command-line SVN:
svn propset svn:mime-type application/octet-stream binaryfilename
Create your repository with the standard tags
,
trunk
, and branches
folders, and check out
files from trunk
. The Subversion project recommends this structure. See https://svn.apache.org/repos/asf/subversion/trunk/doc/user/svn-best-practices.html.
If you use MATLAB to create an SVN repository, it creates the standard repository
structure. To enable tagging, the repository must have the standard
trunk/
and tags/
folders. After you create
a repository with this structure, you can click Tag in the
Source Control context menu to add tags to all of
your files. For more information, see Tag Versions of Files.
With SVN, you can use tags to identify specific revisions of all files. To use
tags with SVN, you need the standard folder structure in your repository and you
need to check out your files from trunk
. See Standard Repository Structure.
Right-click in the Current Folder browser, and select Source Control > Tag.
Specify the tag text and click Submit. The tag
is added to every file in the folder. Errors appear if you do not have a
tags
folder in your repository.
Note
You can retrieve a tagged version of your files from source control, but you
cannot tag them again with a new tag. You must check out from
trunk
to create new tags.
To require that users remember to get a lock on files before editing, configure SVN to make files with specified extensions read only. When your files are read only, you need to select Right-click in the Current Folder browser, and select Source Control > Get File Lock before you can edit them. This setting prevents editing of files without getting the file lock. When the file has a lock, other users know the file is being edited, and you can avoid merge issues.
To enforce locking files, modify entries in the SVN config
file. To locate your SVN config
file, see Register Binary Files with SVN.
To make files with a .m
extension read only, add a
property to your SVN config
file in the
[auto-props]
section. If there is no entry for files
with a .m
extension, add one with the
needs-lock
property.
*.m = svn:needs-lock=yes
If an entry exists, you can combine properties in any order, but multiple entries must be on a single line separated by semicolons.
To make files with a .mlx
extension read only, add a
property to your SVN config
file in the
[auto-props]
section. Since you must register files
with a .mlx
extension as binary, there is an entry for
the file type. Add the needs-lock
property to the entry
in any order, but on the same line and separated by a semicolon.
*.mlx = svn:mime-type=application/octet-stream;svn:needs-lock=yes
Re-create the sandbox for the configuration to take effect.
With this setting, you need to select Get File Lock
before you can edit files with a .m
extension. See Get SVN File Locks.
You can specify a repository location using the file://
protocol. However, Subversion documentation strongly recommends that only a single user access a
repository directly via file://
URLs. See the Web page:
Caution
Do not allow multiple users to access a repository directly via
file://
URLs or you risk corrupting the repository. Use
file://
URLs only for single-user repositories.
Be aware of this caution if you use MATLAB to create a repository. MATLAB uses the file://
protocol. Creating new
repositories is provided for local, single-user access only, for testing and
debugging. Accessing a repository via file://
URLs is slower than
using a server.
When you want to share a repository, you need to set up a server. You can use
svnserve
or the Apache™ SVN module.
See the Web page references: