comparison mercurial/lock.py @ 25660:328739ea70c3

global: mass rewrite to use modern exception syntax Python 2.6 introduced the "except type as instance" syntax, replacing the "except type, instance" syntax that came before. Python 3 dropped support for the latter syntax. Since we no longer support Python 2.4 or 2.5, we have no need to continue supporting the "except type, instance". This patch mass rewrites the exception syntax to be Python 2.6+ and Python 3 compatible. This patch was produced by running `2to3 -f except -w -n .`.
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 23 Jun 2015 22:20:08 -0700
parents f484be02bd35
children 8cd30e9277ae
comparison
equal deleted inserted replaced
25659:d60678a567a9 25660:328739ea70c3
56 timeout = self.timeout 56 timeout = self.timeout
57 while True: 57 while True:
58 try: 58 try:
59 self.trylock() 59 self.trylock()
60 return self.timeout - timeout 60 return self.timeout - timeout
61 except error.LockHeld, inst: 61 except error.LockHeld as inst:
62 if timeout != 0: 62 if timeout != 0:
63 time.sleep(1) 63 time.sleep(1)
64 if timeout > 0: 64 if timeout > 0:
65 timeout -= 1 65 timeout -= 1
66 continue 66 continue
76 lockname = '%s:%s' % (lock._host, self.pid) 76 lockname = '%s:%s' % (lock._host, self.pid)
77 while not self.held: 77 while not self.held:
78 try: 78 try:
79 self.vfs.makelock(lockname, self.f) 79 self.vfs.makelock(lockname, self.f)
80 self.held = 1 80 self.held = 1
81 except (OSError, IOError), why: 81 except (OSError, IOError) as why:
82 if why.errno == errno.EEXIST: 82 if why.errno == errno.EEXIST:
83 locker = self.testlock() 83 locker = self.testlock()
84 if locker is not None: 84 if locker is not None:
85 raise error.LockHeld(errno.EAGAIN, 85 raise error.LockHeld(errno.EAGAIN,
86 self.vfs.join(self.f), self.desc, 86 self.vfs.join(self.f), self.desc,
100 The lock file is only deleted when None is returned. 100 The lock file is only deleted when None is returned.
101 101
102 """ 102 """
103 try: 103 try:
104 locker = self.vfs.readlock(self.f) 104 locker = self.vfs.readlock(self.f)
105 except (OSError, IOError), why: 105 except (OSError, IOError) as why:
106 if why.errno == errno.ENOENT: 106 if why.errno == errno.ENOENT:
107 return None 107 return None
108 raise 108 raise
109 try: 109 try:
110 host, pid = locker.split(":", 1) 110 host, pid = locker.split(":", 1)