~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/reconfigure.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-12-05 13:51:54 UTC
  • mfrom: (3878.1.3 sorted_get_record_stream)
  • Revision ID: pqm@pqm.ubuntu.com-20081205135154-uwqcpl3lruah9fo3
(jam) Use I/O order for an 'unordered' get_record_stream request.

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