主要内容

Set Up SVN Source Control

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.

SVN Source Control Options

To use the version of SVN provided with MATLAB, when you retrieve a file from source control, selectSVN在里面Source control integrationlist. For instructions, seeCheck 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. SeeRegister 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 theCommand-Line SVN Integration (compatibility mode)Source control integrationoption, 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. WithCommand-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.

Register Binary Files with SVN

If you use third-party source control tools, you must register your MATLAB and Simulink®文件扩展诸如.mlx.,.mat,。fig,.mlapp,.mdl,。slx,.mdlp,。slxp,。sldd, 和每分钟作为二进制格式。还注册ME​​X文件的扩展,例如.mexa64,.mexmaci64, 和.mexw64。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 if 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 file extensions such as。xlsx,。jpg,每分钟df,.docx., 和so on.

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.

  1. Locate your SVNconfig文件。查找这些位置中的文件:

    • C:\用户\myusername\AppData\Roaming\Subversion\config要么C:\Documents and Settings\myusername\Application Data\Subversion\configon Windows®

    • 〜/ .subversion.在Linux上®要么macOS

  2. If you do not find aconfig文件,创建一个新的文件。看Create SVN Config File

  3. 如果你找到现有的configfile, you have previously installed SVN. Edit theconfig文件。看Update Existing SVN Config File

Create SVN Config File

  1. 如果你没有找到svnconfigfile, create a text file containing these lines:

    [误入歧途]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
  2. 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,每分钟df,.docx., etc. Add a line to theconfigfile 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
  3. Name the fileconfigand save it in the appropriate location:

    • C:\用户\myusername\AppData\Roaming\Subversion\config要么C:\Documents and Settings\myusername\Application Data\Subversion\configon Windows

    • 〜/ .subversion.在Linux上要么macOS

After you create the SVNconfigfile, SVN treats new files with these extensions as binary. If you already have binary files in repositories, seeRegister Files Already in Repositories

Update Existing SVN Config File

如果你找到现有的configfile, you have previously installed SVN. Edit theconfig将文件注册为二进制文件。

  1. Edit theconfigfile in a text editor.

  2. Locate the[误入歧途]部分,并验证以下行是否启用汽车道具withyes:

    enable-auto-props = yes
    Ensure that this line is not commented (that is, that it does not start with#)。配置文件可以包含穰mple lines that are commented out. If there is a#character at the beginning of the line, delete it.

  3. Locate the[auto-props]section. Ensure that[auto-props]is not commented. If there is a#character at the beginning, delete it.

  4. 在结尾添加以下行[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
    这些行可防止SVN将注释添加到MATLAB和SIMULINK文件上的冲突和自动化。万博1manbetx

  5. 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,每分钟df,.docx., etc. Add a line to theconfigfile 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
  6. Save theconfig文件。

创建或更新SVN后configfile, SVN treats new files as binary. If you already have files in repositories, register them as described inRegister Files Already in Repositories

Register Files Already in Repositories

Caution

Changing your SVNconfig文件不会影响已提交给SVN存储库的文件。如果文件未注册为二进制文件,请使用svn propset要手动将文件注册为二进制文件。

To manually register a file in a repository as binary, use the following command with command-line SVN:

SVN Propset SVN:MIME类型应用程序/八位字节流binaryfilename.

标准存储库结构

Create your repository with the standardtags,trunk, 和分支folders, and check out files fromtrunk。Subversion项目建议使用这种结构。看https://svn.apache.org/repos/asf/subversion/trunk/doc/user/svn-best-practices.html

After you create a repository with this structure, you can clickTag在里面Source Controlcontext menu to add tags to all of your files. For more information, see标记版本的文件

标记版本的文件

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 fromtrunk。看标准存储库结构

  1. Right-click in the Current Folder browser, and selectSource Control>Tag

  2. Specify the tag text and clickSubmit。The tag is added to every file in the folder. Errors appear if you do not have atags存储库中的文件夹。

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 fromtrunk创建新标签。

执行之前锁定文件编辑

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 selectSource Control>Get File Lockbefore 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.

要强制执行锁定文件,请修改SVN中的条目config文件。找到你的SVNconfigfile, seeRegister Binary Files with SVN

  1. To make files with a.mextension read only, add a property to your SVNconfigfile in the[auto-props]section. If there is no entry for files with a.mextension, add one with theneeds-lockproperty.

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

  2. To make files with a.mlx.extension read only, add a property to your SVNconfigfile 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 theneeds-lockproperty to the entry in any order, but on the same line and separated by a semicolon.

    * .mlx = svn:mime-type = application / octet-stream; svn:需要 - 锁定=是
  3. Re-create the sandbox for the configuration to take effect.

使用此设置,您需要选择Get File Lockbefore you can edit files with a.mextension. See获取SVN文件锁定

共享Subversion存储库

当您想要共享存储库时,需要设置服务器。您可以使用svnserve.要么the Apache™ SVN module. See the Web page references:

相关话题