Пример #1
0
 def mergeWith(self,file2):
     filetype.mergeWith(self,file2)
     if self.file0[1]<file2.file0[1]:
         self.modified=True
         self.file0=file2.file0
         self.type=file2.type
         return
     if self.file0[1]==file2.file0[1]:
         if random.random()<0.5:
             self.modified=True
             self.file0=file2.file0
             self.type=file2.type
             return
Пример #2
0
 def mergeWith(self,file2):
     filetype.mergeWith(self,file2)
     tmpList=[]
     i=0
     j=0
     while True:
         if self.lazyRead(i)==None:
             while file2.lazyRead(j)!=None:
                 tmpList.append(file2.lazyRead(j))
                 j+=1
             break
         if file2.lazyRead(j)==None:
             while self.lazyRead(i)!=None:
                 tmpList.append(self.lazyRead(i))
                 i+=1
             break
         while self.lazyRead(i)!=None and file2.lazyRead(j)!=None and self.lazyRead(i)[0]<file2.lazyRead(j)[0]:
             tmpList.append(self.lazyRead(i))
             i+=1
         while self.lazyRead(i)!=None and file2.lazyRead(j)!=None and self.lazyRead(i)[0]>file2.lazyRead(j)[0]:
             tmpList.append(file2.lazyRead(j))
             j+=1
         while self.lazyRead(i)!=None and file2.lazyRead(j)!=None and self.lazyRead(i)[0]==file2.lazyRead(j)[0]:
             # Attentez: merge stratege may be changed in the future
             if self.lazyRead(i)[1][1]==file2.lazyRead(j)[1][1]:
                 if self.lazyRead(i)[1][0]!=file2.lazyRead(j)[1][0]:
                     #raise ex.exception_file.MergeConflictException("Conflict @ kvmap.")
                     if random.random()<0.5:
                         tTuple=self.lazyRead(i)
                     else:
                         tTuple=file2.lazyRead(j)
                 else:
                     tTuple=self.lazyRead(i)
             else:
                 tTuple=self.lazyRead(i) if self.lazyRead(i)[1][1]>file2.lazyRead(j)[1][1] else file2.lazyRead(j)
             tmpList.append(tTuple)
             i+=1
             j+=1
     self.readData=tmpList
     self.haveRead=len(self.readData)
     self.file0=(self.file0[0],max(self.file0[1],file2.file0[1]))