~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/reconfigure.py

  • Committer: Aaron Bentley
  • Date: 2007-12-12 15:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 3113.
  • Revision ID: abentley@panoramicfeedback.com-20071212151713-ox5n8rlx8m3nsspy
Add support for reconfiguring repositories into branches or trees

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
223
211
            repo = self.bzrdir.create_repository()
224
212
        else:
225
213
            repo = self.repository
226
 
        if self._create_branch:
 
214
        if self._create_branch and self.referenced_branch is not None:
227
215
            repo.fetch(self.referenced_branch.repository,
228
216
                       self.referenced_branch.last_revision())
 
217
        last_revision_info = None
229
218
        if self._destroy_reference:
230
 
            reference_info = self.referenced_branch.last_revision_info()
 
219
            last_revision_info = self.referenced_branch.last_revision_info()
231
220
            self.bzrdir.destroy_branch()
232
221
        if self._destroy_branch:
233
 
            reference_info = self.local_branch.last_revision_info()
 
222
            last_revision_info = self.local_branch.last_revision_info()
234
223
            self.bzrdir.destroy_branch()
235
224
        if self._create_branch:
236
225
            local_branch = self.bzrdir.create_branch()
237
 
            local_branch.set_last_revision_info(*reference_info)
 
226
            if last_revision_info is not None:
 
227
                local_branch.set_last_revision_info(*last_revision_info)
238
228
        else:
239
229
            local_branch = self.local_branch
240
230
        if self._create_reference: