61
58
class GitDir(bzrdir.BzrDir):
62
59
"""An adapter to the '.git' dir used by git."""
64
_gitrepository_class = git_repository.GitRepository
66
61
def __init__(self, transport, lockfiles, format):
67
62
self._format = format
68
63
self.root_transport = transport
85
80
def open_branch(self, ignored=None):
86
"""'create' a branch for this dir."""
87
repo = self.open_repository()
88
if repo._git.heads == []:
91
head = repo._git.heads[0].commit.id
92
return git_branch.GitBranch(self, repo, head,
93
self.root_transport.base, self._lockfiles)
81
"""'crate' a branch for this dir."""
82
return git_branch.GitBranch(self, self._lockfiles)
95
84
def open_repository(self, shared=False):
96
85
"""'open' a repository for this dir."""
97
return self._gitrepository_class(self, self._lockfiles)
86
return git_repository.GitRepository(self, self._lockfiles)
99
def open_workingtree(self, recommend_upgrade=True):
88
def open_workingtree(self):
100
89
loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
101
90
raise errors.bzr_errors.NoWorkingTree(loc)
103
def cloning_metadir(self):
104
return bzrdir.BzrDirFormat.get_default_format()
107
93
class GitBzrDirFormat(bzrdir.BzrDirFormat):
108
94
"""The .git directory control format."""
110
_gitdir_class = GitDir
113
97
def _known_formats(self):
114
98
return set([GitBzrDirFormat()])
122
106
url = transport.base
123
107
if url.startswith('readonly+'):
124
108
url = url[len('readonly+'):]
109
path = urlutils.local_path_from_url(url)
125
110
if not transport.has('.git'):
126
111
raise errors.bzr_errors.NotBranchError(path=transport.base)
127
112
lockfiles = GitLockableFiles(GitLock())
128
return self._gitdir_class(transport, lockfiles, self)
113
return GitDir(transport, lockfiles, self)
131
116
def probe_transport(klass, transport):
143
128
raise errors.bzr_errors.NotBranchError(path=transport.base)
144
129
raise errors.bzr_errors.NotBranchError(path=transport.base)
146
def get_format_description(self):
147
return "Local Git Repository"
150
132
bzrdir.BzrDirFormat.register_control_format(GitBzrDirFormat)