##// END OF EJS Templates
localrepo: use context manager for transaction in commit()...
Martin von Zweigbergk -
r41398:57c462db default
parent child Browse files
Show More
@@ -2409,7 +2409,7 b' class localrepository(object):'
2409 match.explicitdir = vdirs.append
2409 match.explicitdir = vdirs.append
2410 match.bad = fail
2410 match.bad = fail
2411
2411
2412 wlock = lock = tr = None
2412 wlock = lock = None
2413 try:
2413 try:
2414 wlock = self.wlock()
2414 wlock = self.wlock()
2415 lock = self.lock() # for recent changelog (see issue4368)
2415 lock = self.lock() # for recent changelog (see issue4368)
@@ -2473,13 +2473,12 b' class localrepository(object):'
2473 try:
2473 try:
2474 self.hook("precommit", throw=True, parent1=hookp1,
2474 self.hook("precommit", throw=True, parent1=hookp1,
2475 parent2=hookp2)
2475 parent2=hookp2)
2476 tr = self.transaction('commit')
2476 with self.transaction('commit'):
2477 ret = self.commitctx(cctx, True)
2477 ret = self.commitctx(cctx, True)
2478 # update bookmarks, dirstate and mergestate
2478 # update bookmarks, dirstate and mergestate
2479 bookmarks.update(self, [p1, p2], ret)
2479 bookmarks.update(self, [p1, p2], ret)
2480 cctx.markcommitted(ret)
2480 cctx.markcommitted(ret)
2481 ms.reset()
2481 ms.reset()
2482 tr.close()
2483 except: # re-raises
2482 except: # re-raises
2484 if edited:
2483 if edited:
2485 self.ui.write(
2484 self.ui.write(
@@ -2487,7 +2486,7 b' class localrepository(object):'
2487 raise
2486 raise
2488
2487
2489 finally:
2488 finally:
2490 lockmod.release(tr, lock, wlock)
2489 lockmod.release(lock, wlock)
2491
2490
2492 def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2):
2491 def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2):
2493 # hack for command that use a temporary commit (eg: histedit)
2492 # hack for command that use a temporary commit (eg: histedit)
@@ -370,9 +370,9 b' check saving last-message.txt, at first'
370 HG: branch 'default'
370 HG: branch 'default'
371 HG: added f
371 HG: added f
372 ====
372 ====
373 note: commit message saved in .hg/last-message.txt
374 transaction abort!
373 transaction abort!
375 rollback completed
374 rollback completed
375 note: commit message saved in .hg/last-message.txt
376 abort: pretxncommit.unexpectedabort hook exited with status 1
376 abort: pretxncommit.unexpectedabort hook exited with status 1
377 [255]
377 [255]
378 $ cat .hg/last-message.txt
378 $ cat .hg/last-message.txt
@@ -394,9 +394,9 b' action)'
394 HG: user: test
394 HG: user: test
395 HG: branch 'default'
395 HG: branch 'default'
396 HG: added f
396 HG: added f
397 note: commit message saved in .hg/last-message.txt
398 transaction abort!
397 transaction abort!
399 rollback completed
398 rollback completed
399 note: commit message saved in .hg/last-message.txt
400 abort: pretxncommit.unexpectedabort hook exited with status 1
400 abort: pretxncommit.unexpectedabort hook exited with status 1
401 [255]
401 [255]
402
402
@@ -305,9 +305,9 b' Test saving last-message.txt'
305 HG: branch 'default'
305 HG: branch 'default'
306 HG: no files changed
306 HG: no files changed
307 ====
307 ====
308 note: commit message saved in .hg/last-message.txt
309 transaction abort!
308 transaction abort!
310 rollback completed
309 rollback completed
310 note: commit message saved in .hg/last-message.txt
311 abort: pretxncommit.unexpectedabort hook exited with status 1
311 abort: pretxncommit.unexpectedabort hook exited with status 1
312 [255]
312 [255]
313 $ cat .hg/last-message.txt
313 $ cat .hg/last-message.txt
@@ -113,9 +113,9 b' same thing, but run $EDITOR'
113 > echo "another precious commit message" > "$1"
113 > echo "another precious commit message" > "$1"
114 > __EOF__
114 > __EOF__
115 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg --config hooks.pretxncommit=false commit 2>&1
115 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg --config hooks.pretxncommit=false commit 2>&1
116 note: commit message saved in .hg/last-message.txt
117 transaction abort!
116 transaction abort!
118 rollback completed
117 rollback completed
118 note: commit message saved in .hg/last-message.txt
119 abort: pretxncommit hook exited with status * (glob)
119 abort: pretxncommit hook exited with status * (glob)
120 [255]
120 [255]
121 $ cat .hg/last-message.txt
121 $ cat .hg/last-message.txt
@@ -320,9 +320,9 b" regardless of '--message')"
320 HG: branch 'tag-and-branch-same-name'
320 HG: branch 'tag-and-branch-same-name'
321 HG: changed .hgtags
321 HG: changed .hgtags
322 ====
322 ====
323 note: commit message saved in .hg/last-message.txt
324 transaction abort!
323 transaction abort!
325 rollback completed
324 rollback completed
325 note: commit message saved in .hg/last-message.txt
326 abort: pretxncommit.unexpectedabort hook exited with status 1
326 abort: pretxncommit.unexpectedabort hook exited with status 1
327 [255]
327 [255]
328 $ cat .hg/last-message.txt
328 $ cat .hg/last-message.txt
General Comments 0
You need to be logged in to leave comments. Login now