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):
95
96
self.transport = transport.clone('.git')
96
97
self._lockfiles = lockfiles
98
self._mode_check_done = None
100
def is_control_filename(self, filename):
101
return filename == '.git' or filename.startswith('.git/')
98
103
def get_branch_transport(self, branch_format):
99
104
if branch_format is None:
105
110
get_repository_transport = get_branch_transport
106
111
get_workingtree_transport = get_branch_transport
108
def open_branch(self, ignored=None):
113
def open_branch(self, ignore_fallbacks=None):
109
114
"""'create' a branch for this dir."""
110
115
repo = self.open_repository()
111
return branch.LocalGitBranch(self, repo, "HEAD", repo._git.head(), self._lockfiles)
116
return branch.LocalGitBranch(self, repo, "HEAD", repo._git.head(),
113
119
def open_repository(self, shared=False):
114
120
"""'open' a repository for this dir."""
115
121
return self._gitrepository_class(self, self._lockfiles)
117
123
def open_workingtree(self, recommend_upgrade=True):
124
loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
118
125
if (not self._git.bare and
119
126
os.path.exists(os.path.join(self._git.controldir(), "index"))):
120
127
return workingtree.GitWorkingTree(self, self.open_repository(),
121
128
self.open_branch())
122
loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
123
raise errors.bzr_errors.NoWorkingTree(loc)
125
130
def create_repository(self, shared=False):
126
131
return self.open_repository()
133
def create_branch(self):
134
return self.open_branch()