/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 bzrlib/multiparent.py

Merge bzr.dev r3466

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from StringIO import StringIO
24
24
 
25
25
from bzrlib import (
 
26
    errors,
26
27
    patiencediff,
27
28
    trace,
28
29
    ui,
37
38
    descendants = {}
38
39
    if versions is None:
39
40
        versions = vf.versions()
 
41
    parents = vf.get_parent_map(versions)
40
42
    def pending_parents(version):
41
 
        return [v for v in vf.get_parents(version) if v in versions and
 
43
        return [v for v in parents[version] if v in versions and
42
44
                v not in seen]
43
45
    for version_id in versions:
44
 
        for parent_id in vf.get_parents(version_id):
 
46
        for parent_id in parents[version_id]:
45
47
            descendants.setdefault(parent_id, []).append(version_id)
46
48
    cur = [v for v in versions if len(pending_parents(v)) == 0]
47
49
    while len(cur) > 0:
55
57
            yield version_id
56
58
            seen.add(version_id)
57
59
        cur = next
58
 
    assert len(seen) == len(versions)
59
60
 
60
61
 
61
62
class MultiParent(object):
193
194
            elif cur_line[0] == '\n':
194
195
                hunks[-1].lines[-1] += '\n'
195
196
            else:
196
 
                assert cur_line[0] == 'c', cur_line[0]
 
197
                if not (cur_line[0] == 'c'):
 
198
                    raise AssertionError(cur_line[0])
197
199
                parent, parent_pos, child_pos, num_lines =\
198
200
                    [int(v) for v in cur_line.split(' ')[1:]]
199
201
                hunks.append(ParentText(parent, parent_pos, child_pos,
368
370
        :param single_parent: If true, omit all but one parent text, (but
369
371
            retain parent metadata).
370
372
        """
371
 
        assert no_cache or not verify
 
373
        if not (no_cache or not verify):
 
374
            raise ValueError()
372
375
        revisions = set(vf.versions())
373
376
        total = len(revisions)
374
377
        pb = ui.ui_factory.nested_progress_bar()
380
383
                    if [p for p in parents if p not in self._parents] != []:
381
384
                        continue
382
385
                    lines = [a + ' ' + l for a, l in
383
 
                             vf.annotate_iter(revision)]
 
386
                             vf.annotate(revision)]
384
387
                    if snapshots is None:
385
388
                        force_snapshot = None
386
389
                    else:
392
395
                        self.clear_cache()
393
396
                        vf.clear_cache()
394
397
                        if verify:
395
 
                            assert lines == self.get_line_list([revision])[0]
 
398
                            if not (lines == self.get_line_list([revision])[0]):
 
399
                                raise AssertionError()
396
400
                            self.clear_cache()
397
401
                    pb.update('Importing revisions',
398
402
                              (total - len(revisions)) + len(added), total)
508
512
        self._parents[version_id] = parent_ids
509
513
 
510
514
    def get_diff(self, version_id):
511
 
        return self._diffs[version_id]
 
515
        try:
 
516
            return self._diffs[version_id]
 
517
        except KeyError:
 
518
            raise errors.RevisionNotPresent(version_id, self)
512
519
 
513
520
    def destroy(self):
514
521
        self._diffs = {}