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
17
"""An adapter between a Git control dir and a Bazaar BzrDir"""
17
"""An adapter between a Git control dir and a Bazaar BzrDir."""
22
from bzrlib.lazy_import import lazy_import
23
22
from bzrlib import (
29
lazy_import(globals(), """
30
from bzrlib.lockable_files import TransportLock
28
LockWarner = getattr(lockable_files, "_LockWarner", None)
31
30
from bzrlib.plugins.git import (
39
from bzrlib.plugins.git import LocalGitBzrDirFormat
43
40
class GitLock(object):
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)
83
84
class LocalGitDir(GitDir):
105
106
get_repository_transport = get_branch_transport
106
107
get_workingtree_transport = get_branch_transport
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
115
def open_repository(self, shared=False):
114
116
"""'open' a repository for this dir."""
115
117
return self._gitrepository_class(self, self._lockfiles)
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)
125
127
def create_repository(self, shared=False):
126
128
return self.open_repository()
130
def create_branch(self):
131
return self.open_branch()