~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-09-17 14:29:23 UTC
  • mfrom: (2796.2.18 bzr.reconfigure)
  • Revision ID: pqm@pqm.ubuntu.com-20070917142923-f06edfgw1d0cvj4w
Add reconfigure command

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
    merge as _mod_merge,
43
43
    merge_directive,
44
44
    osutils,
 
45
    reconfigure,
45
46
    registry,
46
47
    repository,
47
48
    revision as _mod_revision,
4152
4153
            self.outf.write('%-20s %s\n' % (tag_name, target))
4153
4154
 
4154
4155
 
 
4156
class cmd_reconfigure(Command):
 
4157
    """Reconfigure the type of a bzr directory.
 
4158
 
 
4159
    A target configuration must be specified.
 
4160
 
 
4161
    For checkouts, the bind-to location will be auto-detected if not specified.
 
4162
    The order of preference is
 
4163
    1. For a lightweight checkout, the current bound location.
 
4164
    2. For branches that used to be checkouts, the previously-bound location.
 
4165
    3. The push location.
 
4166
    4. The parent location.
 
4167
    If none of these is available, --bind-to must be specified.
 
4168
    """
 
4169
 
 
4170
    takes_args = ['location?']
 
4171
    takes_options = [RegistryOption.from_kwargs('target_type',
 
4172
                     title='Target type',
 
4173
                     help='The type to reconfigure the directory to.',
 
4174
                     value_switches=True, enum_switch=False,
 
4175
                     branch='Reconfigure to a branch.',
 
4176
                     tree='Reconfigure to a tree.',
 
4177
                     checkout='Reconfigure to a checkout.'),
 
4178
                     Option('bind-to', help='Branch to bind checkout to.',
 
4179
                            type=str),
 
4180
                     Option('force',
 
4181
                        help='Perform reconfiguration even if local changes'
 
4182
                        ' will be lost.')
 
4183
                     ]
 
4184
 
 
4185
    def run(self, location=None, target_type=None, bind_to=None, force=False):
 
4186
        directory = bzrdir.BzrDir.open(location)
 
4187
        if target_type is None:
 
4188
            raise BzrCommandError('No target configuration specified')
 
4189
        elif target_type == 'branch':
 
4190
            reconfiguration = reconfigure.Reconfigure.to_branch(directory)
 
4191
        elif target_type == 'tree':
 
4192
            reconfiguration = reconfigure.Reconfigure.to_tree(directory)
 
4193
        elif target_type == 'checkout':
 
4194
            reconfiguration = reconfigure.Reconfigure.to_checkout(directory,
 
4195
                                                                  bind_to)
 
4196
        reconfiguration.apply(force)
 
4197
 
 
4198
 
4155
4199
def _create_prefix(cur_transport):
4156
4200
    needed = [cur_transport]
4157
4201
    # Recurse upwards until we can create a directory successfully