Show More
@@ -121,7 +121,7 b' class transaction(object):' | |||
|
121 | 121 | |
|
122 | 122 | This is used by strip to delay vision of strip offset. The transaction |
|
123 | 123 | sees either none or all of the strip actions to be done.""" |
|
124 |
self._queue.append( |
|
|
124 | self._queue.append([]) | |
|
125 | 125 | |
|
126 | 126 | @active |
|
127 | 127 | def endgroup(self): |
@@ -130,31 +130,22 b' class transaction(object):' | |||
|
130 | 130 | This is used by strip to delay vision of strip offset. The transaction |
|
131 | 131 | sees either none or all of the strip actions to be done.""" |
|
132 | 132 | q = self._queue.pop() |
|
133 |
self.entries.extend(q |
|
|
134 | self._backupentries.extend(q[1]) | |
|
133 | self.entries.extend(q) | |
|
135 | 134 | |
|
136 | 135 | offsets = [] |
|
137 | backups = [] | |
|
138 | for f, o, _data in q[0]: | |
|
136 | for f, o, _data in q: | |
|
139 | 137 | offsets.append((f, o)) |
|
140 | 138 | |
|
141 | for f, b in q[1]: | |
|
142 | backups.append((f, b)) | |
|
143 | ||
|
144 | 139 | d = ''.join(['%s\0%d\n' % (f, o) for f, o in offsets]) |
|
145 | 140 | self.file.write(d) |
|
146 | 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 | 143 | @active |
|
153 | 144 | def add(self, file, offset, data=None): |
|
154 | 145 | if file in self.map or file in self._backupmap: |
|
155 | 146 | return |
|
156 | 147 | if self._queue: |
|
157 |
self._queue[-1 |
|
|
148 | self._queue[-1].append((file, offset, data)) | |
|
158 | 149 | return |
|
159 | 150 | |
|
160 | 151 | self.entries.append((file, offset, data)) |
@@ -174,6 +165,9 b' class transaction(object):' | |||
|
174 | 165 | * `file`: the file path, relative to .hg/store |
|
175 | 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 | 172 | if file in self.map or file in self._backupmap: |
|
179 | 173 | return |
@@ -188,10 +182,6 b' class transaction(object):' | |||
|
188 | 182 | self.add(file, 0) |
|
189 | 183 | return |
|
190 | 184 | |
|
191 | if self._queue: | |
|
192 | self._queue[-1][1].append((file, backupfile)) | |
|
193 | return | |
|
194 | ||
|
195 | 185 | self._backupentries.append((file, backupfile)) |
|
196 | 186 | self._backupmap[file] = len(self._backupentries) - 1 |
|
197 | 187 | self._backupsfile.write("%s\0%s\n" % (file, backupfile)) |
General Comments 0
You need to be logged in to leave comments.
Login now