~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/dirstate.py

Use a clearer variable for num_present_parents while reading dirblocks

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 by Canonical Ltd
 
1
# Copyright (C) 2006, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
471
471
            field_count = len(fields)
472
472
            # Each line now has an extra '\n' field which is not used
473
473
            # so we just skip over it
474
 
            # number of fields per dir_entry + number of fields per parent_entry + newline
475
 
            num_parents = len(self._parents) - len(self._ghosts)
476
 
            entry_size = 7 + (7 * (num_parents)) + 1
 
474
            # number of fields per dir_entry
 
475
            #  + number of fields per parent_entry
 
476
            #  + newline
 
477
            num_present_parents = len(self._parents) - len(self._ghosts)
 
478
            entry_size = 7 + (7 * (num_present_parents)) + 1
477
479
            expected_field_count = entry_size * self._num_entries
478
480
            # is the file too short ?
479
481
            assert field_count - cur == expected_field_count, \
483
485
                    self._num_entries, fields)
484
486
 
485
487
            # Fast path the case where there are 1 or 2 parents
486
 
            if num_parents == 0:
 
488
            if num_present_parents == 0:
487
489
                entries = [(fields[pos:pos+7], []) for pos in xrange(cur, field_count, entry_size)]
488
 
            elif num_parents == 1:
 
490
            elif num_present_parents == 1:
489
491
                entries = [(fields[pos:pos+7], [fields[pos+7:pos+14],])
490
492
                    for pos in xrange(cur, field_count, entry_size)]
491
 
            elif num_parents == 2:
 
493
            elif num_present_parents == 2:
492
494
                entries = [(fields[pos:pos+7], [
493
495
                            fields[pos+7:pos+14],
494
496
                            fields[pos+14:pos+21],])