~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shell.py

  • Committer: Aaron Bentley
  • Date: 2005-11-15 18:34:19 UTC
  • mto: (283.2.1 bzrtools2)
  • mto: This revision was merged to the branch mainline in revision 285.
  • Revision ID: abentley@panoramicfeedback.com-20051115183419-54559bb4dcd71373
Got prompt and title working

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from itertools import chain
24
24
from bzrlib.errors import BzrError
25
25
from bzrlib.commands import get_cmd_object, get_all_cmds
 
26
from bzrlib.branch import Branch
26
27
 
27
28
SHELL_BLACKLIST = set(['rm', 'ls'])
28
29
COMPLETION_BLACKLIST = set(['shell'])
76
77
        cmd.Cmd.__init__(self)
77
78
        self.prompt = "bzr> "
78
79
        try:
79
 
            self.tree = arch.tree_root(".")
 
80
            self.branch = Branch.open_containing('.')[0]
80
81
        except:
81
 
            self.tree = None
 
82
            self.branch = None
82
83
        self.set_title()
83
84
        self.set_prompt()
84
85
        self.identchars += '-'
108
109
        self.set_prompt()
109
110
 
110
111
    def set_prompt(self):
111
 
        if self.tree is not None:
 
112
        if self.branch is not None:
112
113
            try:
113
 
                prompt = pylon.alias_or_version(self.tree.tree_version, 
114
 
                                                self.tree, 
115
 
                                                full=False)
116
 
                if prompt is not None:
117
 
                    prompt = " " + prompt +":"+ pylon.tree_cwd(self.tree)
 
114
                prompt_data = (self.branch.nick, self.branch.revno(), 
 
115
                               self.branch.working_tree().relpath('.'))
 
116
                prompt = " %s:%d/%s" % prompt_data
118
117
            except:
119
118
                prompt = ""
120
119
        else:
123
122
 
124
123
    def set_title(self, command=None):
125
124
        try:
126
 
            version = pylon.alias_or_version(self.tree.tree_version, self.tree, 
127
 
                                             full=False)
 
125
            b = Branch.open_containing('.')[0]
 
126
            version = "%s:%d" % (b.nick, b.revno())
128
127
        except:
129
128
            version = "[no version]"
130
129
        if command is None:
146
145
        except Exception, e:
147
146
            print e
148
147
        try:
149
 
            self.tree = arch.tree_root(".")
 
148
            self.branch = Branch.open_containing(".")[0]
150
149
        except:
151
 
            self.tree = None
 
150
            self.branch = None
152
151
 
153
152
    def do_help(self, line):
154
153
        self.default("help "+line)