/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 processors/generic_processor.py

Add support for -Dfast-import.

Passing -Dfast-import to bzr now makes fast import output some more
information to ~/.bzr.log that may be useful in tracking down problems.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from bzrlib import (
23
23
    builtins,
24
24
    bzrdir,
 
25
    debug,
25
26
    delta,
26
27
    errors,
27
28
    generate_ids,
35
36
    )
36
37
from bzrlib.repofmt import pack_repo
37
38
from bzrlib.trace import (
 
39
    error,
 
40
    mutter,
38
41
    note,
39
42
    warning,
40
 
    error,
41
43
    )
42
44
import bzrlib.util.configobj.configobj as configobj
43
45
from bzrlib.plugins.fastimport import (
123
125
        msg = "%s WARNING: %s" % (self._time_of_day(), msg)
124
126
        warning(msg, *args)
125
127
 
 
128
    def debug(self, mgs, *args):
 
129
        """Output a debug message if the appropriate -D option was given."""
 
130
        if "fast-import" in debug.debug_flags:
 
131
            msg = "%s DEBUG: %s" % (self._time_of_day(), msg)
 
132
            mutter(msg, *args)
 
133
 
126
134
    def _time_of_day(self):
127
135
        """Time of day as a string."""
128
136
        # Note: this is a separate method so tests can patch in a fixed value
129
137
        return time.strftime("%H:%M:%S")
130
 
 
 
138
    
131
139
    def pre_process(self):
132
140
        self._start_time = time.time()
133
141
        self._load_info_and_params()
248
256
            for lost_info in branches_lost:
249
257
                head_revision = lost_info[1]
250
258
                branch_name = lost_info[0]
251
 
                note("\t %s = %s", head_revision, branch_name)
 
259
                self.note("\t %s = %s", head_revision, branch_name)
252
260
 
253
261
        # Update the working trees as requested and dump stats
254
262
        self._tree_count = 0
569
577
        msg = "WARNING: %s (%s)" % (msg, self.command.id)
570
578
        warning(msg, *args)
571
579
 
 
580
    def debug(self, msg, *args):
 
581
        """Output a mutter if the appropriate -D option was given."""
 
582
        if "fast-import" in debug.debug_flags:
 
583
            msg = "%s (%s)" % (msg, self.command.id)
 
584
            mutter(msg, *args)
 
585
 
572
586
    def pre_process_files(self):
573
587
        """Prepare for committing."""
574
588
        self.revision_id = self.gen_revision_id()
584
598
                for p in parents]
585
599
        else:
586
600
            self.parents = []
 
601
        self.debug("revision parents are %s", str(self.parents))
587
602
 
588
603
        # Seed the inventory from the previous one
589
604
        if len(self.parents) == 0:
647
662
            data = self.cache_mgr.fetch_blob(filecmd.dataref)
648
663
        else:
649
664
            data = filecmd.data
 
665
        self.debug("modifying %s", filecmd.path)
650
666
        self._modify_inventory(filecmd.path, filecmd.kind,
651
667
            filecmd.is_executable, data)
652
668
 
653
669
    def delete_handler(self, filecmd):
654
670
        path = filecmd.path
 
671
        self.debug("deleting %s", path)
655
672
        fileid = self.bzr_file_id(path)
656
673
        try:
657
674
            del self.inventory[fileid]
678
695
    def rename_handler(self, filecmd):
679
696
        old_path = filecmd.old_path
680
697
        new_path = filecmd.new_path
 
698
        self.debug("renaming %s to %s", old_path, new_path)
681
699
        file_id = self.bzr_file_id(old_path)
682
700
        basename, new_parent_ie = self._ensure_directory(new_path)
683
701
        new_parent_id = new_parent_ie.file_id
 
702
        existing_id = self.inventory.path2id(new_path)
 
703
        if existing_id is not None:
 
704
            self.inventory.remove_recursive_id(existing_id)
684
705
        self.inventory.rename(file_id, new_parent_id, basename)
685
706
        self.cache_mgr._rename_path(old_path, new_path)
686
707
 
694
715
          is_new = True if the file_id is newly created
695
716
        """
696
717
        try:
697
 
            return self.cache_mgr.file_ids[path], False
 
718
            id = self.cache_mgr.file_ids[path]
 
719
            return id, False
698
720
        except KeyError:
699
721
            id = generate_ids.gen_file_id(path)
700
722
            self.cache_mgr.file_ids[path] = id
 
723
            self.debug("Generated new file id %s for '%s'", id, path)
701
724
            return id, True
702
725
 
703
726
    def bzr_file_id(self, path):