~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shell.py

  • Committer: Aaron Bentley
  • Date: 2011-02-01 23:25:16 UTC
  • mto: This revision was merged to the branch mainline in revision 752.
  • Revision ID: aaron@aaronbentley.com-20110201232516-2sn2xwh2o3m0ssvk
Cherrypick changing release.py into a check script.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import cmd
19
19
from itertools import chain
20
20
import os
21
 
try:
22
 
    import readline
23
 
except ImportError:
24
 
    _has_readline = False
25
 
else:
26
 
    _has_readline = True
 
21
import readline
27
22
import shlex
28
23
import stat
29
24
import string
30
25
import sys
31
26
 
32
 
from bzrlib import osutils, trace
 
27
from bzrlib import osutils
33
28
from bzrlib.branch import Branch
34
29
from bzrlib.config import config_dir, ensure_config_dir_exists
35
30
from bzrlib.commands import get_cmd_object, all_command_names, get_alias
105
100
        ensure_config_dir_exists()
106
101
        self.history_file = osutils.pathjoin(config_dir(), 'shell-history')
107
102
        whitespace = ''.join(c for c in string.whitespace if c < chr(127))
108
 
        if _has_readline:
109
 
            readline.set_completer_delims(whitespace)
110
 
            if os.access(self.history_file, os.R_OK) and \
111
 
                os.path.isfile(self.history_file):
112
 
                readline.read_history_file(self.history_file)
 
103
        readline.set_completer_delims(whitespace)
 
104
        if os.access(self.history_file, os.R_OK) and \
 
105
            os.path.isfile(self.history_file):
 
106
            readline.read_history_file(self.history_file)
113
107
        self.cwd = os.getcwd()
114
108
 
115
109
    def write_history(self):
116
 
        if _has_readline:
117
 
            readline.write_history_file(self.history_file)
 
110
        readline.write_history_file(self.history_file)
118
111
 
119
112
    def do_quit(self, args):
120
113
        self.write_history()
205
198
            else:
206
199
                return (cmd_obj.run_argv_aliases(args, alias_args) or 0)
207
200
        except BzrError, e:
208
 
            trace.log_exception_quietly()
209
201
            print e
210
202
        except KeyboardInterrupt, e:
211
203
            print "Interrupted"
212
204
        except Exception, e:
213
 
            trace.log_exception_quietly()
 
205
#            print "Unhandled error:\n%s" % errors.exception_str(e)
214
206
            print "Unhandled error:\n%s" % (e)
215
207
 
216
208