/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

Special-case NULL_REVISION when looking for Git shas.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2007 Canonical Ltd
 
2
# Copyright (C) 2010 Jelmer Vernooij
2
3
#
3
4
# This program is free software; you can redistribute it and/or modify
4
5
# it under the terms of the GNU General Public License as published by
28
29
 
29
30
from bzrlib.plugins.git import (
30
31
    LocalGitBzrDirFormat,
31
 
    get_rich_root_format,
32
32
    )
33
33
 
34
34
 
76
76
        return True
77
77
 
78
78
    def cloning_metadir(self, stacked=False):
79
 
        return get_rich_root_format(stacked)
 
79
        return bzrdir.format_registry.make_bzrdir("default")
80
80
 
81
81
    def _branch_name_to_ref(self, name):
82
82
        raise NotImplementedError(self._branch_name_to_ref)
113
113
        self._mode_check_done = None
114
114
 
115
115
    def _branch_name_to_ref(self, name):
116
 
        from bzrlib.plugins.git.branch import branch_name_to_ref
117
 
        if name in (None, "HEAD"):
 
116
        from bzrlib.plugins.git.refs import branch_name_to_ref
 
117
        ref = branch_name_to_ref(name, None)
 
118
        if ref == "HEAD":
118
119
            from dulwich.repo import SYMREF
119
 
            refcontents = self._git.refs.read_ref("HEAD")
 
120
            refcontents = self._git.refs.read_ref(ref)
120
121
            if refcontents.startswith(SYMREF):
121
 
                name = refcontents[len(SYMREF):]
122
 
            else:
123
 
                name = "HEAD"
124
 
        return branch_name_to_ref(name, "HEAD")
 
122
                ref = refcontents[len(SYMREF):]
 
123
        return ref
125
124
 
126
125
    def is_control_filename(self, filename):
127
126
        return filename == '.git' or filename.startswith('.git/')
128
127
 
129
 
    def get_branch_transport(self, branch_format):
 
128
    def get_branch_transport(self, branch_format, name=None):
130
129
        if branch_format is None:
131
130
            return self.transport
132
131
        if isinstance(branch_format, LocalGitBzrDirFormat):
133
132
            return self.transport
134
133
        raise bzr_errors.IncompatibleFormat(branch_format, self._format)
135
134
 
136
 
    get_repository_transport = get_branch_transport
137
 
    get_workingtree_transport = get_branch_transport
 
135
    def get_repository_transport(self, format):
 
136
        if format is None:
 
137
            return self.transport
 
138
        if isinstance(format, LocalGitBzrDirFormat):
 
139
            return self.transport
 
140
        raise bzr_errors.IncompatibleFormat(format, self._format)
 
141
 
 
142
    def get_workingtree_transport(self, format):
 
143
        if format is None:
 
144
            return self.transport
 
145
        if isinstance(format, LocalGitBzrDirFormat):
 
146
            return self.transport
 
147
        raise bzr_errors.IncompatibleFormat(format, self._format)
138
148
 
139
149
    def _open_branch(self, name=None, ignore_fallbacks=None, unsupported=False):
140
150
        """'create' a branch for this dir."""
167
177
                pass
168
178
            else:
169
179
                from bzrlib.plugins.git.workingtree import GitWorkingTree
170
 
                return GitWorkingTree(self, repo, self.open_branch(), index)
 
180
                try:
 
181
                    branch = self.open_branch()
 
182
                except bzr_errors.NotBranchError:
 
183
                    pass
 
184
                else:
 
185
                    return GitWorkingTree(self, repo, branch, index)
171
186
        loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
172
187
        raise bzr_errors.NoWorkingTree(loc)
173
188
 
176
191
 
177
192
    def create_branch(self, name=None):
178
193
        refname = self._branch_name_to_ref(name)
179
 
        self._git.refs[refname] = "0" * 40
 
194
        from dulwich.protocol import ZERO_SHA
 
195
        self._git.refs[refname or "HEAD"] = ZERO_SHA
180
196
        return self.open_branch(name)
181
197
 
182
198
    def backup_bzrdir(self):