/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

  • Committer: Jelmer Vernooij
  • Date: 2010-05-05 09:58:55 UTC
  • mto: (0.200.912 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20100505095855-i0165hooflvk9chy
Ignore control files in inventories.

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
79
80
        return get_rich_root_format(stacked)
80
81
 
81
82
    def _branch_name_to_ref(self, name):
82
 
        from bzrlib.plugins.git.branch import branch_name_to_ref
83
 
        return branch_name_to_ref(name)
 
83
        raise NotImplementedError(self._branch_name_to_ref)
 
84
 
 
85
    if bzrlib_version >= (2, 2):
 
86
        def open_branch(self, name=None, ignore_fallbacks=None,
 
87
            unsupported=False):
 
88
            return self._open_branch(name=name,
 
89
                ignore_fallbacks=ignore_fallbacks, unsupported=unsupported)
 
90
    else:
 
91
        def open_branch(self, ignore_fallbacks=None, unsupported=False):
 
92
            return self._open_branch(name=None,
 
93
                ignore_fallbacks=ignore_fallbacks, unsupported=unsupported)
84
94
 
85
95
 
86
96
class LocalGitDir(GitDir):
103
113
        self._lockfiles = lockfiles
104
114
        self._mode_check_done = None
105
115
 
 
116
    def _branch_name_to_ref(self, name):
 
117
        from bzrlib.plugins.git.refs import branch_name_to_ref
 
118
        if name in (None, "HEAD"):
 
119
            from dulwich.repo import SYMREF
 
120
            refcontents = self._git.refs.read_ref("HEAD")
 
121
            if refcontents.startswith(SYMREF):
 
122
                name = refcontents[len(SYMREF):]
 
123
            else:
 
124
                name = "HEAD"
 
125
        return branch_name_to_ref(name, "HEAD")
 
126
 
106
127
    def is_control_filename(self, filename):
107
128
        return filename == '.git' or filename.startswith('.git/')
108
129
 
109
 
    def get_branch_transport(self, branch_format):
 
130
    def get_branch_transport(self, branch_format, name):
110
131
        if branch_format is None:
111
132
            return self.transport
112
133
        if isinstance(branch_format, LocalGitBzrDirFormat):
113
134
            return self.transport
114
135
        raise bzr_errors.IncompatibleFormat(branch_format, self._format)
115
136
 
116
 
    get_repository_transport = get_branch_transport
117
 
    get_workingtree_transport = get_branch_transport
 
137
    def get_repository_transport(self, format):
 
138
        if format is None:
 
139
            return self.transport
 
140
        if isinstance(format, LocalGitBzrDirFormat):
 
141
            return self.transport
 
142
        raise bzr_errors.IncompatibleFormat(format, self._format)
 
143
 
 
144
    def get_workingtree_transport(self, format):
 
145
        if format is None:
 
146
            return self.transport
 
147
        if isinstance(format, LocalGitBzrDirFormat):
 
148
            return self.transport
 
149
        raise bzr_errors.IncompatibleFormat(format, self._format)
118
150
 
119
151
    def _open_branch(self, name=None, ignore_fallbacks=None, unsupported=False):
120
152
        """'create' a branch for this dir."""
123
155
        return LocalGitBranch(self, repo, self._branch_name_to_ref(name),
124
156
            self._lockfiles)
125
157
 
126
 
    if bzrlib_version >= (2, 2):
127
 
        open_branch = _open_branch
128
 
    else:
129
 
        def open_branch(self, ignore_fallbacks=None, unsupported=False):
130
 
            return self._open_branch(name=None,
131
 
                ignore_fallbacks=ignore_fallbacks, unsupported=unsupported)
132
 
 
133
158
    def destroy_branch(self, name=None):
134
159
        del self._git.refs[self._branch_name_to_ref(name)]
135
160
 
136
161
    def list_branches(self):
137
162
        ret = []
138
163
        for name in self._git.get_refs():
139
 
            if name.startswith("refs/heads/") or name == "HEAD":
 
164
            if name.startswith("refs/heads/"):
140
165
                ret.append(self.open_branch(name=name))
141
166
        return ret
142
167
 
147
172
    def open_workingtree(self, recommend_upgrade=True):
148
173
        if not self._git.bare:
149
174
            from dulwich.errors import NoIndexPresent
 
175
            repo = self.open_repository()
150
176
            try:
151
 
                from bzrlib.plugins.git.workingtree import GitWorkingTree
152
 
                return GitWorkingTree(self, self.open_repository(),
153
 
                                                      self.open_branch())
 
177
                index = repo._git.open_index()
154
178
            except NoIndexPresent:
155
179
                pass
 
180
            else:
 
181
                from bzrlib.plugins.git.workingtree import GitWorkingTree
 
182
                return GitWorkingTree(self, repo, self.open_branch(), index)
156
183
        loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
157
184
        raise bzr_errors.NoWorkingTree(loc)
158
185
 
161
188
 
162
189
    def create_branch(self, name=None):
163
190
        refname = self._branch_name_to_ref(name)
164
 
        self._git.refs[refname] = "0" * 40
 
191
        from dulwich.protocol import ZERO_SHA
 
192
        self._git.refs[refname] = ZERO_SHA
165
193
        return self.open_branch(name)
166
194
 
167
195
    def backup_bzrdir(self):