~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

[merge] fix weave join to display nicer progress messages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
819
819
        # two loops so that we do not change ourselves before verifying it
820
820
        # will be ok
821
821
        # work through in index order to make sure we get all dependencies
 
822
        names_to_join = []
 
823
        processed = 0
822
824
        for other_idx, name in enumerate(other._names):
823
825
            self._check_version_consistent(other, other_idx, name)
 
826
            sha1 = other._sha1s[other_idx]
 
827
 
 
828
            processed += 1
 
829
 
 
830
            if name in self._name_map:
 
831
                idx = self.lookup(name)
 
832
                n1 = set(map(other.idx_to_name, other._parents[other_idx]))
 
833
                n2 = set(map(self.idx_to_name, self._parents[idx]))
 
834
                if sha1 ==  self._sha1s[idx] and n1 == n2:
 
835
                        continue
 
836
 
 
837
            names_to_join.append((other_idx, name))
824
838
 
825
839
        if pb and not msg:
826
840
            msg = 'weave join'
827
841
 
828
842
        merged = 0
829
 
        processed = 0
830
843
        time0 = time.time( )
831
 
        for other_idx, name in enumerate(other._names):
 
844
        for other_idx, name in names_to_join:
832
845
            # TODO: If all the parents of the other version are already
833
846
            # present then we can avoid some work by just taking the delta
834
847
            # and adjusting the offsets.
835
848
            new_parents = self._imported_parents(other, other_idx)
836
849
            sha1 = other._sha1s[other_idx]
837
850
 
838
 
            processed += 1
839
 
 
840
 
            if name in self._name_map:
841
 
                idx = self.lookup(name)
842
 
                n1 = set(map(other.idx_to_name, other._parents[other_idx]))
843
 
                n2 = set(map(self.idx_to_name, self._parents[idx]))
844
 
                if sha1 ==  self._sha1s[idx] and n1 == n2:
845
 
                        continue
 
851
            merged += 1
846
852
 
847
853
            if pb:
848
 
                pb.update(msg, other_idx, len(other._names))
 
854
                pb.update(msg, merged, len(names_to_join))
849
855
           
850
 
            merged += 1
851
856
            lines = other.get_lines(other_idx)
852
857
            self.add(name, new_parents, lines, sha1)
853
858
 
854
859
        mutter("merged = %d, processed = %d, file_id=%s; deltat=%d"%(
855
 
                merged,processed,self._weave_name, time.time( )-time0))
856
 
 
857
 
 
858
 
 
 
860
                merged, processed, self._weave_name, time.time( )-time0))
859
861
 
860
862
    def _imported_parents(self, other, other_idx):
861
863
        """Return list of parents in self corresponding to indexes in other."""