~bzr-hg/bzr-hg/trunk

« back to all changes in this revision

Viewing changes to changegroup.py

  • Committer: Jelmer Vernooij
  • Date: 2011-04-03 09:15:58 UTC
  • mfrom: (339.1.22 692901-fix-keyerror)
  • Revision ID: jelmer@samba.org-20110403091558-9jo5r760ku1v4vq2
Merge fix for several incremental fetch bugs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
    files_from_delta,
40
40
    manifest_and_flags_from_tree,
41
41
    )
42
 
from bzrlib.plugins.hg.overlay import (
43
 
    get_overlay,
44
 
    )
45
42
from bzrlib.plugins.hg.parsers import (
46
43
    format_changeset,
47
44
    format_manifest,
133
130
        yield text, node_parents, revid
134
131
 
135
132
 
136
 
def text_contents(repo, changelog_ids, path, keys, overlay):
 
133
def text_contents(repo, path, keys, overlay):
 
134
    """Generate revlog text tuples.
 
135
 
 
136
    :param repo: Bazaar repository
 
137
    :param lookup_changeset_id: lookup function of hg csid by bzr revid
 
138
    :param path: UTF8 path
 
139
    :param keys: (fileid, revision) tuples of texts to convert
 
140
    :param overlay: Overlay
 
141
    """
137
142
    def text_as_node((fileid, revision)):
138
143
        try:
139
144
            return text_nodes[revision]
158
163
            base_reported = True
159
164
        fulltext = record.get_bytes_as('fulltext')
160
165
        parents = as_hg_parents(record.parents, text_as_node)
161
 
        text_nodes[record.key[1]] = hghash(fulltext, parents[0], parents[1])
162
 
        yield (fulltext, parents, changelog_ids[record.key[1]])
 
166
        node = hghash(fulltext, parents[0], parents[1])
 
167
        text_nodes[record.key[1]] = node
 
168
        yield (record, parents, node)
163
169
 
164
170
 
165
171
def write_chunk(f, buffer):
180
186
    :param revids: Iterable over the revision ids of the revisions to group
181
187
    :return: changegroup string
182
188
    """
 
189
    from bzrlib.plugins.hg.overlay import get_overlay
183
190
    ret = StringIO()
184
191
    overlay = get_overlay(repo, mapping)
185
192
    files = {}
206
213
        # FIXME: Mangle path in the same way that mercurial does
207
214
        write_chunk(ret, path)
208
215
        write_delta_chunks(ret,
209
 
            text_contents(repo, changelog_ids, path, keys, overlay))
 
216
            ((record.get_bytes_as('fulltext'), parents, changelog_ids[record.key[1]]) for (record, parents, node) in text_contents(repo, path, keys, overlay)))
210
217
    write_chunk(ret, "")
211
218
    ret.seek(0)
212
219
    return ret, changelog_ids