##// END OF EJS Templates
transaction: mark backup-related attributes private...
Pierre-Yves David -
r23249:84720eab default
parent child Browse files
Show More
@@ -83,22 +83,22 b' class transaction(object):'
83 83 self.onclose = onclose
84 84 self.onabort = onabort
85 85 self.entries = []
86 self.map = {}
86 87 # a list of ('path', 'backuppath') entries.
87 self.backupentries = []
88 self.map = {}
89 self.backupmap = {}
88 self._backupentries = []
89 self._backupmap = {}
90 90 self.journal = journal
91 91 self._queue = []
92 92 # a dict of arguments to be passed to hooks
93 93 self.hookargs = {}
94 94
95 self.backupjournal = "%s.backupfiles" % journal
95 self._backupjournal = "%s.backupfiles" % journal
96 96 self.file = opener.open(self.journal, "w")
97 self.backupsfile = opener.open(self.backupjournal, 'w')
98 self.backupsfile.write('%d\n' % version)
97 self._backupsfile = opener.open(self._backupjournal, 'w')
98 self._backupsfile.write('%d\n' % version)
99 99 if createmode is not None:
100 100 opener.chmod(self.journal, createmode & 0666)
101 opener.chmod(self.backupjournal, createmode & 0666)
101 opener.chmod(self._backupjournal, createmode & 0666)
102 102
103 103 # hold file generations to be performed on commit
104 104 self._filegenerators = {}
@@ -123,7 +123,7 b' class transaction(object):'
123 123 def endgroup(self):
124 124 q = self._queue.pop()
125 125 self.entries.extend(q[0])
126 self.backupentries.extend(q[1])
126 self._backupentries.extend(q[1])
127 127
128 128 offsets = []
129 129 backups = []
@@ -138,12 +138,12 b' class transaction(object):'
138 138 self.file.flush()
139 139
140 140 d = ''.join(['%s\0%s\n' % (f, b) for f, b in backups])
141 self.backupsfile.write(d)
142 self.backupsfile.flush()
141 self._backupsfile.write(d)
142 self._backupsfile.flush()
143 143
144 144 @active
145 145 def add(self, file, offset, data=None):
146 if file in self.map or file in self.backupmap:
146 if file in self.map or file in self._backupmap:
147 147 return
148 148 if self._queue:
149 149 self._queue[-1][0].append((file, offset, data))
@@ -167,7 +167,7 b' class transaction(object):'
167 167 * `hardlink`: use a hardlink to quickly create the backup
168 168 """
169 169
170 if file in self.map or file in self.backupmap:
170 if file in self.map or file in self._backupmap:
171 171 return
172 172 backupfile = "%s.backup.%s" % (self.journal, file)
173 173 if vfs is None:
@@ -184,10 +184,10 b' class transaction(object):'
184 184 self._queue[-1][1].append((file, backupfile))
185 185 return
186 186
187 self.backupentries.append((file, backupfile))
188 self.backupmap[file] = len(self.backupentries) - 1
189 self.backupsfile.write("%s\0%s\n" % (file, backupfile))
190 self.backupsfile.flush()
187 self._backupentries.append((file, backupfile))
188 self._backupmap[file] = len(self._backupentries) - 1
189 self._backupsfile.write("%s\0%s\n" % (file, backupfile))
190 self._backupsfile.flush()
191 191
192 192 @active
193 193 def addfilegenerator(self, genid, filenames, genfunc, order=0, vfs=None):
@@ -238,8 +238,8 b' class transaction(object):'
238 238 def find(self, file):
239 239 if file in self.map:
240 240 return self.entries[self.map[file]]
241 if file in self.backupmap:
242 return self.backupentries[self.backupmap[file]]
241 if file in self._backupmap:
242 return self._backupentries[self._backupmap[file]]
243 243 return None
244 244
245 245 @active
@@ -324,17 +324,17 b' class transaction(object):'
324 324 if self.count != 0:
325 325 return
326 326 self.file.close()
327 self.backupsfile.close()
327 self._backupsfile.close()
328 328 self.entries = []
329 329 if self.after:
330 330 self.after()
331 331 if self.opener.isfile(self.journal):
332 332 self.opener.unlink(self.journal)
333 if self.opener.isfile(self.backupjournal):
334 self.opener.unlink(self.backupjournal)
335 for _f, b in self.backupentries:
333 if self.opener.isfile(self._backupjournal):
334 self.opener.unlink(self._backupjournal)
335 for _f, b in self._backupentries:
336 336 self.opener.unlink(b)
337 self.backupentries = []
337 self._backupentries = []
338 338 self.journal = None
339 339 # run post close action
340 340 categories = sorted(self._postclosecallback)
@@ -352,24 +352,24 b' class transaction(object):'
352 352 self.count = 0
353 353 self.usages = 0
354 354 self.file.close()
355 self.backupsfile.close()
355 self._backupsfile.close()
356 356
357 357 if self.onabort is not None:
358 358 self.onabort()
359 359
360 360 try:
361 if not self.entries and not self.backupentries:
361 if not self.entries and not self._backupentries:
362 362 if self.journal:
363 363 self.opener.unlink(self.journal)
364 if self.backupjournal:
365 self.opener.unlink(self.backupjournal)
364 if self._backupjournal:
365 self.opener.unlink(self._backupjournal)
366 366 return
367 367
368 368 self.report(_("transaction abort!\n"))
369 369
370 370 try:
371 371 _playback(self.journal, self.report, self.opener,
372 self.entries, self.backupentries, False)
372 self.entries, self._backupentries, False)
373 373 self.report(_("rollback completed\n"))
374 374 except Exception:
375 375 self.report(_("rollback failed - please run hg recover\n"))
General Comments 0
You need to be logged in to leave comments. Login now