comparison mercurial/revlog.py @ 2075:343aeefb553b

Make the appendfile class inline-data index friendly The appendfile class needs a few changes to make it work with interleaved index files. It needs to support the tell() method, opening in a+ mode, and it needs to delay the checkinlinesize call until after the append file is written. Given that open(file, "a+") doesn't always seek to the end of the file, this adds seek operations to appendfile that understand whence args
author mason@suse.com
date Tue, 04 Apr 2006 16:38:43 -0400
parents 1e6745f78989
children d007df6daf8e
comparison
equal deleted inserted replaced
2074:01ee43dda681 2075:343aeefb553b
673 % (self.datafile, rev)) 673 % (self.datafile, rev))
674 674
675 self.cache = (node, rev, text) 675 self.cache = (node, rev, text)
676 return text 676 return text
677 677
678 def checkinlinesize(self, fp, tr): 678 def checkinlinesize(self, tr, fp=None):
679 if not self.inlinedata(): 679 if not self.inlinedata():
680 return 680 return
681 if not fp:
682 fp = self.opener(self.indexfile, 'r')
681 size = fp.tell() 683 size = fp.tell()
682 if size < 131072: 684 if size < 131072:
683 return 685 return
684 tr.add(self.datafile, 0) 686 tr.add(self.datafile, 0)
685 df = self.opener(self.datafile, 'w') 687 df = self.opener(self.datafile, 'w')
784 f.write(entry) 786 f.write(entry)
785 787
786 if self.inlinedata(): 788 if self.inlinedata():
787 f.write(data[0]) 789 f.write(data[0])
788 f.write(data[1]) 790 f.write(data[1])
789 self.checkinlinesize(f, transaction) 791 self.checkinlinesize(transaction, f)
790 792
791 self.cache = (node, n, text) 793 self.cache = (node, n, text)
792 return node 794 return node
793 795
794 def ancestor(self, a, b): 796 def ancestor(self, a, b):
964 self.index.append(e) 966 self.index.append(e)
965 self.nodemap[node] = r 967 self.nodemap[node] = r
966 if self.inlinedata(): 968 if self.inlinedata():
967 ifh.write(struct.pack(self.indexformat, *e)) 969 ifh.write(struct.pack(self.indexformat, *e))
968 ifh.write(cdelta) 970 ifh.write(cdelta)
969 self.checkinlinesize(ifh, transaction) 971 self.checkinlinesize(transaction, ifh)
970 if not self.inlinedata(): 972 if not self.inlinedata():
971 dfh = self.opener(self.datafile, "a") 973 dfh = self.opener(self.datafile, "a")
972 ifh = self.opener(self.indexfile, "a") 974 ifh = self.opener(self.indexfile, "a")
973 else: 975 else:
974 if not dfh: 976 if not dfh: