/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/push.py

  • Committer: Robert Collins
  • Date: 2009-04-20 04:19:45 UTC
  • mto: This revision was merged to the branch mainline in revision 4304.
  • Revision ID: robertc@robertcollins.net-20090420041945-qvim67wg99c3euki
Move directory checking for bzr push options into Branch.create_clone_on_transport.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
        directory exists without a current .bzr directory in it
80
80
    """
81
81
    to_transport = transport.get_transport(location)
82
 
    br_to = repository_to = dir_to = None
83
82
    try:
84
83
        dir_to = bzrdir.BzrDir.open_from_transport(to_transport)
85
84
    except errors.NotBranchError:
86
 
        pass # Didn't find anything
 
85
        # Didn't find anything
 
86
        dir_to = None
87
87
 
88
 
    push_result = PushResult()
89
88
    if dir_to is None:
90
 
        # The destination doesn't exist; create it.
91
 
        # XXX: Refactor the create_prefix/no_create_prefix code into a
92
 
        #      common helper function
93
 
 
94
 
        def make_directory(transport):
95
 
            transport.mkdir('.')
96
 
            return transport
97
 
 
98
 
        def redirected(transport, e, redirection_notice):
99
 
            note(redirection_notice)
100
 
            return transport._redirected_to(e.source, e.target)
101
 
 
102
 
        try:
103
 
            to_transport = transport.do_catching_redirections(
104
 
                make_directory, to_transport, redirected)
105
 
        except errors.FileExists:
106
 
            if not use_existing_dir:
107
 
                raise errors.BzrCommandError("Target directory %s"
108
 
                     " already exists, but does not have a valid .bzr"
109
 
                     " directory. Supply --use-existing-dir to push"
110
 
                     " there anyway." % location)
111
 
        except errors.NoSuchFile:
112
 
            if not create_prefix:
113
 
                raise errors.BzrCommandError("Parent directory of %s"
114
 
                    " does not exist."
115
 
                    "\nYou may supply --create-prefix to create all"
116
 
                    " leading parent directories."
117
 
                    % location)
118
 
            builtins._create_prefix(to_transport)
119
 
        except errors.TooManyRedirections:
120
 
            raise errors.BzrCommandError("Too many redirections trying "
121
 
                                         "to make %s." % location)
122
 
 
123
 
        # Now the target directory exists, but doesn't have a .bzr
124
 
        # directory. So we need to create it, along with any work to create
125
 
        # all of the dependent branches, etc.
126
89
        br_to = br_from.create_clone_on_transport(to_transport,
127
 
            revision_id=revision_id, stacked_on=stacked_on)
 
90
            revision_id=revision_id, stacked_on=stacked_on,
 
91
            create_prefix=create_prefix, use_existing_dir=use_existing_dir)
 
92
        push_result = PushResult()
128
93
        # TODO: Some more useful message about what was copied
129
94
        try:
130
95
            push_result.stacked_on = br_to.get_stacked_on_url()