comparison hgext/mq.py @ 4571:eb403f295ff1

mq: grab locks before starting a transaction
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Wed, 13 Jun 2007 19:15:58 -0300
parents 0c61124ad877
children eb3b7dd1e158
comparison
equal deleted inserted replaced
4570:78c50632437e 4571:eb403f295ff1
436 return (True, files, fuzz) 436 return (True, files, fuzz)
437 437
438 def apply(self, repo, series, list=False, update_status=True, 438 def apply(self, repo, series, list=False, update_status=True,
439 strict=False, patchdir=None, merge=None, wlock=None, 439 strict=False, patchdir=None, merge=None, wlock=None,
440 all_files={}): 440 all_files={}):
441 if not wlock:
442 wlock = repo.wlock()
443 lock = repo.lock()
441 tr = repo.transaction() 444 tr = repo.transaction()
442 try: 445 try:
443 ret = self._apply(tr, repo, series, list, update_status, 446 ret = self._apply(tr, repo, series, list, update_status,
444 strict, patchdir, merge, wlock, 447 strict, patchdir, merge, wlock,
445 all_files=all_files) 448 lock=lock, all_files=all_files)
446 tr.close() 449 tr.close()
447 self.save_dirty() 450 self.save_dirty()
448 return ret 451 return ret
449 except: 452 except:
450 try: 453 try:
454 repo.wreload() 457 repo.wreload()
455 raise 458 raise
456 459
457 def _apply(self, tr, repo, series, list=False, update_status=True, 460 def _apply(self, tr, repo, series, list=False, update_status=True,
458 strict=False, patchdir=None, merge=None, wlock=None, 461 strict=False, patchdir=None, merge=None, wlock=None,
459 all_files={}): 462 lock=None, all_files={}):
460 # TODO unify with commands.py 463 # TODO unify with commands.py
461 if not patchdir: 464 if not patchdir:
462 patchdir = self.path 465 patchdir = self.path
463 err = 0 466 err = 0
464 if not wlock:
465 wlock = repo.wlock()
466 lock = repo.lock()
467 n = None 467 n = None
468 for patchname in series: 468 for patchname in series:
469 pushable, reason = self.pushable(patchname) 469 pushable, reason = self.pushable(patchname)
470 if not pushable: 470 if not pushable:
471 self.explain_pushable(patchname, all_patches=True) 471 self.explain_pushable(patchname, all_patches=True)