Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8.1, 0.8.2, and 0.8.3

thgtaskbar: improve error handling during thgstatus calls

Catch errors on stderr (usually failed extension loads)
Catch hgrc parse errors
Catch hgignore parse errors
Report all errors to task bar options dialog logger tab.

Fixes #393

Changeset 181a4945dbab

Parent 9f7a4df29816

by Steve Borho

Changes to one file · Browse files at 181a4945dbab Showing diff from parent 9f7a4df29816 Diff from another changeset...

Change 1 of 4 Show Entire File thgtaskbar.py Stacked
 
6
7
8
 
9
10
11
 
22
23
24
25
 
26
27
28
 
59
60
61
62
 
63
64
65
 
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
256
257
 
6
7
8
9
10
11
12
 
23
24
25
 
26
27
28
29
 
60
61
62
 
63
64
65
66
 
239
240
241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
@@ -6,6 +6,7 @@
 import sys  import time  import threading +import cStringIO  import Queue    from win32api import * @@ -22,7 +23,7 @@
 from mercurial import demandimport  demandimport.ignore.append('win32com.shell')  demandimport.enable() -from mercurial import ui +from mercurial import ui, error  from thgutil import thread2, paths, shlib    if hasattr(sys, "frozen"): @@ -59,7 +60,7 @@
  action = NIM_ADD   try:   Shell_NotifyIcon(action, nid) - except error: + except e:   # This is common when windows is starting, and this code is hit   # before the taskbar has been created.   print "Failed to add the taskbar icon - is explorer running?" @@ -238,20 +239,32 @@
  if roots:   _ui = ui.ui();   failedroots = set() - for r in sorted(roots): - try: - shlib.update_thgstatus(_ui, r, wait=False) - shlib.shell_notify([r]) - logger.msg('Updated ' + r) - except (IOError, OSError): - print "IOError or OSError on updating %s (check permissions)" % r - logger.msg('Failed updating %s (check permissions)' % r) - failedroots.add(r) - notifypaths -= failedroots - if notifypaths: - time.sleep(2) - shlib.shell_notify(list(notifypaths)) - logger.msg('Shell notified') + errorstream = cStringIO.StringIO() + _stderr = sys.stderr + sys.stderr = errorstream + try: + for r in sorted(roots): + try: + shlib.update_thgstatus(_ui, r, wait=False) + shlib.shell_notify([r]) + logger.msg('Updated ' + r) + except (IOError, OSError): + print "IOError or OSError on updating %s (check permissions)" % r + logger.msg('Failed updating %s (check permissions)' % r) + failedroots.add(r) + except (error.Abort, error.ConfigError, error.RepoError), e: + logger.msg('Failed updating %s (%s)' % (r, str(e))) + failedroots.add(r) + notifypaths -= failedroots + if notifypaths: + time.sleep(2) + shlib.shell_notify(list(notifypaths)) + logger.msg('Shell notified') + errmsg = errorstream.getvalue() + if errmsg: + logger.msg('stderr: %s' % errmsg) + finally: + sys.stderr = _stderr    requests = Queue.Queue(0)