~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Wouter van Heyst
  • Date: 2006-07-02 15:46:00 UTC
  • mto: This revision was merged to the branch mainline in revision 1867.
  • Revision ID: larstiq@larstiq.dyndns.org-20060702154600-848abd3894fadfc1
Allow bzr init to create remote branches

Show diffs side-by-side

added added

removed removed

Lines of Context:
1005
1005
                            type=get_format_type),
1006
1006
                     ]
1007
1007
    def run(self, location=None, format=None):
 
1008
        from bzrlib.transport import get_transport
1008
1009
        if format is None:
1009
1010
            format = get_format_type('default')
 
1011
        transport = get_transport(location)
1010
1012
        if location is None:
1011
1013
            location = u'.'
1012
1014
        else:
1015
1017
            # Just using os.mkdir, since I don't
1016
1018
            # believe that we want to create a bunch of
1017
1019
            # locations if the user supplies an extended path
1018
 
            if not os.path.exists(location):
1019
 
                os.mkdir(location)
 
1020
            if not transport.has('.'):
 
1021
                transport.mkdir('')
 
1022
                    
1020
1023
        try:
1021
1024
            existing_bzrdir = bzrdir.BzrDir.open(location)
1022
1025
        except NotBranchError:
1024
1027
            bzrdir.BzrDir.create_branch_convenience(location, format=format)
1025
1028
        else:
1026
1029
            if existing_bzrdir.has_branch():
1027
 
                if existing_bzrdir.has_workingtree():
1028
 
                    raise errors.AlreadyBranchError(location)
1029
 
                else:
1030
 
                    raise errors.BranchExistsWithoutWorkingTree(location)
 
1030
                if isinstance(transport, LocalTransport):
 
1031
                    if not existing_bzrdir.has_workingtree():
 
1032
                        raise errors.BranchExistsWithoutWorkingTree(location)
 
1033
                raise errors.AlreadyBranchError(location)
1031
1034
            else:
1032
1035
                existing_bzrdir.create_branch()
1033
1036
                existing_bzrdir.create_workingtree()