Show More
@@ -85,27 +85,39 b' class changelog(revlog):' | |||
|
85 | 85 | def delayupdate(self): |
|
86 | 86 | "delay visibility of index updates to other readers" |
|
87 | 87 | self._realopener = self.opener |
|
88 |
self.opener = self._ |
|
|
88 | self.opener = self._delayopener | |
|
89 | self._delaycount = self.count() | |
|
89 | 90 | self._delaybuf = [] |
|
91 | self._delayname = None | |
|
90 | 92 | |
|
91 | 93 | def finalize(self, tr): |
|
92 | 94 | "finalize index updates" |
|
93 | 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 | 100 | fp = self.opener(self.indexfile, 'a') |
|
96 | 101 | fp.write("".join(self._delaybuf)) |
|
97 | 102 | fp.close() |
|
98 | 103 | del self._delaybuf |
|
104 | # split when we're done | |
|
99 | 105 | self.checkinlinesize(tr) |
|
100 | 106 | |
|
101 |
def _ |
|
|
107 | def _delayopener(self, name, mode='r'): | |
|
102 | 108 | fp = self._realopener(name, mode) |
|
109 | # only divert the index | |
|
103 | 110 | if not name == self.indexfile: |
|
104 | 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 | 117 | return appender(fp, self._delaybuf) |
|
106 | 118 | |
|
107 | 119 | def checkinlinesize(self, tr, fp=None): |
|
108 |
if self.opener == self._ |
|
|
120 | if self.opener == self._delayopener: | |
|
109 | 121 | return |
|
110 | 122 | return revlog.checkinlinesize(self, tr, fp) |
|
111 | 123 |
General Comments 0
You need to be logged in to leave comments.
Login now