/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 bzrlib/smart/bzrdir.py

  • Committer: Robert J. Tanner
  • Date: 2009-04-29 05:53:21 UTC
  • mfrom: (4311 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4312.
  • Revision ID: tanner@real-time.com-20090429055321-v2s5l1mgki9f6cgn
[merge] 1.14 back to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
 
20
20
from bzrlib import branch, errors, repository
21
 
from bzrlib.bzrdir import BzrDir, BzrDirFormat, BzrDirMetaFormat1
 
21
from bzrlib.bzrdir import (
 
22
    BzrDir,
 
23
    BzrDirFormat,
 
24
    BzrDirMetaFormat1,
 
25
    network_format_registry,
 
26
    )
22
27
from bzrlib.smart.request import (
23
28
    FailedSmartServerResponse,
24
29
    SmartServerRequest,
297
302
            return FailedSmartServerResponse(('norepository', ))
298
303
 
299
304
 
 
305
class SmartServerBzrDirRequestConfigFile(SmartServerRequestBzrDir):
 
306
 
 
307
    def do_bzrdir_request(self):
 
308
        """Get the configuration bytes for a config file in bzrdir.
 
309
        
 
310
        The body is not utf8 decoded - it is the literal bytestream from disk.
 
311
        """
 
312
        config = self._bzrdir._get_config()
 
313
        if config is None:
 
314
            content = ''
 
315
        else:
 
316
            content = config._get_config_file().read()
 
317
        return SuccessfulSmartServerResponse((), content)
 
318
 
 
319
 
300
320
class SmartServerRequestInitializeBzrDir(SmartServerRequest):
301
321
 
302
322
    def do(self, path):
310
330
        return SuccessfulSmartServerResponse(('ok', ))
311
331
 
312
332
 
 
333
class SmartServerRequestBzrDirInitializeEx(SmartServerRequestBzrDir):
 
334
 
 
335
    def parse_NoneTrueFalse(self, arg):
 
336
        if not arg:
 
337
            return None
 
338
        if arg == 'False':
 
339
            return False
 
340
        if arg == 'True':
 
341
            return True
 
342
        raise AssertionError("invalid arg %r" % arg)
 
343
 
 
344
    def parse_NoneString(self, arg):
 
345
        return arg or None
 
346
 
 
347
    def _serialize_NoneTrueFalse(self, arg):
 
348
        if arg is False:
 
349
            return 'False'
 
350
        if not arg:
 
351
            return ''
 
352
        return 'True'
 
353
 
 
354
    def do(self, bzrdir_network_name, path, use_existing_dir, create_prefix,
 
355
        force_new_repo, stacked_on, stack_on_pwd, repo_format_name,
 
356
        make_working_trees, shared_repo):
 
357
        """Initialize a bzrdir at path as per BzrDirFormat.initialize_ex
 
358
 
 
359
        :return: SmartServerResponse()
 
360
        """
 
361
        target_transport = self.transport_from_client_path(path)
 
362
        format = network_format_registry.get(bzrdir_network_name)
 
363
        use_existing_dir = self.parse_NoneTrueFalse(use_existing_dir)
 
364
        create_prefix = self.parse_NoneTrueFalse(create_prefix)
 
365
        force_new_repo = self.parse_NoneTrueFalse(force_new_repo)
 
366
        stacked_on = self.parse_NoneString(stacked_on)
 
367
        stack_on_pwd = self.parse_NoneString(stack_on_pwd)
 
368
        make_working_trees = self.parse_NoneTrueFalse(make_working_trees)
 
369
        shared_repo = self.parse_NoneTrueFalse(shared_repo)
 
370
        if stack_on_pwd == '.':
 
371
            stack_on_pwd = target_transport.base
 
372
        repo_format_name = self.parse_NoneString(repo_format_name)
 
373
        repo, bzrdir, stacking, repository_policy = \
 
374
            format.initialize_on_transport_ex(target_transport,
 
375
            use_existing_dir=use_existing_dir, create_prefix=create_prefix,
 
376
            force_new_repo=force_new_repo, stacked_on=stacked_on,
 
377
            stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
 
378
            make_working_trees=make_working_trees, shared_repo=shared_repo)
 
379
        if repo is None:
 
380
            repo_path = ''
 
381
            repo_name = ''
 
382
            rich_root = tree_ref = external_lookup = ''
 
383
            repo_bzrdir_name = ''
 
384
            final_stack = None
 
385
            final_stack_pwd = None
 
386
        else:
 
387
            repo_path = self._repo_relpath(bzrdir.root_transport, repo)
 
388
            if repo_path == '':
 
389
                repo_path = '.'
 
390
            rich_root, tree_ref, external_lookup = self._format_to_capabilities(
 
391
                repo._format)
 
392
            repo_name = repo._format.network_name()
 
393
            repo_bzrdir_name = repo.bzrdir._format.network_name()
 
394
            final_stack = repository_policy._stack_on
 
395
            final_stack_pwd = repository_policy._stack_on_pwd
 
396
        final_stack = final_stack or ''
 
397
        final_stack_pwd = final_stack_pwd or ''
 
398
        return SuccessfulSmartServerResponse((repo_path, rich_root, tree_ref,
 
399
            external_lookup, repo_name, repo_bzrdir_name,
 
400
            bzrdir._format.network_name(),
 
401
            self._serialize_NoneTrueFalse(stacking), final_stack,
 
402
            final_stack_pwd))
 
403
 
 
404
 
313
405
class SmartServerRequestOpenBranch(SmartServerRequestBzrDir):
314
406
 
315
407
    def do_bzrdir_request(self):