~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/bzrdir.py

  • Committer: Joe Julian
  • Date: 2010-01-10 02:25:31 UTC
  • mto: (4634.119.7 2.0)
  • mto: This revision was merged to the branch mainline in revision 4959.
  • Revision ID: joe@julianfamily.org-20100110022531-wqk61rsagz8xsiga
Added MANIFEST.in to allow bdist_rpm to have all the required include files and tools. bdist_rpm will still fail to build correctly on some distributions due to a disttools bug http://bugs.python.org/issue644744

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Server-side bzrdir related request implmentations."""
18
18
 
19
19
 
20
 
from bzrlib import branch, errors, repository
21
 
from bzrlib.bzrdir import BzrDir, BzrDirFormat, BzrDirMetaFormat1
 
20
from bzrlib import branch, errors, repository, urlutils
 
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,
325
330
        return SuccessfulSmartServerResponse(('ok', ))
326
331
 
327
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
 
358
        BzrDirFormat.initialize_on_transport_ex.
 
359
 
 
360
        New in 1.16.  (Replaces BzrDirFormat.initialize_ex verb from 1.15).
 
361
 
 
362
        :return: return SuccessfulSmartServerResponse((repo_path, rich_root,
 
363
            tree_ref, external_lookup, repo_network_name,
 
364
            repo_bzrdir_network_name, bzrdir_format_network_name,
 
365
            NoneTrueFalse(stacking), final_stack, final_stack_pwd,
 
366
            repo_lock_token))
 
367
        """
 
368
        target_transport = self.transport_from_client_path(path)
 
369
        format = network_format_registry.get(bzrdir_network_name)
 
370
        use_existing_dir = self.parse_NoneTrueFalse(use_existing_dir)
 
371
        create_prefix = self.parse_NoneTrueFalse(create_prefix)
 
372
        force_new_repo = self.parse_NoneTrueFalse(force_new_repo)
 
373
        stacked_on = self.parse_NoneString(stacked_on)
 
374
        stack_on_pwd = self.parse_NoneString(stack_on_pwd)
 
375
        make_working_trees = self.parse_NoneTrueFalse(make_working_trees)
 
376
        shared_repo = self.parse_NoneTrueFalse(shared_repo)
 
377
        if stack_on_pwd == '.':
 
378
            stack_on_pwd = target_transport.base
 
379
        repo_format_name = self.parse_NoneString(repo_format_name)
 
380
        repo, bzrdir, stacking, repository_policy = \
 
381
            format.initialize_on_transport_ex(target_transport,
 
382
            use_existing_dir=use_existing_dir, create_prefix=create_prefix,
 
383
            force_new_repo=force_new_repo, stacked_on=stacked_on,
 
384
            stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
 
385
            make_working_trees=make_working_trees, shared_repo=shared_repo)
 
386
        if repo is None:
 
387
            repo_path = ''
 
388
            repo_name = ''
 
389
            rich_root = tree_ref = external_lookup = ''
 
390
            repo_bzrdir_name = ''
 
391
            final_stack = None
 
392
            final_stack_pwd = None
 
393
            repo_lock_token = ''
 
394
        else:
 
395
            repo_path = self._repo_relpath(bzrdir.root_transport, repo)
 
396
            if repo_path == '':
 
397
                repo_path = '.'
 
398
            rich_root, tree_ref, external_lookup = self._format_to_capabilities(
 
399
                repo._format)
 
400
            repo_name = repo._format.network_name()
 
401
            repo_bzrdir_name = repo.bzrdir._format.network_name()
 
402
            final_stack = repository_policy._stack_on
 
403
            final_stack_pwd = repository_policy._stack_on_pwd
 
404
            # It is returned locked, but we need to do the lock to get the lock
 
405
            # token.
 
406
            repo.unlock()
 
407
            repo_lock_token = repo.lock_write() or ''
 
408
            if repo_lock_token:
 
409
                repo.leave_lock_in_place()
 
410
            repo.unlock()
 
411
        final_stack = final_stack or ''
 
412
        final_stack_pwd = final_stack_pwd or ''
 
413
 
 
414
        # We want this to be relative to the bzrdir.
 
415
        if final_stack_pwd:
 
416
            final_stack_pwd = urlutils.relative_url(
 
417
                target_transport.base, final_stack_pwd)
 
418
 
 
419
        # Can't meaningfully return a root path.
 
420
        if final_stack.startswith('/'):
 
421
            client_path = self._root_client_path + final_stack[1:]
 
422
            final_stack = urlutils.relative_url(
 
423
                self._root_client_path, client_path)
 
424
            final_stack_pwd = '.'
 
425
 
 
426
        return SuccessfulSmartServerResponse((repo_path, rich_root, tree_ref,
 
427
            external_lookup, repo_name, repo_bzrdir_name,
 
428
            bzrdir._format.network_name(),
 
429
            self._serialize_NoneTrueFalse(stacking), final_stack,
 
430
            final_stack_pwd, repo_lock_token))
 
431
 
 
432
 
328
433
class SmartServerRequestOpenBranch(SmartServerRequestBzrDir):
329
434
 
330
435
    def do_bzrdir_request(self):