##// END OF EJS Templates
transaction: drop backupentries logic from startgroup and endgroup...
Pierre-Yves David -
r23251:85c634ff default
parent child Browse files
Show More
@@ -121,7 +121,7 b' class transaction(object):'
121
121
122 This is used by strip to delay vision of strip offset. The transaction
122 This is used by strip to delay vision of strip offset. The transaction
123 sees either none or all of the strip actions to be done."""
123 sees either none or all of the strip actions to be done."""
124 self._queue.append(([], []))
124 self._queue.append([])
125
125
126 @active
126 @active
127 def endgroup(self):
127 def endgroup(self):
@@ -130,31 +130,22 b' class transaction(object):'
130 This is used by strip to delay vision of strip offset. The transaction
130 This is used by strip to delay vision of strip offset. The transaction
131 sees either none or all of the strip actions to be done."""
131 sees either none or all of the strip actions to be done."""
132 q = self._queue.pop()
132 q = self._queue.pop()
133 self.entries.extend(q[0])
133 self.entries.extend(q)
134 self._backupentries.extend(q[1])
135
134
136 offsets = []
135 offsets = []
137 backups = []
136 for f, o, _data in q:
138 for f, o, _data in q[0]:
139 offsets.append((f, o))
137 offsets.append((f, o))
140
138
141 for f, b in q[1]:
142 backups.append((f, b))
143
144 d = ''.join(['%s\0%d\n' % (f, o) for f, o in offsets])
139 d = ''.join(['%s\0%d\n' % (f, o) for f, o in offsets])
145 self.file.write(d)
140 self.file.write(d)
146 self.file.flush()
141 self.file.flush()
147
142
148 d = ''.join(['%s\0%s\n' % (f, b) for f, b in backups])
149 self._backupsfile.write(d)
150 self._backupsfile.flush()
151
152 @active
143 @active
153 def add(self, file, offset, data=None):
144 def add(self, file, offset, data=None):
154 if file in self.map or file in self._backupmap:
145 if file in self.map or file in self._backupmap:
155 return
146 return
156 if self._queue:
147 if self._queue:
157 self._queue[-1][0].append((file, offset, data))
148 self._queue[-1].append((file, offset, data))
158 return
149 return
159
150
160 self.entries.append((file, offset, data))
151 self.entries.append((file, offset, data))
@@ -174,6 +165,9 b' class transaction(object):'
174 * `file`: the file path, relative to .hg/store
165 * `file`: the file path, relative to .hg/store
175 * `hardlink`: use a hardlink to quickly create the backup
166 * `hardlink`: use a hardlink to quickly create the backup
176 """
167 """
168 if self._queue:
169 msg = 'cannot use transaction.addbackup inside "group"'
170 raise RuntimeError(msg)
177
171
178 if file in self.map or file in self._backupmap:
172 if file in self.map or file in self._backupmap:
179 return
173 return
@@ -188,10 +182,6 b' class transaction(object):'
188 self.add(file, 0)
182 self.add(file, 0)
189 return
183 return
190
184
191 if self._queue:
192 self._queue[-1][1].append((file, backupfile))
193 return
194
195 self._backupentries.append((file, backupfile))
185 self._backupentries.append((file, backupfile))
196 self._backupmap[file] = len(self._backupentries) - 1
186 self._backupmap[file] = len(self._backupentries) - 1
197 self._backupsfile.write("%s\0%s\n" % (file, backupfile))
187 self._backupsfile.write("%s\0%s\n" % (file, backupfile))
General Comments 0
You need to be logged in to leave comments. Login now