~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/reconfigure.py

  • Committer: Aaron Bentley
  • Date: 2008-04-06 04:44:17 UTC
  • mto: This revision was merged to the branch mainline in revision 3364.
  • Revision ID: aaron@aaronbentley.com-20080406044417-v6lch0yugh7d1vtk
Implement conversion to standalone

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
            raise errors.AlreadySharing(bzrdir)
132
132
        return reconfiguration
133
133
 
 
134
    @classmethod
 
135
    def to_standalone(klass, bzrdir):
 
136
        """Convert a standalone branch into a sharing branch"""
 
137
        reconfiguration = klass(bzrdir)
 
138
        reconfiguration._set_sharing(sharing=False)
 
139
        if not reconfiguration.changes_planned():
 
140
            raise errors.AlreadyStandalone(bzrdir)
 
141
        return reconfiguration
 
142
 
134
143
    def _plan_changes(self, want_tree, want_branch, want_bound,
135
144
                      want_reference):
136
145
        """Determine which changes are needed to assume the configuration"""
177
186
        if sharing:
178
187
            if self.local_repository is not None:
179
188
                self._destroy_repository = True
 
189
        else:
 
190
            if self.local_repository is None:
 
191
                self._create_repository = True
180
192
 
181
193
    def changes_planned(self):
182
194
        """Return True if changes are planned, False otherwise"""
236
248
            self._check()
237
249
        if self._create_repository:
238
250
            repo = self.bzrdir.create_repository()
 
251
            if self.local_branch and not self._destroy_branch:
 
252
                repo.fetch(self.local_branch.repository,
 
253
                           self.local_branch.last_revision())
239
254
        else:
240
255
            repo = self.repository
241
256
        if self._create_branch and self.referenced_branch is not None: