~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-03-09 08:50:48 UTC
  • mfrom: (1553.5.83 bzr.mbp.locks)
  • Revision ID: pqm@pqm.ubuntu.com-20060309085048-37f21fd146dabe93
[merge] LockDir integration into new formats

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
    return tree, new_list
71
71
 
72
72
 
 
73
def get_format_type(typestring):
 
74
    """Parse and return a format specifier."""
 
75
    if typestring == "metadir":
 
76
        return bzrdir.BzrDirMetaFormat1()
 
77
    if typestring == "knit":
 
78
        format = bzrdir.BzrDirMetaFormat1()
 
79
        format.repository_format = bzrlib.repository.RepositoryFormatKnit1()
 
80
        return format
 
81
    msg = "No known bzr-dir format %s. Supported types are: metadir\n" %\
 
82
        (typestring)
 
83
    raise BzrCommandError(msg)
 
84
 
 
85
 
73
86
# TODO: Make sure no commands unconditionally use the working directory as a
74
87
# branch.  If a filename argument is used, the first of them should be used to
75
88
# specify the branch.  (Perhaps this can be factored out into some kind of
866
879
        bzr commit -m 'imported project'
867
880
    """
868
881
    takes_args = ['location?']
869
 
    def run(self, location=None):
 
882
    takes_options = [
 
883
                     Option('format', 
 
884
                            help='Create a specific format rather than the'
 
885
                                 ' current default format. Currently this '
 
886
                                 ' option only accepts =metadir',
 
887
                            type=get_format_type),
 
888
                     ]
 
889
    def run(self, location=None, format=None):
870
890
        from bzrlib.branch import Branch
871
891
        if location is None:
872
892
            location = u'.'
878
898
            # locations if the user supplies an extended path
879
899
            if not os.path.exists(location):
880
900
                os.mkdir(location)
881
 
        bzrdir.BzrDir.create_standalone_workingtree(location)
 
901
        if format is None:
 
902
            # create default
 
903
            bzrdir.BzrDir.create_standalone_workingtree(location)
 
904
        else:
 
905
            new_dir = format.initialize(location)
 
906
            new_dir.create_repository()
 
907
            new_dir.create_branch()
 
908
            # TODO: ask the bzrdir format for the right classs
 
909
            import bzrlib.workingtree
 
910
            bzrlib.workingtree.WorkingTreeFormat3().initialize(new_dir)
882
911
 
883
912
 
884
913
class cmd_diff(Command):
1524
1553
            c.write()
1525
1554
 
1526
1555
 
1527
 
def get_format_type(typestring):
1528
 
    """Parse and return a format specifier."""
1529
 
    if typestring == "metadir":
1530
 
        return bzrdir.BzrDirMetaFormat1()
1531
 
    if typestring == "knit":
1532
 
        format = bzrdir.BzrDirMetaFormat1()
1533
 
        format.repository_format = bzrlib.repository.RepositoryFormatKnit1()
1534
 
        return format
1535
 
    msg = "No known bzr-dir format %s. Supported types are: metadir\n" %\
1536
 
        (typestring)
1537
 
    raise BzrCommandError(msg)
1538
 
 
1539
 
 
1540
1556
class cmd_upgrade(Command):
1541
1557
    """Upgrade branch storage to current format.
1542
1558