/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

Reduce number of round trips when fetching from Git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
        return self._gitrepository_class(self, self._lockfiles)
121
121
 
122
122
    def open_workingtree(self, recommend_upgrade=True):
123
 
        if not self._git.bare and self._git.has_index():
 
123
        if (not self._git.bare and 
 
124
            os.path.exists(os.path.join(self._git.controldir(), "index"))):
124
125
            return workingtree.GitWorkingTree(self, self.open_repository(), 
125
126
                                                  self.open_branch())
126
127
        loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
131
132
 
132
133
    def create_branch(self):
133
134
        return self.open_branch()
134
 
 
135
 
    def backup_bzrdir(self):
136
 
        if self._git.bare:
137
 
            self.root_transport.copy_tree(".git", ".git.backup")
138
 
            return (self.root_transport.abspath(".git"),
139
 
                    self.root_transport.abspath(".git.backup"))
140
 
        else:
141
 
            raise errors.bzr_errors.BzrError("Unable to backup bare repositories")
142
 
 
143
 
    def create_workingtree(self, revision_id=None, from_branch=None,
144
 
        accelerator_tree=None, hardlink=False):
145
 
        if self._git.bare:
146
 
            raise errors.bzr_errors.BzrError("Can't create working tree in a bare repo")
147
 
        from dulwich.index import write_index
148
 
        write_index(self.root_transport.abspath(".git/index"), [])
149
 
        return self.open_workingtree()