/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-08-10 15:00:17 UTC
  • mfrom: (7490.40.99 work)
  • mto: This revision was merged to the branch mainline in revision 7521.
  • Revision ID: jelmer@jelmer.uk-20200810150017-vs7xnrd1vat4iktg
Merge lp:brz/3.1.

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,
196
191
        else:
197
192
            wt = None
198
193
        if recurse == 'down':
199
 
            with cleanup.ExitStack() as stack:
 
194
            with contextlib.ExitStack() as stack:
200
195
                basis = None
201
196
                if wt is not None:
202
197
                    basis = wt.basis_tree()
222
217
                        target, basis.get_reference_revision(path),
223
218
                        force_new_repo=force_new_repo, recurse=recurse,
224
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()
225
225
        return result
226
226
 
227
227
    def clone_on_transport(self, transport, revision_id=None,
256
256
            determine_wants = interrepo.determine_wants_all
257
257
        (pack_hint, _, refs) = interrepo.fetch_objects(determine_wants,
258
258
                                                       mapping=default_mapping)
259
 
        for name, val in viewitems(refs):
 
259
        for name, val in refs.items():
260
260
            target_git_repo.refs[name] = val
261
261
        result_dir = LocalGitDir(transport, target_git_repo, format)
262
262
        if revision_id is not None:
587
587
            else:
588
588
                base_url = urlutils.local_path_to_url(
589
589
                    decode_git_path(commondir)).rstrip('/.git/') + '/'
590
 
            if not PY3:
591
 
                params = {k: v.encode('utf-8') for (k, v) in viewitems(params)}
592
590
            return urlutils.join_segment_parameters(base_url, params)
593
591
        return None
594
592