~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/reconfigure.py

merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
 
63
63
        :param bzrdir: The bzrdir to reconfigure
64
64
        :raise errors.AlreadyBranch: if bzrdir is already a branch
65
 
        :raise errors.ReconfigurationNotSupported: if bzrdir does not contain
66
 
            a branch or branch reference
67
65
        """
68
66
        reconfiguration = Reconfigure(bzrdir)
69
67
        reconfiguration._plan_changes(want_tree=False, want_branch=True,
78
76
 
79
77
        :param bzrdir: The bzrdir to reconfigure
80
78
        :raise errors.AlreadyTree: if bzrdir is already a tree
81
 
        :raise errors.ReconfigurationNotSupported: if bzrdir does not contain
82
 
            a branch or branch reference
83
79
        """
84
80
        reconfiguration = Reconfigure(bzrdir)
85
81
        reconfiguration._plan_changes(want_tree=True, want_branch=True,
95
91
        :param bzrdir: The bzrdir to reconfigure
96
92
        :param bound_location: The location the checkout should be bound to.
97
93
        :raise errors.AlreadyCheckout: if bzrdir is already a checkout
98
 
        :raise errors.ReconfigurationNotSupported: if bzrdir does not contain
99
 
            a branch or branch reference
100
94
        """
101
95
        reconfiguration = Reconfigure(bzrdir, bound_location)
102
96
        reconfiguration._plan_changes(want_tree=True, want_branch=True,
113
107
        :param bound_location: The location the checkout should be bound to.
114
108
        :raise errors.AlreadyLightweightCheckout: if bzrdir is already a
115
109
            lightweight checkout
116
 
        :raise errors.ReconfigurationNotSupported: if bzrdir does not contain
117
 
            a branch or branch reference
118
110
        """
119
111
        reconfiguration = klass(bzrdir, reference_location)
120
112
        reconfiguration._plan_changes(want_tree=True, want_branch=False,
130
122
            raise errors.ReconfigurationNotSupported(self.bzrdir)
131
123
        if want_branch and want_reference:
132
124
            raise errors.ReconfigurationNotSupported(self.bzrdir)
133
 
        if (want_branch or want_reference) and (self.local_branch is None and
134
 
                                                self.referenced_branch
135
 
                                                is None):
136
 
            raise errors.ReconfigurationNotSupported(self.bzrdir)
137
125
        if self.repository is None:
138
126
            if not want_reference:
139
127
                self._create_repository = True
140
128
        else:
141
129
            if want_reference and (self.repository.bzrdir.root_transport.base
142
130
                                   == self.bzrdir.root_transport.base):
143
 
                self._destroy_repository = True
 
131
                if not self.repository.is_shared():
 
132
                    self._destroy_repository = True
144
133
        if self.referenced_branch is None:
145
134
            if want_reference:
146
135
                self._create_reference = True
168
157
        """Return True if changes are planned, False otherwise"""
169
158
        return (self._unbind or self._bind or self._destroy_tree
170
159
                or self._create_tree or self._destroy_reference
171
 
                or self._create_branch or self._create_repository)
 
160
                or self._create_branch or self._create_repository
 
161
                or self._create_reference)
172
162
 
173
163
    def _check(self):
174
164
        """Raise if reconfiguration would destroy local changes"""
223
213
            repo = self.bzrdir.create_repository()
224
214
        else:
225
215
            repo = self.repository
226
 
        if self._create_branch:
 
216
        if self._create_branch and self.referenced_branch is not None:
227
217
            repo.fetch(self.referenced_branch.repository,
228
218
                       self.referenced_branch.last_revision())
 
219
        last_revision_info = None
229
220
        if self._destroy_reference:
230
 
            reference_info = self.referenced_branch.last_revision_info()
 
221
            last_revision_info = self.referenced_branch.last_revision_info()
231
222
            self.bzrdir.destroy_branch()
232
223
        if self._destroy_branch:
233
 
            reference_info = self.local_branch.last_revision_info()
 
224
            last_revision_info = self.local_branch.last_revision_info()
234
225
            self.bzrdir.destroy_branch()
235
226
        if self._create_branch:
236
227
            local_branch = self.bzrdir.create_branch()
237
 
            local_branch.set_last_revision_info(*reference_info)
 
228
            if last_revision_info is not None:
 
229
                local_branch.set_last_revision_info(*last_revision_info)
238
230
        else:
239
231
            local_branch = self.local_branch
240
232
        if self._create_reference: