Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.7, 0.7.1, and 0.7.2

rename: further robustness improvements

Catch stderr and util.Abort(). Exit on success only

Changeset 285d2dcec3a4

Parent 8ae7eb737959

by Steve Borho

Changes to one file · Browse files at 285d2dcec3a4 Showing diff from parent 8ae7eb737959 Diff from another changeset...

Change 1 of 2 Show Entire File hggtk/​rename.py Stacked
 
7
8
9
 
10
 
11
12
13
 
58
59
60
 
 
 
61
62
63
64
65
66
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
69
70
 
7
8
9
10
11
12
13
14
15
 
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
@@ -7,7 +7,9 @@
 import os  import sys  import gtk +import cStringIO  from shlib import shell_notify +from dialog import error_dialog  from mercurial import hg, ui, commands, util  from mercurial.repo import RepoError   @@ -58,13 +60,26 @@
  opts['after'] = False   opts['dry_run'] = False   + saved = sys.stderr + errors = cStringIO.StringIO() + quit = False   try: - # Sigh, some errors go to ui.warn(), which is regrettable - commands.rename(repo.ui, repo, dialog.orig, new_name, **opts) - gtk.main_quit() - except util.Abort, e: - from dialog import error_dialog - error_dialog(None, 'rename error', str(e)) + sys.stderr = errors + repo.ui.pushbuffer() + try: + commands.rename(repo.ui, repo, dialog.orig, new_name, **opts) + quit = True + except util.Abort, inst: + error_dialog(None, 'rename error', str(inst)) + quit = False + finally: + sys.stderr = saved + textout = errors.getvalue() + repo.ui.popbuffer() + errors.close() + if len(textout) > 1: + error_dialog(None, 'rename error', textout) + elif quit: + gtk.main_quit()    if __name__ == "__main__":   opts = {'fname' : sys.argv[1]}