~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Martin Pool
  • Date: 2005-05-05 06:38:18 UTC
  • Revision ID: mbp@sourcefrog.net-20050505063818-3eb3260343878325
- do upload CHANGELOG to web server, even though it's autogenerated

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
 
19
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
25
from bzrlib.osutils import quotefn, pumpfile, isdir, isfile
25
 
from bzrlib.tree import RevisionTree, EmptyTree, Tree
 
26
from bzrlib.tree import RevisionTree, EmptyTree, WorkingTree, Tree
26
27
from bzrlib.revision import Revision
27
28
from bzrlib import Branch, Inventory, InventoryEntry, ScratchBranch, BZRDIR, \
28
29
     format_date
29
 
from bzrlib import merge
30
30
 
31
31
 
32
32
def _squish_command_name(cmd):
37
37
    assert cmd.startswith("cmd_")
38
38
    return cmd[4:].replace('_','-')
39
39
 
40
 
def _parse_revision_str(revstr):
41
 
    """This handles a revision string -> revno. 
42
 
 
43
 
    There are several possibilities:
44
 
 
45
 
        '234'       -> 234
46
 
        '234:345'   -> [234, 345]
47
 
        ':234'      -> [None, 234]
48
 
        '234:'      -> [234, None]
49
 
 
50
 
    In the future we will also support:
51
 
        'uuid:blah-blah-blah'   -> ?
52
 
        'hash:blahblahblah'     -> ?
53
 
        potentially:
54
 
        'tag:mytag'             -> ?
55
 
    """
56
 
    if revstr.find(':') != -1:
57
 
        revs = revstr.split(':')
58
 
        if len(revs) > 2:
59
 
            raise ValueError('More than 2 pieces not supported for --revision: %r' % revstr)
60
 
 
61
 
        if not revs[0]:
62
 
            revs[0] = None
63
 
        else:
64
 
            revs[0] = int(revs[0])
65
 
 
66
 
        if not revs[1]:
67
 
            revs[1] = None
68
 
        else:
69
 
            revs[1] = int(revs[1])
70
 
    else:
71
 
        revs = int(revstr)
72
 
    return revs
73
 
 
74
40
def get_all_cmds():
75
41
    """Return canonical name and class for all registered commands."""
76
42
    for k, v in globals().iteritems():
92
58
    for cmdname, cmdclass in get_all_cmds():
93
59
        if cmd in cmdclass.aliases:
94
60
            return cmdname, cmdclass
95
 
 
96
 
    cmdclass = ExternalCommand.find_command(cmd)
97
 
    if cmdclass:
98
 
        return cmd, cmdclass
99
 
 
100
 
    raise BzrCommandError("unknown command %r" % cmd)
101
 
 
102
 
 
103
 
class Command(object):
 
61
    else:
 
62
        raise BzrCommandError("unknown command %r" % cmd)
 
63
 
 
64
 
 
65
class Command:
104
66
    """Base class for commands.
105
67
 
106
68
    The docstring for an actual command should give a single-line
149
111
        return 0
150
112
 
151
113
 
152
 
class ExternalCommand(Command):
153
 
    """Class to wrap external commands.
154
 
 
155
 
    We cheat a little here, when get_cmd_class() calls us we actually give it back
156
 
    an object we construct that has the appropriate path, help, options etc for the
157
 
    specified command.
158
 
 
159
 
    When run_bzr() tries to instantiate that 'class' it gets caught by the __call__
160
 
    method, which we override to call the Command.__init__ method. That then calls
161
 
    our run method which is pretty straight forward.
162
 
 
163
 
    The only wrinkle is that we have to map bzr's dictionary of options and arguments
164
 
    back into command line options and arguments for the script.
165
 
    """
166
 
 
167
 
    def find_command(cls, cmd):
168
 
        bzrpath = os.environ.get('BZRPATH', '')
169
 
 
170
 
        for dir in bzrpath.split(':'):
171
 
            path = os.path.join(dir, cmd)
172
 
            if os.path.isfile(path):
173
 
                return ExternalCommand(path)
174
 
 
175
 
        return None
176
 
 
177
 
    find_command = classmethod(find_command)
178
 
 
179
 
    def __init__(self, path):
180
 
        self.path = path
181
 
 
182
 
        # TODO: If either of these fail, we should detect that and
183
 
        # assume that path is not really a bzr plugin after all.
184
 
 
185
 
        pipe = os.popen('%s --bzr-usage' % path, 'r')
186
 
        self.takes_options = pipe.readline().split()
187
 
        self.takes_args = pipe.readline().split()
188
 
        pipe.close()
189
 
 
190
 
        pipe = os.popen('%s --bzr-help' % path, 'r')
191
 
        self.__doc__ = pipe.read()
192
 
        pipe.close()
193
 
 
194
 
    def __call__(self, options, arguments):
195
 
        Command.__init__(self, options, arguments)
196
 
        return self
197
 
 
198
 
    def run(self, **kargs):
199
 
        opts = []
200
 
        args = []
201
 
 
202
 
        keys = kargs.keys()
203
 
        keys.sort()
204
 
        for name in keys:
205
 
            value = kargs[name]
206
 
            if OPTIONS.has_key(name):
207
 
                # it's an option
208
 
                opts.append('--%s' % name)
209
 
                if value is not None and value is not True:
210
 
                    opts.append(str(value))
211
 
            else:
212
 
                # it's an arg, or arg list
213
 
                if type(value) is not list:
214
 
                    value = [value]
215
 
                for v in value:
216
 
                    if v is not None:
217
 
                        args.append(str(v))
218
 
 
219
 
        self.status = os.spawnv(os.P_WAIT, self.path, [self.path] + opts + args)
220
 
        return self.status
221
 
 
222
114
 
223
115
class cmd_status(Command):
224
116
    """Display status summary.
225
117
 
226
 
    This reports on versioned and unknown files, reporting them
227
 
    grouped by state.  Possible states are:
228
 
 
229
 
    added
230
 
        Versioned in the working copy but not in the previous revision.
231
 
 
232
 
    removed
233
 
        Versioned in the previous revision but removed or deleted
234
 
        in the working copy.
235
 
 
236
 
    renamed
237
 
        Path of this file changed from the previous revision;
238
 
        the text may also have changed.  This includes files whose
239
 
        parent directory was renamed.
240
 
 
241
 
    modified
242
 
        Text has changed since the previous revision.
243
 
 
244
 
    unchanged
245
 
        Nothing about this file has changed since the previous revision.
246
 
        Only shown with --all.
247
 
 
248
 
    unknown
249
 
        Not versioned and not matching an ignore pattern.
250
 
 
251
 
    To see ignored files use 'bzr ignored'.  For details in the
252
 
    changes to file texts, use 'bzr diff'.
253
 
 
254
 
    If no arguments are specified, the status of the entire working
255
 
    directory is shown.  Otherwise, only the status of the specified
256
 
    files or directories is reported.  If a directory is given, status
257
 
    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.
258
121
    """
259
 
    takes_args = ['file*']
260
 
    takes_options = ['all', 'show-ids']
 
122
    takes_options = ['all']
261
123
    aliases = ['st', 'stat']
262
124
    
263
 
    def run(self, all=False, show_ids=False, file_list=None):
264
 
        if file_list:
265
 
            b = Branch(file_list[0], lock_mode='r')
266
 
            file_list = [b.relpath(x) for x in file_list]
267
 
            # special case: only one path was given and it's the root
268
 
            # of the branch
269
 
            if file_list == ['']:
270
 
                file_list = None
271
 
        else:
272
 
            b = Branch('.', lock_mode='r')
273
 
        import status
274
 
        status.show_status(b, show_unchanged=all, show_ids=show_ids,
275
 
                           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)
276
129
 
277
130
 
278
131
class cmd_cat_revision(Command):
321
174
        bzrlib.add.smart_add(file_list, verbose)
322
175
 
323
176
 
324
 
class cmd_relpath(Command):
 
177
def Relpath(Command):
325
178
    """Show path of a file relative to root"""
326
 
    takes_args = ['filename']
 
179
    takes_args = ('filename')
327
180
    
328
 
    def run(self, filename):
329
 
        print Branch(filename).relpath(filename)
 
181
    def run(self):
 
182
        print Branch(self.args['filename']).relpath(filename)
330
183
 
331
184
 
332
185
 
341
194
        else:
342
195
            inv = b.get_revision_inventory(b.lookup_revision(revision))
343
196
 
344
 
        for path, entry in inv.entries():
 
197
        for path, entry in inv.iter_entries():
345
198
            print '%-50s %s' % (entry.file_id, path)
346
199
 
347
200
 
403
256
 
404
257
 
405
258
class cmd_info(Command):
406
 
    """Show statistical information about a branch."""
407
 
    takes_args = ['branch?']
408
 
    
409
 
    def run(self, branch=None):
 
259
    """Show statistical information for this branch"""
 
260
    def run(self):
410
261
        import info
411
 
 
412
 
        from branch import find_branch
413
 
        b = find_branch(branch)
414
 
        info.show_info(b)
 
262
        info.show_info(Branch('.'))        
415
263
 
416
264
 
417
265
class cmd_remove(Command):
527
375
 
528
376
    def run(self, revision=None, file_list=None):
529
377
        from bzrlib.diff import show_diff
530
 
        from bzrlib import find_branch
531
 
 
532
 
        if file_list:
533
 
            b = find_branch(file_list[0], lock_mode='r')
534
 
            file_list = [b.relpath(f) for f in file_list]
535
 
            if file_list == ['']:
536
 
                # just pointing to top-of-tree
537
 
                file_list = None
538
 
        else:
539
 
            b = Branch('.', lock_mode='r')
540
378
    
541
 
        show_diff(b, revision, specific_files=file_list)
542
 
 
543
 
 
544
 
        
 
379
        show_diff(Branch('.'), revision, file_list)
545
380
 
546
381
 
547
382
class cmd_deleted(Command):
566
401
                else:
567
402
                    print path
568
403
 
569
 
 
570
 
class cmd_modified(Command):
571
 
    """List files modified in working tree."""
572
 
    hidden = True
573
 
    def run(self):
574
 
        import statcache
575
 
        b = Branch('.')
576
 
        inv = b.read_working_inventory()
577
 
        sc = statcache.update_cache(b, inv)
578
 
        basis = b.basis_tree()
579
 
        basis_inv = basis.inventory
580
 
        
581
 
        # We used to do this through iter_entries(), but that's slow
582
 
        # when most of the files are unmodified, as is usually the
583
 
        # case.  So instead we iterate by inventory entry, and only
584
 
        # calculate paths as necessary.
585
 
 
586
 
        for file_id in basis_inv:
587
 
            cacheentry = sc.get(file_id)
588
 
            if not cacheentry:                 # deleted
589
 
                continue
590
 
            ie = basis_inv[file_id]
591
 
            if cacheentry[statcache.SC_SHA1] != ie.text_sha1:
592
 
                path = inv.id2path(file_id)
593
 
                print path
594
 
 
595
 
 
596
 
 
597
 
class cmd_added(Command):
598
 
    """List files added in working tree."""
599
 
    hidden = True
600
 
    def run(self):
601
 
        b = Branch('.')
602
 
        wt = b.working_tree()
603
 
        basis_inv = b.basis_tree().inventory
604
 
        inv = wt.inventory
605
 
        for file_id in inv:
606
 
            if file_id in basis_inv:
607
 
                continue
608
 
            path = inv.id2path(file_id)
609
 
            if not os.access(b.abspath(path), os.F_OK):
610
 
                continue
611
 
            print path
612
 
                
613
 
        
614
 
 
615
404
class cmd_root(Command):
616
405
    """Show the tree root directory.
617
406
 
620
409
    takes_args = ['filename?']
621
410
    def run(self, filename=None):
622
411
        """Print the branch root."""
623
 
        from branch import find_branch
624
 
        b = find_branch(filename)
625
 
        print getattr(b, 'base', None) or getattr(b, 'baseurl')
 
412
        print bzrlib.branch.find_branch_root(filename)
 
413
 
626
414
 
627
415
 
628
416
class cmd_log(Command):
629
417
    """Show log of this branch.
630
418
 
631
 
    To request a range of logs, you can use the command -r begin:end
632
 
    -r revision requests a specific revision, -r :end or -r begin: are
633
 
    also valid.
634
 
 
635
 
    TODO: Make --revision support uuid: and hash: [future tag:] notation.
636
 
  
 
419
    TODO: Options to show ids; to limit range; etc.
637
420
    """
638
 
 
639
 
    takes_args = ['filename?']
640
 
    takes_options = ['forward', 'timezone', 'verbose', 'show-ids', 'revision']
641
 
    
642
 
    def run(self, filename=None, timezone='original',
643
 
            verbose=False,
644
 
            show_ids=False,
645
 
            forward=False,
646
 
            revision=None):
647
 
        from bzrlib import show_log, find_branch
648
 
        import codecs
649
 
 
650
 
        direction = (forward and 'forward') or 'reverse'
651
 
        
652
 
        if filename:
653
 
            b = find_branch(filename, lock_mode='r')
654
 
            fp = b.relpath(filename)
655
 
            if fp:
656
 
                file_id = b.read_working_inventory().path2id(fp)
657
 
            else:
658
 
                file_id = None  # points to branch root
659
 
        else:
660
 
            b = find_branch('.', lock_mode='r')
661
 
            file_id = None
662
 
 
663
 
        if revision == None:
664
 
            revision = [None, None]
665
 
        elif isinstance(revision, int):
666
 
            revision = [revision, revision]
667
 
        else:
668
 
            # pair of revisions?
669
 
            pass
670
 
            
671
 
        assert len(revision) == 2
672
 
 
673
 
        mutter('encoding log as %r' % bzrlib.user_encoding)
674
 
        outf = codecs.getwriter(bzrlib.user_encoding)(sys.stdout)
675
 
 
676
 
        show_log(b, file_id,
677
 
                 show_timezone=timezone,
678
 
                 verbose=verbose,
679
 
                 show_ids=show_ids,
680
 
                 to_file=outf,
681
 
                 direction=direction,
682
 
                 start_revision=revision[0],
683
 
                 end_revision=revision[1])
684
 
 
685
 
 
686
 
 
687
 
class cmd_touching_revisions(Command):
688
 
    """Return revision-ids which affected a particular file.
689
 
 
690
 
    A more user-friendly interface is "bzr log FILE"."""
691
 
    hidden = True
692
 
    takes_args = ["filename"]
693
 
    def run(self, filename):
694
 
        b = Branch(filename, lock_mode='r')
695
 
        inv = b.read_working_inventory()
696
 
        file_id = inv.path2id(b.relpath(filename))
697
 
        for revno, revision_id, what in bzrlib.log.find_touching_revisions(b, file_id):
698
 
            print "%6d %s" % (revno, what)
 
421
    takes_options = ['timezone', 'verbose']
 
422
    def run(self, timezone='original', verbose=False):
 
423
        Branch('.', lock_mode='r').write_log(show_timezone=timezone, verbose=verbose)
699
424
 
700
425
 
701
426
class cmd_ls(Command):
735
460
 
736
461
 
737
462
class cmd_ignore(Command):
738
 
    """Ignore a command or pattern
739
 
 
740
 
    To remove patterns from the ignore list, edit the .bzrignore file.
741
 
 
742
 
    If the pattern contains a slash, it is compared to the whole path
743
 
    from the branch root.  Otherwise, it is comapred to only the last
744
 
    component of the path.
745
 
 
746
 
    Ignore patterns are case-insensitive on case-insensitive systems.
747
 
 
748
 
    Note: wildcards must be quoted from the shell on Unix.
749
 
 
750
 
    examples:
751
 
        bzr ignore ./Makefile
752
 
        bzr ignore '*.class'
753
 
    """
 
463
    """Ignore a command or pattern"""
754
464
    takes_args = ['name_pattern']
755
465
    
756
466
    def run(self, name_pattern):
757
 
        from bzrlib.atomicfile import AtomicFile
758
 
        import codecs
759
 
 
760
467
        b = Branch('.')
761
 
        ifn = b.abspath('.bzrignore')
762
 
 
763
 
        if os.path.exists(ifn):
764
 
            f = open(ifn, 'rt')
765
 
            try:
766
 
                igns = f.read().decode('utf-8')
767
 
            finally:
768
 
                f.close()
769
 
        else:
770
 
            igns = ''
771
 
 
772
 
        if igns and igns[-1] != '\n':
773
 
            igns += '\n'
774
 
        igns += name_pattern + '\n'
775
 
 
776
 
        try:
777
 
            f = AtomicFile(ifn, 'wt')
778
 
            f.write(igns.encode('utf-8'))
779
 
            f.commit()
780
 
        finally:
781
 
            f.close()
 
468
 
 
469
        # XXX: This will fail if it's a hardlink; should use an AtomicFile class.
 
470
        f = open(b.abspath('.bzrignore'), 'at')
 
471
        f.write(name_pattern + '\n')
 
472
        f.close()
782
473
 
783
474
        inv = b.working_tree().inventory
784
475
        if inv.path2id('.bzrignore'):
790
481
 
791
482
 
792
483
class cmd_ignored(Command):
793
 
    """List ignored files and the patterns that matched them.
794
 
 
795
 
    See also: bzr ignore"""
 
484
    """List ignored files and the patterns that matched them."""
796
485
    def run(self):
797
486
        tree = Branch('.').working_tree()
798
487
        for path, file_class, kind, file_id in tree.list_files():
808
497
 
809
498
    example:
810
499
        bzr lookup-revision 33
811
 
    """
 
500
        """
812
501
    hidden = True
813
502
    takes_args = ['revno']
814
503
    
827
516
    If no revision is specified this exports the last committed revision."""
828
517
    takes_args = ['dest']
829
518
    takes_options = ['revision']
830
 
    def run(self, dest, revision=None):
 
519
    def run(self, dest, revno=None):
831
520
        b = Branch('.')
832
 
        if revision == None:
833
 
            rh = b.revision_history()[-1]
 
521
        if revno == None:
 
522
            rh = b.revision_history[-1]
834
523
        else:
835
 
            rh = b.lookup_revision(int(revision))
 
524
            rh = b.lookup_revision(int(revno))
836
525
        t = b.revision_tree(rh)
837
526
        t.export(dest)
838
527
 
861
550
class cmd_commit(Command):
862
551
    """Commit changes into a new revision.
863
552
 
864
 
    If selected files are specified, only changes to those files are
865
 
    committed.  If a directory is specified then its contents are also
866
 
    committed.
867
 
 
868
 
    A selected-file commit may fail in some cases where the committed
869
 
    tree would be invalid, such as trying to commit a file in a
870
 
    newly-added directory that is not itself committed.
 
553
    TODO: Commit only selected files.
871
554
 
872
555
    TODO: Run hooks on tree to-be-committed, and after commit.
873
556
 
874
557
    TODO: Strict commit that fails if there are unknown or deleted files.
875
558
    """
876
 
    takes_args = ['selected*']
877
 
    takes_options = ['message', 'file', 'verbose']
 
559
    takes_options = ['message', 'verbose']
878
560
    aliases = ['ci', 'checkin']
879
561
 
880
 
    def run(self, message=None, file=None, verbose=True, selected_list=None):
881
 
        from bzrlib.commit import commit
882
 
 
883
 
        ## Warning: shadows builtin file()
884
 
        if not message and not file:
885
 
            raise BzrCommandError("please specify a commit message",
886
 
                                  ["use either --message or --file"])
887
 
        elif message and file:
888
 
            raise BzrCommandError("please specify either --message or --file")
889
 
        
890
 
        if file:
891
 
            import codecs
892
 
            message = codecs.open(file, 'rt', bzrlib.user_encoding).read()
893
 
 
894
 
        b = Branch('.')
895
 
        commit(b, message, verbose=verbose, specific_files=selected_list)
 
562
    def run(self, message=None, verbose=False):
 
563
        if not message:
 
564
            raise BzrCommandError("please specify a commit message")
 
565
        Branch('.').commit(message, verbose=verbose)
896
566
 
897
567
 
898
568
class cmd_check(Command):
904
574
    takes_args = ['dir?']
905
575
    def run(self, dir='.'):
906
576
        import bzrlib.check
907
 
        bzrlib.check.check(Branch(dir))
 
577
        bzrlib.check.check(Branch(dir, find_root=False))
908
578
 
909
579
 
910
580
 
925
595
    def run(self):
926
596
        failures, tests = 0, 0
927
597
 
928
 
        import doctest, bzrlib.store
 
598
        import doctest, bzrlib.store, bzrlib.tests
929
599
        bzrlib.trace.verbose = False
930
600
 
931
601
        for m in bzrlib.store, bzrlib.inventory, bzrlib.branch, bzrlib.osutils, \
932
 
            bzrlib.tree, bzrlib.commands, bzrlib.add:
 
602
            bzrlib.tree, bzrlib.tests, bzrlib.commands, bzrlib.add:
933
603
            mf, mt = doctest.testmod(m)
934
604
            failures += mf
935
605
            tests += mt
942
612
        print '%-40s %3d tests' % ('total', tests),
943
613
        if failures:
944
614
            print '%3d FAILED!' % failures
945
 
            return 1
946
615
        else:
947
616
            print
948
 
            return 0
949
617
 
950
618
 
951
619
 
970
638
    def run(self):
971
639
        print "it sure does!"
972
640
 
973
 
def parse_spec(spec):
974
 
    if '/@' in spec:
975
 
        parsed = spec.split('/@')
976
 
        assert len(parsed) == 2
977
 
        if parsed[1] == "":
978
 
            parsed[1] = -1
979
 
        else:
980
 
            parsed[1] = int(parsed[1])
981
 
            assert parsed[1] >=0
982
 
    else:
983
 
        parsed = [spec, None]
984
 
    return parsed
985
 
 
986
 
class cmd_merge(Command):
987
 
    """Perform a three-way merge of trees."""
988
 
    takes_args = ['other_spec', 'base_spec']
989
 
 
990
 
    def run(self, other_spec, base_spec):
991
 
        merge.merge(parse_spec(other_spec), parse_spec(base_spec))
992
641
 
993
642
class cmd_assert_fail(Command):
994
643
    """Test reporting of assertion failures"""
1009
658
        help.help(topic)
1010
659
 
1011
660
 
1012
 
class cmd_update_stat_cache(Command):
1013
 
    """Update stat-cache mapping inodes to SHA-1 hashes.
1014
 
 
1015
 
    For testing only."""
1016
 
    hidden = True
1017
 
    def run(self):
1018
 
        import statcache
1019
 
        b = Branch('.')
1020
 
        statcache.update_cache(b.base, b.read_working_inventory())
1021
 
 
1022
 
 
1023
661
######################################################################
1024
662
# main routine
1025
663
 
1030
668
OPTIONS = {
1031
669
    'all':                    None,
1032
670
    'help':                   None,
1033
 
    'file':                   unicode,
1034
 
    'forward':                None,
1035
671
    'message':                unicode,
1036
672
    'profile':                None,
1037
 
    'revision':               _parse_revision_str,
 
673
    'revision':               int,
1038
674
    'show-ids':               None,
1039
675
    'timezone':               str,
1040
676
    'verbose':                None,
1044
680
 
1045
681
SHORT_OPTIONS = {
1046
682
    'm':                      'message',
1047
 
    'F':                      'file', 
1048
683
    'r':                      'revision',
1049
684
    'v':                      'verbose',
1050
685
}
1183
818
            return 0
1184
819
        cmd = str(args.pop(0))
1185
820
    except IndexError:
1186
 
        import help
1187
 
        help.help()
 
821
        log_error('usage: bzr COMMAND')
 
822
        log_error('  try "bzr help"')
1188
823
        return 1
1189
 
          
1190
824
 
1191
825
    canonical_cmd, cmd_class = get_cmd_class(cmd)
1192
826
 
1201
835
    allowed = cmd_class.takes_options
1202
836
    for oname in opts:
1203
837
        if oname not in allowed:
1204
 
            raise BzrCommandError("option '--%s' is not allowed for command %r"
 
838
            raise BzrCommandError("option %r is not allowed for command %r"
1205
839
                                  % (oname, cmd))
1206
840
 
1207
841
    # mix arguments and options into one dictionary
1232
866
            os.close(pffileno)
1233
867
            os.remove(pfname)
1234
868
    else:
1235
 
        return cmd_class(cmdopts, cmdargs).status 
 
869
        cmdobj = cmd_class(cmdopts, cmdargs).status 
1236
870
 
1237
871
 
1238
872
def _report_exception(summary, quiet=False):
1280
914
            return 2
1281
915
        except Exception, e:
1282
916
            quiet = False
1283
 
            if (isinstance(e, IOError) 
1284
 
                and hasattr(e, 'errno')
1285
 
                and e.errno == errno.EPIPE):
 
917
            if isinstance(e, IOError) and e.errno == errno.EPIPE:
1286
918
                quiet = True
1287
919
                msg = 'broken pipe'
1288
920
            else: