-
Notifications
You must be signed in to change notification settings - Fork 5
/
aedes_check_updates.m
112 lines (98 loc) · 2.62 KB
/
aedes_check_updates.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
function [isUpdateAvailable,HeadRev,WorkingCopyRev,error_msg]=aedes_check_updates()
% AEDES_CHECK_UPDATES - Check if Aedes updates are available
%
% Synopsis:
% [isUpdateAvailable,HeadRev,WorkingCopyRev] = aedes_check_updates()
%
% Description:
% Checks if there are updates available for Aedes. The
% "isUpdateAvailable" output argument is true if the head revision number
% in SVN repository is larger than working copy revision. If the
% "HeadRev" output argument is -1, there is a problem with the network.
% If "HeadRev" is empty, there is a problem running SVN commands.
%
% Examples:
%
%
% See also:
% AEDES, AEDES_UPDATE
% This function is a part of Aedes - A graphical tool for analyzing
% medical images
%
% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
%
% Department of Physics, Department of Neurobiology
% University of Kuopio, FINLAND
%
% This program may be used under the terms of the GNU General Public
% License version 2.0 as published by the Free Software Foundation
% and appearing in the file LICENSE.TXT included in the packaging of
% this program.
%
% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
isUpdateAvailable = false;
HeadRev = [];
error_msg = '';
% Get current revision and repository URL
[rev,repo,workingcopy] = aedes_revision;
if isempty(repo)
WorkingCopyRev = rev;
return
end
WorkingCopyRev = rev;
% Get head repository revision
[HeadRev,msg]=l_GetHeadRevision(repo);
if isempty(HeadRev)
% Something wrong with running SVN commands. Perhaps SVN is not
% installed? Network problems?
error_msg = msg;
else
if rev<HeadRev
isUpdateAvailable = true;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Get Head Repository Revision
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [HeadRev,msg]=l_GetHeadRevision(repo_url)
HeadRev = [];
msg = '';
% Try to determine the head revision in svn
if isunix
% Unix/Linux
[s,w] = unix(['svn info ',repo_url]);
if s~=0
msg=w;
return
end
elseif ispc
% Windows
[s,w] = dos(['svn info ',repo_url]);
if s~=0
msg=w;
return
end
else
% Mac OS X
[s,w] = unix(['svn info ',repo_url]);
if s~=0
msg=w;
return
end
end
% Scan the lines from the output
C=textscan(w,'%s','delimiter','\n');
if ~isempty(C)
C=C{:};
else
return
end
% Get revision line
rev_ind = find(strncmpi(C,'Revision:',4));
if ~isempty(rev_ind)
rev_str = C{rev_ind};
else
return
end
HeadRev=str2num(rev_str(11:end));