~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

  • Committer: Aaron Bentley
  • Date: 2005-10-04 04:32:32 UTC
  • mfrom: (1185.12.6)
  • mto: (1185.12.13)
  • mto: This revision was merged to the branch mainline in revision 1419.
  • Revision ID: aaron.bentley@utoronto.ca-20051004043231-40302a149769263b
merged my own changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
284
284
                ie = inv[file_id]
285
285
                if ie.kind == 'root_directory':
286
286
                    continue
287
 
                assert hasattr(ie, 'name_version'), \
288
 
                    'no name_version on {%s} in {%s}' % \
 
287
                assert hasattr(ie, 'revision'), \
 
288
                    'no revision on {%s} in {%s}' % \
289
289
                    (file_id, rev.revision_id)
290
 
                if ie.kind == 'file':
291
 
                    assert hasattr(ie, 'text_version')
292
290
 
293
291
        new_inv_xml = serializer_v5.write_inventory_to_string(inv)
294
292
        new_inv_sha1 = sha_string(new_inv_xml)
325
323
        parent_invs = map(self._load_updated_inventory, rev.parent_ids)
326
324
        for file_id in inv:
327
325
            ie = inv[file_id]
328
 
            self._set_name_version(rev, ie, parent_invs)
 
326
            self._set_revision(rev, ie, parent_invs)
329
327
            if ie.kind != 'file':
330
328
                continue
331
329
            self._convert_file_version(rev, ie, parent_invs)
332
330
 
333
331
 
334
 
    def _set_name_version(self, rev, ie, parent_invs):
 
332
    def _set_revision(self, rev, ie, parent_invs):
335
333
        """Set name version for a file.
336
334
 
337
335
        Done in a slightly lazy way: if the file is renamed or in a merge revision
341
339
        if ie.kind == 'root_directory':
342
340
            return
343
341
        if len(parent_invs) != 1:
344
 
            ie.name_version = rev.revision_id
 
342
            ie.revision = rev.revision_id
345
343
        else:
346
344
            old_inv = parent_invs[0]
347
345
            if not old_inv.has_id(file_id):
348
 
                ie.name_version = rev.revision_id
 
346
                ie.revision = rev.revision_id
349
347
            else:
350
348
                old_ie = old_inv[file_id]
351
349
                if (old_ie.parent_id != ie.parent_id
352
350
                    or old_ie.name != ie.name):
353
 
                    ie.name_version = rev.revision_id
 
351
                    ie.revision = rev.revision_id
354
352
                else:
355
 
                    ie.name_version = old_ie.name_version
 
353
                    ie.revision = old_ie.revision
356
354
 
357
355
 
358
356
 
373
371
        for parent_inv in parent_invs:
374
372
            if parent_inv.has_id(file_id):
375
373
                parent_ie = parent_inv[file_id]
376
 
                old_text_version = parent_ie.text_version
377
 
                assert old_text_version in self.converted_revs 
378
 
                if old_text_version not in file_parents:
379
 
                    file_parents.append(old_text_version)
 
374
                old_revision = parent_ie.revision
 
375
                # if this fails, its a ghost ?
 
376
                assert old_revision in self.converted_revs 
 
377
                if old_revision not in file_parents:
 
378
                    file_parents.append(old_revision)
380
379
                if parent_ie.text_sha1 != ie.text_sha1:
381
380
                    text_changed = True
382
381
        if len(file_parents) != 1 or text_changed:
384
383
            assert sha_strings(file_lines) == ie.text_sha1
385
384
            assert sum(map(len, file_lines)) == ie.text_size
386
385
            w.add(rev_id, file_parents, file_lines, ie.text_sha1)
387
 
            ie.text_version = rev_id
 
386
            ie.revision = rev_id
388
387
            self.text_count += 1
389
388
            ##mutter('import text {%s} of {%s}',
390
389
            ##       ie.text_id, file_id)
391
390
        else:
392
391
            ##mutter('text of {%s} unchanged from parent', file_id)
393
 
            ie.text_version = file_parents[0]
 
392
            ie.revision = file_parents[0]
394
393
        del ie.text_id
395
394
 
396
395