Matlab/Subversion interaction through scripting

21 ビュー (過去 30 日間)
Carl Banks
Carl Banks 2018 年 2 月 12 日
回答済み: Per-Anders Ekstrom 2023 年 4 月 2 日
Hi, I have a question about Matlab/Source Control interaction. The documents for the 2017a (our current) show, but it is all though the GUI. There's nothing in this documentation on how to do these things programmatically. (Which is disappointing since one of the very few thinks Mathworks has done mostly reliably is to allow for programmatic control of most things you can do with the GUI.)
My immediate need is for a way for a Matlab script to check if a file has local changes or not. The only thing I can do now is to run the Subversion command line tools and parse the output. That's undesirable for me for a few reasons, the most obvious one being that all my users would have to install the command line tools. (None of them currently use command line tools, they use Tortoise or Matlab integrated.) Other things I'd like to do is obtain revision numbers for traceability purposes (plots generated from our Simulink models can include the revision number in the plot title, that kind of thing).
Anyway, if anyone has some ideas I'd appreciate.

採用された回答

Carl Banks
Carl Banks 2018 年 2 月 12 日
編集済み: Carl Banks 2018 年 2 月 12 日
Never mind. I did some digging for ideas myself, and realized SVNkit, which is the Java SVN library, is installed with Matlab and available from the Matlab through its Java interoperability. Presumably the Matlab GUI uses it for its underlying source control interaction.
Knowing that, it's pretty straightforward to just use svnkit for the functionality I seek (insofar as Java is straightforward). For example, to get a file's revision number and test if it is locally modified:
svn_client_manager = org.tmatesoft.svn.core.wc.SVNClientManager.newInstance;
status_data = svn_client.getStatusClient.doStatus(java.io.File(working_filename),false);
revision = status_data.getRevision.getNumber;
status = char(status_data.getNodeStatus);
if strcmp(status,'modified')
disp 'FILE WAS MODIFIED'
end
So, I think I'm good.
  4 件のコメント
raghavendra kandukuri
raghavendra kandukuri 2020 年 1 月 23 日
what is "working_filename", is it .m script file name you are checking?
Sumit Gupta
Sumit Gupta 2020 年 3 月 6 日
編集済み: Sumit Gupta 2020 年 3 月 7 日
Hello Carl,
the script always provides head revision number of the repository root, even if different path is passed to java.io.File. Am looking for revision number of a file path. Please help me to fix this.
Regards,
kirankumar.

サインインしてコメントする。

その他の回答 (1 件)

Per-Anders Ekstrom
Per-Anders Ekstrom 2023 年 4 月 2 日
Maybe a little late answer for you, but this code might help anybody that wants to perform SVN-operations from the command line. The code make use of (as in yur own example) the already built-in subversion support (SVNKit) that is used by the graphical user interface, and thus, no installing of any external SVN command-line clients is required.

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by