~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-04-20 08:03:24 UTC
  • mfrom: (1662.1.19 bzr.mbp.integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060420080324-8acbffaeefd8f243
(mbp) better error messages from bzr init

Show diffs side-by-side

added added

removed removed

Lines of Context:
883
883
    Use this to create an empty branch, or before importing an
884
884
    existing project.
885
885
 
 
886
    If there is a repository in a parent directory of the location, then 
 
887
    the history of the branch will be stored in the repository.  Otherwise
 
888
    init creates a standalone branch which carries its own history in 
 
889
    .bzr.
 
890
 
 
891
    If there is already a branch at the location but it has no working tree,
 
892
    the tree can be populated with 'bzr checkout'.
 
893
 
886
894
    Recipe for importing a tree of files:
887
895
        cd ~/project
888
896
        bzr init
911
919
            if not os.path.exists(location):
912
920
                os.mkdir(location)
913
921
        try:
914
 
            existing = bzrdir.BzrDir.open(location)
 
922
            existing_bzrdir = bzrdir.BzrDir.open(location)
915
923
        except NotBranchError:
 
924
            # really a NotBzrDir error...
916
925
            bzrdir.BzrDir.create_branch_convenience(location, format=format)
917
926
        else:
918
 
            try:
919
 
                existing.open_branch()
920
 
            except NotBranchError:
921
 
                existing.create_branch()
922
 
                existing.create_workingtree()
 
927
            if existing_bzrdir.has_branch():
 
928
                if existing_bzrdir.has_workingtree():
 
929
                    raise errors.AlreadyBranchError(location)
 
930
                else:
 
931
                    raise errors.BranchExistsWithoutWorkingTree(location)
923
932
            else:
924
 
                raise errors.AlreadyBranchError(location)
 
933
                existing_bzrdir.create_branch()
 
934
                existing_bzrdir.create_workingtree()
925
935
 
926
936
 
927
937
class cmd_init_repository(Command):