MatrixBerryCore
getrevisionbypath.m
Go to the documentation of this file.
1 function rev=getrevisionbypath(ReferencePath,varargin)
2 import mxberry.core.throwerror;
3 UNVERSIONED_MESSAGE='unversioned';
4 UNVERSIONED_FILE_SVN_MESSAGE='Unversioned file';
5 %
6 isErrorsIgnored=false;
7 [~,prop]=parseparams(varargin);
8 nProp=length(varargin);
9 for k=1:2:nProp-1
10  switch lower(prop{k})
11  case 'ignoreerrors'
12  isErrorsIgnored=prop{k+1};
13  otherwise
14  mxberry.core.throwerror('wrongInput',...
15  'unknown property %s',prop{k});
16  end
17 end
18 try
19  [svnErr,svnMsg]=system(['svnversion ' '"',ReferencePath,'"']);
20  % create cellstring with one row per line
21  svnMsg=textscan(svnMsg,'%s','whitespace',char(10));
22  % check for an error reported by the operating system
23  if svnErr~=0
24  throwerror('svnError',strrep([svnMsg{1}{:}],'\','/'));
25  else
26  rev=svnMsg{end};
27  if strcmp(rev,UNVERSIONED_FILE_SVN_MESSAGE)
28  rev=UNVERSIONED_MESSAGE;
29  end
30  end
31 catch meObj
32  if ~isErrorsIgnored
33  rethrow(meObj);
34  else
35  rev=UNVERSIONED_MESSAGE;
36  end
37 end
function throwerror(in msgTag, in varargin)
THROWERROR works similarly to built-in ERROR function in case when there is no output arguments but s...
function getrevisionbypath(in ReferencePath, in varargin)
function parseparams(in args, in propNameList, in nRegExpected, in nPropExpected)
PARSEPARAMS behaves exactly as a built-in Matlab function apart from the incorrect behavior of Matlab...