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

  • Committer: Jelmer Vernooij
  • Date: 2011-03-23 18:30:49 UTC
  • mto: (0.200.1150 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20110323183049-phj89rqlbwphhtvu
Provide custom GitDir.sprout() for bzr 2.4 compatibility.

Show diffs side-by-side

added added

removed removed

Lines of Context:
123
123
    def get_config(self):
124
124
        return GitDirConfig()
125
125
 
 
126
    def sprout(self, url, revision_id=None, force_new_repo=False,
 
127
               recurse='down', possible_transports=None,
 
128
               accelerator_tree=None, hardlink=False, stacked=False,
 
129
               source_branch=None, create_tree_if_local=True):
 
130
        from bzrlib.repository import InterRepository
 
131
        from bzrlib.transport.local import LocalTransport
 
132
        from bzrlib.transport import get_transport
 
133
        target_transport = get_transport(url, possible_transports)
 
134
        target_transport.ensure_base()
 
135
        cloning_format = self.cloning_metadir()
 
136
        # Create/update the result branch
 
137
        result = cloning_format.initialize_on_transport(target_transport)
 
138
        source_branch = self.open_branch()
 
139
        source_repository = self.find_repository()
 
140
        try:
 
141
            result_repo = result.find_repository()
 
142
        except bzr_errors.NoRepositoryPresent:
 
143
            result_repo = result.create_repository()
 
144
            target_is_empty = True
 
145
        else:
 
146
            target_is_empty = None # Unknown
 
147
        if stacked:
 
148
            raise bzr_errors.IncompatibleRepositories(source_repository, result_repo)
 
149
        interrepo = InterRepository.get(source_repository, result_repo)
 
150
 
 
151
        if revision_id is not None:
 
152
            determine_wants = source_repository.determine_wants_revid_and_tags(
 
153
                revision_id)
 
154
        else:
 
155
            from bzrlib.plugins.git.object_store import get_object_store
 
156
            store = get_object_store(result_repo, source_branch.mapping)
 
157
            determine_wants = store.determine_wants_all
 
158
        interrepo.fetch_objects(determine_wants=determine_wants,
 
159
            mapping=source_branch.mapping)
 
160
        result_branch = source_branch.sprout(result,
 
161
            revision_id=revision_id, repository=result_repo)
 
162
        if (create_tree_if_local and isinstance(target_transport, LocalTransport)
 
163
            and (result_repo is None or result_repo.make_working_trees())):
 
164
            wt = result.create_workingtree(accelerator_tree=accelerator_tree,
 
165
                hardlink=hardlink, from_branch=result_branch)
 
166
            wt.lock_write()
 
167
            try:
 
168
                if wt.path2id('') is None:
 
169
                    try:
 
170
                        wt.set_root_id(self.open_workingtree.get_root_id())
 
171
                    except bzr_errors.NoWorkingTree:
 
172
                        pass
 
173
            finally:
 
174
                wt.unlock()
 
175
        return result
 
176
 
126
177
    def clone_on_transport(self, transport, revision_id=None,
127
178
        force_new_repo=False, preserve_stacking=False, stacked_on=None,
128
179
        create_prefix=False, use_existing_dir=True, no_tree=False):
137
188
        source_repo = self.open_repository()
138
189
        source_git_repo = source_repo._git
139
190
        if revision_id is not None:
140
 
            git_sha, mapping = source_repo.lookup_bzr_revision_id(revision_id)
141
 
            if git_sha == ZERO_SHA:
142
 
                wants = []
143
 
            else:
144
 
                wants = [git_sha]
145
 
            determine_wants = lambda heads: wants
 
191
            determine_wants = source_repo.determine_wants_revid_and_tags(revision_id)
146
192
        else:
147
193
            determine_wants = target_git_repo.object_store.determine_wants_all
148
194
        refs = source_git_repo.fetch(target_git_repo, determine_wants)