~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/push.py

1st cut merge of bzr.dev r3907

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
            transport.mkdir('.')
75
75
            return transport
76
76
 
77
 
        def redirected(redirected_transport, e, redirection_notice):
78
 
            return transport.get_transport(e.get_target_url())
 
77
        def redirected(transport, e, redirection_notice):
 
78
            note(redirection_notice)
 
79
            return transport._redirected_to(e.source, e.target)
79
80
 
80
81
        try:
81
82
            to_transport = transport.do_catching_redirections(
101
102
        # Now the target directory exists, but doesn't have a .bzr
102
103
        # directory. So we need to create it, along with any work to create
103
104
        # all of the dependent branches, etc.
104
 
        if stacked_on is not None:
105
 
            # This should be buried in the clone method itself. TODO.
106
 
            try:
107
 
                # if the from format is stackable, this will either work or
108
 
                # trigger NotStacked. If it's not, an error will be given to
109
 
                # the user.
110
 
                br_from.get_stacked_on_url()
111
 
            except errors.NotStacked:
112
 
                pass
113
 
            # now we need to sprout the repository,
114
 
            dir_to = br_from.bzrdir._format.initialize_on_transport(to_transport)
115
 
            br_from.repository._format.initialize(dir_to)
116
 
            br_to = br_from._format.initialize(dir_to)
117
 
            br_to.set_stacked_on_url(stacked_on)
118
 
            # and copy the data up.
119
 
            br_from.push(br_to)
120
 
        else:
121
 
            dir_to = br_from.bzrdir.clone_on_transport(to_transport,
122
 
                revision_id=revision_id)
 
105
        dir_to = br_from.bzrdir.clone_on_transport(to_transport,
 
106
            revision_id=revision_id, stacked_on=stacked_on)
123
107
        br_to = dir_to.open_branch()
124
108
        # TODO: Some more useful message about what was copied
125
 
        if stacked_on is not None:
126
 
            note('Created new stacked branch referring to %s.' % stacked_on)
 
109
        try:
 
110
            finally_stacked_on = br_to.get_stacked_on_url()
 
111
        except (errors.UnstackableBranchFormat,
 
112
                errors.UnstackableRepositoryFormat,
 
113
                errors.NotStacked):
 
114
            finally_stacked_on = None
 
115
        if finally_stacked_on is not None:
 
116
            note('Created new stacked branch referring to %s.' %
 
117
                 finally_stacked_on)
127
118
        else:
128
119
            note('Created new branch.')
129
120
        # We successfully created the target, remember it