comparison hgext/mq.py @ 27865:f6979b8f33c1

with: use context manager for transaction in qimport
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:47 -0800
parents 4b8e3ffee94f
children c7cd551f07d0
comparison
equal deleted inserted replaced
27864:4b8e3ffee94f 27865:f6979b8f33c1
2077 raise error.Abort(_('revision %d has unmanaged children') 2077 raise error.Abort(_('revision %d has unmanaged children')
2078 % rev.first()) 2078 % rev.first())
2079 lastparent = None 2079 lastparent = None
2080 2080
2081 diffopts = self.diffopts({'git': git}) 2081 diffopts = self.diffopts({'git': git})
2082 tr = repo.transaction('qimport') 2082 with repo.transaction('qimport') as tr:
2083 try:
2084 for r in rev: 2083 for r in rev:
2085 if not repo[r].mutable(): 2084 if not repo[r].mutable():
2086 raise error.Abort(_('revision %d is not mutable') % r, 2085 raise error.Abort(_('revision %d is not mutable') % r,
2087 hint=_('see "hg help phases" ' 2086 hint=_('see "hg help phases" '
2088 'for details')) 2087 'for details'))
2119 # if we added anything with --rev, move the secret root 2118 # if we added anything with --rev, move the secret root
2120 phases.retractboundary(repo, tr, phases.secret, [n]) 2119 phases.retractboundary(repo, tr, phases.secret, [n])
2121 self.parseseries() 2120 self.parseseries()
2122 self.applieddirty = True 2121 self.applieddirty = True
2123 self.seriesdirty = True 2122 self.seriesdirty = True
2124 tr.close()
2125 finally:
2126 tr.release()
2127 2123
2128 for i, filename in enumerate(files): 2124 for i, filename in enumerate(files):
2129 if existing: 2125 if existing:
2130 if filename == '-': 2126 if filename == '-':
2131 raise error.Abort(_('-e is incompatible with import from -') 2127 raise error.Abort(_('-e is incompatible with import from -')