Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

wctxactions: use try/finally to recover cwd

Changeset b8f4a72322a4

Parent 3aab2ae731cc

by Steve Borho

Changes to one file · Browse files at b8f4a72322a4 Showing diff from parent 3aab2ae731cc Diff from another changeset...

 
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
 
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
@@ -75,27 +75,29 @@
  name = func.__name__.title()   notify = False   cwd = os.getcwd() - os.chdir(repo.root)   try: - # All operations should quietly succeed. Any error should - # result in a message box - notify = func(parent, hu, repo, files) - o, e = hu.getdata() - if e: - QMessageBox.warning(parent, name + _(' reported errors'), str(e)) - elif o: - QMessageBox.information(parent, name + _(' output'), str(o)) - elif notify: - wfiles = [repo.wjoin(x) for x in files] - shlib.shell_notify(wfiles) - except (util.Abort, IOError, OSError), e: - QMessageBox.critical(parent, name + _(' Aborted'), str(e)) - except (error.LookupError), e: - QMessageBox.critical(parent, name + _(' Aborted'), str(e)) - except NotImplementedError: - QMessageBox.critical(parent, name + _(' not implemented'), - 'Please add it :)') - os.chdir(cwd) + os.chdir(repo.root) + try: + # All operations should quietly succeed. Any error should + # result in a message box + notify = func(parent, hu, repo, files) + o, e = hu.getdata() + if e: + QMessageBox.warning(parent, name + _(' errors'), str(e)) + elif o: + QMessageBox.information(parent, name + _(' output'), str(o)) + elif notify: + wfiles = [repo.wjoin(x) for x in files] + shlib.shell_notify(wfiles) + except (util.Abort, IOError, OSError), e: + QMessageBox.critical(parent, name + _(' Aborted'), str(e)) + except (error.LookupError), e: + QMessageBox.critical(parent, name + _(' Aborted'), str(e)) + except NotImplementedError: + QMessageBox.critical(parent, name + _(' not implemented'), + 'Please add it :)') + finally: + os.chdir(cwd)   return notify    def vdiff(parent, ui, repo, files):