/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-07-28 02:47:10 UTC
  • mfrom: (7519.1.1 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200728024710-a2ylds219f1lsl62
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/388173

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""An adapter between a Git control dir and a Bazaar ControlDir."""
19
19
 
20
 
from __future__ import absolute_import
 
20
import contextlib
21
21
 
22
22
from .. import (
23
23
    branch as _mod_branch,
24
 
    cleanup,
25
24
    errors as brz_errors,
26
25
    trace,
27
26
    osutils,
28
27
    urlutils,
29
28
    )
30
 
from ..sixish import (
31
 
    PY3,
32
 
    viewitems,
33
 
    )
34
29
from ..transport import (
35
30
    do_catching_redirections,
36
31
    get_transport_from_path,
44
39
    RepositoryAcquisitionPolicy,
45
40
    )
46
41
 
 
42
from .mapping import (
 
43
    decode_git_path,
 
44
    encode_git_path,
 
45
    )
47
46
from .push import (
48
47
    GitPushResult,
49
48
    )
192
191
        else:
193
192
            wt = None
194
193
        if recurse == 'down':
195
 
            with cleanup.ExitStack() as stack:
 
194
            with contextlib.ExitStack() as stack:
196
195
                basis = None
197
196
                if wt is not None:
198
197
                    basis = wt.basis_tree()
218
217
                        target, basis.get_reference_revision(path),
219
218
                        force_new_repo=force_new_repo, recurse=recurse,
220
219
                        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()
221
225
        return result
222
226
 
223
227
    def clone_on_transport(self, transport, revision_id=None,
252
256
            determine_wants = interrepo.determine_wants_all
253
257
        (pack_hint, _, refs) = interrepo.fetch_objects(determine_wants,
254
258
                                                       mapping=default_mapping)
255
 
        for name, val in viewitems(refs):
 
259
        for name, val in refs.items():
256
260
            target_git_repo.refs[name] = val
257
261
        result_dir = LocalGitDir(transport, target_git_repo, format)
258
262
        if revision_id is not None:
542
546
                    target_branch._format, self._format)
543
547
            # TODO(jelmer): Do some consistency checking across branches..
544
548
            self.control_transport.put_bytes(
545
 
                'commondir', target_path.encode('utf-8'))
 
549
                'commondir', encode_git_path(target_path))
546
550
            # TODO(jelmer): Urgh, avoid mucking about with internals.
547
551
            self._git._commontransport = (
548
552
                target_branch.repository._git._commontransport.clone())
582
586
                base_url = self.user_url.rstrip('/')
583
587
            else:
584
588
                base_url = urlutils.local_path_to_url(
585
 
                    commondir.decode(osutils._fs_enc)).rstrip('/.git/') + '/'
586
 
            if not PY3:
587
 
                params = {k: v.encode('utf-8') for (k, v) in viewitems(params)}
 
589
                    decode_git_path(commondir)).rstrip('/.git/') + '/'
588
590
            return urlutils.join_segment_parameters(base_url, params)
589
591
        return None
590
592