Sorry - I forgot to cc to the mailing list.
Sven.
attached mail follows:
Hi Sergio,
as far as I know there are only global revision numbers in Subversion.
Thus the combination of the path in the repository and the revision
number defines a file or directory in location and time. Every time
something is committed into or moved or copied in the repository the
revision number is increased by one.
If you want to get all revision numbers relating to your source code you
could use svnversion.exe. You must install the svn command line
utilities to use it. Then you could call svnversion in your matlab
programme. The following code could help you to develop a routine:
function v=getSVN_Revision(ReferencePath)
%V=GETSVN_REVISION(REFERENCEPATH) get the subversion revision
% v=getSVN_Revision(ReferencePath)
% ReferencePath : path of the source code part of the working directory
% v : vector with 1 or 2 elements representing the lowest and
% highest revision of the referenced path
% set default return value
v=[0];
% call subversion to find out version control revision
[svnErr,svnMsg]=system(['svnversion ' ReferencePath]);
% create cellstring with one row per line
svnMsg=strread(svnMsg,'%s','whitespace',char(10));
% check for an error reported by the operating system
if svnErr~=0
% an error is reported
if strmatch('''svnversion',svnMsg{1})==1
warnMsgID='SVN:installationProblem';
warnMsg=['Problem using version control system:' 10 ...
' Subversion could not be executed!'];
else
warnMsgID='SVN:versioningProblem';
warnMsg=['Problem using version control system:' 10 ...
' ' [svnMsg{:}] ];
end
else
d1=regexp(svnMsg{1},'\d+|:','match');
if isempty(d1)
warnMsgID='SVN:versioningProblem';
warnMsg=['Problem using version control system:' 10 ...
' ' [svnMsg{:}] ];
else
v(1)=str2double(d1{1});
if length(d1)==3
v(2)=str2double(d1{3});
end
if sum(cellfun('length',d1))~=length(svnMsg{1})
warnMsgID='SVN:versioningProblem';
warnMsg=['Problem using version control system:' 10 ...
' Working directory is not up to date !'];
else
warnMsgID=[];
end
end
end
if ~isempty(warnMsgID)
button=uigetpref('SVN_Interface','ContinueOnRevisionProblem',...
'Version problem',...
[warnMsg 10 'Continue anyway ?'],...
{'Yes','No';'Yes','No'},...
'DefaultButton','Yes');
if strcmpi(button,'Yes')
warning(warnMsgID,'%s',warnMsg);
else
error(['User canceled -> ' warnMsg])
end
end
To get the URL use:
function URL=SVN_getURL(WorkingCopy)
% default return value
URL=[];
% call subversion with the given parameter string to get a list of all
% properties
ParamStr=sprintf('info "%s"',WorkingCopy);
svnMsg=SVN_Call(ParamStr);
URL_Idx=strmatch('URL:',svnMsg);
if isempty(URL_Idx)
error('SVN:versioningProblem', '%s',...
['Problem using version control system - no URL found:' 10 ...
' ' [svnMsg{:}]])
end
URL=svnMsg{URL_Idx}(6:end);
and
function [svnMsg, varargout]=SVN_Call(ParamStr)
% History: 2005-11-30 created
% 2005-12-12 callStr changed to make SVN return values
% independent from localization
Msg=struct([]);
% call subversion with the given parameter string
%callStr=sprintf('svn %s',ParamStr);
callStr=sprintf('set LC_MESSAGES=en_En&&svn %s',ParamStr);
[svnErr,svnMsg]=system(callStr);
% create cellstring with one row per line
svnMsg=strread(svnMsg,'%s','delimiter','\n','whitespace','');
% check for an error reported by the operating system
if svnErr~=0
% an error is reported
if strmatch('''svn',svnMsg{1})==1
Msg(1).identifier='SVN:installationProblem';
Msg(1).message=['Problem using version control system:' 10 ...
' Subversion could not be executed!'];
else
Msg(1).identifier='SVN:versioningProblem';
Msg(1).message=['Problem using version control system:' 10 ...
cell2str(svnMsg,' ')];
end
elseif ~isempty(svnMsg)
if strmatch('svn:',svnMsg{1})==1
Msg(1).identifier='SVN:versioningProblem';
Msg(1).message=['Problem using version control system:' 10 ...
cell2str(svnMsg,' ')];
end
end
if nargout>1
varargout{1}=Msg;
else
error(Msg);
end
function s=cell2str(cstr,indent)
% define linebreak
NewLine=char([10]);
if iscellstr(cstr)
% add indent and linebreak to each cell element
h=strcat({indent}, cstr,{NewLine});
% convert to char array
s=[h{:}];
% remove last NewLine
s=s(1:(end-length(NewLine)));
else
s=cstr;
end
Sergio Zlotnik schrieb:
> Hi Sven,
>
> the keyword substitution is definitely better then SuvWCRev.
>
> I know that the next is a newbie question, but... Is there some way to
> define a global revision number?
> What I want to do is to include in the output of my program something
> like 'run with revision N'.
>
> Thanks again!
> Sergio
attached mail follows:
Hi Sergio,
you could use
-> keyword substitution
as described in the subversion book. See
http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.advanced.props.special.keywords
If you prefer using SubWCRev.exe:
There are no client side hook scripts available, yet. So you have to
write a wrapper script for commiting and updating calling SubWCRev after
each commit or update.
Regards,
Sven
Sergio Zlotnik schrieb:
> Hi everyone,
>
> Does someone know how to include the revision number in a .m file?
>
> I'm working on both windows and Linux.
> I try the SubWCRev.exe on windows and it works fine. But I don't know
> how to run it automatically.
>
> Thanks in advance,
> Sergio.
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Tue Apr 10 14:40:20 2007