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

  • Committer: Aaron Bentley
  • Date: 2008-04-09 20:24:11 UTC
  • mto: This revision was merged to the branch mainline in revision 3359.
  • Revision ID: aaron@aaronbentley.com-20080409202411-7sygk52ahrxvq3pn
Update from review comments

Show diffs side-by-side

added added

removed removed

Lines of Context:
179
179
        :param force_new_repo: Do not use a shared repository for the target 
180
180
                               even if one is available.
181
181
        """
 
182
        from remote import RemoteBzrDir
182
183
        transport.ensure_base()
183
184
        result = self.cloning_metadir().initialize_on_transport(transport)
184
185
        repository_policy = None
190
191
            # may need to copy content in
191
192
            repository_policy = result.determine_repository_policy(
192
193
                force_new_repo)
 
194
            make_working_trees = local_repo.make_working_trees()
 
195
            if isinstance(result, RemoteBzrDir):
 
196
                make_working_trees = None
193
197
            result_repo = repository_policy.acquire_repository(
194
 
                local_repo.make_working_trees(),
195
 
                local_repo.is_shared())
 
198
                make_working_trees, local_repo.is_shared())
196
199
            result_repo.fetch(local_repo, revision_id=revision_id)
197
200
        # 1 if there is a branch present
198
201
        #   make sure its content is available in the target repository
2651
2654
        return output
2652
2655
 
2653
2656
 
2654
 
class RepositoryPolicy(object):
2655
 
    """Base class for other policies to inherit from"""
 
2657
class RepositoryAcquisitionPolicy(object):
 
2658
    """Abstract base class for repository acquisition policies.
2656
2659
 
2657
 
    def __init__(self):
2658
 
        pass
 
2660
    A repository acquisition policy decides how a BzrDir acquires a repository
 
2661
    for a branch that is being created.  The most basic policy decision is
 
2662
    whether to create a new repository or use an existing one.
 
2663
    """
2659
2664
 
2660
2665
    def configure_branch(self, branch):
2661
2666
        """Apply any configuration data from this policy to the branch.
2665
2670
        pass
2666
2671
 
2667
2672
    def acquire_repository(self, make_working_trees=None, shared=False):
2668
 
        """Apply any configuration data from this policy to the branch"""
2669
 
        raise NotImplemented(RepositoryPolicy.acquire_repository)
2670
 
 
2671
 
 
2672
 
class CreateRepository(RepositoryPolicy):
 
2673
        """Acquire a repository for this bzrdir.
 
2674
 
 
2675
        Implementations may create a new repository or use a pre-exising
 
2676
        repository.
 
2677
        :param make_working_trees: If creating a repository, set
 
2678
            make_working_trees to this value (if non-None)
 
2679
        :param shared: If creating a repository, make it shared if True
 
2680
        :return: A repository
 
2681
        """
 
2682
        raise NotImplemented(RepositoryAcquisitionPolicy.acquire_repository)
 
2683
 
 
2684
 
 
2685
class CreateRepository(RepositoryAcquisitionPolicy):
2673
2686
    """A policy of creating a new repository"""
2674
2687
 
2675
2688
    def __init__(self, bzrdir):
2676
 
        RepositoryPolicy.__init__(self)
 
2689
        RepositoryAcquisitionPolicy.__init__(self)
2677
2690
        self._bzrdir = bzrdir
2678
2691
 
2679
2692
    def acquire_repository(self, make_working_trees=None, shared=False):
2680
 
        """Implementation of RepositoryPolicy.acquire_repository
 
2693
        """Implementation of RepositoryAcquisitionPolicy.acquire_repository
2681
2694
 
2682
 
        Creates the desired repository
 
2695
        Creates the desired repository in the bzrdir we already have.
2683
2696
        """
2684
2697
        repository = self._bzrdir.create_repository(shared=shared)
2685
2698
        if make_working_trees is not None:
2687
2700
        return repository
2688
2701
 
2689
2702
 
2690
 
class UseExistingRepository(RepositoryPolicy):
 
2703
class UseExistingRepository(RepositoryAcquisitionPolicy):
2691
2704
    """A policy of reusing an existing repository"""
2692
2705
 
2693
2706
    def __init__(self, repository):
2694
 
        RepositoryPolicy.__init__(self)
 
2707
        RepositoryAcquisitionPolicy.__init__(self)
2695
2708
        self._repository = repository
2696
2709
 
2697
2710
    def acquire_repository(self, make_working_trees=None, shared=False):
2698
 
        """Implementation of RepositoryPolicy.acquire_repository
 
2711
        """Implementation of RepositoryAcquisitionPolicy.acquire_repository
2699
2712
 
2700
2713
        Returns an existing repository to use
2701
2714
        """