~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/reconfigure.py

  • Committer: Ian Clatworthy
  • Date: 2009-09-09 15:30:59 UTC
  • mto: (4634.37.2 prepare-2.0)
  • mto: This revision was merged to the branch mainline in revision 4689.
  • Revision ID: ian.clatworthy@canonical.com-20090909153059-sb038agvd38ci2q8
more link fixes in the User Guide

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""Reconfigure a controldir into a new tree/branch/repository layout.
 
17
"""Reconfigure a bzrdir into a new tree/branch/repository layout.
18
18
 
19
19
Various types of reconfiguration operation are available either by
20
20
constructing a class or using a factory method on Reconfigure.
21
21
"""
22
22
 
23
 
from __future__ import absolute_import
24
 
 
25
23
 
26
24
from bzrlib import (
27
25
    branch,
28
 
    controldir,
 
26
    bzrdir,
29
27
    errors,
30
28
    trace,
31
29
    ui,
32
30
    urlutils,
33
31
    )
34
 
from bzrlib.i18n import gettext
 
32
 
35
33
 
36
34
# TODO: common base class for all reconfigure operations, making no
37
35
# assumptions about what kind of change will be done.
50
48
        try:
51
49
            branch.set_stacked_on_url(on_url)
52
50
            if not trace.is_quiet():
53
 
                ui.ui_factory.note(gettext(
54
 
                    "{0} is now stacked on {1}\n").format(
55
 
                      branch.base, branch.get_stacked_on_url()))
 
51
                ui.ui_factory.note(
 
52
                    "%s is now stacked on %s\n"
 
53
                    % (branch.base, branch.get_stacked_on_url()))
56
54
        finally:
57
55
            branch.unlock()
58
56
 
65
63
        try:
66
64
            branch.set_stacked_on_url(None)
67
65
            if not trace.is_quiet():
68
 
                ui.ui_factory.note(gettext(
69
 
                    "%s is now not stacked\n")
 
66
                ui.ui_factory.note(
 
67
                    "%s is now not stacked\n"
70
68
                    % (branch.base,))
71
69
        finally:
72
70
            branch.unlock()
84
82
            self.repository = None
85
83
            self.local_repository = None
86
84
        else:
87
 
            if (self.repository.user_url == self.bzrdir.user_url):
 
85
            if (self.repository.bzrdir.root_transport.base ==
 
86
                self.bzrdir.root_transport.base):
88
87
                self.local_repository = self.repository
89
88
            else:
90
89
                self.local_repository = None
91
90
        try:
92
91
            branch = self.bzrdir.open_branch()
93
 
            if branch.user_url == bzrdir.user_url:
 
92
            if branch.bzrdir.root_transport.base == bzrdir.root_transport.base:
94
93
                self.local_branch = branch
95
94
                self.referenced_branch = None
96
95
            else:
218
217
            if not want_reference:
219
218
                self._create_repository = True
220
219
        else:
221
 
            if want_reference and (
222
 
                self.repository.user_url == self.bzrdir.user_url):
 
220
            if want_reference and (self.repository.bzrdir.root_transport.base
 
221
                                   == self.bzrdir.root_transport.base):
223
222
                if not self.repository.is_shared():
224
223
                    self._destroy_repository = True
225
224
        if self.referenced_branch is None:
266
265
 
267
266
    def _check(self):
268
267
        """Raise if reconfiguration would destroy local changes"""
269
 
        if self._destroy_tree and self.tree.has_changes():
 
268
        if self._destroy_tree:
 
269
            # XXX: What about pending merges ? -- vila 20090629
 
270
            if self.tree.has_changes(self.tree.basis_tree()):
270
271
                raise errors.UncommittedChanges(self.tree)
271
272
        if self._create_reference and self.local_branch is not None:
272
273
            reference_branch = branch.Branch.open(self._select_bind_location())
345
346
            if self._create_reference:
346
347
                reference_branch.repository.fetch(self.repository)
347
348
            elif self.local_branch is not None and not self._destroy_branch:
348
 
                up = self.local_branch.user_transport.clone('..')
349
 
                up_bzrdir = controldir.ControlDir.open_containing_from_transport(
350
 
                    up)[0]
 
349
                up = self.local_branch.bzrdir.root_transport.clone('..')
 
350
                up_bzrdir = bzrdir.BzrDir.open_containing_from_transport(up)[0]
351
351
                new_repo = up_bzrdir.find_repository()
352
352
                new_repo.fetch(self.repository)
353
353
        last_revision_info = None
369
369
        else:
370
370
            local_branch = self.local_branch
371
371
        if self._create_reference:
372
 
            self.bzrdir.set_branch_reference(reference_branch)
 
372
            format = branch.BranchReferenceFormat().initialize(self.bzrdir,
 
373
                reference_branch)
373
374
        if self._destroy_tree:
374
375
            self.bzrdir.destroy_workingtree()
375
376
        if self._create_tree: