source: an2_update.m @ 29

Last change on this file since 29 was 29, checked in by tjniskan, 12 years ago
  • Added preliminary support for T1-maps in an2_fitmaps.m
  • Corrected a minor bug in the update system
  • Corrected a minor bug in an2_data_read.m that affected reading of

MAT-files (and also MAP-files generated by an2_fitmaps.m)

M analyze2.m
M an2_revision.m
M an2_fitmaps.m
M an2_data_read.m
M an2_update.m

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

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