/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Aaron Bentley
  • Date: 2006-08-16 04:57:05 UTC
  • mto: This revision was merged to the branch mainline in revision 1934.
  • Revision ID: aaron.bentley@utoronto.ca-20060816045705-b4e53acd83d8acb7
Strip out all the EnumOption stuff

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
                           NoSuchFile, NoWorkingTree, FileInWrongBranch,
49
49
                           NotVersionedError, NotABundle)
50
50
from bzrlib.merge import Merge3Merger
51
 
from bzrlib.option import Option, EnumOption
 
51
from bzrlib.option import Option
52
52
from bzrlib.progress import DummyProgress, ProgressPhase
53
53
from bzrlib.revision import common_ancestor
54
54
from bzrlib.revisionspec import RevisionSpec
982
982
        for revision_id in revision_ids:
983
983
            self.outf.write(revision_id + '\n')
984
984
 
985
 
branch_format_option = EnumOption('Branch Format', get_format_type, 
986
 
                                  [('default', 
987
 
                                    'The current best format (knit)'),
988
 
                                   ('knit', '0.8+ append-only format'),
989
 
                                   ('metaweave', '0.8 transitional format'),
990
 
                                   ('weave', '0.1+ format')
991
 
                                  ])
992
 
 
993
 
repo_format_option = EnumOption('Repository Format', get_format_type, 
994
 
                                [('default', 
995
 
                                  'The current best format (knit)'),
996
 
                                 ('knit', '0.8+ append-only format'),
997
 
                                 ('metaweave', '0.8 transitional format'),
998
 
                                ])
999
985
 
1000
986
class cmd_init(Command):
1001
987
    """Make a directory into a versioned branch.
1019
1005
        bzr commit -m 'imported project'
1020
1006
    """
1021
1007
    takes_args = ['location?']
1022
 
    takes_options = [branch_format_option]
1023
 
    def run(self, location=None, branch_format=None):
1024
 
        if branch_format is None:
1025
 
            branch_format = get_format_type('default')
 
1008
    takes_options = [
 
1009
                     Option('format', 
 
1010
                            help='Specify a format for this branch. Current'
 
1011
                                 ' formats are: default, knit, metaweave and'
 
1012
                                 ' weave. Default is knit; metaweave and'
 
1013
                                 ' weave are deprecated',
 
1014
                            type=get_format_type),
 
1015
                     ]
 
1016
    def run(self, location=None, format=None):
 
1017
        if format is None:
 
1018
            format = get_format_type('default')
1026
1019
        if location is None:
1027
1020
            location = u'.'
1028
1021
 
1043
1036
            existing_bzrdir = bzrdir.BzrDir.open(location)
1044
1037
        except NotBranchError:
1045
1038
            # really a NotBzrDir error...
1046
 
            bzrdir.BzrDir.create_branch_convenience(location, 
1047
 
                                                    format=branch_format)
 
1039
            bzrdir.BzrDir.create_branch_convenience(location, format=format)
1048
1040
        else:
1049
1041
            if existing_bzrdir.has_branch():
1050
1042
                if (isinstance(to_transport, LocalTransport)
1071
1063
        (add files here)
1072
1064
    """
1073
1065
    takes_args = ["location"] 
1074
 
    takes_options = [repo_format_option,
 
1066
    takes_options = [Option('format', 
 
1067
                            help='Specify a format for this repository.'
 
1068
                                 ' Current formats are: default, knit,'
 
1069
                                 ' metaweave and weave. Default is knit;'
 
1070
                                 ' metaweave and weave are deprecated',
 
1071
                            type=get_format_type),
1075
1072
                     Option('trees',
1076
1073
                             help='Allows branches in repository to have'
1077
1074
                             ' a working tree')]
1078
1075
    aliases = ["init-repo"]
1079
 
    def run(self, location, repository_format=None, trees=False):
1080
 
        if repository_format is None:
1081
 
            repository_format = get_format_type('default')
 
1076
    def run(self, location, format=None, trees=False):
 
1077
        if format is None:
 
1078
            format = get_format_type('default')
 
1079
 
 
1080
        if location is None:
 
1081
            location = '.'
 
1082
 
1082
1083
        to_transport = transport.get_transport(location)
1083
1084
        try:
1084
1085
            to_transport.mkdir('.')
1085
1086
        except errors.FileExists:
1086
1087
            pass
1087
1088
 
1088
 
        newdir = repository_format.initialize_on_transport(to_transport)
 
1089
        newdir = format.initialize_on_transport(to_transport)
1089
1090
        repo = newdir.create_repository(shared=True)
1090
1091
        repo.set_make_working_trees(trees)
1091
1092
 
1284
1285
                             help='show files changed in each revision'),
1285
1286
                     'show-ids', 'revision',
1286
1287
                     'log-format',
 
1288
                     'line', 'long', 
1287
1289
                     Option('message',
1288
1290
                            help='show revisions whose message matches this regexp',
1289
1291
                            type=str),
 
1292
                     'short',
1290
1293
                     ]
1291
1294
    encoding_type = 'replace'
1292
1295
 
1297
1300
            forward=False,
1298
1301
            revision=None,
1299
1302
            log_format=None,
1300
 
            message=None):
 
1303
            message=None,
 
1304
            long=False,
 
1305
            short=False,
 
1306
            line=False):
1301
1307
        from bzrlib.log import log_formatter, show_log
1302
1308
        assert message is None or isinstance(message, basestring), \
1303
1309
            "invalid message argument %r" % message
1351
1357
            (rev2, rev1) = (rev1, rev2)
1352
1358
 
1353
1359
        if (log_format == None):
1354
 
            log_format = b.get_config().log_format()
 
1360
            default = b.get_config().log_format()
 
1361
            log_format = get_log_format(long=long, short=short, line=line, 
 
1362
                                        default=default)
1355
1363
        lf = log_formatter(log_format,
1356
1364
                           show_ids=show_ids,
1357
1365
                           to_file=self.outf,
1367
1375
                 search=message)
1368
1376
 
1369
1377
 
 
1378
def get_log_format(long=False, short=False, line=False, default='long'):
 
1379
    log_format = default
 
1380
    if long:
 
1381
        log_format = 'long'
 
1382
    if short:
 
1383
        log_format = 'short'
 
1384
    if line:
 
1385
        log_format = 'line'
 
1386
    return log_format
 
1387
 
 
1388
 
1370
1389
class cmd_touching_revisions(Command):
1371
1390
    """Return revision-ids which affected a particular file.
1372
1391
 
1780
1799
    during other operations to upgrade.
1781
1800
    """
1782
1801
    takes_args = ['url?']
1783
 
    takes_options = [ branch_format_option ]
1784
 
 
1785
 
    def run(self, url='.', branch_format=None):
 
1802
    takes_options = [
 
1803
                     Option('format', 
 
1804
                            help='Upgrade to a specific format. Current formats'
 
1805
                                 ' are: default, knit, metaweave and weave.'
 
1806
                                 ' Default is knit; metaweave and weave are'
 
1807
                                 ' deprecated',
 
1808
                            type=get_format_type),
 
1809
                    ]
 
1810
 
 
1811
 
 
1812
    def run(self, url='.', format=None):
1786
1813
        from bzrlib.upgrade import upgrade
1787
 
        if branch_format is None:
1788
 
            branch_format = get_format_type('default')
1789
 
        upgrade(url, branch_format)
 
1814
        if format is None:
 
1815
            format = get_format_type('default')
 
1816
        upgrade(url, format)
1790
1817
 
1791
1818
 
1792
1819
class cmd_whoami(Command):
2378
2405
                     Option('theirs-only', 
2379
2406
                            'Display changes in the remote branch only'), 
2380
2407
                     'log-format',
 
2408
                     'line',
 
2409
                     'long', 
 
2410
                     'short',
2381
2411
                     'show-ids',
2382
2412
                     'verbose'
2383
2413
                     ]
2385
2415
 
2386
2416
    @display_command
2387
2417
    def run(self, other_branch=None, reverse=False, mine_only=False,
2388
 
            theirs_only=False, log_format=None,
 
2418
            theirs_only=False, log_format=None, long=False, short=False, line=False, 
2389
2419
            show_ids=False, verbose=False):
2390
2420
        from bzrlib.missing import find_unmerged, iter_log_data
2391
2421
        from bzrlib.log import log_formatter
2404
2434
            remote_branch.lock_read()
2405
2435
            try:
2406
2436
                local_extra, remote_extra = find_unmerged(local_branch, remote_branch)
2407
 
                if (log_format is None):
2408
 
                    log_format = local_branch.get_config().log_format()
 
2437
                if (log_format == None):
 
2438
                    default = local_branch.get_config().log_format()
 
2439
                    log_format = get_log_format(long=long, short=short, 
 
2440
                                                line=line, default=default)
2409
2441
                lf = log_formatter(log_format,
2410
2442
                                   to_file=self.outf,
2411
2443
                                   show_ids=show_ids,