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

Add simple HACKING document.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2007 Canonical Ltd
 
2
# Copyright (C) 2008-2009 Jelmer Vernooij <jelmer@samba.org>
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
16
17
 
17
18
"""An adapter between a Git Repository and a Bazaar Branch"""
18
19
 
 
20
import dulwich as git
19
21
import os
20
22
import time
21
23
 
40
42
from bzrlib.plugins.git.foreign import (
41
43
    versionedfiles,
42
44
    )
43
 
from bzrlib.plugins.git.mapping import default_mapping, mapping_registry, inventory_to_tree_and_blobs, revision_to_commit
 
45
from bzrlib.plugins.git.mapping import (
 
46
    default_mapping,
 
47
    inventory_to_tree_and_blobs,
 
48
    mapping_registry,
 
49
    revision_to_commit,
 
50
    )
44
51
from bzrlib.plugins.git.versionedfiles import GitTexts
45
52
 
46
 
import dulwich as git
47
 
 
48
53
 
49
54
class GitTags(object):
50
55
 
101
106
 
102
107
    def all_revision_ids(self):
103
108
        ret = set([revision.NULL_REVISION])
104
 
        if self._git.heads() == []:
 
109
        heads = self._git.heads()
 
110
        if heads == {}:
105
111
            return ret
106
 
        bzr_heads = [self.get_mapping().revision_id_foreign_to_bzr(h) for h in self._git.heads()]
 
112
        bzr_heads = [self.get_mapping().revision_id_foreign_to_bzr(h) for h in heads.itervalues()]
107
113
        ret = set(bzr_heads)
108
114
        graph = self.get_graph()
109
115
        for rev, parents in graph.iter_ancestry(bzr_heads):
139
145
        """See Repository.get_ancestry().
140
146
        """
141
147
        if revision_id is None:
142
 
            return self._all_revision_ids()
 
148
            return [None, revision.NULL_REVISION] + self._all_revision_ids()
143
149
        assert isinstance(revision_id, str)
144
150
        ancestry = []
145
151
        graph = self.get_graph()
146
152
        for rev, parents in graph.iter_ancestry([revision_id]):
147
 
            if rev == revision.NULL_REVISION:
148
 
                rev = None
149
153
            ancestry.append(rev)
150
154
        ancestry.reverse()
151
 
        return ancestry
 
155
        return [None] + ancestry
152
156
 
153
157
    def import_revision_gist(self, source, revid, parent_lookup):
154
 
        """Impor the gist of another revision into this Git repository.
 
158
        """Import the gist of a revision into this Git repository.
155
159
 
156
160
        """
157
161
        objects = []
166
170
        return commit.sha().hexdigest()
167
171
 
168
172
    def dfetch(self, source, stop_revision):
 
173
        """Import the gist of the ancestry of a particular revision."""
169
174
        if stop_revision is None:
170
175
            raise NotImplementedError
171
176
        revidmap = {}