comparison mercurial/commands.py @ 38321:9b1536b02221

backout: use context manager for locks Differential Revision: https://phab.mercurial-scm.org/D3744
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 14 Jun 2018 15:08:19 -0700
parents eef4668be8a3
children e218ed5ba484
comparison
equal deleted inserted replaced
38320:eef4668be8a3 38321:9b1536b02221
558 of another revision. 558 of another revision.
559 559
560 Returns 0 on success, 1 if nothing to backout or there are unresolved 560 Returns 0 on success, 1 if nothing to backout or there are unresolved
561 files. 561 files.
562 ''' 562 '''
563 wlock = lock = None 563 with repo.wlock(), repo.lock():
564 try:
565 wlock = repo.wlock()
566 lock = repo.lock()
567 return _dobackout(ui, repo, node, rev, **opts) 564 return _dobackout(ui, repo, node, rev, **opts)
568 finally:
569 release(lock, wlock)
570 565
571 def _dobackout(ui, repo, node=None, rev=None, **opts): 566 def _dobackout(ui, repo, node=None, rev=None, **opts):
572 opts = pycompat.byteskwargs(opts) 567 opts = pycompat.byteskwargs(opts)
573 if opts.get('commit') and opts.get('no_commit'): 568 if opts.get('commit') and opts.get('no_commit'):
574 raise error.Abort(_("cannot use --commit with --no-commit")) 569 raise error.Abort(_("cannot use --commit with --no-commit"))