source: an2_update.m @ 53

Last change on this file since 53 was 45, checked in by tjniskan, 11 years ago
  • Changed a small thing in license notices

M an2_export_gui.m
M an2_cellsprintf.m
M an2_getfilefilter.m
M an2_calc_wait.m
M an2_smiswrite.m
M misclib/spectrsum.m
M misclib/shiftind.m
M misclib/nifti4dto3d.m
M misclib/nifti3dto4d.m
M misclib/dcm_info.m
M misclib/addicon.m
M misclib/makelcmraw.m
M an2_check_file_exist.m
M an2_iseven.m
M an2_cellwrite.m
M an2_wbar.m
M an2_rot3d.m
M an2_readfdf.m
M an2_revision.m
M an2_viewprocpar.m
M an2_checkcthdr.m
M an2_readprocpar.m
M an2_fitmaps.m
M an2_read_nifti.m
M an2_data_read.m
M an2_smisread.m
M an2_resviewer.m
M an2_maptool.m
M aedes.m
M an2_helpabout.m
M an2_res2table.m
M an2_copy_roi.m
M plugins/save_roi_as_mask.m
M plugins/write_difference_images.m
M plugins/plot_profile.m
M plugins/calculate_t2_map.m
M plugins/calculate_t1r_map.m
M plugins/view_kspace.m
M plugins/copy_data_to_workspace.m
M plugins/take_snapshot.m
M an2_inputdlg.m
M an2_roi_copy_gui.m
M an2_readctdata.m
M an2_readfid.m
M an2_readfidprefs.m
M an2_readtab.m
M an2_check_updates.m
M an2_killfigs.m
M an2_roi_stats.m
M an2_saveres.m
M an2_rotateflip.m
M an2_juigetfiles.m
M an2_gui_defaults.m
M an2_editstack.m
M an2_errordump.m
M an2_update.m
M an2_write_nifti.m

  • Property svn:executable set to *
File size: 7.9 KB
Line 
1function done=an2_update(opt)
2% AN2_UPDATE - Aedes update tool
3%
4% Synopsis:
5%       done=an2_update(opt)
6%
7% Description:
8%       
9%
10% Examples:
11%       
12%
13% See also:
14%       AN2_CHECK_UPDATES, AN2_REVISION, AEDES
15
16% This function is a part of Aedes - A graphical tool for analyzing
17% medical images
18%
19% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
20%
21% Department of Physics, Department of Neurobiology
22% University of Kuopio, FINLAND
23%
24% This program may be used under the terms of the GNU General Public
25% License version 2.0 as published by the Free Software Foundation
26% and appearing in the file LICENSE.TXT included in the packaging of
27% this program.
28%
29% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
30% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
31
32
33done = false;
34ShowChangeLog = false;
35
36if nargin==0
37  opt = 'semiprompt';
38end
39
40% Check if updates are available
41[isUpdateAvailable,HeadRev,WorkingCopyRev]=an2_check_updates();
42
43if isUpdateAvailable
44  if strcmpi(opt,'noprompt')
45        fprintf(1,'Updating from revision %d to %d\n',...
46          WorkingCopyRev,HeadRev)
47  elseif any(strcmpi(opt,{'prompt','semiprompt'}))
48        % Prompt for updates
49        dialog_str = {'Updates for Aedes are available.',...
50          '',...
51          ['Your current revision: ',num2str(WorkingCopyRev)],...
52          ['The latest revision: ',num2str(HeadRev)],...
53          '',...
54          'Do you want install updates now?',...
55          '',...
56          '',...
57          ['NOTE: You can disable automatic update checking from the',...
58          ' Tools-menu in Aedes.']};
59        resp=questdlg(dialog_str,'Updates available. Install now?',...
60          'Yes','No','Yes');
61        if strcmpi(resp,'No')
62          done = [];
63          return
64        end
65        [cwh,txh]=an2_calc_wait('Installing updates...');
66  end
67elseif isempty(HeadRev)
68  % Something wrong with SVN
69  if strcmpi(opt,'prompt')
70        h=warndlg('Could not check updates. Is SVN properly installed?',...
71          'Could not check updates','modal');
72        uiwait(h);
73        return
74  elseif any(strcmpi(opt,{'noprompt','semiprompt'}))
75        fprintf(1,'Could not check updates. Is SVN properly installed?\n')
76        return
77  end
78
79elseif HeadRev<0
80  % Something wrong with network. Not inside University network
81  if strcmpi(opt,'prompt')
82        h=warndlg('Could not check updates. Are you connected to Kuopio University network?',...
83          'Could not check updates','modal');
84        uiwait(h);
85        return
86  elseif any(strcmpi(opt,{'noprompt','semiprompt'}))
87        fprintf(1,'Could not check updates. Are you connected to Kuopio University network?\n')
88        return
89  end
90else
91  % No updates available, Aedes is up-to-date. Don't display anything if
92  % semiprompt mode is selected
93  if strcmpi(opt,'prompt')
94        h=helpdlg('No updates available. Aedes is up-to-date.',...
95          'Aedes up-to-date');
96        uiwait(h);
97  elseif strcmpi(opt,'noprompt')
98        fprintf(1,'No updates available. Aedes is up-to-date.\n');
99  end
100  return
101end
102
103
104% Update to the latest revision
105[fp,fn,fe]=fileparts(mfilename('fullpath'));
106if isunix
107  [s,w]=unix(['svn up "',fp,'"']);
108  C=textscan(w,'%s','delimiter','\n');
109  C=C{:};
110elseif ispc
111  [s,w]=dos(['svn up "',fp,'"']);
112  C=textscan(w,'%s','delimiter','\n');
113  C=C{:};
114else
115 
116end
117if s~=0
118  try
119        delete(cwh)
120  catch
121  end
122  if any(strcmpi(opt,{'prompt','semiprompt'}))
123        h=errordlg({'Update failed because of following error:',...
124          C{:}},...
125          'Update failed','modal');
126        uiwait(h);
127        return
128  elseif strcmpi(opt,'noprompt')
129        fprintf(1,'\n********************* ERROR ***********************\n')
130        fprintf(1,'Update failed because of following error:\n');
131        fprintf(1,'%s\n',C{:});
132        fprintf(1,'***************************************************\n')
133        return
134  end
135end
136
137try
138  set(txh,'String','Installing updates...done')
139  pause(0.5)
140  delete(cwh)
141catch
142end
143
144
145% Check for conflict or merge
146c_ind = [];
147g_ind = [];
148for ii=1:length(C)
149  if strncmpi(C{ii},'C  ',3)
150        % Conflict
151        c_ind(end+1)=ii;
152  elseif strncmpi(C{ii},'G  ',3)
153        % Merge
154        g_ind(end+1)=ii;
155  end
156end
157
158%%%%%%%%%%%%%%%%%%
159%c_ind = [];
160%g_ind = [];
161%%%%%%%%%%%%%%%%%%
162
163%% Everything went ok ------------------------
164if isempty(c_ind) && isempty(g_ind)
165  % Update successful
166  if any(strcmpi(opt,{'prompt','semiprompt'}))
167        resp=questdlg({['Updated successfully to revision ',num2str(HeadRev),'.'],...
168          '',...
169          ['You can use "View Details..." the view the changelog.']},...
170          'Update successful','OK','View Details...','View Details...');
171        if strcmpi(resp,'View Details...')
172          ShowChangeLog = true;
173        else
174          ShowChangeLog = false;
175        end
176  elseif strcmpi(opt,'noprompt')
177        fprintf(1,'Updated successfully to revision %d\n',HeadRev);
178       
179        % Echo the update information to the command window
180        fprintf(1,'%s\n',C{:});
181        fprintf(1,'Update complete.\n');
182  end
183 
184  % Clear functions just in case...
185  clear functions
186 
187  done = true;
188 
189  % Show the Change log and information
190  if ShowChangeLog
191        if isunix
192          [s,w] = unix(sprintf('svn log "%s" -r%d:%d',...
193                fp,HeadRev,WorkingCopyRev+1));
194          if s~=0
195               
196          end
197        elseif ispc
198          [s,w] = dos(sprintf('svn log "%s" -r%d:%d',...
199                fp,HeadRev,WorkingCopyRev+1));
200          if s~=0
201               
202          end
203        else
204         
205        end
206        W = textscan(w,'%s','delimiter','\n');
207        W=W{:};
208        web(['text://',...
209          '<title>Update information and changelog</title>',...
210          sprintf('<h1>Updated Aedes successfully to revision %d</h1>',...
211          HeadRev),...
212          sprintf('<h2>Updated files from revision %d to %d</h2>',...
213          WorkingCopyRev,HeadRev),...
214          sprintf('%s<br>',C{:}),...
215          '<br>',...
216          sprintf('<h2>Changelog from revision %d to %d</h2>',...
217          WorkingCopyRev,HeadRev),...
218          sprintf('%s<br>',W{:})]);
219  end
220 
221  % Merges and/or conflicts detected ----------
222elseif ~isempty(c_ind) || ~isempty(g_ind)
223 
224  % Echo the update information to the command window
225  fprintf(1,'%s\n',C{:});
226  fprintf(1,'Update complete.\n');
227 
228  % List of files with conflicts
229  c_files = C(c_ind);
230 
231  % List of files with merges
232  g_files = C(g_ind);
233 
234  % Update successful but with conflicts and/or merges
235  if isempty(c_ind)
236        % Only merges
237        fprintf(1,'\n********************* WARNING *********************\n')
238        fprintf(1,['Updated to revision %d but with errors.\n',...
239          'The following files contain MERGES:\n'],HeadRev)
240        fprintf(1,'%s\n',g_files{:})
241        fprintf(1,'***************************************************\n')
242        if any(strcmpi(opt,{'prompt','semiprompt'}))
243          h = warndlg({['Updated to revision ',num2str(HeadRev),' but with errors.'],...
244                '',...
245                'The following files contain MERGES:',...
246                '',...
247                g_files{:},...
248                '',...
249                'Contact the fellow in the About-dialog...'},...
250                'Updated with errors','modal');
251          uiwait(h);
252        end
253       
254  elseif isempty(g_ind)
255        % Only conflicts
256        fprintf(1,'\n********************* WARNING *********************\n')
257        fprintf(1,['Updated to revision %d but with errors.\n',...
258          'The following files contain CONFLICTS:\n'],HeadRev)
259        fprintf(1,'%s\n',g_files{:})
260        fprintf(1,'***************************************************\n')
261        if any(strcmpi(opt,{'prompt','semiprompt'}))
262          h = warndlg({['Updated to revision ',num2str(HeadRev),' but with errors.'],...
263                '',...
264                'The following files contain CONFLICTS:',...
265                '',...
266                c_files{:},...
267                '',...
268                'Contact the fellow in the About-dialog...'},...
269                'Updated with errors','modal');
270          uiwait(h);
271        end
272       
273  else
274        % Both conflicts and merges
275        fprintf(1,'\n********************* WARNING *********************\n')
276        fprintf(1,['Updated to revision %d but with errors.\n',...
277          'The following files contain CONFLICTS:\n'],HeadRev)
278        fprintf(1,'%s\n',c_files{:})
279        fprintf(1,'\nThe following files contain MERGES:\n')
280        fprintf(1,'%s\n',g_files{:})
281        fprintf(1,'***************************************************\n')
282        if any(strcmpi(opt,{'prompt','semiprompt'}))
283          h = warndlg({['Updated to revision ',num2str(HeadRev),' but with errors.'],...
284                '',...
285                'The following files contain CONFLICTS:',...
286                '',...
287                c_files{:},...
288                '',...
289                'The following files contain MERGES:',...
290                '',...
291                g_files{:},...
292                '',...
293                'Contact the fellow in the About-dialog...'},...
294                'Updated with errors','modal');
295          uiwait(h);
296        end
297  end
298 
299  % Clear functions just in case...
300  clear functions
301 
302  done = true;
303 
304end
Note: See TracBrowser for help on using the repository browser.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008