comparison mercurial/transaction.py @ 23512:0ff6b65afeb0

transaction: remove the redundant 'onclose' mechanism It is superseded by the 'addfinalize' function and all its user have been migrated.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 04 Dec 2014 13:51:41 -0800
parents 1b51d1b05482
children 4c7ea2d9bad9
comparison
equal deleted inserted replaced
23511:acc73273b27e 23512:0ff6b65afeb0
82 # only pure backup file remains, it is sage to ignore any error 82 # only pure backup file remains, it is sage to ignore any error
83 pass 83 pass
84 84
85 class transaction(object): 85 class transaction(object):
86 def __init__(self, report, opener, vfsmap, journal, after=None, 86 def __init__(self, report, opener, vfsmap, journal, after=None,
87 createmode=None, onclose=None, onabort=None): 87 createmode=None, onabort=None):
88 """Begin a new transaction 88 """Begin a new transaction
89 89
90 Begins a new transaction that allows rolling back writes in the event of 90 Begins a new transaction that allows rolling back writes in the event of
91 an exception. 91 an exception.
92 92
93 * `after`: called after the transaction has been committed 93 * `after`: called after the transaction has been committed
94 * `createmode`: the mode of the journal file that will be created 94 * `createmode`: the mode of the journal file that will be created
95 * `onclose`: called as the transaction is closing, but before it is
96 closed
97 * `onabort`: called as the transaction is aborting, but before any files 95 * `onabort`: called as the transaction is aborting, but before any files
98 have been truncated 96 have been truncated
99 """ 97 """
100 self.count = 1 98 self.count = 1
101 self.usages = 1 99 self.usages = 1
105 # a map to access file in various {location -> vfs} 103 # a map to access file in various {location -> vfs}
106 vfsmap = vfsmap.copy() 104 vfsmap = vfsmap.copy()
107 vfsmap[''] = opener # set default value 105 vfsmap[''] = opener # set default value
108 self._vfsmap = vfsmap 106 self._vfsmap = vfsmap
109 self.after = after 107 self.after = after
110 self.onclose = onclose
111 self.onabort = onabort 108 self.onabort = onabort
112 self.entries = [] 109 self.entries = []
113 self.map = {} 110 self.map = {}
114 self.journal = journal 111 self.journal = journal
115 self._queue = [] 112 self._queue = []
373 if self.count == 1: 370 if self.count == 1:
374 self._generatefiles() 371 self._generatefiles()
375 categories = sorted(self._finalizecallback) 372 categories = sorted(self._finalizecallback)
376 for cat in categories: 373 for cat in categories:
377 self._finalizecallback[cat](self) 374 self._finalizecallback[cat](self)
378 if self.onclose is not None:
379 self.onclose()
380 375
381 self.count -= 1 376 self.count -= 1
382 if self.count != 0: 377 if self.count != 0:
383 return 378 return
384 self.file.close() 379 self.file.close()