~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/multiparent.py

  • Committer: Ian Clatworthy
  • Date: 2008-03-27 07:51:10 UTC
  • mto: (3311.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 3312.
  • Revision ID: ian.clatworthy@canonical.com-20080327075110-afgd7x03ybju06ez
Reduce evangelism in the User Guide

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
from bzrlib.lazy_import import lazy_import
18
18
 
28
28
    trace,
29
29
    ui,
30
30
    )
31
 
from bzrlib import bencode
 
31
from bzrlib.util import bencode
32
32
""")
33
33
from bzrlib.tuned_gzip import GzipFile
34
34
 
35
35
 
36
 
def topo_iter_keys(vf, keys=None):
37
 
    if keys is None:
38
 
        keys = vf.keys()
39
 
    parents = vf.get_parent_map(keys)
40
 
    return _topo_iter(parents, keys)
41
 
 
42
36
def topo_iter(vf, versions=None):
 
37
    seen = set()
 
38
    descendants = {}
43
39
    if versions is None:
44
40
        versions = vf.versions()
45
41
    parents = vf.get_parent_map(versions)
46
 
    return _topo_iter(parents, versions)
47
 
 
48
 
def _topo_iter(parents, versions):
49
 
    seen = set()
50
 
    descendants = {}
51
42
    def pending_parents(version):
52
 
        if parents[version] is None:
53
 
            return []
54
43
        return [v for v in parents[version] if v in versions and
55
44
                v not in seen]
56
45
    for version_id in versions:
57
 
        if parents[version_id] is None:
58
 
            # parentless
59
 
            continue
60
46
        for parent_id in parents[version_id]:
61
47
            descendants.setdefault(parent_id, []).append(version_id)
62
48
    cur = [v for v in versions if len(pending_parents(v)) == 0]
71
57
            yield version_id
72
58
            seen.add(version_id)
73
59
        cur = next
 
60
    assert len(seen) == len(versions)
74
61
 
75
62
 
76
63
class MultiParent(object):
208
195
            elif cur_line[0] == '\n':
209
196
                hunks[-1].lines[-1] += '\n'
210
197
            else:
211
 
                if not (cur_line[0] == 'c'):
212
 
                    raise AssertionError(cur_line[0])
 
198
                assert cur_line[0] == 'c', cur_line[0]
213
199
                parent, parent_pos, child_pos, num_lines =\
214
200
                    [int(v) for v in cur_line.split(' ')[1:]]
215
201
                hunks.append(ParentText(parent, parent_pos, child_pos,
290
276
            ' %(num_lines)r)' % self.__dict__
291
277
 
292
278
    def __eq__(self, other):
293
 
        if self.__class__ is not other.__class__:
 
279
        if self.__class__ != other.__class__:
294
280
            return False
295
281
        return (self.__dict__ == other.__dict__)
296
282
 
316
302
        return version in self._parents
317
303
 
318
304
    def do_snapshot(self, version_id, parent_ids):
319
 
        """Determine whether to perform a snapshot for this version"""
 
305
        """Determine whether to perform a a snapshot for this version"""
320
306
        if self.snapshot_interval is None:
321
307
            return False
322
308
        if self.max_snapshots is not None and\
384
370
        :param single_parent: If true, omit all but one parent text, (but
385
371
            retain parent metadata).
386
372
        """
387
 
        if not (no_cache or not verify):
388
 
            raise ValueError()
 
373
        assert no_cache or not verify
389
374
        revisions = set(vf.versions())
390
375
        total = len(revisions)
391
376
        pb = ui.ui_factory.nested_progress_bar()
397
382
                    if [p for p in parents if p not in self._parents] != []:
398
383
                        continue
399
384
                    lines = [a + ' ' + l for a, l in
400
 
                             vf.annotate(revision)]
 
385
                             vf.annotate_iter(revision)]
401
386
                    if snapshots is None:
402
387
                        force_snapshot = None
403
388
                    else:
409
394
                        self.clear_cache()
410
395
                        vf.clear_cache()
411
396
                        if verify:
412
 
                            if not (lines == self.get_line_list([revision])[0]):
413
 
                                raise AssertionError()
 
397
                            assert lines == self.get_line_list([revision])[0]
414
398
                            self.clear_cache()
415
399
                    pb.update('Importing revisions',
416
400
                              (total - len(revisions)) + len(added), total)