/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/reconfigure.py

  • Committer: Jelmer Vernooij
  • Date: 2018-02-18 21:42:57 UTC
  • mto: This revision was merged to the branch mainline in revision 6859.
  • Revision ID: jelmer@jelmer.uk-20180218214257-jpevutp1wa30tz3v
Update TODO to reference Breezy, not Bazaar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
constructing a class or using a factory method on Reconfigure.
21
21
"""
22
22
 
 
23
from __future__ import absolute_import
 
24
 
23
25
 
24
26
from . import (
25
27
    branch,
116
118
        # it may be a path relative to the cwd or a url; the branch wants
117
119
        # a path relative to itself...
118
120
        on_url = urlutils.relative_url(branch.base,
119
 
                                       urlutils.normalize_url(stacked_on_url))
120
 
        with branch.lock_write():
 
121
            urlutils.normalize_url(stacked_on_url))
 
122
        branch.lock_write()
 
123
        try:
121
124
            branch.set_stacked_on_url(on_url)
122
125
            if not trace.is_quiet():
123
126
                ui.ui_factory.note(gettext(
124
127
                    "{0} is now stacked on {1}\n").format(
125
 
                    branch.base, branch.get_stacked_on_url()))
 
128
                      branch.base, branch.get_stacked_on_url()))
 
129
        finally:
 
130
            branch.unlock()
126
131
 
127
132
 
128
133
class ReconfigureUnstacked(object):
129
134
 
130
135
    def apply(self, controldir):
131
136
        branch = controldir.open_branch()
132
 
        with branch.lock_write():
 
137
        branch.lock_write()
 
138
        try:
133
139
            branch.set_stacked_on_url(None)
134
140
            if not trace.is_quiet():
135
141
                ui.ui_factory.note(gettext(
136
142
                    "%s is now not stacked\n")
137
143
                    % (branch.base,))
 
144
        finally:
 
145
            branch.unlock()
138
146
 
139
147
 
140
148
class Reconfigure(object):
265
273
            raise ReconfigurationNotSupported(reconfiguration.controldir)
266
274
        if with_trees and reconfiguration.repository.make_working_trees():
267
275
            raise AlreadyWithTrees(controldir)
268
 
        elif (not with_trees and
269
 
              not reconfiguration.repository.make_working_trees()):
 
276
        elif (not with_trees
 
277
              and not reconfiguration.repository.make_working_trees()):
270
278
            raise AlreadyWithNoTrees(controldir)
271
279
        else:
272
280
            reconfiguration._repository_trees = with_trees
284
292
                self._create_repository = True
285
293
        else:
286
294
            if want_reference and (
287
 
                    self.repository.user_url == self.controldir.user_url):
 
295
                self.repository.user_url == self.controldir.user_url):
288
296
                if not self.repository.is_shared():
289
297
                    self._destroy_repository = True
290
298
        if self.referenced_branch is None:
324
332
 
325
333
    def changes_planned(self):
326
334
        """Return True if changes are planned, False otherwise"""
327
 
        return (self._unbind or self._bind or self._destroy_tree or
328
 
                self._create_tree or self._destroy_reference or
329
 
                self._create_branch or self._create_repository or
330
 
                self._create_reference or self._destroy_repository)
 
335
        return (self._unbind or self._bind or self._destroy_tree
 
336
                or self._create_tree or self._destroy_reference
 
337
                or self._create_branch or self._create_repository
 
338
                or self._create_reference or self._destroy_repository)
331
339
 
332
340
    def _check(self):
333
341
        """Raise if reconfiguration would destroy local changes"""
334
342
        if self._destroy_tree and self.tree.has_changes():
335
 
            raise errors.UncommittedChanges(self.tree)
 
343
                raise errors.UncommittedChanges(self.tree)
336
344
        if self._create_reference and self.local_branch is not None:
337
345
            reference_branch = branch.Branch.open(self._select_bind_location())
338
 
            if (reference_branch.last_revision()
339
 
                    != self.local_branch.last_revision()):
 
346
            if (reference_branch.last_revision() !=
 
347
                self.local_branch.last_revision()):
340
348
                raise UnsyncedBranches(self.controldir, reference_branch)
341
349
 
342
350
    def _select_bind_location(self):