Main Content

refreshSourceControl

更新工程文件的源代码管理状态

说明

示例

refreshSourceControl(proj) 更新指定工程中所有文件的源代码管理状态。在查询单个文件的 SourceControlStatus 属性之前,请使用 refreshSourceControl 获取最新源代码管理信息。

如果您使用 listModifiedFiles 查找工程中所有修改的文件,您不需要先调用 refreshSourceControl

示例

全部折叠

打开 Times Table App 工程。使用 currentProject 从当前加载的工程创建一个工程对象。

openExample("matlab/TimesTableProjectExample")
proj = currentProject;

在查询单个文件之前刷新源代码管理状态。

refreshSourceControl(proj)

获取所有未修改的工程文件。使用 ismember 函数获取一个 logicals 数组,说明 Times Table App 工程中的哪些文件未经修改。使用该数组获取未修改文件的列表。

unmodifiedStatus = ismember([mainProject.Files.SourceControlStatus], ...
    matlab.sourcecontrol.Status.Unmodified);
mainProject.Files(unmodifiedStatus)
ans = 
  1×9 ProjectFile array with properties:

    Path
    Labels
    Revision
    SourceControlStatus

输入参数

全部折叠

工程,指定为 matlab.project.Project 对象。使用 currentProject 从当前加载的工程创建一个工程对象。

版本历史记录

在 R2019a 中推出