~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/reconfigure.py

  • Committer: Vincent Ladeuil
  • Date: 2009-06-22 12:52:39 UTC
  • mto: (4471.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4472.
  • Revision ID: v.ladeuil+lp@free.fr-20090622125239-kabo9smxt9c3vnir
Use a consistent scheme for naming pyrex source files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Reconfigure a bzrdir into a new tree/branch/repository layout"""
18
18
 
31
31
            self.repository = self.bzrdir.find_repository()
32
32
        except errors.NoRepositoryPresent:
33
33
            self.repository = None
 
34
            self.local_repository = None
34
35
        else:
35
36
            if (self.repository.bzrdir.root_transport.base ==
36
37
                self.bzrdir.root_transport.base):
62
63
        self._create_tree = False
63
64
        self._create_repository = False
64
65
        self._destroy_repository = False
 
66
        self._repository_trees = None
65
67
 
66
68
    @staticmethod
67
69
    def to_branch(bzrdir):
140
142
            raise errors.AlreadyStandalone(bzrdir)
141
143
        return reconfiguration
142
144
 
 
145
    @classmethod
 
146
    def set_repository_trees(klass, bzrdir, with_trees):
 
147
        """Adjust a repository's working tree presence default"""
 
148
        reconfiguration = klass(bzrdir)
 
149
        if not reconfiguration.repository.is_shared():
 
150
            raise errors.ReconfigurationNotSupported(reconfiguration.bzrdir)
 
151
        if with_trees and reconfiguration.repository.make_working_trees():
 
152
            raise errors.AlreadyWithTrees(bzrdir)
 
153
        elif (not with_trees
 
154
              and not reconfiguration.repository.make_working_trees()):
 
155
            raise errors.AlreadyWithNoTrees(bzrdir)
 
156
        else:
 
157
            reconfiguration._repository_trees = with_trees
 
158
        return reconfiguration
 
159
 
143
160
    def _plan_changes(self, want_tree, want_branch, want_bound,
144
161
                      want_reference):
145
162
        """Determine which changes are needed to assume the configuration"""
252
269
        if not force:
253
270
            self._check()
254
271
        if self._create_repository:
255
 
            repo = self.bzrdir.create_repository()
 
272
            if self.local_branch and not self._destroy_branch:
 
273
                old_repo = self.local_branch.repository
 
274
            elif self._create_branch and self.referenced_branch is not None:
 
275
                old_repo = self.referenced_branch.repository
 
276
            else:
 
277
                old_repo = None
 
278
            if old_repo is not None:
 
279
                repository_format = old_repo._format
 
280
            else:
 
281
                repository_format = None
 
282
            if repository_format is not None:
 
283
                repo = repository_format.initialize(self.bzrdir)
 
284
            else:
 
285
                repo = self.bzrdir.create_repository()
256
286
            if self.local_branch and not self._destroy_branch:
257
287
                repo.fetch(self.local_branch.repository,
258
288
                           self.local_branch.last_revision())
286
316
                local_branch.set_last_revision_info(*last_revision_info)
287
317
            if self._destroy_reference:
288
318
                self.referenced_branch.tags.merge_to(local_branch.tags)
 
319
                self.referenced_branch.update_references(local_branch)
289
320
        else:
290
321
            local_branch = self.local_branch
291
322
        if self._create_reference:
302
333
            local_branch.bind(branch.Branch.open(bind_location))
303
334
        if self._destroy_repository:
304
335
            self.bzrdir.destroy_repository()
 
336
        if self._repository_trees is not None:
 
337
            repo.set_make_working_trees(self._repository_trees)