~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Martin Pool
  • Date: 2005-05-09 01:23:17 UTC
  • Revision ID: mbp@sourcefrog.net-20050509012317-a503ae2eed842146
- doc: please run tests after installation

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
 
18
18
 
19
 
import sys, os
 
19
import sys, os, time, os.path
 
20
from sets import Set
20
21
 
21
22
import bzrlib
22
23
from bzrlib.trace import mutter, note, log_error
23
24
from bzrlib.errors import bailout, BzrError, BzrCheckError, BzrCommandError
24
 
from bzrlib.osutils import quotefn
25
 
from bzrlib import Branch, Inventory, InventoryEntry, BZRDIR, \
 
25
from bzrlib.osutils import quotefn, pumpfile, isdir, isfile
 
26
from bzrlib.tree import RevisionTree, EmptyTree, WorkingTree, Tree
 
27
from bzrlib.revision import Revision
 
28
from bzrlib import Branch, Inventory, InventoryEntry, ScratchBranch, BZRDIR, \
26
29
     format_date
27
30
 
28
31
 
34
37
    assert cmd.startswith("cmd_")
35
38
    return cmd[4:].replace('_','-')
36
39
 
37
 
def _parse_revision_str(revstr):
38
 
    """This handles a revision string -> revno. 
39
 
 
40
 
    There are several possibilities:
41
 
 
42
 
        '234'       -> 234
43
 
        '234:345'   -> [234, 345]
44
 
        ':234'      -> [None, 234]
45
 
        '234:'      -> [234, None]
46
 
 
47
 
    In the future we will also support:
48
 
        'uuid:blah-blah-blah'   -> ?
49
 
        'hash:blahblahblah'     -> ?
50
 
        potentially:
51
 
        'tag:mytag'             -> ?
52
 
    """
53
 
    if revstr.find(':') != -1:
54
 
        revs = revstr.split(':')
55
 
        if len(revs) > 2:
56
 
            raise ValueError('More than 2 pieces not supported for --revision: %r' % revstr)
57
 
 
58
 
        if not revs[0]:
59
 
            revs[0] = None
60
 
        else:
61
 
            revs[0] = int(revs[0])
62
 
 
63
 
        if not revs[1]:
64
 
            revs[1] = None
65
 
        else:
66
 
            revs[1] = int(revs[1])
67
 
    else:
68
 
        revs = int(revstr)
69
 
    return revs
70
 
 
71
40
def get_all_cmds():
72
41
    """Return canonical name and class for all registered commands."""
73
42
    for k, v in globals().iteritems():
89
58
    for cmdname, cmdclass in get_all_cmds():
90
59
        if cmd in cmdclass.aliases:
91
60
            return cmdname, cmdclass
92
 
 
93
 
    cmdclass = ExternalCommand.find_command(cmd)
94
 
    if cmdclass:
95
 
        return cmd, cmdclass
96
 
 
97
 
    raise BzrCommandError("unknown command %r" % cmd)
98
 
 
99
 
 
100
 
class Command(object):
 
61
    else:
 
62
        raise BzrCommandError("unknown command %r" % cmd)
 
63
 
 
64
 
 
65
class Command:
101
66
    """Base class for commands.
102
67
 
103
68
    The docstring for an actual command should give a single-line
146
111
        return 0
147
112
 
148
113
 
149
 
class ExternalCommand(Command):
150
 
    """Class to wrap external commands.
151
 
 
152
 
    We cheat a little here, when get_cmd_class() calls us we actually give it back
153
 
    an object we construct that has the appropriate path, help, options etc for the
154
 
    specified command.
155
 
 
156
 
    When run_bzr() tries to instantiate that 'class' it gets caught by the __call__
157
 
    method, which we override to call the Command.__init__ method. That then calls
158
 
    our run method which is pretty straight forward.
159
 
 
160
 
    The only wrinkle is that we have to map bzr's dictionary of options and arguments
161
 
    back into command line options and arguments for the script.
162
 
    """
163
 
 
164
 
    def find_command(cls, cmd):
165
 
        import os.path
166
 
        bzrpath = os.environ.get('BZRPATH', '')
167
 
 
168
 
        for dir in bzrpath.split(':'):
169
 
            path = os.path.join(dir, cmd)
170
 
            if os.path.isfile(path):
171
 
                return ExternalCommand(path)
172
 
 
173
 
        return None
174
 
 
175
 
    find_command = classmethod(find_command)
176
 
 
177
 
    def __init__(self, path):
178
 
        self.path = path
179
 
 
180
 
        # TODO: If either of these fail, we should detect that and
181
 
        # assume that path is not really a bzr plugin after all.
182
 
 
183
 
        pipe = os.popen('%s --bzr-usage' % path, 'r')
184
 
        self.takes_options = pipe.readline().split()
185
 
        self.takes_args = pipe.readline().split()
186
 
        pipe.close()
187
 
 
188
 
        pipe = os.popen('%s --bzr-help' % path, 'r')
189
 
        self.__doc__ = pipe.read()
190
 
        pipe.close()
191
 
 
192
 
    def __call__(self, options, arguments):
193
 
        Command.__init__(self, options, arguments)
194
 
        return self
195
 
 
196
 
    def run(self, **kargs):
197
 
        opts = []
198
 
        args = []
199
 
 
200
 
        keys = kargs.keys()
201
 
        keys.sort()
202
 
        for name in keys:
203
 
            value = kargs[name]
204
 
            if OPTIONS.has_key(name):
205
 
                # it's an option
206
 
                opts.append('--%s' % name)
207
 
                if value is not None and value is not True:
208
 
                    opts.append(str(value))
209
 
            else:
210
 
                # it's an arg, or arg list
211
 
                if type(value) is not list:
212
 
                    value = [value]
213
 
                for v in value:
214
 
                    if v is not None:
215
 
                        args.append(str(v))
216
 
 
217
 
        self.status = os.spawnv(os.P_WAIT, self.path, [self.path] + opts + args)
218
 
        return self.status
219
 
 
220
114
 
221
115
class cmd_status(Command):
222
116
    """Display status summary.
223
117
 
224
 
    This reports on versioned and unknown files, reporting them
225
 
    grouped by state.  Possible states are:
226
 
 
227
 
    added
228
 
        Versioned in the working copy but not in the previous revision.
229
 
 
230
 
    removed
231
 
        Versioned in the previous revision but removed or deleted
232
 
        in the working copy.
233
 
 
234
 
    renamed
235
 
        Path of this file changed from the previous revision;
236
 
        the text may also have changed.  This includes files whose
237
 
        parent directory was renamed.
238
 
 
239
 
    modified
240
 
        Text has changed since the previous revision.
241
 
 
242
 
    unchanged
243
 
        Nothing about this file has changed since the previous revision.
244
 
        Only shown with --all.
245
 
 
246
 
    unknown
247
 
        Not versioned and not matching an ignore pattern.
248
 
 
249
 
    To see ignored files use 'bzr ignored'.  For details in the
250
 
    changes to file texts, use 'bzr diff'.
251
 
 
252
 
    If no arguments are specified, the status of the entire working
253
 
    directory is shown.  Otherwise, only the status of the specified
254
 
    files or directories is reported.  If a directory is given, status
255
 
    is reported for everything inside that directory.
 
118
    For each file there is a single line giving its file state and name.
 
119
    The name is that in the current revision unless it is deleted or
 
120
    missing, in which case the old name is shown.
256
121
    """
257
 
    takes_args = ['file*']
258
 
    takes_options = ['all', 'show-ids']
 
122
    takes_options = ['all']
259
123
    aliases = ['st', 'stat']
260
124
    
261
 
    def run(self, all=False, show_ids=False, file_list=None):
262
 
        if file_list:
263
 
            b = Branch(file_list[0])
264
 
            file_list = [b.relpath(x) for x in file_list]
265
 
            # special case: only one path was given and it's the root
266
 
            # of the branch
267
 
            if file_list == ['']:
268
 
                file_list = None
269
 
        else:
270
 
            b = Branch('.')
271
 
        import status
272
 
        status.show_status(b, show_unchanged=all, show_ids=show_ids,
273
 
                           specific_files=file_list)
 
125
    def run(self, all=False):
 
126
        #import bzrlib.status
 
127
        #bzrlib.status.tree_status(Branch('.'))
 
128
        Branch('.').show_status(show_all=all)
274
129
 
275
130
 
276
131
class cmd_cat_revision(Command):
313
168
    recursively add that parent, rather than giving an error?
314
169
    """
315
170
    takes_args = ['file+']
316
 
    takes_options = ['verbose', 'no-recurse']
 
171
    takes_options = ['verbose']
317
172
    
318
 
    def run(self, file_list, verbose=False, no_recurse=False):
319
 
        bzrlib.add.smart_add(file_list, verbose, not no_recurse)
 
173
    def run(self, file_list, verbose=False):
 
174
        bzrlib.add.smart_add(file_list, verbose)
320
175
 
321
176
 
322
177
class cmd_relpath(Command):
323
178
    """Show path of a file relative to root"""
324
179
    takes_args = ['filename']
325
 
    hidden = True
326
180
    
327
181
    def run(self, filename):
328
182
        print Branch(filename).relpath(filename)
331
185
 
332
186
class cmd_inventory(Command):
333
187
    """Show inventory of the current working copy or a revision."""
334
 
    takes_options = ['revision', 'show-ids']
 
188
    takes_options = ['revision']
335
189
    
336
 
    def run(self, revision=None, show_ids=False):
 
190
    def run(self, revision=None):
337
191
        b = Branch('.')
338
192
        if revision == None:
339
193
            inv = b.read_working_inventory()
340
194
        else:
341
195
            inv = b.get_revision_inventory(b.lookup_revision(revision))
342
196
 
343
 
        for path, entry in inv.entries():
344
 
            if show_ids:
345
 
                print '%-50s %s' % (path, entry.file_id)
346
 
            else:
347
 
                print path
 
197
        for path, entry in inv.iter_entries():
 
198
            print '%-50s %s' % (entry.file_id, path)
348
199
 
349
200
 
350
201
class cmd_move(Command):
405
256
 
406
257
 
407
258
class cmd_info(Command):
408
 
    """Show statistical information about a branch."""
409
 
    takes_args = ['branch?']
410
 
    
411
 
    def run(self, branch=None):
 
259
    """Show statistical information for this branch"""
 
260
    def run(self):
412
261
        import info
413
 
 
414
 
        from branch import find_branch
415
 
        b = find_branch(branch)
416
 
        info.show_info(b)
 
262
        info.show_info(Branch('.'))        
417
263
 
418
264
 
419
265
class cmd_remove(Command):
467
313
 
468
314
class cmd_revision_history(Command):
469
315
    """Display list of revision ids on this branch."""
470
 
    hidden = True
471
316
    def run(self):
472
317
        for patchid in Branch('.').revision_history():
473
318
            print patchid
525
370
    """
526
371
    
527
372
    takes_args = ['file*']
528
 
    takes_options = ['revision', 'diff-options']
 
373
    takes_options = ['revision']
529
374
    aliases = ['di']
530
375
 
531
 
    def run(self, revision=None, file_list=None, diff_options=None):
 
376
    def run(self, revision=None, file_list=None):
532
377
        from bzrlib.diff import show_diff
533
 
        from bzrlib import find_branch
534
 
 
535
 
        if file_list:
536
 
            b = find_branch(file_list[0])
537
 
            file_list = [b.relpath(f) for f in file_list]
538
 
            if file_list == ['']:
539
 
                # just pointing to top-of-tree
540
 
                file_list = None
541
 
        else:
542
 
            b = Branch('.')
543
378
    
544
 
        show_diff(b, revision, specific_files=file_list,
545
 
                  external_diff_options=diff_options)
546
 
 
547
 
 
548
 
        
 
379
        show_diff(Branch('.'), revision, file_list)
549
380
 
550
381
 
551
382
class cmd_deleted(Command):
570
401
                else:
571
402
                    print path
572
403
 
573
 
 
574
 
class cmd_modified(Command):
575
 
    """List files modified in working tree."""
576
 
    hidden = True
577
 
    def run(self):
578
 
        import statcache
579
 
        b = Branch('.')
580
 
        inv = b.read_working_inventory()
581
 
        sc = statcache.update_cache(b, inv)
582
 
        basis = b.basis_tree()
583
 
        basis_inv = basis.inventory
584
 
        
585
 
        # We used to do this through iter_entries(), but that's slow
586
 
        # when most of the files are unmodified, as is usually the
587
 
        # case.  So instead we iterate by inventory entry, and only
588
 
        # calculate paths as necessary.
589
 
 
590
 
        for file_id in basis_inv:
591
 
            cacheentry = sc.get(file_id)
592
 
            if not cacheentry:                 # deleted
593
 
                continue
594
 
            ie = basis_inv[file_id]
595
 
            if cacheentry[statcache.SC_SHA1] != ie.text_sha1:
596
 
                path = inv.id2path(file_id)
597
 
                print path
598
 
 
599
 
 
600
 
 
601
 
class cmd_added(Command):
602
 
    """List files added in working tree."""
603
 
    hidden = True
604
 
    def run(self):
605
 
        b = Branch('.')
606
 
        wt = b.working_tree()
607
 
        basis_inv = b.basis_tree().inventory
608
 
        inv = wt.inventory
609
 
        for file_id in inv:
610
 
            if file_id in basis_inv:
611
 
                continue
612
 
            path = inv.id2path(file_id)
613
 
            if not os.access(b.abspath(path), os.F_OK):
614
 
                continue
615
 
            print path
616
 
                
617
 
        
618
 
 
619
404
class cmd_root(Command):
620
405
    """Show the tree root directory.
621
406
 
624
409
    takes_args = ['filename?']
625
410
    def run(self, filename=None):
626
411
        """Print the branch root."""
627
 
        from branch import find_branch
628
 
        b = find_branch(filename)
629
 
        print getattr(b, 'base', None) or getattr(b, 'baseurl')
 
412
        print bzrlib.branch.find_branch_root(filename)
 
413
 
630
414
 
631
415
 
632
416
class cmd_log(Command):
633
417
    """Show log of this branch.
634
418
 
635
 
    To request a range of logs, you can use the command -r begin:end
636
 
    -r revision requests a specific revision, -r :end or -r begin: are
637
 
    also valid.
 
419
    TODO: Option to limit range.
638
420
 
639
 
    TODO: Make --revision support uuid: and hash: [future tag:] notation.
640
 
  
 
421
    TODO: Perhaps show most-recent first with an option for last.
641
422
    """
642
 
 
643
423
    takes_args = ['filename?']
644
 
    takes_options = ['forward', 'timezone', 'verbose', 'show-ids', 'revision']
645
 
    
646
 
    def run(self, filename=None, timezone='original',
647
 
            verbose=False,
648
 
            show_ids=False,
649
 
            forward=False,
650
 
            revision=None):
651
 
        from bzrlib import show_log, find_branch
652
 
        import codecs
653
 
 
654
 
        direction = (forward and 'forward') or 'reverse'
655
 
        
 
424
    takes_options = ['timezone', 'verbose', 'show-ids']
 
425
    def run(self, filename=None, timezone='original', verbose=False, show_ids=False):
 
426
        b = Branch((filename or '.'), lock_mode='r')
656
427
        if filename:
657
 
            b = find_branch(filename)
658
 
            fp = b.relpath(filename)
659
 
            if fp:
660
 
                file_id = b.read_working_inventory().path2id(fp)
661
 
            else:
662
 
                file_id = None  # points to branch root
663
 
        else:
664
 
            b = find_branch('.')
665
 
            file_id = None
666
 
 
667
 
        if revision == None:
668
 
            revision = [None, None]
669
 
        elif isinstance(revision, int):
670
 
            revision = [revision, revision]
671
 
        else:
672
 
            # pair of revisions?
673
 
            pass
674
 
            
675
 
        assert len(revision) == 2
676
 
 
677
 
        mutter('encoding log as %r' % bzrlib.user_encoding)
678
 
        outf = codecs.getwriter(bzrlib.user_encoding)(sys.stdout)
679
 
 
680
 
        show_log(b, file_id,
681
 
                 show_timezone=timezone,
682
 
                 verbose=verbose,
683
 
                 show_ids=show_ids,
684
 
                 to_file=outf,
685
 
                 direction=direction,
686
 
                 start_revision=revision[0],
687
 
                 end_revision=revision[1])
 
428
            filename = b.relpath(filename)
 
429
        bzrlib.show_log(b, filename,
 
430
                        show_timezone=timezone,
 
431
                        verbose=verbose,
 
432
                        show_ids=show_ids)
688
433
 
689
434
 
690
435
 
691
436
class cmd_touching_revisions(Command):
692
 
    """Return revision-ids which affected a particular file.
693
 
 
694
 
    A more user-friendly interface is "bzr log FILE"."""
 
437
    """Return revision-ids which affected a particular file."""
695
438
    hidden = True
696
439
    takes_args = ["filename"]
697
440
    def run(self, filename):
698
 
        b = Branch(filename)
 
441
        b = Branch(filename, lock_mode='r')
699
442
        inv = b.read_working_inventory()
700
443
        file_id = inv.path2id(b.relpath(filename))
701
444
        for revno, revision_id, what in bzrlib.log.find_touching_revisions(b, file_id):
739
482
 
740
483
 
741
484
class cmd_ignore(Command):
742
 
    """Ignore a command or pattern
743
 
 
744
 
    To remove patterns from the ignore list, edit the .bzrignore file.
745
 
 
746
 
    If the pattern contains a slash, it is compared to the whole path
747
 
    from the branch root.  Otherwise, it is comapred to only the last
748
 
    component of the path.
749
 
 
750
 
    Ignore patterns are case-insensitive on case-insensitive systems.
751
 
 
752
 
    Note: wildcards must be quoted from the shell on Unix.
753
 
 
754
 
    examples:
755
 
        bzr ignore ./Makefile
756
 
        bzr ignore '*.class'
757
 
    """
 
485
    """Ignore a command or pattern"""
758
486
    takes_args = ['name_pattern']
759
487
    
760
488
    def run(self, name_pattern):
761
 
        from bzrlib.atomicfile import AtomicFile
762
 
        import os.path
763
 
 
764
489
        b = Branch('.')
765
 
        ifn = b.abspath('.bzrignore')
766
 
 
767
 
        if os.path.exists(ifn):
768
 
            f = open(ifn, 'rt')
769
 
            try:
770
 
                igns = f.read().decode('utf-8')
771
 
            finally:
772
 
                f.close()
773
 
        else:
774
 
            igns = ''
775
 
 
776
 
        # TODO: If the file already uses crlf-style termination, maybe
777
 
        # we should use that for the newly added lines?
778
 
 
779
 
        if igns and igns[-1] != '\n':
780
 
            igns += '\n'
781
 
        igns += name_pattern + '\n'
782
 
 
783
 
        try:
784
 
            f = AtomicFile(ifn, 'wt')
785
 
            f.write(igns.encode('utf-8'))
786
 
            f.commit()
787
 
        finally:
788
 
            f.close()
 
490
 
 
491
        # XXX: This will fail if it's a hardlink; should use an AtomicFile class.
 
492
        f = open(b.abspath('.bzrignore'), 'at')
 
493
        f.write(name_pattern + '\n')
 
494
        f.close()
789
495
 
790
496
        inv = b.working_tree().inventory
791
497
        if inv.path2id('.bzrignore'):
797
503
 
798
504
 
799
505
class cmd_ignored(Command):
800
 
    """List ignored files and the patterns that matched them.
801
 
 
802
 
    See also: bzr ignore"""
 
506
    """List ignored files and the patterns that matched them."""
803
507
    def run(self):
804
508
        tree = Branch('.').working_tree()
805
509
        for path, file_class, kind, file_id in tree.list_files():
815
519
 
816
520
    example:
817
521
        bzr lookup-revision 33
818
 
    """
 
522
        """
819
523
    hidden = True
820
524
    takes_args = ['revno']
821
525
    
868
572
class cmd_commit(Command):
869
573
    """Commit changes into a new revision.
870
574
 
871
 
    If selected files are specified, only changes to those files are
872
 
    committed.  If a directory is specified then its contents are also
873
 
    committed.
874
 
 
875
 
    A selected-file commit may fail in some cases where the committed
876
 
    tree would be invalid, such as trying to commit a file in a
877
 
    newly-added directory that is not itself committed.
 
575
    TODO: Commit only selected files.
878
576
 
879
577
    TODO: Run hooks on tree to-be-committed, and after commit.
880
578
 
881
579
    TODO: Strict commit that fails if there are unknown or deleted files.
882
580
    """
883
 
    takes_args = ['selected*']
884
581
    takes_options = ['message', 'file', 'verbose']
885
582
    aliases = ['ci', 'checkin']
886
583
 
887
 
    def run(self, message=None, file=None, verbose=True, selected_list=None):
888
 
        from bzrlib.commit import commit
889
 
 
 
584
    def run(self, message=None, file=None, verbose=False):
890
585
        ## Warning: shadows builtin file()
891
586
        if not message and not file:
892
587
            raise BzrCommandError("please specify a commit message",
898
593
            import codecs
899
594
            message = codecs.open(file, 'rt', bzrlib.user_encoding).read()
900
595
 
901
 
        b = Branch('.')
902
 
        commit(b, message, verbose=verbose, specific_files=selected_list)
 
596
        Branch('.').commit(message, verbose=verbose)
903
597
 
904
598
 
905
599
class cmd_check(Command):
911
605
    takes_args = ['dir?']
912
606
    def run(self, dir='.'):
913
607
        import bzrlib.check
914
 
        bzrlib.check.check(Branch(dir))
 
608
        bzrlib.check.check(Branch(dir, find_root=False))
915
609
 
916
610
 
917
611
 
932
626
    def run(self):
933
627
        failures, tests = 0, 0
934
628
 
935
 
        import doctest, bzrlib.store
 
629
        import doctest, bzrlib.store, bzrlib.tests
936
630
        bzrlib.trace.verbose = False
937
631
 
938
632
        for m in bzrlib.store, bzrlib.inventory, bzrlib.branch, bzrlib.osutils, \
939
 
            bzrlib.tree, bzrlib.commands, bzrlib.add:
 
633
            bzrlib.tree, bzrlib.tests, bzrlib.commands, bzrlib.add:
940
634
            mf, mt = doctest.testmod(m)
941
635
            failures += mf
942
636
            tests += mt
949
643
        print '%-40s %3d tests' % ('total', tests),
950
644
        if failures:
951
645
            print '%3d FAILED!' % failures
952
 
            return 1
953
646
        else:
954
647
            print
955
 
            return 0
956
648
 
957
649
 
958
650
 
977
669
    def run(self):
978
670
        print "it sure does!"
979
671
 
980
 
def parse_spec(spec):
981
 
    if '/@' in spec:
982
 
        parsed = spec.split('/@')
983
 
        assert len(parsed) == 2
984
 
        if parsed[1] == "":
985
 
            parsed[1] = -1
986
 
        else:
987
 
            parsed[1] = int(parsed[1])
988
 
            assert parsed[1] >=0
989
 
    else:
990
 
        parsed = [spec, None]
991
 
    return parsed
992
 
 
993
 
class cmd_merge(Command):
994
 
    """Perform a three-way merge of trees."""
995
 
    takes_args = ['other_spec', 'base_spec']
996
 
 
997
 
    def run(self, other_spec, base_spec):
998
 
        from bzrlib.merge import merge
999
 
        merge(parse_spec(other_spec), parse_spec(base_spec))
1000
672
 
1001
673
class cmd_assert_fail(Command):
1002
674
    """Test reporting of assertion failures"""
1017
689
        help.help(topic)
1018
690
 
1019
691
 
1020
 
class cmd_update_stat_cache(Command):
1021
 
    """Update stat-cache mapping inodes to SHA-1 hashes.
1022
 
 
1023
 
    For testing only."""
1024
 
    hidden = True
1025
 
    def run(self):
1026
 
        import statcache
1027
 
        b = Branch('.')
1028
 
        statcache.update_cache(b.base, b.read_working_inventory())
1029
 
 
 
692
######################################################################
 
693
# main routine
1030
694
 
1031
695
 
1032
696
# list of all available options; the rhs can be either None for an
1034
698
# the type.
1035
699
OPTIONS = {
1036
700
    'all':                    None,
1037
 
    'diff-options':           str,
1038
701
    'help':                   None,
1039
702
    'file':                   unicode,
1040
 
    'forward':                None,
1041
703
    'message':                unicode,
1042
 
    'no-recurse':             None,
1043
704
    'profile':                None,
1044
 
    'revision':               _parse_revision_str,
 
705
    'revision':               int,
1045
706
    'show-ids':               None,
1046
707
    'timezone':               str,
1047
708
    'verbose':                None,
1050
711
    }
1051
712
 
1052
713
SHORT_OPTIONS = {
 
714
    'm':                      'message',
1053
715
    'F':                      'file', 
1054
 
    'h':                      'help',
1055
 
    'm':                      'message',
1056
716
    'r':                      'revision',
1057
717
    'v':                      'verbose',
1058
718
}
1191
851
            return 0
1192
852
        cmd = str(args.pop(0))
1193
853
    except IndexError:
1194
 
        import help
1195
 
        help.help()
 
854
        log_error('usage: bzr COMMAND')
 
855
        log_error('  try "bzr help"')
1196
856
        return 1
1197
 
          
1198
857
 
1199
858
    canonical_cmd, cmd_class = get_cmd_class(cmd)
1200
859
 
1240
899
            os.close(pffileno)
1241
900
            os.remove(pfname)
1242
901
    else:
1243
 
        return cmd_class(cmdopts, cmdargs).status 
 
902
        cmdobj = cmd_class(cmdopts, cmdargs).status 
1244
903
 
1245
904
 
1246
905
def _report_exception(summary, quiet=False):
1288
947
            return 2
1289
948
        except Exception, e:
1290
949
            quiet = False
1291
 
            if (isinstance(e, IOError) 
1292
 
                and hasattr(e, 'errno')
1293
 
                and e.errno == errno.EPIPE):
 
950
            if isinstance(e, IOError) and e.errno == errno.EPIPE:
1294
951
                quiet = True
1295
952
                msg = 'broken pipe'
1296
953
            else: