819
819
# two loops so that we do not change ourselves before verifying it
821
821
# work through in index order to make sure we get all dependencies
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]
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:
837
names_to_join.append((other_idx, name))
825
839
if pb and not msg:
826
840
msg = 'weave join'
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]
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:
848
pb.update(msg, other_idx, len(other._names))
854
pb.update(msg, merged, len(names_to_join))
851
856
lines = other.get_lines(other_idx)
852
857
self.add(name, new_parents, lines, sha1)
854
859
mutter("merged = %d, processed = %d, file_id=%s; deltat=%d"%(
855
merged,processed,self._weave_name, time.time( )-time0))
860
merged, processed, self._weave_name, time.time( )-time0))
860
862
def _imported_parents(self, other, other_idx):
861
863
"""Return list of parents in self corresponding to indexes in other."""