# HG changeset patch # User Martin von Zweigbergk # Date 1497896292 25200 # Node ID 04c9dd951a414980aff0315a28794786c6c2fead # Parent 070920db8b87e874561514a4a348adbd7d199c32 rebase: use context manager for locking in pullrebase() diff -r 070920db8b87 -r 04c9dd951a41 hgext/rebase.py --- a/hgext/rebase.py Mon Jun 19 11:18:05 2017 -0700 +++ b/hgext/rebase.py Mon Jun 19 11:18:12 2017 -0700 @@ -1378,10 +1378,7 @@ hint = _('use hg pull followed by hg rebase -d DEST') raise error.Abort(msg, hint=hint) - wlock = lock = None - try: - wlock = repo.wlock() - lock = repo.lock() + with repo.wlock(), repo.lock(): if opts.get('update'): del opts['update'] ui.debug('--update and --rebase are not compatible, ignoring ' @@ -1425,8 +1422,6 @@ # not passing argument to get the bare update behavior # with warning and trumpets commands.update(ui, repo) - finally: - release(lock, wlock) else: if opts.get('tool'): raise error.Abort(_('--tool can only be used with --rebase'))