mercurial/lock.py
changeset 25660 328739ea70c3
parent 23032 f484be02bd35
child 25956 8cd30e9277ae
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)