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

  • Committer: Jelmer Vernooij
  • Date: 2020-02-21 03:58:42 UTC
  • mfrom: (7490.3.4 work)
  • mto: This revision was merged to the branch mainline in revision 7495.
  • Revision ID: jelmer@jelmer.uk-20200221035842-j97r6b74q8cgxb21
merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
    RepositoryAcquisitionPolicy,
40
40
    )
41
41
 
42
 
from .mapping import (
43
 
    decode_git_path,
44
 
    encode_git_path,
45
 
    )
46
42
from .push import (
47
43
    GitPushResult,
48
44
    )
217
213
                        target, basis.get_reference_revision(path),
218
214
                        force_new_repo=force_new_repo, recurse=recurse,
219
215
                        stacked=stacked)
220
 
        if getattr(result_repo, '_git', None):
221
 
            # Don't leak resources:
222
 
            # TODO(jelmer): This shouldn't be git-specific, and possibly
223
 
            # just use read locks.
224
 
            result_repo._git.object_store.close()
225
216
        return result
226
217
 
227
218
    def clone_on_transport(self, transport, revision_id=None,
232
223
        """See ControlDir.clone_on_transport."""
233
224
        from ..repository import InterRepository
234
225
        from .mapping import default_mapping
235
 
        from ..transport.local import LocalTransport
236
226
        if stacked_on is not None:
237
227
            raise _mod_branch.UnstackableBranchFormat(
238
228
                self._format, self.user_url)
258
248
                                                       mapping=default_mapping)
259
249
        for name, val in refs.items():
260
250
            target_git_repo.refs[name] = val
261
 
        result_dir = LocalGitDir(transport, target_git_repo, format)
 
251
        result_dir = self.__class__(transport, target_git_repo, format)
262
252
        if revision_id is not None:
263
253
            result_dir.open_branch().set_last_revision(revision_id)
264
 
        if not no_tree and isinstance(result_dir.root_transport, LocalTransport):
 
254
        try:
 
255
            # Cheaper to check if the target is not local, than to try making
 
256
            # the tree and fail.
 
257
            result_dir.root_transport.local_abspath('.')
265
258
            if result_dir.open_repository().make_working_trees():
266
 
                try:
267
 
                    local_wt = self.open_workingtree()
268
 
                except brz_errors.NoWorkingTree:
269
 
                    pass
270
 
                except brz_errors.NotLocalUrl:
271
 
                    result_dir.create_workingtree(revision_id=revision_id)
272
 
                else:
273
 
                    local_wt.clone(result_dir, revision_id=revision_id)
 
259
                self.open_workingtree().clone(
 
260
                    result_dir, revision_id=revision_id)
 
261
        except (brz_errors.NoWorkingTree, brz_errors.NotLocalUrl):
 
262
            pass
274
263
 
275
264
        return result_dir
276
265
 
305
294
        """
306
295
        return UseExistingRepository(self.find_repository())
307
296
 
308
 
    def branch_names(self):
309
 
        from .refs import ref_to_branch_name
310
 
        ret = []
311
 
        for ref in self.get_refs_container().keys():
312
 
            try:
313
 
                branch_name = ref_to_branch_name(ref)
314
 
            except UnicodeDecodeError:
315
 
                trace.warning("Ignoring branch %r with unicode error ref", ref)
316
 
                continue
317
 
            except ValueError:
318
 
                continue
319
 
            ret.append(branch_name)
320
 
        return ret
321
 
 
322
297
    def get_branches(self):
323
298
        from .refs import ref_to_branch_name
324
299
        ret = {}
546
521
                    target_branch._format, self._format)
547
522
            # TODO(jelmer): Do some consistency checking across branches..
548
523
            self.control_transport.put_bytes(
549
 
                'commondir', encode_git_path(target_path))
 
524
                'commondir', target_path.encode('utf-8'))
550
525
            # TODO(jelmer): Urgh, avoid mucking about with internals.
551
526
            self._git._commontransport = (
552
527
                target_branch.repository._git._commontransport.clone())
586
561
                base_url = self.user_url.rstrip('/')
587
562
            else:
588
563
                base_url = urlutils.local_path_to_url(
589
 
                    decode_git_path(commondir)).rstrip('/.git/') + '/'
 
564
                    commondir.decode(osutils._fs_enc)).rstrip('/.git/') + '/'
590
565
            return urlutils.join_segment_parameters(base_url, params)
591
566
        return None
592
567