~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Aaron Bentley
  • Date: 2005-09-19 02:52:24 UTC
  • mto: (1185.1.29)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: aaron.bentley@utoronto.ca-20050919025224-1cc3c70640086e09
TODO re tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
# would help with validation and shell completion.
33
33
 
34
34
 
35
 
# TODO: Help messages for options.
36
 
 
37
 
# TODO: Define arguments by objects, rather than just using names.
38
 
# Those objects can specify the expected type of the argument, which
39
 
# would help with validation and shell completion.
40
 
 
41
 
 
42
35
 
43
36
import sys
44
37
import os
148
141
    return revs
149
142
 
150
143
 
 
144
def get_merge_type(typestring):
 
145
    """Attempt to find the merge class/factory associated with a string."""
 
146
    from merge import merge_types
 
147
    try:
 
148
        return merge_types[typestring][0]
 
149
    except KeyError:
 
150
        templ = '%s%%7s: %%s' % (' '*12)
 
151
        lines = [templ % (f[0], f[1][1]) for f in merge_types.iteritems()]
 
152
        type_list = '\n'.join(lines)
 
153
        msg = "No known merge type %s. Supported types are:\n%s" %\
 
154
            (typestring, type_list)
 
155
        raise BzrCommandError(msg)
 
156
 
 
157
 
151
158
def _builtin_commands():
152
159
    import bzrlib.builtins
153
160
    r = {}
345
352
# the type.
346
353
OPTIONS = {
347
354
    'all':                    None,
348
 
    'basis':                  str,
349
355
    'diff-options':           str,
350
356
    'help':                   None,
351
357
    'file':                   unicode,
367
373
    'long':                   None,
368
374
    'root':                   str,
369
375
    'no-backup':              None,
 
376
    'merge-type':             get_merge_type,
370
377
    'pattern':                str,
371
378
    }
372
379
 
578
585
    --profile
579
586
        Run under the Python profiler.
580
587
    """
581
 
    # Load all of the transport methods
582
 
    import bzrlib.transport.local, bzrlib.transport.http
583
588
    
584
589
    argv = [a.decode(bzrlib.user_encoding) for a in argv]
585
590
 
658
663
        bzrlib.trace.log_exception('assertion failed: ' + str(e))
659
664
        return 3
660
665
    except KeyboardInterrupt, e:
661
 
        bzrlib.trace.log_exception('interrupted')
 
666
        bzrlib.trace.note('interrupted')
662
667
        return 2
663
668
    except Exception, e:
664
669
        import errno
671
676
            bzrlib.trace.log_exception()
672
677
            return 2
673
678
 
 
679
 
674
680
if __name__ == '__main__':
675
681
    sys.exit(main(sys.argv))