/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

Share sha map cache connections inside threads.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
"""An adapter between a Git control dir and a Bazaar BzrDir"""
 
17
"""An adapter between a Git control dir and a Bazaar BzrDir."""
18
18
 
19
19
import os
20
20
 
21
21
import bzrlib
22
 
from bzrlib.lazy_import import lazy_import
23
22
from bzrlib import (
24
23
    bzrdir,
25
24
    lockable_files,
26
25
    urlutils,
27
26
    )
28
27
 
29
 
lazy_import(globals(), """
30
 
from bzrlib.lockable_files import TransportLock
 
28
LockWarner = getattr(lockable_files, "_LockWarner", None)
 
29
 
31
30
from bzrlib.plugins.git import (
 
31
    LocalGitBzrDirFormat,
 
32
    branch,
32
33
    errors,
33
 
    branch,
 
34
    get_rich_root_format,
34
35
    repository,
35
36
    workingtree,
36
37
    )
37
 
""")
38
 
 
39
 
from bzrlib.plugins.git import LocalGitBzrDirFormat
40
 
 
41
38
 
42
39
 
43
40
class GitLock(object):
66
63
        self._lock = lock
67
64
        self._transaction = None
68
65
        self._lock_mode = None
69
 
        self._lock_count = 0
70
66
        self._transport = transport
 
67
        if LockWarner is None:
 
68
            # Bzr 1.13
 
69
            self._lock_count = 0
 
70
        else:
 
71
            self._lock_warner = LockWarner(repr(self))
71
72
 
72
73
 
73
74
class GitDir(bzrdir.BzrDir):
77
78
        return True
78
79
 
79
80
    def cloning_metadir(self, stacked=False):
80
 
        return bzrlib.bzrdir.format_registry.make_bzrdir("1.9-rich-root")
 
81
        return get_rich_root_format(stacked)
81
82
 
82
83
 
83
84
class LocalGitDir(GitDir):
105
106
    get_repository_transport = get_branch_transport
106
107
    get_workingtree_transport = get_branch_transport
107
108
 
108
 
    def open_branch(self, ignored=None):
 
109
    def open_branch(self, ignore_fallbacks=None):
109
110
        """'create' a branch for this dir."""
110
111
        repo = self.open_repository()
111
 
        return branch.LocalGitBranch(self, repo, "HEAD", repo._git.head(), self._lockfiles)
 
112
        return branch.LocalGitBranch(self, repo, "HEAD", repo._git.head(),
 
113
            self._lockfiles)
112
114
 
113
115
    def open_repository(self, shared=False):
114
116
        """'open' a repository for this dir."""
115
117
        return self._gitrepository_class(self, self._lockfiles)
116
118
 
117
119
    def open_workingtree(self, recommend_upgrade=True):
 
120
        loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
 
121
        raise errors.bzr_errors.NoWorkingTree(loc)
118
122
        if (not self._git.bare and 
119
123
            os.path.exists(os.path.join(self._git.controldir(), "index"))):
120
124
            return workingtree.GitWorkingTree(self, self.open_repository(), 
121
125
                                                  self.open_branch())
122
 
        loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
123
 
        raise errors.bzr_errors.NoWorkingTree(loc)
124
126
 
125
127
    def create_repository(self, shared=False):
126
128
        return self.open_repository()
 
129
 
 
130
    def create_branch(self):
 
131
        return self.open_branch()