Mercurial > hg
changeset 23249:84720eab4fbd
transaction: mark backup-related attributes private
As the transaction is gaining more functions and attributes, it is important to clarify
what is part of the public API.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 05 Nov 2014 09:31:57 +0000 |
parents | e754b62373ad |
children | 8919dc7f2dbb |
files | mercurial/transaction.py |
diffstat | 1 files changed, 28 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/transaction.py Wed Nov 05 01:30:29 2014 +0000 +++ b/mercurial/transaction.py Wed Nov 05 09:31:57 2014 +0000 @@ -83,22 +83,22 @@ self.onclose = onclose self.onabort = onabort self.entries = [] + self.map = {} # a list of ('path', 'backuppath') entries. - self.backupentries = [] - self.map = {} - self.backupmap = {} + self._backupentries = [] + self._backupmap = {} self.journal = journal self._queue = [] # a dict of arguments to be passed to hooks self.hookargs = {} - self.backupjournal = "%s.backupfiles" % journal + self._backupjournal = "%s.backupfiles" % journal self.file = opener.open(self.journal, "w") - self.backupsfile = opener.open(self.backupjournal, 'w') - self.backupsfile.write('%d\n' % version) + self._backupsfile = opener.open(self._backupjournal, 'w') + self._backupsfile.write('%d\n' % version) if createmode is not None: opener.chmod(self.journal, createmode & 0666) - opener.chmod(self.backupjournal, createmode & 0666) + opener.chmod(self._backupjournal, createmode & 0666) # hold file generations to be performed on commit self._filegenerators = {} @@ -123,7 +123,7 @@ def endgroup(self): q = self._queue.pop() self.entries.extend(q[0]) - self.backupentries.extend(q[1]) + self._backupentries.extend(q[1]) offsets = [] backups = [] @@ -138,12 +138,12 @@ self.file.flush() d = ''.join(['%s\0%s\n' % (f, b) for f, b in backups]) - self.backupsfile.write(d) - self.backupsfile.flush() + self._backupsfile.write(d) + self._backupsfile.flush() @active def add(self, file, offset, data=None): - if file in self.map or file in self.backupmap: + if file in self.map or file in self._backupmap: return if self._queue: self._queue[-1][0].append((file, offset, data)) @@ -167,7 +167,7 @@ * `hardlink`: use a hardlink to quickly create the backup """ - if file in self.map or file in self.backupmap: + if file in self.map or file in self._backupmap: return backupfile = "%s.backup.%s" % (self.journal, file) if vfs is None: @@ -184,10 +184,10 @@ self._queue[-1][1].append((file, backupfile)) return - self.backupentries.append((file, backupfile)) - self.backupmap[file] = len(self.backupentries) - 1 - self.backupsfile.write("%s\0%s\n" % (file, backupfile)) - self.backupsfile.flush() + self._backupentries.append((file, backupfile)) + self._backupmap[file] = len(self._backupentries) - 1 + self._backupsfile.write("%s\0%s\n" % (file, backupfile)) + self._backupsfile.flush() @active def addfilegenerator(self, genid, filenames, genfunc, order=0, vfs=None): @@ -238,8 +238,8 @@ def find(self, file): if file in self.map: return self.entries[self.map[file]] - if file in self.backupmap: - return self.backupentries[self.backupmap[file]] + if file in self._backupmap: + return self._backupentries[self._backupmap[file]] return None @active @@ -324,17 +324,17 @@ if self.count != 0: return self.file.close() - self.backupsfile.close() + self._backupsfile.close() self.entries = [] if self.after: self.after() if self.opener.isfile(self.journal): self.opener.unlink(self.journal) - if self.opener.isfile(self.backupjournal): - self.opener.unlink(self.backupjournal) - for _f, b in self.backupentries: + if self.opener.isfile(self._backupjournal): + self.opener.unlink(self._backupjournal) + for _f, b in self._backupentries: self.opener.unlink(b) - self.backupentries = [] + self._backupentries = [] self.journal = None # run post close action categories = sorted(self._postclosecallback) @@ -352,24 +352,24 @@ self.count = 0 self.usages = 0 self.file.close() - self.backupsfile.close() + self._backupsfile.close() if self.onabort is not None: self.onabort() try: - if not self.entries and not self.backupentries: + if not self.entries and not self._backupentries: if self.journal: self.opener.unlink(self.journal) - if self.backupjournal: - self.opener.unlink(self.backupjournal) + if self._backupjournal: + self.opener.unlink(self._backupjournal) return self.report(_("transaction abort!\n")) try: _playback(self.journal, self.report, self.opener, - self.entries, self.backupentries, False) + self.entries, self._backupentries, False) self.report(_("rollback completed\n")) except Exception: self.report(_("rollback failed - please run hg recover\n"))