comparison mercurial/commands.py @ 28510:5b675a5665ef

with: use context manager in unbundle
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:49 -0800
parents 55394c6fe74e
children 2b3a21052be9
comparison
equal deleted inserted replaced
28509:55394c6fe74e 28510:5b675a5665ef
6829 6829
6830 Returns 0 on success, 1 if an update has unresolved files. 6830 Returns 0 on success, 1 if an update has unresolved files.
6831 """ 6831 """
6832 fnames = (fname1,) + fnames 6832 fnames = (fname1,) + fnames
6833 6833
6834 lock = repo.lock() 6834 with repo.lock():
6835 try:
6836 for fname in fnames: 6835 for fname in fnames:
6837 f = hg.openpath(ui, fname) 6836 f = hg.openpath(ui, fname)
6838 gen = exchange.readbundle(ui, f, fname) 6837 gen = exchange.readbundle(ui, f, fname)
6839 if isinstance(gen, bundle2.unbundle20): 6838 if isinstance(gen, bundle2.unbundle20):
6840 tr = repo.transaction('unbundle') 6839 tr = repo.transaction('unbundle')
6859 _('packed bundles cannot be applied with ' 6858 _('packed bundles cannot be applied with '
6860 '"hg unbundle"'), 6859 '"hg unbundle"'),
6861 hint=_('use "hg debugapplystreamclonebundle"')) 6860 hint=_('use "hg debugapplystreamclonebundle"'))
6862 else: 6861 else:
6863 modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname) 6862 modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname)
6864 finally:
6865 lock.release()
6866 6863
6867 return postincoming(ui, repo, modheads, opts.get('update'), None) 6864 return postincoming(ui, repo, modheads, opts.get('update'), None)
6868 6865
6869 @command('^update|up|checkout|co', 6866 @command('^update|up|checkout|co',
6870 [('C', 'clean', None, _('discard uncommitted changes (no backup)')), 6867 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),