/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 git_dir.py

Flat is better than nested, remove the gitlib hierarchy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    def unlock(self):
45
45
        pass
46
46
 
47
 
    def peek(self):
48
 
        pass
49
 
 
50
47
 
51
48
class GitLockableFiles(lockable_files.LockableFiles):
52
49
    """Git specific lockable files abstraction."""
61
58
class GitDir(bzrdir.BzrDir):
62
59
    """An adapter to the '.git' dir used by git."""
63
60
 
64
 
    _gitrepository_class = git_repository.GitRepository
65
 
 
66
61
    def __init__(self, transport, lockfiles, format):
67
62
        self._format = format
68
63
        self.root_transport = transport
83
78
        return True
84
79
 
85
80
    def open_branch(self, ignored=None):
86
 
        """'create' a branch for this dir."""
87
 
        repo = self.open_repository()
88
 
        if repo._git.heads == []:
89
 
            head = None
90
 
        else:
91
 
            head = repo._git.heads[0].commit.id
92
 
        return git_branch.GitBranch(self, repo, head, 
93
 
                                    self.root_transport.base, self._lockfiles)
 
81
        """'crate' a branch for this dir."""
 
82
        return git_branch.GitBranch(self, self._lockfiles)
94
83
 
95
84
    def open_repository(self, shared=False):
96
85
        """'open' a repository for this dir."""
97
 
        return self._gitrepository_class(self, self._lockfiles)
 
86
        return git_repository.GitRepository(self, self._lockfiles)
98
87
 
99
 
    def open_workingtree(self, recommend_upgrade=True):
 
88
    def open_workingtree(self):
100
89
        loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
101
90
        raise errors.bzr_errors.NoWorkingTree(loc)
102
91
 
103
 
    def cloning_metadir(self):
104
 
        return bzrdir.BzrDirFormat.get_default_format()
105
 
 
106
92
 
107
93
class GitBzrDirFormat(bzrdir.BzrDirFormat):
108
94
    """The .git directory control format."""
109
95
 
110
 
    _gitdir_class = GitDir
111
 
 
112
96
    @classmethod
113
97
    def _known_formats(self):
114
98
        return set([GitBzrDirFormat()])
122
106
        url = transport.base
123
107
        if url.startswith('readonly+'):
124
108
            url = url[len('readonly+'):]
 
109
        path = urlutils.local_path_from_url(url)
125
110
        if not transport.has('.git'):
126
111
            raise errors.bzr_errors.NotBranchError(path=transport.base)
127
112
        lockfiles = GitLockableFiles(GitLock())
128
 
        return self._gitdir_class(transport, lockfiles, self)
 
113
        return GitDir(transport, lockfiles, self)
129
114
 
130
115
    @classmethod
131
116
    def probe_transport(klass, transport):
143
128
            raise errors.bzr_errors.NotBranchError(path=transport.base)
144
129
        raise errors.bzr_errors.NotBranchError(path=transport.base)
145
130
 
146
 
    def get_format_description(self):
147
 
        return "Local Git Repository"
148
 
 
149
131
 
150
132
bzrdir.BzrDirFormat.register_control_format(GitBzrDirFormat)