~bzr/bzr-cvsps-import/trunk

« back to all changes in this revision

Viewing changes to cvsps/importer.py

  • Committer: John Arbash Meinel
  • Date: 2007-10-23 03:20:23 UTC
  • Revision ID: john@arbash-meinel.com-20071023032023-nwhpfdazds4hhhfq
Implement a form of 'path_content_summary'.
Bazaar 0.92 changed CommitBuilder.record_entry_contents() api, so
we have to have path_content_summary defined.

Show diffs side-by-side

added added

removed removed

Lines of Context:
329
329
            cur = entry
330
330
        return cur
331
331
 
 
332
    def path_content_summary(self, path, file_id=None):
 
333
        if path not in self._modified_paths:
 
334
            # Return the content summary from the basis inventory
 
335
            # kind, size, executable, sha
 
336
            if file_id is None:
 
337
                file_id = self._inventory.path2id(path)
 
338
            if file_id not in self._base_inventory:
 
339
                # Should only happen for the root
 
340
                ie = self._inventory[file_id]
 
341
            else:
 
342
                ie = self._base_inventory[file_id]
 
343
            if ie.kind == 'file':
 
344
                return (ie.kind, ie.text_size, ie.executable, ie.text_sha1)
 
345
            else:
 
346
                return (ie.kind, None, None, None)
 
347
        else:
 
348
            action, kind = self._modified_paths[path]
 
349
            assert action != 'remove'
 
350
            if kind == 'file':
 
351
                txt = self._texts[path]
 
352
                executable = self._executable[path]
 
353
                return (kind, len(txt), executable or False, None)
 
354
            else:
 
355
                assert kind == 'directory'
 
356
                return (kind, None, None, None)
 
357
 
332
358
    def remove_file(self, path):
333
359
        """Remove a given file from the inventory."""
334
360
        file_id = self._inventory.path2id(path)
403
429
                    timestamp=timestamp, timezone=timezone,
404
430
                    committer=committer, revprops=revprops,
405
431
                    revision_id=revision_id)
 
432
        # XXX: Bazaar 0.92 broke api compatibility, the only way to detect it
 
433
        #       (other than inspecting version_info) is to count the number of
 
434
        #       arguments
 
435
        num_args = builder.record_entry_contents.func_code.co_argcount
 
436
        if num_args == 6:
 
437
            use_path_content_summary = True
 
438
        else:
 
439
            use_path_content_summary = False
406
440
        try:
407
441
            for path, ie in self._inventory.iter_entries_by_dir():
408
442
                new_ie = ie.copy()
418
452
                    if ie.parent_id is not None and ie.revision is None:
419
453
                        import pdb; pdb.set_trace()
420
454
 
421
 
                builder.record_entry_contents(new_ie, parent_invs, path, self)
 
455
                if use_path_content_summary:
 
456
                    builder.record_entry_contents(new_ie, parent_invs, path,
 
457
                        self, self.path_content_summary(path, new_ie.file_id))
 
458
                else:
 
459
                    builder.record_entry_contents(new_ie, parent_invs, path,
 
460
                                                  self)
422
461
 
423
462
            builder.finish_inventory()
424
463
            message = self._escape_commit_message(message)