##// END OF EJS Templates
changelog: optimize delayed updates for clone vs pull...
Matt Mackall -
r4269:73c918c7 default
parent child Browse files
Show More
@@ -85,27 +85,39 b' class changelog(revlog):'
85 def delayupdate(self):
85 def delayupdate(self):
86 "delay visibility of index updates to other readers"
86 "delay visibility of index updates to other readers"
87 self._realopener = self.opener
87 self._realopener = self.opener
88 self.opener = self._appendopener
88 self.opener = self._delayopener
89 self._delaycount = self.count()
89 self._delaybuf = []
90 self._delaybuf = []
91 self._delayname = None
90
92
91 def finalize(self, tr):
93 def finalize(self, tr):
92 "finalize index updates"
94 "finalize index updates"
93 self.opener = self._realopener
95 self.opener = self._realopener
94 if self._delaybuf:
96 # move redirected index data back into place
97 if self._delayname:
98 util.rename(self._delayname + ".a", self._delayname)
99 elif self._delaybuf:
95 fp = self.opener(self.indexfile, 'a')
100 fp = self.opener(self.indexfile, 'a')
96 fp.write("".join(self._delaybuf))
101 fp.write("".join(self._delaybuf))
97 fp.close()
102 fp.close()
98 del self._delaybuf
103 del self._delaybuf
104 # split when we're done
99 self.checkinlinesize(tr)
105 self.checkinlinesize(tr)
100
106
101 def _appendopener(self, name, mode='r'):
107 def _delayopener(self, name, mode='r'):
102 fp = self._realopener(name, mode)
108 fp = self._realopener(name, mode)
109 # only divert the index
103 if not name == self.indexfile:
110 if not name == self.indexfile:
104 return fp
111 return fp
112 # if we're doing an initial clone, divert to another file
113 if self._delaycount == 0:
114 self._delayname = fp.name
115 return self._realopener(name + ".a", mode)
116 # otherwise, divert to memory
105 return appender(fp, self._delaybuf)
117 return appender(fp, self._delaybuf)
106
118
107 def checkinlinesize(self, tr, fp=None):
119 def checkinlinesize(self, tr, fp=None):
108 if self.opener == self._appendopener:
120 if self.opener == self._delayopener:
109 return
121 return
110 return revlog.checkinlinesize(self, tr, fp)
122 return revlog.checkinlinesize(self, tr, fp)
111
123
@@ -4,4 +4,4 b' adding changesets'
4 killed!
4 killed!
5 transaction abort!
5 transaction abort!
6 rollback completed
6 rollback completed
7 .hg/00changelog.i .hg/journal.dirstate .hg/requires .hg/store .hg/store/00changelog.i
7 .hg/00changelog.i .hg/journal.dirstate .hg/requires .hg/store .hg/store/00changelog.i .hg/store/00changelog.i.a
General Comments 0
You need to be logged in to leave comments. Login now