comparison mercurial/transaction.py @ 30046:9b41cfe0af31

style: don't use capital letter for constant For better or worse, our coding do not use all caps for constants. We rename constant name introduced in a5009789960c.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Sat, 16 Apr 2016 15:59:30 -0700
parents 14e683d6b273
children 50fef8252820
comparison
equal deleted inserted replaced
30043:1b3a0b0c414f 30046:9b41cfe0af31
30 'bookmarks', 30 'bookmarks',
31 'dirstate' 31 'dirstate'
32 ]) 32 ])
33 33
34 class GenerationGroup(object): 34 class GenerationGroup(object):
35 ALL='all' 35 all='all'
36 PREFINALIZE='prefinalize' 36 prefinalize='prefinalize'
37 POSTFINALIZE='postfinalize' 37 postfinalize='postfinalize'
38 38
39 def active(func): 39 def active(func):
40 def _active(self, *args, **kwds): 40 def _active(self, *args, **kwds):
41 if self.count == 0: 41 if self.count == 0:
42 raise error.Abort(_( 42 raise error.Abort(_(
287 """ 287 """
288 # For now, we are unable to do proper backup and restore of custom vfs 288 # For now, we are unable to do proper backup and restore of custom vfs
289 # but for bookmarks that are handled outside this mechanism. 289 # but for bookmarks that are handled outside this mechanism.
290 self._filegenerators[genid] = (order, filenames, genfunc, location) 290 self._filegenerators[genid] = (order, filenames, genfunc, location)
291 291
292 def _generatefiles(self, suffix='', group=GenerationGroup.ALL): 292 def _generatefiles(self, suffix='', group=GenerationGroup.all):
293 # write files registered for generation 293 # write files registered for generation
294 any = False 294 any = False
295 for id, entry in sorted(self._filegenerators.iteritems()): 295 for id, entry in sorted(self._filegenerators.iteritems()):
296 any = True 296 any = True
297 order, filenames, genfunc, location = entry 297 order, filenames, genfunc, location = entry
298 298
299 # for generation at closing, check if it's before or after finalize 299 # for generation at closing, check if it's before or after finalize
300 postfinalize = group == GenerationGroup.POSTFINALIZE 300 postfinalize = group == GenerationGroup.postfinalize
301 if (group != GenerationGroup.ALL and 301 if (group != GenerationGroup.all and
302 (id in postfinalizegenerators) != (postfinalize)): 302 (id in postfinalizegenerators) != (postfinalize)):
303 continue 303 continue
304 304
305 vfs = self._vfsmap[location] 305 vfs = self._vfsmap[location]
306 files = [] 306 files = []
425 @active 425 @active
426 def close(self): 426 def close(self):
427 '''commit the transaction''' 427 '''commit the transaction'''
428 if self.count == 1: 428 if self.count == 1:
429 self.validator(self) # will raise exception if needed 429 self.validator(self) # will raise exception if needed
430 self._generatefiles(group=GenerationGroup.PREFINALIZE) 430 self._generatefiles(group=GenerationGroup.prefinalize)
431 categories = sorted(self._finalizecallback) 431 categories = sorted(self._finalizecallback)
432 for cat in categories: 432 for cat in categories:
433 self._finalizecallback[cat](self) 433 self._finalizecallback[cat](self)
434 # Prevent double usage and help clear cycles. 434 # Prevent double usage and help clear cycles.
435 self._finalizecallback = None 435 self._finalizecallback = None
436 self._generatefiles(group=GenerationGroup.POSTFINALIZE) 436 self._generatefiles(group=GenerationGroup.postfinalize)
437 437
438 self.count -= 1 438 self.count -= 1
439 if self.count != 0: 439 if self.count != 0:
440 return 440 return
441 self.file.close() 441 self.file.close()