Mercurial > hg
comparison hgext/histedit.py @ 41166:9365b8cb90e0
histedit: use context manager for locks
Differential Revision: https://phab.mercurial-scm.org/D5542
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 09 Jan 2019 15:34:24 -0800 |
parents | a3a24ad10efb |
children | 9bc7ec924234 |
comparison
equal
deleted
inserted
replaced
41165:a3a24ad10efb | 41166:9365b8cb90e0 |
---|---|
205 discovery, | 205 discovery, |
206 error, | 206 error, |
207 exchange, | 207 exchange, |
208 extensions, | 208 extensions, |
209 hg, | 209 hg, |
210 lock, | |
211 logcmdutil, | 210 logcmdutil, |
212 merge as mergemod, | 211 merge as mergemod, |
213 mergeutil, | 212 mergeutil, |
214 node, | 213 node, |
215 obsolete, | 214 obsolete, |
223 from mercurial.utils import ( | 222 from mercurial.utils import ( |
224 stringutil, | 223 stringutil, |
225 ) | 224 ) |
226 | 225 |
227 pickle = util.pickle | 226 pickle = util.pickle |
228 release = lock.release | |
229 cmdtable = {} | 227 cmdtable = {} |
230 command = registrar.command(cmdtable) | 228 command = registrar.command(cmdtable) |
231 | 229 |
232 configtable = {} | 230 configtable = {} |
233 configitem = registrar.configitem(configtable) | 231 configitem = registrar.configitem(configtable) |
1599 return _chistedit(ui, repo, *freeargs, **opts) | 1597 return _chistedit(ui, repo, *freeargs, **opts) |
1600 return _texthistedit(ui, repo, *freeargs, **opts) | 1598 return _texthistedit(ui, repo, *freeargs, **opts) |
1601 | 1599 |
1602 def _texthistedit(ui, repo, *freeargs, **opts): | 1600 def _texthistedit(ui, repo, *freeargs, **opts): |
1603 state = histeditstate(repo) | 1601 state = histeditstate(repo) |
1604 try: | 1602 with repo.wlock() as wlock, repo.lock() as lock: |
1605 state.wlock = repo.wlock() | 1603 state.wlock = wlock |
1606 state.lock = repo.lock() | 1604 state.lock = lock |
1607 _histedit(ui, repo, state, *freeargs, **opts) | 1605 _histedit(ui, repo, state, *freeargs, **opts) |
1608 finally: | |
1609 release(state.lock, state.wlock) | |
1610 | 1606 |
1611 goalcontinue = 'continue' | 1607 goalcontinue = 'continue' |
1612 goalabort = 'abort' | 1608 goalabort = 'abort' |
1613 goaleditplan = 'edit-plan' | 1609 goaleditplan = 'edit-plan' |
1614 goalnew = 'new' | 1610 goalnew = 'new' |