~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
609
609
class cmd_checkout(Command):
610
610
    """Create a new checkout of an existing branch.
611
611
 
 
612
    If BRANCH_LOCATION is omitted, checkout will reconstitute a working tree for
 
613
    the branch found in '.'. This is useful if you have removed the working tree
 
614
    or if it was never created - i.e. if you pushed the branch to its current
 
615
    location using SFTP.
 
616
    
612
617
    If the TO_LOCATION is omitted, the last component of the BRANCH_LOCATION will
613
618
    be used.  In other words, "checkout ../foo/bar" will attempt to create ./bar.
614
619
 
621
626
    uses the inventory and file contents from the basis branch in preference to the
622
627
    branch being checked out. [Not implemented yet.]
623
628
    """
624
 
    takes_args = ['branch_location', 'to_location?']
 
629
    takes_args = ['branch_location?', 'to_location?']
625
630
    takes_options = ['revision', # , 'basis']
626
631
                     Option('lightweight',
627
632
                            help="perform a lightweight checkout. Lightweight "
632
637
                            ),
633
638
                     ]
634
639
 
635
 
    def run(self, branch_location, to_location=None, revision=None, basis=None,
 
640
    def run(self, branch_location=None, to_location=None, revision=None, basis=None,
636
641
            lightweight=False):
637
642
        if revision is None:
638
643
            revision = [None]
639
644
        elif len(revision) > 1:
640
645
            raise BzrCommandError(
641
646
                'bzr checkout --revision takes exactly 1 revision value')
 
647
        if branch_location is None:
 
648
            branch_location = bzrlib.osutils.getcwd()
 
649
            to_location = branch_location
642
650
        source = Branch.open(branch_location)
643
651
        if len(revision) == 1 and revision[0] is not None:
644
652
            revision_id = revision[0].in_history(source)[1]
646
654
            revision_id = None
647
655
        if to_location is None:
648
656
            to_location = os.path.basename(branch_location.rstrip("/\\"))
 
657
        # if the source and to_location are the same, 
 
658
        # and there is no working tree,
 
659
        # then reconstitute a branch
 
660
        if (bzrlib.osutils.abspath(to_location) == 
 
661
            bzrlib.osutils.abspath(branch_location)):
 
662
            try:
 
663
                source.bzrdir.open_workingtree()
 
664
            except errors.NoWorkingTree:
 
665
                source.bzrdir.create_workingtree()
 
666
                return
649
667
        try:
650
668
            os.mkdir(to_location)
651
669
        except OSError, e:
884
902
                            ' option only accepts "metadir" and "knit"'
885
903
                            ' WARNING: the knit format is currently unstable'
886
904
                            ' and only for experimental use.',
887
 
                            type=get_format_type)]
 
905
                            type=get_format_type),
 
906
                     Option('trees',
 
907
                             help='Allows branches in repository to have'
 
908
                             ' a working tree')]
888
909
    aliases = ["init-repo"]
889
 
    def run(self, location, format=None):
 
910
    def run(self, location, format=None, trees=False):
890
911
        from bzrlib.bzrdir import BzrDirMetaFormat1
891
912
        from bzrlib.transport import get_transport
892
913
        if format is None:
894
915
        get_transport(location).mkdir('')
895
916
        newdir = format.initialize(location)
896
917
        repo = newdir.create_repository(shared=True)
897
 
        repo.set_make_working_trees(False)
 
918
        repo.set_make_working_trees(trees)
898
919
 
899
920
 
900
921
class cmd_diff(Command):
1638
1659
        if typestring == "memory":
1639
1660
            from bzrlib.transport.memory import MemoryServer
1640
1661
            return MemoryServer
 
1662
        if typestring == "fakenfs":
 
1663
            from bzrlib.transport.fakenfs import FakeNFSServer
 
1664
            return FakeNFSServer
1641
1665
        msg = "No known transport type %s. Supported types are: sftp\n" %\
1642
1666
            (typestring)
1643
1667
        raise BzrCommandError(msg)