~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/reconfigure.py

  • Committer: Aaron Bentley
  • Date: 2007-09-09 08:00:32 UTC
  • mto: This revision was merged to the branch mainline in revision 2826.
  • Revision ID: aaron.bentley@utoronto.ca-20070909080032-rj0kri2uwfqfvrif
Implement converting a lightweight checkout to a branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
        self.bzrdir = bzrdir
28
28
        self.new_bound_location = new_bound_location
29
29
        try:
 
30
            self.repository = self.bzrdir.open_repository()
 
31
        except errors.NoRepositoryPresent:
 
32
            self.repository = None
 
33
        try:
30
34
            branch = self.bzrdir.open_branch()
31
35
            if branch.bzrdir.root_transport.base == bzrdir.root_transport.base:
32
36
                self.local_branch = branch
42
46
            self.tree = None
43
47
        self.unbind = False
44
48
        self.bind = False
 
49
        self.destroy_reference = False
 
50
        self.create_branch = False
45
51
        self.destroy_tree = False
46
52
        self.create_tree = False
 
53
        self.create_repository = False
47
54
 
48
55
    @staticmethod
49
56
    def to_branch(bzrdir):
70
77
        return reconfiguration
71
78
 
72
79
    def select_changes(self, tree, branch, bound):
 
80
        if self.repository is None:
 
81
            self.create_repository = True
73
82
        if self.local_branch is None:
74
83
            if branch is True:
75
 
                raise errors.ReconfigurationNotSupported(self.bzrdir)
 
84
                if self.referenced_branch is not None:
 
85
                    self.destroy_reference = True
 
86
                    self.create_branch = True
76
87
        else:
77
88
            if bound:
78
89
                if self.local_branch.get_bound_location() is None:
111
122
    def apply(self, force=False):
112
123
        if not force:
113
124
            self._check()
 
125
        if self.create_repository:
 
126
            self.bzrdir.create_repository()
 
127
        if self.destroy_reference:
 
128
            self.bzrdir.destroy_branch()
 
129
        if self.create_branch:
 
130
            self.bzrdir.create_branch()
114
131
        if self.destroy_tree:
115
132
            self.bzrdir.destroy_workingtree()
116
133
        if self.create_tree: