comparison hgext/evolve.py @ 1256:f8cb01637e75 stable

graft: avoid potential deadlock We must acquire 'wlock' before 'lock'.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 20 Apr 2015 13:48:06 +0200
parents a2d4901e211e
children c52c15100fb2
comparison
equal deleted inserted replaced
1255:a2d4901e211e 1256:f8cb01637e75
2238 kwargs = dict(kwargs) 2238 kwargs = dict(kwargs)
2239 revs = list(revs) + kwargs.get('rev', []) 2239 revs = list(revs) + kwargs.get('rev', [])
2240 kwargs['rev'] = [] 2240 kwargs['rev'] = []
2241 obsoleted = kwargs.setdefault('obsolete', []) 2241 obsoleted = kwargs.setdefault('obsolete', [])
2242 2242
2243 lock = repo.lock() 2243 wlock = lock = None
2244 try: 2244 try:
2245 wlock = repo.wlock()
2246 lock = repo.lock()
2245 if kwargs.get('old_obsolete'): 2247 if kwargs.get('old_obsolete'):
2246 if kwargs.get('continue'): 2248 if kwargs.get('continue'):
2247 obsoleted.extend(repo.opener.read('graftstate').splitlines()) 2249 obsoleted.extend(repo.opener.read('graftstate').splitlines())
2248 else: 2250 else:
2249 obsoleted.extend(revs) 2251 obsoleted.extend(revs)
2254 raise error.Abort(_('cannot graft multiple revisions while ' 2256 raise error.Abort(_('cannot graft multiple revisions while '
2255 'obsoleting (for now).')) 2257 'obsoleting (for now).'))
2256 2258
2257 return commitwrapper(orig, ui, repo,*revs, **kwargs) 2259 return commitwrapper(orig, ui, repo,*revs, **kwargs)
2258 finally: 2260 finally:
2259 lock.release() 2261 lockmod.release(lock, wlock)
2260 2262
2261 @eh.extsetup 2263 @eh.extsetup
2262 def oldevolveextsetup(ui): 2264 def oldevolveextsetup(ui):
2263 for cmd in ['kill', 'uncommit', 'touch', 'fold']: 2265 for cmd in ['kill', 'uncommit', 'touch', 'fold']:
2264 entry = extensions.wrapcommand(cmdtable, cmd, 2266 entry = extensions.wrapcommand(cmdtable, cmd,