/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: Robert Collins
  • Date: 2009-03-19 04:08:21 UTC
  • mto: This revision was merged to the branch mainline in revision 4174.
  • Revision ID: robertc@robertcollins.net-20090319040821-c1id0avkcpjvr0hw
Fix bzr failing to stack when a server requests it and the branch it is pushing from cannot stack but the branch it should stack on can.

Show diffs side-by-side

added added

removed removed

Lines of Context:
192
192
        transport.ensure_base()
193
193
        require_stacking = (stacked_on is not None)
194
194
        format = self.cloning_metadir(require_stacking)
 
195
        # Bug: We create a metadir without knowing if it can support stacking,
 
196
        # we should look up the policy needs first.
195
197
        result = format.initialize_on_transport(transport)
196
198
        repository_policy = None
197
199
        try:
387
389
                                    stack_on_pwd=None, require_stacking=False):
388
390
        """Return an object representing a policy to use.
389
391
 
390
 
        This controls whether a new repository is created, or a shared
391
 
        repository used instead.
 
392
        This controls whether a new repository is created, and the format of
 
393
        that repository, or some existing shared repository used instead.
392
394
 
393
395
        If stack_on is supplied, will not seek a containing shared repo.
394
396
 
408
410
                if stack_on is not None:
409
411
                    stack_on_pwd = found_bzrdir.root_transport.base
410
412
                    stop = True
411
 
                    note('Using default stacking branch %s at %s', stack_on,
412
 
                         stack_on_pwd)
413
413
            # does it have a repository ?
414
414
            try:
415
415
                repository = found_bzrdir.open_repository()
418
418
            else:
419
419
                if ((found_bzrdir.root_transport.base !=
420
420
                     self.root_transport.base) and not repository.is_shared()):
 
421
                    # Don't look higher, can't use a higher shared repo.
421
422
                    repository = None
 
423
                    stop = True
422
424
                else:
423
425
                    stop = True
424
426
            if not stop:
2833
2835
        # Always return a RemoteRepositoryFormat object, but if a specific bzr
2834
2836
        # repository format has been asked for, tell the RemoteRepositoryFormat
2835
2837
        # that it should use that for init() etc.
2836
 
        result =  remote.RemoteRepositoryFormat()
 
2838
        result = remote.RemoteRepositoryFormat()
2837
2839
        custom_format = getattr(self, '_repository_format', None)
2838
2840
        if custom_format:
2839
 
            # We will use the custom format to create repositories over the
2840
 
            # wire; expose its details like rich_root_data for code to query
2841
2841
            if isinstance(custom_format, remote.RemoteRepositoryFormat):
2842
 
                result._custom_format = custom_format._custom_format
 
2842
                return custom_format
2843
2843
            else:
 
2844
                # We will use the custom format to create repositories over the
 
2845
                # wire; expose its details like rich_root_data for code to
 
2846
                # query
2844
2847
                result._custom_format = custom_format
2845
2848
        return result
2846
2849
 
3148
3151
 
3149
3152
        Creates the desired repository in the bzrdir we already have.
3150
3153
        """
 
3154
        stack_on = self._get_full_stack_on()
 
3155
        if stack_on:
 
3156
            # Stacking is desired. requested by the target, but does the place it
 
3157
            # points at support stacking? If it doesn't then we should
 
3158
            # not implicitly upgrade. We check this here.
 
3159
            format = self._bzrdir._format
 
3160
            if not (format.repository_format.supports_external_lookups
 
3161
                and format.get_branch_format().supports_stacking()):
 
3162
                # May need to upgrade - but only do if the target also
 
3163
                # supports stacking. Note that this currently wastes
 
3164
                # network round trips to check - but we only do this
 
3165
                # when the source can't stack so it will fade away
 
3166
                # as people do upgrade.
 
3167
                try:
 
3168
                    target_dir = BzrDir.open(stack_on,
 
3169
                        possible_transports=[self._bzrdir.root_transport])
 
3170
                except errors.NotBranchError:
 
3171
                    # Nothing there, don't change formats
 
3172
                    pass
 
3173
                else:
 
3174
                    try:
 
3175
                        target_branch = target_dir.open_branch()
 
3176
                    except errors.NotBranchError:
 
3177
                        # No branch, don't change formats
 
3178
                        pass
 
3179
                    else:
 
3180
                        branch_format = target_branch._format
 
3181
                        repo_format = target_branch.repository._format
 
3182
                        if not (branch_format.supports_stacking()
 
3183
                            and repo_format.supports_external_lookups):
 
3184
                            # Doesn't stack itself, don't force an upgrade
 
3185
                            pass
 
3186
                        else:
 
3187
                            # Does support stacking, use its format.
 
3188
                            format.repository_format = repo_format
 
3189
                            format.set_branch_format(branch_format)
 
3190
                            note('Source format does not support stacking, '
 
3191
                                'using format: \'%s\'\n  %s\n',
 
3192
                                branch_format.get_format_description(),
 
3193
                                repo_format.get_format_description())
 
3194
            if not self._require_stacking:
 
3195
                # We have picked up automatic stacking somewhere.
 
3196
                note('Using default stacking branch %s at %s', self._stack_on,
 
3197
                    self._stack_on_pwd)
3151
3198
        repository = self._bzrdir.create_repository(shared=shared)
3152
3199
        self._add_fallback(repository,
3153
3200
                           possible_transports=[self._bzrdir.transport])